akhauriyash/Code-Regression huggingface dataset:
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <utility>

int main() {
  size_t h, w;
  int k;
  scanf("%zu %zu %d", &h, &w, &k);

  std::vector<std::string> s(h);
  for (auto& si: s) {
    char buf[1024];
    scanf("%s", buf);
    si = buf;
  }

  int res = h+w;
  for (size_t b = 0; b < (1_zu << (h-1)); ++b) {
    std::vector<size_t> ind(h);
    size_t ii = 0;
    ind[0] = ii;
    for (size_t j = 1; j < h; ++j) {
      if (b >> (j-1) & 1) ++ii;
      ind[j] = ii;
    }

    int cur = __builtin_popcountll(b);
    bool valid = true;
    std::vector<int> sums(ii+1);
    for (size_t j = 0; j < w; ++j) {
      bool koware = false;
      for (size_t i = 0; i < h; ++i) {
        if (s[i][j] == '0') continue;
        ++sums[ind[i]];
        if (sums[ind[i]] > k) {
          koware = true;
          break;
        }
      }
      if (koware) {
        ++cur;
        sums.assign(ii+1, 0);
        for (size_t i = 0; i < h; ++i) {
          if (s[i][j] == '1') ++sums[ind[i]];
        }
        for (auto si: sums) {
          if (si > k) {
            valid = false;
            break;
          }
        }
      }
    }
    if (valid) res = std::min(res, cur);
  }
  printf("%d\n", res);
}


Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int score = 0;
  rep(i, n - 1)
  {
    if (s[i] == s[i + 1])
      score++;
  }
  int ans = min(score + 2 * k, n - 1);
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
    int x,y,i,j;
    int flag = 0;
    scanf("%d %d",&x,&y);
    
    for(i = 0; i <= x; i++){
        j = x-i;
        if((2*i) + (4*j) == y) flag = 1;
    }
    if(flag == 1) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 1664
<?php
fscanf(STDIN, "%d", $n);
$n1 = fgets(STDIN);
$n2 = fgets(STDIN);

$a = explode(' ', $n1);
$b = explode(' ', $n2);

$aSum = 0;
$bSum = 0;
$canDeal = 0;
for ($i = 0; $i < $n; $i++) {
    if ($a[$i] > $b[$i]) {
        $canDeal -= $a[$i] - $b[$i];
        continue;
    }
    $canDeal += floor(($b[$i] - $a[$i]) / 2);
}
if ($canDeal < 0) {
    echo "No";
    return;
}

echo "Yes";
return;

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

using namespace std;
bool comp(int a, int b)
{
    return (a < b);
}

