akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
cnt = 0

for i in range(N):
  cnt += B[A[i]-1]


for j in range(N-1):
  if A[j+1] - A[j] == 1:
    cnt += C[A[j]-1]
  
print(cnt)

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

typedef long long ll;

using namespace std;

const int N = 1e5+100, M=220, MOD = 1e9+7;

int add(ll a, int b){
    return (a + b) % MOD;
}

int mul(ll a, int b){
    return (a * b) % MOD;
}

int a[M], cnt[N], ps[N];
int c[M][M];
int dp[2][N];

int main(){
    int n, x;cin >> n >> x;
    for(int i=0 ; i<n ; i++){
        cin >> a[i];
        cnt[a[i]] ++;
    }
    
    for(int i=0 ; i<N ; i++)
        ps[i] = cnt[i] + (i>0 ? ps[i-1] : 0);

    sort(a, a+n);
    for(int i=0 ; i<=n ; i++){
        c[i][i] = c[0][i] = 1;
        for(int j=1 ; j<i ; j++)
            c[j][i] = add(c[j][i-1] , c[j-1][i-1]);
    }

    for(int i=1 ; i<=n ; i++){
        int m=1;
        for(int j=1 ; j<=i ; j++){
            m = mul(m, j);
            c[j][i] = mul(c[j][i], m);
        }
    }

    dp[n&1][x] = 1;
    for(int i=n-1 ; i>=0 ; i--){
        int d = (i&1);
        
        for(int j=0 ; j<N ; j++)
            dp[d][j] = dp[1-d][j];

        for(int j=a[i] ; j<N ; j++){
            int ig = ps[j] - ps[j % a[i]];
            dp[d][j % a[i]] = add(dp[d][j % a[i]], mul(dp[1-d][j], c[ig-1][ps[j]-1]));
        }
    }

    int ans=0;
    for(int i=0 ; i<a[0] ; i++){
        ans = add(ans, mul(dp[0][i], i));
    }

    int less=0;
    for(int i=0 ; i<n ; i++)
        if(a[i] > x)
            less ++;
    ans = mul(ans, c[less][n]);

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


Measured memory_bytes: 1920
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

a, b, n = MAP()
x = min(b-1, n)
ans = (a*x)//b - a*(x//b)
print(ans)

Measured memory_bytes: 10236
#include <stdio.h>

int main(){
	
	int lenght;
	int index;
	char character [55];
	scanf("%d %d", &lenght, &index);
	getchar();
	scanf("%s", &character);
	character [index-1] += 32;
	printf("%s\n", character);
		
	return 0;
}

Measured memory_bytes: 1640
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

constexpr unsigned Mod = 1000000007;

constexpr unsigned Add(unsigned a, unsigned b) { return (a + b) % Mod; }

int main() {
  int N;
  scanf("%d", &N);
  static char S[3000];
  scanf("%s", S);
  static unsigned F[3000];
  fill(F, F + N, 1);
  for (auto i = 1; i < N; ++i) {
    if (S[i - 1] == '<')
      for (auto j = 1; j < N - i; ++j)
        F[j] = Add(F[j - 1], F[j]);
    else {
      auto f = exchange(F[N - i - 1], F[N - i]);
      for (auto j = N - i - 1; j; --j)
        f = exchange(F[j - 1], Add(f, F[j]));
    }
  }
  printf("%u\n", F[0]);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll i,j,k,n,m,c,t,y,mx;
    string s,x;
    cin>>n;
    map<string,ll>mp;
    for(i=0;i<n;i++){
        cin>>s;
        mp[s]++;
    } vector<pair<ll,string> >v;
    for(auto z:mp){
        x=z.first;
        y=z.second;
        v.push_back({y,x});
    } sort(v.begin(),v.end());
    vector<string>vec;
    mx=v[v.size()-1].first;
    for(i=v.size()-1;i>=0;i--){
      if(v[i].first!=mx ) break;
      vec.push_back(v[i].second);
    }sort(vec.begin(),vec.end());
    for(auto x:vec) cout<<x<<"\n";
}


Measured memory_bytes: 41148
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#define M 1000000007LU

main()
{
  uint64_t m, n, r;
  
  scanf("%llu%llu", &m, &n);
  
  r = 1;
  while (n > 0) {
    if (n % 2 == 1) {
      r = (r * m) % M;
    }
    m = (m * m) % M;
    n /= 2;
  }
  printf("%llu\n", r);

  return EXIT_SUCCESS;
}

Measured memory_bytes: 604
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (ll i = 0 ; i < n; ++i) {
        cout << s[i];
        cout << t[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
import sys

n = int(input())
b = list(map(int, input().split()))

c = list()

for i in range(n, 0, -1):
    for j in range(i):
        if b[i - j - 1] == i - j:
            c.insert(0, b[i - j - 1])
            del b[i - j - 1]
            break
        if i == j + 1:
            print(-1)
            sys.exit()

for i in c:
    print(i)

Measured memory_bytes: 3064
// https://beta.atcoder.jp/contests/abc106

#define SUBMIT

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

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

    int i = 0;
    auto one_count = 0;
    while (i < S.length() && S[i] == '1') {
        one_count++;
        i++;
    }

    if (K <= one_count) cout << "1" << endl;
    else cout << static_cast<char>(S[i]) << endl;
    return 0;
}

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

int main()
{
  ll N, L;
  cin >> N >> L;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  for (ll i = 0; i < N - 1; i++)
  {
    if (A.at(i) + A.at(i + 1) >= L)
    {
      cout << "Possible" << endl;
      for (ll j = 0; j < i; j++)
      {
        cout << j + 1 << endl;
      }
      for (ll j = N - 2; j > i; j--)
      {
        cout << j + 1 << endl;
      }
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << "Impossible" << endl;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<tuple<int, int, int, int>>> v(H, vector<tuple<int, int, int, int>>(W, make_tuple(0, 0, 0, 0)));
    vector<string> s(H);
    REP(i, H) {
        cin >> s[i];
    }
    REP(i, H) {
        int left = -1;
        REP(j, W) {
            if(s[i][j] == '#') {
                left = j;
            }else{
                v[i][j] = make_tuple(left, 0, 0, 0);
            }
        }
        int right = W;
        for(int j = W - 1;0 <= j;j--) {
            if(s[i][j] == '#') {
                right = j;
            }else{
                int l = get<0>(v[i][j]);
                v[i][j] = make_tuple(l, right, 0, 0);
            }
        }
    }

    REP(j, W) {
        int up = -1;
        REP(i, H) {
            if(s[i][j] == '#') {
                up = i;
            }else{
                int l = get<0>(v[i][j]);
                int r = get<1>(v[i][j]);
                v[i][j] = make_tuple(l, r, up, 0);
            }
        }
        int down = H;
        for(int i = H - 1;0 <= i;i--) {
            if(s[i][j] == '#') {
                down = i;
            }else{
                int l = get<0>(v[i][j]);
                int r = get<1>(v[i][j]);
                int u = get<2>(v[i][j]);
                v[i][j] = make_tuple(l, r, u, down);
            }
        }
    }

    int res = -1;
    REP(i, H) {
        REP(j, W) {
            int l = get<0>(v[i][j]);
            int r = get<1>(v[i][j]);
            int u = get<2>(v[i][j]);
            int d = get<3>(v[i][j]);
            if(l < r && u < d) {
                res = max(res, (r - l) + (d - u) - 3);
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 66944
n = int(input())
s = []
ans = [0 for i in range(4)]
for _ in range(n):
    ss = input()
    s.append(ss)
    if ss == "AC": ans[0] += 1
    if ss == "WA": ans[1] += 1
    if ss == "TLE": ans[2] += 1
    if ss == "RE": ans[3] += 1
ac = "AC "
tle = "TLE "
wa = "WA "
re = "RE "
kakeru = "x "
ans_str = [str(i) for i in ans]
print(ac + kakeru + ans_str[0])
print(wa+kakeru+ans_str[1])
print(tle+kakeru+ans_str[2])
print(re+kakeru+ans_str[3])

Measured memory_bytes: 16324
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;
int N, M;
int f[1001][1001];

int main() {
   cin >> N >> M;
   vector<int> A, B;
   A.resize(N);
   B.resize(M);
   for (int i = 0; i < N; i++) {
      cin >> A[i];
   }
   sort(A.begin(), A.end());
   for (int i = 0; i < M; i++) {
      cin >> B[i];
   }
   sort(B.begin(), B.end());
   // for (int i = 0; i < N; i++) cout << A[i] << endl;
   // for (int i = 0; i < M; i++) cout << B[i] << endl;
   
   // multiple cut
   for (int i = 1; i < N; i++) {
      if (A[i] == A[i - 1]) {
         cout << 0 << endl;
         return 0;
      }
   }
   for (int i = 1; i < M; i++) {
      if (B[i] == B[i - 1]) {
         cout << 0 << endl;
         return 0;
      }
   }

   ll ans = 1;
   for (int i = N * M; i > 0; i--) {
      // cout << "------" << endl; 
      decltype(A)::iterator itA = lower_bound(A.begin(), A.end(), i);
      int posA = A.end() - itA;
      // cout << i << " " << A.end() - itA << endl;
      decltype(B)::iterator itB = lower_bound(B.begin(), B.end(), i);
      int posB = B.end() - itB;
      // cout << i << " " << B.end() - itB << endl;

      if (A[itA - A.begin()] == i && B[itB - B.begin()] == i) {
         // cout << i << ":" << 1 << endl;
         ans *= 1;
      } else if (A[itA - A.begin()] == i) {
         // cout << i << ":" << posB << endl;
         ans *= posB;
         ans %= MOD;
      } else if (B[itB - B.begin()] == i) {
         // cout << i << ":" << posA << endl;
         ans *= posA;
         ans %= MOD;
      }
      else {
         // cout << i << ":" << posA * posB - (N * M - i) << endl;
         ans *= posA * posB - (N * M - i);
         ans %= MOD;
      }
   }
   cout << ans << endl;   
   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        cnt += a % 2;
    }
    cout << (cnt % 2 != 1 ? "YES" : "NO") << endl;
    return 0;
}

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

using namespace std;

int n, m;

const long long MOD = 1000000007;

long long C(long long a) {
    return a * (a - 1) / 2;
}

int main() {
   cin >> n >> m;
  
        long long ansn = 0;
        long long resn = 0; cin >> resn;
        for (int i = 0; i < n-1; ++i) {
            long long tmp = C(n) - C(i+1) - C(n-1-i);
            long long x; cin >> x;
            ansn += (x - resn) * tmp % MOD;
            ansn %= MOD;
            resn = x;
        }
        long long ansm = 0;
      
        long long resm = 0; cin >> resm;
      
        for (int i = 0; i < m-1; ++i) {
          
            long long tmp = C(m) - C(i+1) - C(m-1-i);
            long long y; cin >> y;
            ansm += (y - resm) * tmp % MOD;
            ansm %= MOD;
            resm = y;
        }
        cout << (ansn * ansm) % MOD << endl;
    }





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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

class BinarySearchTree
{
public:
    BinarySearchTree()
    : root((Node*)nullptr)
    {}
    ~BinarySearchTree() {}

    struct Node
    {
        Node() {}
        Node(int u)
        : key(u), p((Node*)nullptr), l((Node*)nullptr), r((Node*)nullptr)
        {}
        Node(const Node& node)
        : key(node.key), p(node.p), l(node.l), r(node.r)
        {}
        ~Node() {} 
        int key;
        Node *p, *l, *r;
    };

    void insert(int u)
    {
        Node* y = nullptr;
        Node* x = root;
        Node* z = new Node(u);
        while (x != nullptr)
        {
            y = x;
            if (z->key < x->key)
            {
                x = x->l;
            }
            else
            {
                x = x->r;
            }
        }
        z->p = y;

        if (y == nullptr)
        {
            root = z;
        }
        else if (z->key < y->key)
        {
            y->l =z;
        }
        else
        {
            y->r = z;
        }
    }

    void preorder(Node* u)
    {
        Node* l = u->l;
        Node* r = u->r;
        cout << " " << u->key;
        if (l) preorder(l);
        if (r) preorder(r);
    }

    void inorder(Node* u)
    {
        Node* l = u->l;
        Node* r = u->r;
        if (l) inorder(l);
        cout << " " << u->key;
        if (r) inorder(r);
    }

    Node* root;
};

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

    int n;
    cin >> n;

    BinarySearchTree bst;
    char cmd[10];
    int u;
    rep (i, n)
    {
        cin >> cmd;
        // cout << i << ": cmd, u = " << cmd << ", " << u << "\n";
        if (cmd[0] == 'i')
        {
            cin >> u;
            bst.insert(u);
        }
        else if (cmd[0] == 'p')
        {
            bst.inorder(bst.root);
            cout << "\n";
            bst.preorder(bst.root);
            cout << "\n";
        }
    }

    return 0;
}



Measured memory_bytes: 26472
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, 1, 1 };

namespace {
    template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
    template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    char a = inp1;

    if (a >= 'a') Cout('a');
    else Cout('A');

    return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>

int main(void){
	int n, r, card[50], i, j, k, tmp, p, c;
	scanf("%d%d",&n,&r);
	while(n != 0 || r != 0){
		for(i = 0;i < n;i++)
			card[i] = n - i;
		for(k = 0;k < r;k++){
			scanf("%d%d",&p,&c);
			for(i = 0;i < c;i++){
				tmp = card[p - 1 + i];
				for(j = p - 1 + i;j > i;j--)
					card[j] = card[j - 1];
				card[i] = tmp;
			}
		}
		printf("%d\n",card[0]);
		scanf("%d%d",&n,&r);
	}
	return 0;
}

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

using namespace std;

int main()
{
    string N; cin>>N;
    int Sum=0;

    for(int i=0;i<N.size();i++){
      N[i]=N[i]-'0';
    }

    for(int i=0;i<N.size();i++){
      Sum+=N[i];
    }

    if(Sum%9==0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3724
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
max_num = 0
x = 0
y = 0
for i in range(n):
    if v[i] > c[i]:
        x += v[i]
        y += c[i]
print(x - y)

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    ll n;
    cin>>n;

    vector<ll> f;
    for (ll i=1; i*i<=n; i++) {
	if (n%i==0) {
	    f.push_back(i);
	    f.push_back(n/i);
	}
    }

    sort(f.begin(), f.end());
    f.erase(unique(f.begin(),f.end()),f.end());




    ll res = 0;

    for (ll k: f) {
	ll m = n/k - 1;
	if (m>0 && k<m) {
	    //cout<<k<<": "<<m<<endl;
	    res += m;
	}
    }


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


Measured memory_bytes: 3612
#include<vector>
#include<cstdio>
#include<iostream>
using namespace std;

vector<int> my_bit(int n);
int mypow(int x, int y);
vector<int> arrange_bit(vector<int> v, int n);


int main(){
    int H, W, K;
    int n_H, n_W, tmp_for_judge;
    int total_sum = 0, count = 0;
    string tmp;
    std::cin >> H >> W >> K;
    vector<vector<int>> grid(H, vector<int>(W));
    vector<int> tate_sum(W,0), yoko_sum(H,0);    
    vector<int> tate_ch(W,0), yoko_ch(H,0);    

    for(int i = 0; i < H; i++){
        std::cin >> tmp;
        for(int j = 0; j < W; j++){
            if(tmp.at(j) == '#'){
                grid[i][j] = 1;
            }else{
                grid[i][j] = 0;
            }
        }
    }

    // for(int i = 0; i < H; i++){
    //     for(int j = 0; j < W; j++){
    //         std::cout << grid[i][j] << " ";
    //     }
    //     std::cout << "\n";
    // }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            yoko_sum[i] += grid[i][j];
        }
    }
    for(int i = 0; i < W; i++){
        for(int j = 0; j < H; j++){
            tate_sum[i] += grid[j][i];
            total_sum += grid[j][i];
        }
    }

    // for(int i = 0; i < H; i++){
    //     std::cout << yoko_sum[i] << "\n";
    // }
    // std::cout << "\n";
    // for(int i = 0; i < W; i++){
    //     std::cout << tate_sum[i] << " ";
    // }

    n_H = mypow(2, H);
    n_W = mypow(2, W);

    for(int i = 0; i < n_H; i++){
        for(int j = 0; j < n_W; j++){
            //ループの最初で初期化
            tmp_for_judge = total_sum;
            //選び方
            tate_ch = arrange_bit(my_bit(i),H);
            yoko_ch = arrange_bit(my_bit(j),W);
            // for(int p = 0; p < tate_ch.size(); p++){
            //     std::cout << tate_ch[p] << " ";
            // }
            // std::cout << "\n";
            //合計を算出。
            for(int k = 0; k < H; k++){
                tmp_for_judge -= yoko_sum[k] * tate_ch[k];
                for(int l = 0; l < W; l++){
                    tmp_for_judge += grid[k][l] * tate_ch[k] * yoko_ch[l];
                }
            }
            for(int l = 0; l < W; l++){
                tmp_for_judge -= tate_sum[l] * yoko_ch[l];    
            }
            if(tmp_for_judge == K){
                count++;
            }

        }
    }
    std::cout << count;

}


vector<int> my_bit(int n){
    int n_loop = 0;//桁数
    int bit_buff;
    double d_n = (double)n;
    //最大桁を算出
    while(d_n >= 1.0){
        n_loop++;
        d_n = d_n/2.0;
    }

    vector<int> ans(n_loop);

    //割ってこう
    for(int i =0; i < n_loop; i++){
        bit_buff = mypow(2, (n_loop - 1 -i));
        if(n >= bit_buff){
            ans[i] = 1;
            n = n - bit_buff; 
        }
    }

    return ans;
}

int mypow(int x, int y){
    int ans = 1;
    for(int i = 0; i < y; i++){
        ans = ans * x;
    }
    return ans;
}

vector<int> arrange_bit(vector<int> v, int n){
    int n_n = v.size();
    vector<int> ans;

    v.insert(v.begin(),(n - n_n),0);

    return v;

}

Measured memory_bytes: 3640
import numpy as np

s = input().strip()

mode = 'R'
start = 0
counts = np.zeros(len(s), dtype=np.int)
for i in range(1, len(s)):
    if mode == 'R':
        if s[i] == 'R':
            pass
        elif s[i] == 'L':
            counts[i - 1] += (i - start + 1) // 2
            counts[i] += (i - start) // 2
            mode = 'L'
            start = i
    if mode == 'L':
        if i == len(s) - 1:
            counts[start - 1] += (i - start + 1) // 2
            counts[start] += (i - start + 2) // 2
        elif s[i] == 'L':
            pass
        elif s[i] == 'R':
            counts[start - 1] += (i - start) // 2
            counts[start] += (i - start + 1) // 2
            mode = 'R'
            start = i

print(' '.join(map(str, counts.tolist())))


Measured memory_bytes: 20440
#include<stdio.h>
#include<string.h>

int main(){
	char A[101],B[101],C[101],ch,ch1,res;
	int a=0,b=0,c=0,t=0;
	scanf("%s",A);
	getchar();
	scanf("%s",B);
	getchar();
	scanf("%s",C);
	while(1){
		if(t==0){
			ch=A[a];
			ch1=A[a+1];
			res='A';
			if(ch1=='\0'){
				break;
			}
			t++;
			a++;
		}
		else{
			if(ch=='a'){
				ch=A[a];
				
				res='A';
				if(ch=='\0'){
					break;
				}				
				a++;
			}
			else if(ch=='b'){
				ch=B[b];
				
				res='B';
				if(ch=='\0'){
					break;
				}
				b++;
			}
			else if(ch=='c'){
				ch=C[c];
				
				res='C';
				if(ch=='\0'){
					break;
				}
				c++;
			}
		}
	}
	printf("%c",res);
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int main() {
  ll n,x,m;
  cin >> n >> x >> m;
  vl fx(m+1,-1),a;
  int len = 0;
  ll ans = 0,tot = 0;
  while(fx[x] == -1){
    tot+=x;
    a.push_back(x);
    fx[x] = len;
    len++;
    x= (x*x)%m;
  }
  if(n <= len){
    rep(i,n)ans+=a[i];
  }else{
    ans+=tot;
    n-=len;
    ll c = len-fx[x];
    ll loopCnt = n/c;
    ll loopSum = 0;
    for(int i=fx[x];i<len;i++)loopSum+=a[i];
    ans+= loopCnt*loopSum;
    n%=c;
    rep(i,n)ans+=a[fx[x]+i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
ll mod = 1000000007;

int main(){
  ll n,m; cin >> n >> m;
  vector<string> a(n);
  rep(i,n){
    string c; cin >> c; a[i]=c;
  }
  if(debug){
    rep(i,n){
      cout << a[i] << endl;
    }
  }
  vector<string> b(m);
  rep(i,m){
    string s; cin >> s; b[i]=s;
  }
  if(debug){
    rep(i,m){
      cout << b[i] << endl;
    }
  }
  auto isIncluded = [&](ll si, ll sj)->bool{
    ll ei = si+m-1; ll ej= sj+m-1;
    if(ei>=n||ej>=n) return false;
    for(ll i=si; i<=ei; i++){
      for(ll j=sj; j<=ej; j++){
        if(a[i][j]!=b[i-si][j-sj]) return false;
      }
    }
    return true;
  };
  rep(i,n)rep(j,n){
    if(isIncluded(i,j)){
      cout << yes;
      return 0;
    }
  }
  cout << no;
  return 0;
}

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

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

using ll = long long;
using namespace std;

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

    int n; cin >> n;
    cout << (n * 800 - n / 15 * 200);
}


Measured memory_bytes: 256
import java.io.*;
class Main{
  public static void main(String []args)throws IOException{
  	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int num = Integer.parseInt(br.readLine());
    
    int happiness;
    
    happiness = (num / 500) * 1000;
    num = num % 500;
    happiness = happiness + (num / 5) * 5;
    
    System.out.println(happiness);
  }
}

Measured memory_bytes: 20820
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main()
{
	int x = 0;
	string s;
	char c;
	while(1){
		cin >> s;
		if(atoi(&s[0]) == 0){
			break;
		}
		x = 0;
		for(int i = 0; i < s.size(); i++){
//			cout << s[i] << endl;
			c = s[i];
			x += atoi(&c);
		}
		cout << x << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
S = input()
str_list = ['dream', 'erase', 'dreamer', 'eraser']
start = 0
success_flag = False
continue_flag = False


def reverse_str(var: str):
    return ''.join(list(reversed(var)))


reverse_S = reverse_str(S)
while True:
    for str_name in str_list:
        if reverse_S[start:start + len(str_name)] == reverse_str(str_name):
            if len(S) == start + len(str_name):
                success_flag = True
                break
            start += len(str_name)
            continue_flag = True
    if success_flag:
        print('YES')
        break
    if not continue_flag:
        print('NO')
        break
    else:
        continue_flag = False


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

using namespace std;
typedef long long llong;

#define MAX 200001
const llong mod = 1000000000 + 7;

llong comb(int n)
{
  return (llong)n * (n - 1) / 2;
}

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> cnt(N + 1);
  llong total = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
    cnt[A[i]]++;
  }

  for (int i = 0; i < N; i++)
  {
    total += comb(cnt[i + 1]);
  }

  for (int i = 0; i < N; i++)
  {
    int j = cnt[A[i]];
    cout << total - (comb(j) - comb(j - 1)) << endl;
  }

  return 0;
}

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

int main(){
  int n;
  cin >>n;
  vector<string> s(n);
  rep(i,n) cin>>s[i];
  sort(s.begin(), s.end());
  int ans = 1;
  for(int i = 1; i<n; i++){
    if(s[i-1]!=s[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9524
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	int b[a],c=0,d=pow(10,9);
	for(int i=0;i<a;i++){
		cin>>b[i];
		if(b[i]<0){
			c++;
			b[i]=b[i]*(-1);
		}
		if(d>b[i])
			d=b[i];
	}
	int long long ans=0;
	if(c%2==0){
		for(int i=0;i<a;i++){
			ans+=b[i];
		}
	}
	else{
		for(int i=0;i<a;i++){
			ans+=b[i];
		}
		ans=ans-d*2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int dp[100001];
char a[100002];
vector<int> b[100001];
int n;

void f(int k,int v){
    if(k==n)return;
    if(a[k]=='1'){
        b[v].push_back(k+1);
        f(k+1,k+1);
    }
    else{
        b[v].push_back(k+1);
        f(k+1,v);
    }
}
int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);

    cin>>a+1;
    n=strlen(a+1);
    int i;
    if(a[n]=='1' || a[1]=='0'){
        cout<<-1;
        return 0;
    }
    for(i=1 ; i<n ; i++){
        if(a[i]!=a[n-i]){
            cout<<-1;
            return 0;
        }

    }

    f(1,1);
    for(i=1 ; i<=n ; i++){
        for(auto &j: b[i]){
            cout<<i<<" "<<j<<"\n";
        }
    }
    return 0;
}


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

typedef long long ll;

const int Maxn = 200005;

int n;
int a[Maxn];
ll res;

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		a[i] -= (i + 1);
	}
	sort(a, a + n);
	int m = n / 2;
	for (int i = 0; i < n; i++)
		res += abs(a[i] - a[m]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::cmp::{max, min};

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let mut l = scan.readn::<i64>(n);
    l.sort();
    let mut ret = 0;
    for i in 0..n {
        for j in i+1..n {
            let a = l[i];
            let b = l[j];
            let d = binary_search(&l, |&c| a < b + c);
            let d2 = binary_search(&l, |&c| b < c + a);
            let e = binary_search_r(&l, |&c| c < a + b);
//            dbg!((d, d2, e));
            let g = max(max(d, d2), j+1);
            let ef = if e + 1 - g > 0 {e + 1 - g} else {0};
//            dbg!(&ef);
            ret += ef;
        }
    }
    println!("{}", ret);
}

#[allow(dead_code)]
fn binary_search<T, F>(arr: &[T], f: F) -> usize where F: Fn(&T) -> bool {
    let mut ok = arr.len() as i64;
    let mut ng = -1i64;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if f(&arr[mid as usize]) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ok as usize
}

#[allow(dead_code)]
fn binary_search_r<T, F>(arr: &[T], f: F) -> usize where F: Fn(&T) -> bool {
    let mut ng = arr.len() as i64;
    let mut ok = -1i64;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if f(&arr[mid as usize]) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ok as usize
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    //ll t;
    //cin>>t;
    //while(t--)
    //{
       ll a,b,c;
       cin>>a>>b>>c;
       cout<<c<<" "<<a<<" "<<b<<endl;
    //}
}


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

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;

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

int main() {

	int N, M;
	cin >> N >> M;

	auto divs = divisor(M);

	int ans;
	for (auto& ele : divs) {
		if (M / ele >= N) {
			ans = ele; 
			break;
		}
	}

	cout << ans << "\n";

	return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	double f;
	while(cin>>f){
		printf("%.10f\n",f*211/27);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int c=0;
string s;
	
int main(){
	cin >> s;
	int r=s.size()-1, l=0;
	while(1){
		if(s[l]!=s[r]){
			if(s[l]=='x') l++;
			else if(s[r]=='x') r--;
			else{
				cout << -1 << endl;
				return 0;
			}
		}else{
			l++;
			r--;
		}
		
		if(r<=l) break;
	}

	r=s.size()-1, l=0;
	while(1){
		if(s[l]!=s[r]){
			if(s[l]=='x') c++,l++;
			else if(s[r]=='x') c++,r--;
		}else{
			l++;
			r--;
		}
		
		if(r<=l) break;
	}
	
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(n); ++i)
#define REP(i, d, n) for(long long i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {//言語変えろ言語変えろ言語変えろ言語変えろ言語変えろ

string a,b;cin>>a>>b;
  int c=0;
  rep(i,a.size()){if(b.at(i)!=a.at(i)){c=9;}}
  
  if(c==0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}

}


Measured memory_bytes: 3632
class UnionFind
  attr_accessor :arr

  def initialize(size)
    @arr = Array.new(size, -1)
  end

  def unite(a, b)
    pa, pb = [parent(a), parent(b)].sort
    return if pa == pb
    @arr[pb] = pa
  end

  def parent(x)
    return x if @arr[x] == -1
    @arr[x] = parent(@arr[x])
  end

  def same(a, b)
    self.parent(a) == self.parent(b)
  end
end

n, m = gets.chomp.split(' ').map(&:to_i)
uf = UnionFind.new(n + 1)
m.times do
  a, b = gets.chomp.split(' ').map(&:to_i)
  uf.unite(a, b)
end
map = Hash.new(0)
(1..n).each do |i|
  map[uf.parent(i)] += 1
end
puts map.values.max


Measured memory_bytes: 25392
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  cout << fixed << setprecision(20);
  int n,k;
  cin >>n >>k;

  double answer=0;

  for(int i=1; i<=n; i++){
    int point =i;
    double sai =1.0/n;
    while(point <k){
      point*=2;
      sai/=2;
    }
    answer+=sai;
  }
  cout <<answer <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
 
int main(){
  ll N;
  vector<vector<ll>> AB;
  cin>>N;
  for(ll i=0;i<N;++i){
    vector<ll> tmp;
    ll a,b;
    cin>>a>>b;
    tmp.push_back(a);
    tmp.push_back(b);
    tmp.push_back(a+b);
    AB.push_back(tmp);
  }
  sort(AB.begin(),AB.end(),[](vector<ll> a,vector<ll> b){return a[2]>b[2];});
  ll asum=0,bsum=0;
  for(ll i=0;i<N;++i){
    if(i%2==0){
      asum+=AB[i][0];
    }else{
      bsum+=AB[i][1];
    }
  }
  cout<<asum-bsum<<endl;
  return 0;
}

Measured memory_bytes: 6324
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

main() {
    int N; cin >> N;
    int M; cin >> M;
    char c[N][M]; 
    int dis[N][M];
    queue<pair<int,int>> q;
    int ans=0;
    rep(i,N){
        rep(j,M){
            cin >> c[i][j];
            if(c[i][j]=='#')
            {q.push(make_pair(i,j)); dis[i][j]=0;}
            else dis[i][j]=-1;
        }
    }
    while(!q.empty()){
        int a=q.front().first,b=q.front().second; q.pop();
        rep(i,4){
            if(dis[a+dx[i]][b+dy[i]]<0 && a+dx[i]!=-1 && a+dx[i]!=N 
            && b+dy[i]!=-1 && b+dy[i]!=M)
            {q.push(make_pair(a+dx[i],b+dy[i])); dis[a+dx[i]][b+dy[i]]=dis[a][b]+1;}
        }
    }
    rep(i,N){
        rep(j,M){
            ans=max(dis[i][j],ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 25396
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 225;

int n, m;
char s[N][N];
int f[N][N][N], g[N][N][N];

int main() {
	scanf("%d %d", &n, &m);
	fo(i, 1, n) scanf("%s", s[i] + 1);
	fd(k, m, 1) {
		fo(i, 1, n) {
			int ky = 1;
			fo(j, i, n) {
				if(j > i && s[j][k] != s[j - 1][k]) ky = 0;
				if(!ky) f[k][i][j] = 0; else {
					f[k][i][j] = k;
					if(k < m && s[i][k] == s[i][k + 1]) {
						f[k][i][j] = max(f[k][i][j], f[k + 1][i][j]);
					}
				}
			}
		}
	}
	fo(ans, 0, 16) {
		if(f[1][1][n] == m) {
			pp("%d\n", ans);
			return 0;
		}
		fo(k, 1, m) fo(i, 1, n) fo(j, i, n)
			g[k][i][j] = f[k][i][j];
		fo(k, 1, m) fo(i, 1, n) {
			int l = i;
			fo(j, i, n) {
				if(g[k][i][j]) f[k][i][j] = max(f[k][i][j], g[g[k][i][j] + 1][i][j]);
				while(l + 1 < j - 1 && g[k][i][l + 1] >= g[k][l + 2][j]) l ++;
				f[k][i][j] = max(f[k][i][j], min(g[k][i][l], g[k][l + 1][j])),
				f[k][i][j] = max(f[k][i][j], min(g[k][i][l + 1], g[k][l + 2][j]));
			}
		}
	}
}

Measured memory_bytes: 75520
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    set<string> s;
    rep(i, N) {
        string S;
        cin >> S;
        s.insert(S);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 19224
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){

  long long W, H;
  scanf("%lld", &W);
  scanf("%lld", &H);
  long long x, y;
  scanf("%lld",&x);
  scanf("%lld",&y);
  bool center = false;
  if (x==(long long)W/2.0 && y==(long long)H/2.0){
    center = true;
  }
  double area = (double)W/2.0*H;
  printf("%lf %d\n",area,center?1:0);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
// initialize: UnionFind UF(N)

class UnionFind {                                              // OOP style
private:
	vector<int> p, rank, setSize;
	// p = path toward the root of disjoint set; p[i] = i means it is root
	// rank = upper bound of the actual height of the tree; not reliable as accurate measure
	// setSize = size of each disjoint set

	int numSets;
public:
	UnionFind(int N) {
		setSize.assign(N, 1);
		numSets = N;
		rank.assign(N, 0);
		p.assign(N, 0);
		for (int i = 0; i < N; i++) p[i] = i;	// each belongs to its own set
	}

	int findSet(int i) {
		return (p[i] == i) ? i : (p[i] = findSet(p[i]));		// path compression: cut short of the path if possible
	}

	bool isSameSet(int i, int j) {
		return findSet(i) == findSet(j);
	}

	void unionSet(int i, int j) {
		if (!isSameSet(i, j)) {
			numSets--;
			int x = findSet(i), y = findSet(j);
			// rank is used to keep the tree short
			if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
			else {
				p[x] = y; setSize[y] += setSize[x];
				if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}

	int numDisjointSets() {		// # of disjoint sets
		return numSets;
	}

	int sizeOfSet(int i) {		// size of set
		return setSize[findSet(i)];
	}
};


#define MAXN 100010

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

	long long n, i, j, k, x, y, ans;
	cin >> n;

	UnionFind uf(MAXN * 2);
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		uf.unionSet(x, y + MAXN);
	}

	unordered_map<int, int> xcount, ycount;
	for (i = 0; i < MAXN * 2; i++) {
		if (uf.sizeOfSet(i) != 1) {
			if (i < MAXN) xcount[uf.findSet(i)]++;
			else ycount[uf.findSet(i)]++;
		}
	}

	ans = 0;
	for (auto p : xcount) {
		ans += p.second * ycount[p.first];
	}
	ans -= n;

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


Measured memory_bytes: 2816
using System;
public class Hello
{
    public static void Main()
    {
        int count = 0;
        var line = Console.ReadLine();
        var l = line.Split(' ');
        for (int i = int.Parse(l[0]); i <= int.Parse(l[1]); i++)
        {
            if(int.Parse(l[2]) % i == 0)
            {
                count++;
            }
        }
        Console.WriteLine(count);
    }
}



Measured memory_bytes: 17960
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author bcools
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a + b >= 10) {
                out.println("error");
            } else {
                out.println(a + b);
            }
        }

    }
}



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


int main(){
  int n,T;
  cin >> n >> T;
  vector<int> c(n);
  vector<int> t(n);
  rep(i,n) {
      cin >> c[i];
      cin >> t[i];
  }
  rep(i,n);
  int M =10000;
  rep(i,n){
      if(T>=t[i]){
          M=min(M,c[i]);
      }
  }
  if(M!=10000)cout << M << endl;
  else cout<< "TLE" << endl;
  }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while(true) {
            String cards = scanner.next();
            if (cards.equals("-")) break;
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String head = cards.substring(0, h);
                String tail = cards.substring(h);
                cards = tail.concat(head);
            }
            System.out.println(cards);
        }
        scanner.close();
    }
}



Measured memory_bytes: 26208
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long ll;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

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

    if(N==0){
        cout << 0 << endl;
        return 0;
    }

    vector<int> x;
    int i=0;
    ll res = 0;
    int amari = 0;
    while(N){
        amari = N%(-2);
        if(amari < 0){
            N = (N/(-2))+1;
            amari += 2;
            x.push_back(amari);
        }
        else{
           N /= (-2); 
           x.push_back(amari);
        }
    }
    reverse(ALL(x));

    REP(i, x.size()){
        cout << x[i];
    }
    cout << endl;
}

Measured memory_bytes: 256