int main()
{
  long long int a, b, c, d, ar[5], maxx, i;
    cin>>a>>b>>c>>d;
    ar[0]=max(a,b,comp)*max(c,d,comp);
    ar[1]=max(a,b,comp)*min(c,d,comp);
    ar[2]=min(a,b,comp)*max(c,d,comp);
    ar[3]=min(a,b,comp)*min(c,d,comp);
    maxx=ar[0];
    for(i=1; i<=3; i++){
    if(ar[i]>maxx)
    maxx=ar[i];
    }
    cout<<maxx;


    return 0;
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  vector<int> a(3);
  cin >> a;

  int k = in();
  sort(rall(a));
  while (k--) a[0] *= 2;

  cout << accumulate(all(a), 0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e15
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef long long ll;
typedef pair<int, int> P;
#define END system("PAUSE");return 0
int a, b;
signed main() {
	cin >> a >> b;
	if (a >= 0 && b >= 0)puts("Positive");
	else {
		if (a <= 0 && b >= 0)puts("Zero");
		else if ((b - a) % 2 == 0)puts("Negative");
		else puts("Positive");
	}
	END;
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

    
  
	int N, A, B, AB; 
  string S;
	cin >> N >> A >> B;
  cin >> S; 
  AB = A + B; 
  for (int i=0; i<N; i++) {
    if (S.at(i) == 'a') {
    	if (AB > 0) {
          AB --;
          cout << "Yes" <<endl; 
        } else {
          cout << "No" << endl;
        }
    } else if (S.at(i) == 'b') {
      if (AB > 0 and B > 0) {
        AB--; B--;
        cout << "Yes" << endl; 
      } else {
        cout << "No" << endl; 
      }
    } else if (S.at(i) == 'c') {
    	cout << "No" << endl; 
    }
  }
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    int n, k; cin >> n >> k;
    vl a(n); rep(i,n) cin >> a[i];
    sort(all(a));

    auto isNeed = [&](int x) {
        if (a[x] >= k) return true;
        vl dp(k, 0); dp[0] = 1;
        rep(i,n) {
            if (i == x) continue;
            per(j,k) {
                if (dp[j] == 0) continue;
                if (j + a[i] >= k) continue;
                dp[j + a[i]] = 1;
            }
        }
        rep(j,k) if (dp[j] and j + a[x] >= k) return true;
        return false;
    };
    int noneed = -1;
    int need = n;
    while (abs(need - noneed) > 1) {
        int mid = (need + noneed) / 2;
        if (isNeed(mid)) need = mid;
        else noneed = mid;
    }
    int ans = noneed + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL

#include <prettyprint.hpp>

#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template<typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template<typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pin;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9 + 7;

template<typename T>
struct Graph {
    int to, rev;
    T cap;

    Graph(int t, int r, const T &c) : to(t), rev(r), cap(c) {};
};

// Ford-Fulkerson
template<typename T>
struct FordFulkerson {
    vector<vector<Graph<T>>> g;
    vector<bool> used;
    int sz;

    FordFulkerson(int N) : sz(N) {
        g.resize(N);
        used.resize(N);
    }

    void add_edge(int from, int to, T cap) {
        g[from].eb(to, (int) g[to].size(), cap);
        g[to].eb(from, (int) g[from].size() - 1, 0);
    }

    T dfs(int v, int t, T flow) {
        if (v == t) return flow;
        if (used[v] || flow == 0) return 0;
        used[v] = true;

        for (auto &e: g[v]) {
            if (used[e.to] || e.cap == 0) continue;

            if (T f = dfs(e.to, t, min(flow, e.cap)) > 0) {
                e.cap -= f;
                g[e.to][e.rev].cap += f;
                return f;
            }
        }

        return 0;
    }

    T max_flow(int start, int end) {
        T flow = 0;
        while (true) {
            used.assign(sz, false);
            int f = dfs(start, end, inf);
            if (f == 0) break;
            flow += f;
        }
        return flow;
    }
};

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int H, W;
    cin >> H >> W;

    char grid[H][W];
    REP(i, H) REP(j, W) {
            cin >> grid[i][j];
    }

    FordFulkerson<int> mf(H + W + 2);

    int s = 0, t = H + W + 1;
    Pin sp, tp;
    REP(h, H) REP(w, W) {
            if (grid[h][w] == '.') continue;

            if (grid[h][w] == 'S') {
                mf.add_edge(s, 1 + w, inf);
                mf.add_edge(s, 1 + h + W, inf);
                sp = {h, w};
            } else if (grid[h][w] == 'T') {
                mf.add_edge(1 + w, t, inf);
                mf.add_edge(1 + h + W, t, inf);
                tp = {h, w};
            } else {
                mf.add_edge(1 + w, 1 + W + h, 1);
                mf.add_edge(1 + W + h, 1 + w, 1);
            }

        }

    if (sp.fi == tp.fi || sp.se == tp.se) {
        print(-1);
        return 0;
    }

    print(mf.max_flow(s, t));
}


Measured memory_bytes: 896
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a, b = [int(x) for x in input().split()]
from fractions import gcd

x = gcd(a,b)

x = prime_factorize(x)
print(len(set(x)) + 1)

Measured memory_bytes: 5100
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;

int hist[50];
int main()
{
  int N, M; cin >> N >> M;
  REP(i, N) {
    int K; cin >> K;
    REP(i, K) {
      int A; cin >> A;
      A--;
      hist[A]++;
    }
  }
  int ans = 0;
  REP(i, M) {
    if (hist[i] == N) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    vector<vector<ll>> c1(26),c2(26);
    rep(i,s.length()){
        c1[s[i]-'a'].push_back(i);
        c2[t[i]-'a'].push_back(i);
    }
    SORT(c1);
    SORT(c2);
    Yes(c1 == c2);
}


Measured memory_bytes: 5140
import java.util.Scanner;

class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        
        int W = scan.nextInt();
        
        int H = scan.nextInt();
        
        int x = scan.nextInt();
        
        int y = scan.nextInt();
        
        int r = scan.nextInt();
        
        if(x + r <= W && y + r <= H && x - r >= 0 && y - r >= 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    } 
}
            


Measured memory_bytes: 26404
import copy

def main():
    H,W = map(int, input().split())
    c = [[int(i) for i in input().split()] for i in range(10)]
    a = [[int(i) for i in input().split()] for i in range(H)]
    #d = copy.deepcopy(c)

    # ワーシャルフロイド法
    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][j], c[i][k] + c[k][j])
    
    ans = 0
    for i in a:
        for j in i:
            if j > 1 or j == 0:
                ans += c[j][1]
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3828
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdio>

typedef long long lli;
#define NMAX 200010

using namespace std;

int pos[NMAX];
int neg[NMAX];
int N,K;

const int mod = (1e9+7);

int main(){
	int t,n,p,i,x,j,sl;
	lli p1,p2;

	// scanf("%d",&t);
    t = 1;

	while(t--){

		scanf("%d%d",&N,&K);

		p = n= 0;
		sl=1;
		while(N--){
			scanf("%d",&x);
			if(x < 0) neg[n++]=x;
			else pos[p++]=x;
			sl = (1LL*sl*x)%mod;
		}
		pos[p] = neg[n]=1;

		if(K >= (p+n)){
			if(sl < 0) sl+=mod;
			printf("%d\n",sl);
			continue;
		}

		sort(pos,pos+p);
		reverse(pos,pos+p);
		sort(neg,neg+n);


		if(!p && (K&1)){
			sl=1;
			i=n;
			while(K--){
				sl = (1LL*sl*neg[--i])%mod;
			}
			if(sl < 0) sl += mod;
			printf("%d\n",sl);
			continue;
		}

		i = j = 0;


		while(K){
			p1 = 1ll*pos[i]*pos[i+1];
			p2 = 1ll*neg[j]*neg[j+1];

			if(K == 1 && i >= p){
				--i;
				j += 2;
				assert(j <= n);
				--K;
				continue;
			}

			if(i >=p || (K > 1 && j < n-1 && p1 < p2)){
				assert(j < n-1);
				K-=2;
				j+=2;
				continue;
			}

			++i;
			--K;
		}

		sl = 1;
		while(i--) sl = (1LL*sl*pos[i])%mod;
		while(j--) sl = (1LL*sl*neg[j])%mod;

		assert(sl >= 0);
		printf("%d\n",sl);
	}
}


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

int main() {
	// your code goes here
	ll n,W;
	cin>>n>>W;
	vector<ll> w(n+1),v(n+1);
	ll dp[n+1][W+1];
	/*
	State
	dp[i][j]: Denotes the maximum value of items(from 1 to i) picked in the bag having total weight <=j
	Recurrence
	2 choices 1: we pick the ith element, 2: we dont pick the ith element 
	The 2 choices are checked for all weights
	dp[i][j]=maximum(value of items picked from 1 to i-1 with weight <=j,value of items picked from 1 to i-1 with weight <=(j-weight[i]) + value[i])
	*/
	for(ll i=1;i<=n;i++)
	cin>>w[i]>>v[i];
	for(ll i=0;i<=n;i++){
		dp[i][0]=0;
	}
	ll ans=0;
	for(ll i=0;i<=W;i++)
		dp[0][i]=0;
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=W;j++){
			if(w[i]>j)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			ans=max(ans,dp[i][j]);
		}
	}
	cout<<ans<<"\n";
	return 0;
}

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

int main(){
  int n, m; cin >> n >> m;
  vector<vector<int>> j(m);
  for (int i = 0; i < n; i++){
    int a, b; cin >> a >> b;
    if (a <= m){
      a--;
      j.at(a).push_back(b);
    }
  }
  priority_queue<int> q;
  int64_t ans = 0;
  for (int i = 0; i < m; i++){
    for (int k : j.at(i)){
      q.push(k);
    }
    if (q.size()){
      int l = q.top();
      q.pop();
      ans += l;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 

typedef long long int ll; 
const ll mod = 1000000007;
vector<string>v;
vector<pair<ll,string> > h; 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll n;
    cin>>n;
    for(ll x=0; x<n; x++){
        string y;
        cin>>y;
        v.push_back(y);
    }
    sort(v.begin(),v.end());
    ll k=0;
    string s=v[0];
    h.push_back(make_pair(1,s));
    for(ll x=1; x<n;x++){
        if(v[x]==v[x-1]){
            h[k].first++;
        }
        else{
            s=v[x];
            h.push_back(make_pair(1,s));
            k++;
        }
    }
    sort(h.begin(),h.end());
    ll a=h[h.size()-1].first;
    for(ll x=0; x<h.size();x++){
        if(h[x].first==a){
            cout<<h[x].second<<"\n";
        }
    }
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  string ans;
  if(a.back() == b.front() && b.back() == c.front()){
    ans = "YES";
  }
  else {
    ans = "NO";
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#if 1

#include <bits/stdc++.h>
using namespace std;
int n;
int a[2005];
int sum[3005];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        sum[a[i]]++;
    }
    sort(a+1,a+n+1);
    for(int i = 1;i <= 3000;i++) {
        sum[i] += sum[i-1];
    }
    long long ra = 0;
    for(int i = 1;i <= n;i++) {
        for(int j = i+1;j <= n;j++) {
            int mi = abs(a[i]-a[j])+1;
            int ma = a[i]+a[j]-1;
            int ans = sum[ma]-sum[mi-1];
            if(mi <= a[i]&&a[i] <= ma) ans--;
            if(mi <= a[j]&&a[j] <= ma) ans--;
            ra += ans;
        }
    }
    cout << ra/3;
}

#endif


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];

ll n;
ll ans = 0;

void dfs(ll x, int a, int b, int c) {
	if (x > n)return;
	if (a && b && c)ans++;
	dfs(10 * x + 3, 1, b, c);
	dfs(10 * x + 5, a, 1, c);
	dfs(10 * x + 7, a, b, 1);
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = n / (a + b)*a;
	ll amari = n % (a + b);
	if (amari >= a)ans += a;
	else ans += amari;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
  short int a, b;   //二つの整数を宣言
  cin >> a >> b;    //二つの整数を入力
  if(a == b) cout << "a == b" << endl;    //等しければ
  else if(a < b) cout << "a < b" << endl;   //後者の方が大きければ
  else if(a > b) cout << "a > b" << endl;   //前者の方が大きければ
  return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
//ll num[ten52];

int main(void)
{
    long long int m,n,i,j;
    cin>>m;
    string s;
    for(i=0;i<m;i++)
    {
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}





Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>
#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
//#define MOD 1000000007
#define MOD 998244353
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

vector< pair<ll,ll> > prime_factorize(ll n){
    vector<pair<ll, ll> > res;
    for (ll p = 2; p*p<=n; ++p){
        if(n%p != 0) continue;
        int num = 0;
        while(n%p == 0){
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n,1));
    return res;
}

int atcoder(){
    ll n,p,ans=1;
    cin>>n>>p;
    
    
    auto v = prime_factorize(p);
    for(auto x : v){
        if(x.second>=n) ans*=pow(x.first,x.second/n);
    }
    cout<<ans<<ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;
typedef long long ll;

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

    
    ll num = 1;
    ll ans = 0;
    while (h > 1) {
       
        ans += num;
        num *=2;
        h /= 2;
    }

    ans += num;

    cout << ans << endl;


}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
h, w, a, b = map(int, input().split())
s = [[0 for i in range(w)] for i in range(h)]
for i in range(a):
    s[0][i] = 1
for j in range(h):
    for i in range(w):
        if (b == 0) | (j < b):
            s[j][i] = s[0][i]
        else:
            s[j][i] = 1-s[0][i]
for i in range(h):
    print("".join(map(str, s[i])))


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

int main()
{
  int h, w, ans;
  cin >> h >> w;
  
  char c[55][55];
  
  rep(i,h) {
    rep(j,w) {
      cin >> c[i][j];
    }
  }
  
  rep(i,h){
    rep(j,w) {
      if (c[i][j] == '#' &&
          c[i+1][j] != '#' && c[i][j+1] != '#' &&
          c[i-1][j] != '#' && c[i][j-1] != '#')	ans++;
    }
  }
  if (ans == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int K,num[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  scanf("%d",&K);
  printf("%d",num[K-1]);
  return 0;
}

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

signed main(){

  int n,a,b,c;
  cin>>n>>a>>b>>c;
  vector<int> l(n);
  for(auto& li:l)cin>>li;

  int ans = 1LL<<28;
  auto dfs = [&](auto&& dfs,int aa,int bb,int cc,int i,int mp){
    if(i==n){
      if(aa==0||bb==0||cc==0)return;
      int tmp = abs(aa-a)+abs(bb-b)+abs(cc-c)+mp-30;
      ans = min(ans,tmp);
      return;
    }
    dfs(dfs,aa+l[i],bb,cc,i+1,mp+10);
    dfs(dfs,aa,bb+l[i],cc,i+1,mp+10);
    dfs(dfs,aa,bb,cc+l[i],i+1,mp+10);
    dfs(dfs,aa,bb,cc,i+1,mp);
  };
  dfs(dfs,0,0,0,0,0);
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  map<int, int> mp;
  rep(i, m) {
    cin >> s[i] >> c[i];
    if (!mp[s[i]]) {
      mp[s[i]] = c[i] + 1;
    } else {
      if (mp[s[i]] != c[i] + 1) {
        cout << -1 << endl;
        return 0;
      }
    }
    if (c[i] == 0 && s[i] == 1 && n > 1) {
      cout << -1 << endl;
      return 0;
    }
  }

  if (m == 0) {
    if (n == 1) {
      cout << 0 << endl;
    } else if (n == 2) {
      cout << 10 << endl;
    } else if (n == 3) {
      cout << 100 << endl;
    }
    return 0;
  }

  for (int j = 1; j <= n; ++j) {
    if (mp[j]) cout << mp[j]-1;
    else if (j == 1) cout << 1;
    else cout << 0;
  }
  cout << endl;
}


Measured memory_bytes: 256
import java.lang.Exception

var nodeList = arrayListOf<Treee>()

fun main(args: Array<String>) {

    val count = readLine()!!.toLong()
    for (i in 1..count) {
        val order = readLine()!!
        when {
            order.contains("insert") -> {
                insert(order.split(" ")[1].toInt())
            }
            order.contains("find") -> {
                println(find(order.split(" ")[1].toInt()))
            }
            order.contains("print") -> {
                printByInorder(nodeList[0])
                println()
                printByPreorder(nodeList[0])
                println()
            }
        }
    }
}


fun find(searchKey: Int): String {
    if (nodeList.count() == 0) return "no"

    var x = nodeList[0]

    while (true) {
        if (searchKey == x.key) {
            return "yes"
        }

        if (x.key < searchKey) {
            if (x.right == null) {
                return "no"
            }
            x = x.right!!
        }

        if (x.key > searchKey) {
            if (x.left == null) {
                return "no"
            }
            x = x.left!!
        }
    }
}

fun insert(addedKey: Int) {
    val addedNode = Treee(nodeList.count(), key = addedKey)

    if (nodeList.count() == 0) {
        nodeList.add(addedNode)
        return
    }

    // ルートノーのから開始
    var x = nodeList[0]
    while (true) {
        if (x.key < addedKey) {

            // 右に配置
            if (x.right == null) {
                x.right = addedNode
                break

            } else {
                x = x.right!!
            }
        } else if (x.key > addedKey) {

            // 左に配置
            if (x.left == null) {
                x.left = addedNode
                break;

            } else {
                x = x.left!!
            }

        } else {
            throw Exception("key is duplicated!!!")
        }
    }

    nodeList.add(addedNode)
}

fun printByPreorder(node: Treee) {

    print(" ${node.key}")

    if (node.left != null) {
        printByPreorder(node.left!!)
    }

    if (node.right != null) {
        printByPreorder(node.right!!)
    }
}


fun printByInorder(node: Treee) {

    if (node.left != null) {
        printByInorder(node.left!!)
    }

    print(" ${node.key}")

    if (node.right != null) {
        printByInorder(node.right!!)
    }
}

data class Treee(
    var id: Int,
    var parent: Int = -1,
    var left: Treee? = null,
    var right: Treee? = null,
    var key: Int
)


Measured memory_bytes: 192360
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int[] x = new int[3];
        for(int i = 0; i < 3; i++){
            x[i] = scn.nextInt();
        }
        Arrays.sort(x);
        System.out.println(x[0] + " "+ x[1] + " " + x[2]);
    }
}


Measured memory_bytes: 26368
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define  clr(v,val)      memset(v,val,sizeof(v))
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
ll setBit1(ll num, ll idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=200000+9,mod=1e9+7;
ll solve(ll r,ll d){

   return r/d;
}
int main(){
    GO();

    int T;
    T=1;
    while(T--){
        int n;
        cin>>n;
        int cnt=0;
        for(int i=1;i<=n;i++){
            int no;
            cin>>no;
            if(no%2!=0&&i%2!=0) cnt++;
        }
        cout<<cnt<<"\n";

    }

}




















































































Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
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;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b,ll c){if(a==b)out(c);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll n,k;cin>>n>>k;
    out(min(abs(n%k),abs(n%k-k)));
}

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

using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
#define inf 1ll<<60
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define int llong
#define be(x) x.begin(), x.end()
typedef pair<int, int> P;


signed main(){
	int n, in;
	cin >> n;
	int sum = 0, maxi = -1;
	for(int i = 0; i < n; i++){
		cin >> in;
		sum += in;
		maxi = max(maxi, in);
	}

	sum -= maxi;
	if(sum > maxi)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
# 素因数分解問題
import math
from collections import Counter

N = int(input())
mod = 10**9+7

def prime_factorize(n):
    c = Counter()
    for i in range(2, int(math.sqrt(n))+2):
      while n % i == 0:
        c[i] += 1
        n //= i
    
    if n > 1:
      c[n] += 1
    return c

counters = []
for n in range(1, N+1):
  counters.append(Counter(prime_factorize(n)))

cnt = Counter()
for c in counters:
  for (key, val) in c.items():
    cnt[key] += val
  
ans = 1

for (key, value) in cnt.items():
  ans *= value + 1

print(ans % mod)

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int main()
{
	int a,c5=0,c7=0;
	for(int i=0;i<3;i++)
	{
		scanf("%d",&a);
		if(a==5)
			c5++;
		else if(a==7)
			c7++;
	}
	if(c5==2 && c7==1)
		printf("YES\n");
	else
		printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

ll calc(int oc, int ec) {
    ll EC = pow(2, ec);
    ll OC = pow(2, oc-1);
    if (oc == 0) OC = 0;
    ll ret = OC*EC;
    return ret;
}

int main(int argc, char const *argv[])
{
    int n, p;
    std::cin >> n >> p;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    int oc = 0;
    int ec = 0;
    for (int i = 0; i < n; i++) {
        if(a[i]%2 == 0) ec++;
        else oc++;
    }
    ll ans = calc(oc, ec);
    ll all = pow(2.0, n);
    if (p == 1) {
        std::cout << ans << std::endl;
    } else {
        std::cout << all-ans << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;


ll dp[3005][3005][4];
int main(){
    ll R, C, K;
    cin >> R >> C >> K;
    vector<ll> r(K), c(K), v(K);
    vector<vector<ll>> GM(R, vector<ll>(C));
    rep(i,K){
        cin >> r[i] >> c[i] >> v[i];
        r[i]--;c[i]--;
        GM[r[i]][c[i]] = v[i];
    }
    //dp[0][0][0] = 0;
    rep(i,R){
        rep(j,C){
            rep(k,3){
                cmax(dp[i][j][k+1], dp[i][j][k]);
            }
            rep(k,3){
                cmax(dp[i][j][3-k], dp[i][j][3-k-1] + GM[i][j]);
            }
            rep(k,4){
                cmax(dp[i+1][j][0], dp[i][j][k]);
                cmax(dp[i][j+1][k], dp[i][j][k]);
            }
        }
    }
    /*
    rep(i,R+1){
        rep(j,C+1){
            cout << dp[i][j][3] << " ";
        }
        cout << endl;
    }*/
    cout << max(dp[R-1][C][3], dp[R][C-1][3])  << endl;
}

Measured memory_bytes: 360140
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
signed main(){
  string s[19];
  for(int i=0;i<19;i++) cin>>s[i];

  int sy,sx;
  vector<int> v;
  for(int i=0;i<19;i++){
    for(int j=0;j<15;j++){
      if(s[i][j]=='O') sy=i,sx=j;
      if(s[i][j]=='X') v.push_back(i*15+j);
    }
  }
  
  int n=v.size();
  int sb=(sy*15+sx)<<n;
  
  map<int,int> m;
  for(int i=0;i<n;i++) m[v[i]]=i;

  int ax[]={-1,-1,-1,0,0,1,1,1};
  int ay[]={-1,0,1,-1,1,-1,0,1};
  
  int ans=-1,mask=(1<<n)-1;
  priority_queue<P> q;
  q.push(P(0,sb));
  map<int,int> ms;
  ms[sb]=0;
  
  while(!q.empty()){
    P p=q.top();q.pop();
    int d=-p.first,b=p.second;
    int cy=(b>>n)/15,cx=(b>>n)%15;
    //cout<<(b>>n)<<" "<<cy<<" "<<cx<<" "<<d<<endl;
    if(ms[b]<d) continue;
    for(int k=0;k<8;k++){
      int ny=cy+ay[k],nx=cx+ax[k],nb=b&mask,nd=d+1;
      if(!m.count(ny*15+nx)) continue;
      //cout<<ny<<" "<<nx<<" "<<nb<<" "<<nd<<endl;
      if(nb&(1<<m[ny*15+nx])) continue;
      while(m.count(ny*15+nx)){
	if(nb&(1<<m[ny*15+nx])) break;
	//cout<<n<<":"<<m[ny*15+nx]<<" "<<nb<<" "<<(1<<m[ny*15+nx])<<endl;
	nb+=1<<m[ny*15+nx];
	ny+=ay[k];
	nx+=ax[k];
      }
      //cout<<ny<<" "<<nx<<" "<<ny*15+nx<<" "<<nb<<endl;
      if(ny==18&&0<=nx&&nx<15){
	ans=nd;
	goto END;
      }
      if(ny>18){
	ans=nd;
	goto END;
      }
      if(ny<0||nx<0||nx>=15) continue;
      nb+=(ny*15+nx)<<n;
      //cout<<nb<<" "<<(nb&mask)<<" "<<(nb>>n)<<endl;
      if(ms.count(nb)&&ms[nb]<=nd) continue;
      ms[nb]=nd;
      q.push(P(-nd,nb));
    }
  }
 END:
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 8404
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<x<<endl;
#define Nmax 500005
using namespace std;

ll n, ans, a, b, H, W, h, w;
string s;

int main()
{
    cin >> H >> W >> h >> w;

    if (H % h){
        cout << "Yes\n";
        for (int i=0;i<H;i++){
            for (int j=0;j<W;j++){
                if (i%h==0) cout << 1000 * (h-1) - 1 << ' ';
                else cout << -1000 << ' ';
            }
            cout << '\n';
        }
    }
    else if (W % w){
        cout << "Yes\n";
        for (int i=0;i<H;i++){
            for (int j=0;j<W;j++){
                if (j%w==0) cout << 1000 * (w-1) - 1 << ' ';
                else cout << -1000 << ' ';
            }
            cout << '\n';
        }
    }
    else{
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 1664
n = int(input())
l = list(map(int,input().split()))
x = [*l]
ans = 0
mod = 1000000007
for i in range(1,n):
  l[i] += l[i-1]
i = 0
while i<n-1:
  ans += (x[i])*(l[n-1] - l[i])
  i += 1
print(ans%mod)


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

int main(){
	int n;
	int cnt;
	while(cin >> n){
		cnt = 0;
		for(int i = 0; i <= 9 ; i++){
			for(int j = 0; j <= 9; j++){
				for(int k = 0; k <= 9; k++){
					for(int l = 0; l <= 9; l++){
						if(i+j+k+l == n){
							cnt++;
						}
					}
				}
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1160
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
int check(int x)
{
	if ((x >= 1) && (x <= 399))
	{
		return 0;
	}
	if ((x >= 400) && (x <= 799))
	{
		return 1;
	}
	if ((x >= 800) && (x <= 1199))
	{
		return 2;
	}
	if ((x >= 1200) && (x <= 1599))
	{
		return 3;
	}
	if ((x >= 1600) && (x <= 1999))
	{
		return 4;
	}
	if ((x >= 2000) && (x <= 2399))
	{
		return 5;
	}
	if ((x >= 2400) && (x <= 2799))
	{
		return 6;
	}
	if ((x >= 2800) && (x <= 3199))
	{
		return 7;
	}

	return 8;

}

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

	int N;
	
	cin >> N;

	int a[9];
	memset(a, 0, sizeof(a));

	rep(i, N)
	{
		int tmp;
		cin >> tmp;
		//int ret = check(tmp);
		a[check(tmp)]++;
	}

	int _min = 0; int _max = 0;

	rep(i, 9)
	{
		if ((a[i] > 0) && (i < 8))
		{
			_min++;
			_max++;
		}
		if (i == 8)
		{
			_max += a[8];
		}
	}
	_min = max(1, _min);

	cout << _min << " " << _max << endl;
	
	return 0;
}


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

using namespace std;
using ll=long long;

int main()
{
    int n;cin >>n;
    ll mod=1000000007;
    ll a[n];for(int i=0;i<n;i++)cin >>a[i];
    ll c[60];
    for(int i=0;i<60;i++)c[i]=0;
    for(int i=0;i<60;i++){
        for(int j=0;j<n;j++){
            if(a[j]>>i&1)c[i]++;
        }
    }
    ll ans=0;
    for(int i=0;i<60;i++){
        ll x=c[i]*(n-c[i])%mod;
        for(int j=0;j<i;j++)x=x*2%mod;
        ans+=x;
        ans%=mod;
    }
    ans%=mod;
    cout << ans<< endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#include <boost/range/algorithm.hpp> // boost::sort(arr)

int main() {
  int x, y;
  cin >> x >> y;
  map<int, int> d;
  d[4] = d[6] = d[9] = d[11] = 1;
  d[2] = 2;
  cout << (d[x] == d[y] ? "Yes": "No") << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	var c int
	if(b % a == 0){
		c = b + a
	} else {
		c = b - a
	}
	fmt.Printf("%d\n", c)
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if(s == "ABC")
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("ABC");
            }
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



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

int main() {
  long long A;
  long double B;
  cin >> A >> B;
  long double e = A*B;
  long long f = e;  // ここでdouble型からint型への変換が起こる(小数点以下が切り捨てられて3になる)
  cout << f << endl;
  
}


Measured memory_bytes: 3740
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  if (n > 500) {
    n -= 800;
  } else {
    n += 800;
  }
  if (n % 100 > 50) {
    n -= 80;
  } else {
    n += 80;
  }
  if (n % 10 > 5) {
    n -= 8;
  } else {
    n += 8;
  }
  printf("%d\n", n);
  return 0;
}


Measured memory_bytes: 128