akhauriyash/Code-Regression huggingface dataset:
x, y = gets.split.map(&:to_i)
ans = 0
if x == 3
  ans += 100000
elsif x == 2
  ans += 200000
elsif x == 1
  ans += 300000
end

if y == 3
  ans += 100000
elsif y == 2
  ans += 200000
elsif y == 1
  ans += 300000
end

if x == 1 && y == 1
  ans += 400000
end

puts ans


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

using namespace std;

long long power(long long n) {
    return n*n*n*n*n;
}

int main() {
    long long x;
    cin >> x;

    for(long long a=-118; a<=119; a++) {
        for(long long b=-119; b<a; b++) {
            if(power(a) - power(b) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
 
ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}
 
ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}
 
int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
 
  int x,y;cin>>x>>y;
  if(x*2 <= y && y <= x*4 && y%2 == 0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

void func(string  &S){

    map<lli,lli> cnt;

    cnt[0]++;
    lli num = 0;
    lli ten = 1;
    reverse(S.begin(),S.end());
    REP(i,0,S.size()){
        num += (S[i]-'0')*ten;
        num%=2019;
        ten *= 10;
        ten %=2019;
        cnt[num]++;
    }

    lli ans = 0;
    for(auto e:cnt){
        ans += (e.second)*(e.second-1)/2;
    }

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    string s;
    cin>>s;
    func(s);
    return 0;
}


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

int main()
{
    int n, w;
    cin >> n >> w;
    vector<string> vec(n);
    string m;
    m = "##";
    for (int i=0; i<w; i++){
        m += '#';
    }
    for (int i=0; i<n; i++){
        string s;
        cin >> s;
        vec.at(i) = '#' + s + '#';
    }
    cout << m << endl;
    for (int i=0; i<n; i++){
        cout << vec.at(i) << endl;
    }
    cout << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#define     int                 ll
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    long double a,b;
    cin>>a>>b;
    a*=b;
    cout<<(int)a<<'\n';
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}


Measured memory_bytes: 3744
def main():
    h, w = map(int, input().split())
    mat = [['#' for _ in range(w+2)] for _ in range(h+2)]

    inp = [[c for c in input()] for _ in range(h)]
    for i in range(1, h+1):
        for j in range(1, w+1):
            mat[i][j] = inp[i-1][j-1]

    for i in range(h+2):
        print(''.join(mat[i]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
import sys

n=int(input())
s=input()
count=0

if n%2==1:
  print("No")
  sys.exit()
else:
  for i in range(int(n/2)):
    if s[i]==s[i+int(n/2)]:
      count+=1
    
if count==n/2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn solve(x: i32) -> i32 {
    let mut i: i32 = 1;
    while i * (i - 1) / 2 < x {
        i += 1;
    }
    i-1
}

fn main() {
    let x: i32 = read();

    println!("{}", solve(x));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int main() {
	string inp; cin >> inp;
	int n = (int)inp.length();
	if (inp[n-1] == 's') cout << inp << "es\n";
	else cout << inp << "s\n";
	return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

const int MAXN = 50;
const int MAXM = 12;

int dp[MAXN][MAXM * MAXN + 1][MAXM * MAXN + 1];

int N, Ma, Mb;
int a[MAXN], b[MAXN], c[MAXN];

int solve(int idx, int A, int B) {
    int& res = dp[idx][A][B];
    if (res != 1e8) return res;
    if (A > 0 and B > 0 and Ma*B == Mb*A) {
        res = 0;
    }
    else if (idx >= N) {
        res = 1e9;
    }
    else {
        res = min(solve(idx+1, A, B), solve(idx+1, A+a[idx], B+b[idx]) + c[idx]);
    }
    return res;
}

int main() {
    cin >> N >> Ma >> Mb;
    rep(i, N) cin >> a[i] >> b[i] >> c[i];
    rep(i, MAXN) rep(j, MAXM*MAXN+1) rep(k, MAXM*MAXN+1) dp[i][j][k] = 1e8;
    int ans = solve(0, 0, 0);
    cout << (ans >= 1e8 ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 70784
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

long ans = 0;

void att(long h) {
  ++ans;
  if(h == 1) {
    return;
  }
  att(h / 2);
  att(h / 2);
}
int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  long n;
  // int m;
  cin >> n;
  // cin >> m;
  // static long a[1000000000001];
  //
  // a[1] = 1;
  // for(int i = 2; i <= n; i++) {
  //   a[i] = 1 + 2 * a[i / 2];
  // }
  //
  // // att(n);
  //
  // // cout << ans << endl;
  // cout << a[n] << endl;
  // cout << int(log2(n)) << endl;
  long res = (long)(pow(2, int(log2(n)) + 1)) - 1;
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 512
s = sorted(input())
t = sorted(input())[::-1]

for n in range(min(len(s)-1,len(t)-1)):
  if ord(s[0])<ord(t[0]):
    print("Yes")
    exit()
  elif ord(s[0])>ord(t[0]):
    print("No")
    exit()
  else:
    s = s[1:]
    t = t[1:]
    
if ord(s[0])<ord(t[0]) :
  print("Yes")
elif ord(s[0])>ord(t[0]):
  print("No")
elif len(s)<len(t):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9100
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll n, m;

int main()
{
    cin >> n >> m;
    ll c_n = 0;
    ll c_m = 0;
    if (n <= 1)
    {
        c_n = 0;
    }
    else
    {
        c_n = n * (n - 1) / 2;
    }

    if (m <= 1)
    {
        c_m = 0;
    }
    else
    {
        c_m = m * (m - 1) / 2;
    }

    cout << c_n + c_m << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int H, W, D, Q, L, R, A;

  std::cin >> H >> W >> D;

  std::vector<std::pair<int, int>> pairs(H * W);

  for (int i = 0; i < H; i ++)
    for (int j = 0; j < W; j ++) {
      std::cin >> A;

      pairs[A - 1] = std::make_pair(j, i);
    }

  std::vector<std::vector<int>> a(D);

  std::vector<std::pair<int, int>> b(H * W);

  for (int i = 0; i < D; i ++) {
    a[i].push_back(0);
    
    for (int j = 0, k = i; k < H * W; j ++, k += D) {
      int l = k + D;

      if (l < H * W) {
        int x0 = pairs[k].first, y0 = pairs[k].second;
        int x1 = pairs[l].first, y1 = pairs[l].second;

        int d = std::abs(x1 - x0) + std::abs(y1 - y0);

        a[i].push_back(d + a[i].back());
      }

      b[k] = std::make_pair(i, j);
    }
  }

  std::cin >> Q;

  for (int i = 0; i < Q; i ++) {
    std::cin >> L >> R;

    L --;
    R --;

    std::cout << a[b[R].first][b[R].second] - a[b[L].first][b[L].second] << std::endl;
  }

  return 0;
}


Measured memory_bytes: 6784
w, h, n = map(int, input().split())

min_x = 0
max_x = w
min_y = 0
max_y = h

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and min_x < x:
        min_x = x
    if a == 2 and x < max_x:
        max_x = x
    if a == 3 and min_y < y:
        min_y = y
    if a == 4 and y < max_y:
        max_y = y

ans = (max_x-min_x)*(max_y-min_y)
if max_x-min_x < 0 or max_y-min_y < 0:
    ans = 0

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b;
    cin >> a >> b ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    //*
    if( a < 6 ){
        cout << 0 << endl;
    } else if (a < 13){
        cout << b / 2 << endl;
    } else {
        cout << b << endl;
    }
    //*/
    
    //cout << c / a * b << endl;

    return 0; 
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#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)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int r, D, x;
  cin >> r >> D >> x;
  rep(i, 10) {
    x = r * x - D;
    cout << x << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    if (n % 2 == 1) {
        cout << "First" << '\n';
        return 0;
    }
    vector<int> was(n);
    function<void(int, int)> dfs = [&](int v, int p) {
        for (int to : g[v]) {
            if (to == p) {
                continue;
            }
            dfs(to, v);
        }
        if (!was[v]) {
            was[v] = 1;
            if (p == -1 || was[p]) {
                cout << "First" << '\n';
                exit(0);
            } else {
                was[p] = 1;
            }
        }
    };
    dfs(0, -1);
    cout << "Second" << '\n';
    return 0;
}


Measured memory_bytes: 9608
Scanf.scanf "%d" (fun t ->
    let z = 1000000007 in
    let ( +@) a b = (a + b) mod z in
    let ( *@) a b = (a * b) mod z in
    let calc n =
        let coeff_even =
            [| 869418286; 727008098; 660103155; 183023413; 471090892; 417297686; 237315285; 542573865;
               444014759; 927321758; 184117322; 5655049;   347662323; 346175634; 765144583; 0         |]
        in
        let coeff_odd =
            [| 869418286; 727008098; 660103155; 183023413; 471090892; 417297686; 237315285; 542573865;
               444014759; 927321758; 184117322; 962779130; 404391958; 700407153; 729548371; 539588932 |]
        in
        let co = if n mod 2 = 0 then coeff_even else coeff_odd in
        Array.fold_left (fun acc v -> acc *@ n +@ v) 0 co |> Printf.printf "%d\n"
    in
    for i = 1 to t do
        Scanf.scanf " %d" calc
    done
)

Measured memory_bytes: 3884
r,c = map(int,input().split())
x = [] * r

for _ in range(r):
    l = list(map(int,input().split()))
    l.append(sum(l))
    x.append (l)

l = []
for i in range(c+1):
    total = 0
    for j in range(r):
        total += x[j][i]
    l.append (total)
x.append (l)

for l in x:
    print(' '.join(map(str, l)))



Measured memory_bytes: 5704
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const long long mod = 1e9 + 7;

int n;
int arr[MAXN];
char c;
void solve(){
    int x = (int)c;
    if(c <= 90)
        cout << "A";
    else
        cout << "a";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i = 0;
    cin >> c;
    solve();
    return 0;
}


Measured memory_bytes: 3608
n,q=map(int,input().split())
s=input()
a=[0]*n
for i in range(n-1):
  if s[i:i+2]=="AC":
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
for i in range(q):
  l,r=map(int,input().split())
  if l==1:
    print(a[r-2])
  else:
    print(a[r-2]-a[l-2])


Measured memory_bytes: 53840
import sys
mod = 10**9 + 7

def nai():
    print(0)
    sys.exit()

N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))

M = max(A)
if M != max(T):
    nai()

iT = T.index(M)
iA = N - 1 - A[::-1].index(M)
if iA < iT:
    nai()
ans = pow(M, max(0, iA - iT - 1), mod)
pre = -1
for t in T[:iT]:
    if pre == t:
        ans = t*ans%mod
    pre = t
pre = -1
for a in A[::-1]:
    if a == M:
        break
    if pre == a:
        ans = a*ans%mod
    pre = a
print(ans)

Measured memory_bytes: 82660
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;


LL modpow(LL a, LL b) {
  LL r = 1;
  while (b) {
    if (b % 2 == 1) r = r * a % kMod;
    a = a * a % kMod;
    b /= 2;
  }
  return r;
}

int main() {
  LL N, K; cin >> N >> K;

  vector<LL> v(K+1);
  for (LL i = 1; i <= K; ++i) {
    LL x = K / i;
    v[i] = modpow(x, N);
  }

  for (LL i = K; i > 0; --i) {
    for (LL j = 2; i * j <= K; ++j) {
      LL index = i * j;
      v[i] = (v[i] + kMod - v[index]) % kMod;
    }
  }

  LL sum = 0;
  for (LL i = 1; i <= K; ++i) {
    LL item = i * v[i] % kMod;
    sum = (sum + item) % kMod;
  }
  cout << sum << endl;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 307;

int n, K;
char s[MAXN];
int dp[MAXN][MAXN][MAXN];

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%s%d", s + 1, &K );
}

void work ()
{
	// main work

	n = strlen ( s + 1 );

	lpi ( i, 0, K ) {
		lpi ( l, 1, n ) dp[l][l][i] = 1;
		lpi ( d, 2, n ) {
			lpi ( l, 1, n - d + 1 ) {
				int r = l + d - 1;
				dp[l][r][i] = qmax ( dp[l + 1][r][i], dp[l][r - 1][i] );
				if ( s[l] == s[r] ) dp[l][r][i] = qmax ( dp[l][r][i], dp[l + 1][r - 1][i] + 2 );
				else if ( i ) dp[l][r][i] = qmax ( dp[l][r][i], dp[l + 1][r - 1][i - 1] + 2 );
			}
		}
	}

	cout << dp[1][n][K] << endl;
}

Measured memory_bytes: 112512
N = int( input())
XYU = [ tuple( input().split()) for _ in range(N)]
U = []
R = []
D = []
L = []
for x, y, u in XYU:
    x, y = int(x), int(y)
    if u == "U":
        U.append((x,y))
    elif u == "D":
        D.append((x,y))
    elif u == "L":
        L.append((x,y))
    else:
        R.append((x,y))
ans = [10**9]
def z(A):
    A.sort()
    n = -10**10
    p = -10**10
    for k, c, a in A:
        if k != n:
            if a == 1:
                n = k
                p = c
                continue
            else:
                continue
        if a == 1:
            p = c
            continue
        if (c - p)*5 < ans[0]:
            ans[0] = (c - p)*5
z([(x,y,1) for x, y in U] + [(x,y,-1) for x, y in D])
z([(y,x,1) for x, y in R] + [(y,x,-1) for x, y in L])
z([(x+y,x-y,1) for x, y in R] + [(x+y,x-y,-1) for x,y in U])
z([(x+y,x-y,1) for x, y in D] + [(x+y,x-y,-1) for x,y in L])
z([(x-y,x+y,1) for x,y in U] + [(x-y,x+y,-1) for x,y in L])
z([(x-y,x+y,1) for x,y in R] + [(x-y,x+y,-1) for x,y in D])
if ans[0] < 10**9:
    print(ans[0])
else:
    print("SAFE")


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

using namespace std;

int main(){
  vector<int> a(3);
  int k;

  cin>>a[0]>>a[1]>>a[2]>>k;

  for(int i=0; i<k; ++i){
    sort(a.begin(),a.end());
    a[2]*=2;
  }

  cout << a[0]+a[1]+a[2] << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
   int n,m; cin>>n>>m;
   vector<int> a(n);
   for(int i=0;i<n;i++) cin>>a[i];
   sort(a.rbegin(),a.rend());
   double sum=0;
   for(int i=0;i<n;i++) sum+=a[i];
   if(a[m-1]>=(sum/4/m)) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n,i;
  char s[111],t[111];
  scanf("%d%s%s",&n,s,t);
  for(i=0;i<n;i++){
    if(strstr(t,&s[i])==t) break;
  }
  printf("%d\n",n+i);
}

Measured memory_bytes: 128
X,K, D= list(map(int,input().split()))
X=abs(X)
if X//D <K:
    K_min=X//D
    X=X-D*(K_min)
    if (K-K_min) %2 ==0:
      print(abs(X))
    else:
      print(abs(X-D))
 
 
else:
    K_min=K
    X=X-D*(K_min)
    print(abs(X))

Measured memory_bytes: 9116
from collections import defaultdict
H, W, D = map(int, input().split())
B = {}
for i in range(H):
    Ai = [int(x) for x in input().split()]
    for j, Aij in enumerate(Ai):
        B[Aij] = (i, j)
costs = defaultdict(list)

costs = [0] * (H * W + 1)
for i in range(D + 1, W * H + 1):
    x1, y1 = B[i - D]
    x2, y2 = B[i]
    costs[i] = costs[i - D] + abs(x1 - x2) + abs(y1 - y2)

Q = int(input())
for i in range(Q):
    Li, Ri = map(int, input().split())
    print(costs[Ri] - costs[Li])

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

int main(){
  int n;
  std::cin >> n;
  struct hoge{
    int p;
    int num;
    std::string name;
  };
  std::vector<hoge> data(n);
  for( int i=0; i<n; ++i ){
    std::cin >> data[i].name >> data[i].p;
    data[i].num = i;
  };
  std::sort( data.begin(), data.end(),
    [](const hoge &a, const hoge &b ){
      int i = (a.name).compare( b.name );
      if ( i < 0 ){
        return true;
      } else if ( i > 0 ){
        return false;
      } else {
        if ( a.p > b.p ){
          return true;
        } else {
          return false;
        }
      }
    }
  );
  for( hoge v: data ){
    std::cout << ( v.num + 1) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
from functools import reduce
import math
from operator import itemgetter

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    ab = []
    cd = []
    for i in range(N):
        s1, s2 = (int(_) for _ in input().split())
        ab.append((s1,s2))
    for i in range(N):
        s1, s2 = (int(_) for _ in input().split())
        cd.append((s1,s2))
    cnt = 0
    ab = sorted(ab, key = itemgetter(0))
    cd = sorted(cd, key = itemgetter(0))
    for i in range(N):
        rp = -1
        tmp = -1
        for j in range(len(ab)):
            # print(ab[j],cd[i])
            if ab[j][0]<cd[i][0] and ab[j][1]<cd[i][1]:
                if ab[j][1] > tmp:                    
                    tmp = ab[j][1]
                    rp = j
        if rp >=0:
            # print(ab[rp])
            ab.pop(rp)
            cnt +=1
    print(cnt)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

bool is_prime(int x) {
    if(x <= 1) return false;
    for(int i = 2; i * i <= x; ++i) {
        if(x % i == 0) return false;
    }
    return true;
}

signed main(void) {
    int x; cin >> x;
    while(!is_prime(x)) x++;
    print(x);

    return 0;
}


Measured memory_bytes: 256
import heapq
N, K = map( int, input().split())
V = list(  map( int, input().split()))
ans = 0
for i in range(N+1):
    for j in range(N+1):
        if i + j > K or i + j > N:
            break
        cnt = i+j
        if j == 0:
            q = V[:i]
            now = sum(q)
            heapq.heapify(q)
            while q and (cnt < K):
                t = heapq.heappop(q)
                if t >= 0:
                    break
                else:
                    now += -t
                    cnt += 1
        else:
            q = V[:i] + V[-j:]
            now = sum(q)
            heapq.heapify(q)
            while q and (cnt < K):
                t = heapq.heappop(q)
                if t >= 0:
                    break
                else:
                    now += -t
                    cnt += 1
        if ans < now:
            ans = now
print( ans)

Measured memory_bytes: 52060
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(int i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ul>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()
/*
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}*/
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
 const int nax = 2005;
int n;
pair<int,int> arr[nax];
int dp[nax][nax];

 int get_ac(int cur,int l ,int r)
 {
     if(cur >= n)
        return 0;
     if(dp[cur][l] != -1)
            return dp[cur][l];
    int left = arr[cur].ff * abs(l - arr[cur].ss)
            + get_ac(cur+1,l+1,r);
     int right = arr[cur].ff * abs(r - arr[cur].ss) +
            get_ac(cur+1,l,r-1);
       dp[cur][l]  = max(left,right);            

    return dp[cur][l];
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    memset(dp,-1,sizeof(dp));
    f(n)
    {
        int val;   cin>>val;
        arr[i].ff = val;
        arr[i].ss = i;
    }
    sort(arr,arr+n);
    reverse(arr,arr+n);
    cout << get_ac(0,0,n-1);
    return 0;
}
    


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

int main(){
    long long int n,m;
    scanf("%lld %lld",&n,&m);
    long long int ans;
    long long int i=0;
    if(m > 2 * n)i = floor((m - 2 * n) / 4.0);
    n += i;
    m -= 2*i;
    if(m >= 2*n)ans = n;
    else ans = floor(m / 2);
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define N 101
using namespace std;
char ch;
int s[N],top;
int main(){
    ch = getchar();
    while(true){
        if(ch == '+'){
            s[--top] = s[top] + s[top+1];
        }
        else if (ch == '-') {
            s[--top] = s[top] - s[top+1];
        }
        else if (ch == '*'){
            s[--top] = s[top]*s[top+1];
        }
        else if (ch == ' '){
            ch = getchar();
            continue;
        }else if(ch >= '0' && ch <= '9'){
            int a = 0;
            a += ch - 48;
            ch = getchar();
            while(ch != ' '){
                a = a*10 + ch - 48;
                ch = getchar();
            }
            s[++top] = a;
        }
        else{
            printf("%d\n",s[top]);
            return 0;
        }
        ch = getchar();
    }
    printf("%d\n",s[top]);
    return 0;
}


Measured memory_bytes: 3148
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	nn := n
	sum := 0
	for {
		sum += nn % 10
		nn /= 10
		if nn == 0 {
			break
		}
	}

	if n % sum == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
c=0;b=1;i=0
while b:
 b=0
 for j in range(n-i-1):
  if a[j]>a[j+1]:a[j],a[j+1]=a[j+1],a[j];b=1;c+=1
 i+=1
print(*a)
print(c)


Measured memory_bytes: 5604
from collections import defaultdict

N = int(input())
L = list(map(int, input().split()))

if len(set(L)) == 1:
    print(N//2)
    exit()
if N == 2:
    print(0)
    exit()


d_even = defaultdict(int)
d_odd = defaultdict(int)

for i in range(N):
    v = L[i]
    if i % 2 == 0:
        d_even[v] += 1
    else:
        d_odd[v] += 1

l_even = sorted(d_even.items(), key=lambda x: -x[1])
l_odd = sorted(d_odd.items(), key=lambda x: -x[1])

if l_even[0][0] != l_odd[0][0]:
    print(N - l_even[0][1] - l_odd[0][1])
else:
    # どちらも試してコストの小さい方を採用する
    ans1 = N - l_even[0][1] - l_odd[1][1]
    ans2 = N - l_even[1][1] - l_odd[0][1]
    print(min(ans1, ans2))


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

using namespace std;

const int N = 20000 + 77;
int n , W[N] , S[N] , T[N] , P[N];
long long dp[N] , A;
bool CMP(int x , int y){
   return W[x] + S[x] < W[y] + S[y];
}
int main(){
   for(int i = 1;i < N;++ i)
      dp[i] = - 1e18;
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n;
   for(int i = 1;i <= n;++ i)
      cin >> W[i] >> S[i] >> T[i] , P[i] = i;
   sort(P + 1 , P + 1 + n , CMP);
   for(int i = 1;i <= n;++ i){
      int id = P[i];
      for(int j = S[id] + W[id];j >= W[id];-- j)
         dp[j] = max(dp[j] , dp[j - W[id]] + T[id]);
   }
   for(int i = 1;i < N;++ i)
      A = max(A , dp[i]);
   cout << A;
   return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    REP(i, n + 1){
        cin >> a.at(i);
    }

    const ll asum = accumulate(ALL(a), 0LL);

    vector<ll> lb(n + 1, 0), ub(n + 1, (n + 1) * asum);
    REP(i, n + 1){
        if(i == n){
            lb.at(i) = a.at(i);
            ub.at(i) = min(ub.at(i), a.at(i));
        }else{
            lb.at(i) = a.at(i) + 1;
        }
        if(i <= 60){
            ub.at(i) = min(ub.at(i), 1LL << i);
        }
    }

    REP(_, 1){
        for(ll i = n - 1; i >= 0; --i){
            lb.at(i) = max(lb.at(i), a.at(i) + lb.at(i + 1) / 2);
            ub.at(i) = min(ub.at(i), a.at(i) + ub.at(i + 1));
        }
        for(ll i = 1; i <= n; ++i){
            lb.at(i) = max(lb.at(i), lb.at(i - 1) - a.at(i - 1));
            ub.at(i) = min(ub.at(i), 2 * (ub.at(i - 1) - a.at(i - 1)));
        }
    }

    ll ans = 0;
    REP(i, n + 1){
        // cerr << i << " " << lb.at(i) << " " << ub.at(i) << endl;
        if(lb.at(i) > ub.at(i)){
            cout << -1 << endl;
            return 0;
        }
        ans += ub.at(i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            var S = ReadLine().Split();
            var A = long.Parse(S[0]);
            var op = S[1][0];
            var B = long.Parse(S[2]);
            if (op == '+')
                WriteLine(A + B);
            else
                WriteLine(A - B);
        }
    }
}

Measured memory_bytes: 27412
#include<iostream>

using namespace std;

long long int A, B;

long long int gcd(long long int a, long long int b) {
	if (a < b) { return gcd(b, a); }

	if (b == 0) { return a; }
	return gcd(b, a%b);
}

int main(void) {

	cin >> A >> B;

	cout << (A*B) / gcd(A, B) << endl;
	return 0;
}

Measured memory_bytes: 256
function main(s) {
	var n = Number(s.split("\n")[0]);
	if (n === 0) {console.log(2); return;}
	if (n === 1) {console.log(1); return;}
	if (n === 77) {console.log("12360848946698171"); return;}
	if (n === 78) {console.log("20000273725560978"); return;}
	if (n === 79) {console.log("32361122672259149"); return;}
	if (n === 80) {console.log("52361396397820127"); return;}
	if (n === 81) {console.log("84722519070079276"); return;}
	if (n === 82) {console.log("137083915467899403"); return;}
	if (n === 83) {console.log("221806434537978679"); return;}
	if (n === 84) {console.log("358890350005878082"); return;}
	if (n === 85) {console.log("580696784543856761"); return;}
	if (n === 86) {console.log("939587134549734843"); return;}
	var x = 2;
	var y = 1;
	var z = 0;
	for (var i = 2; i <= n; i++) {
		z = x + y;
		x = y;
		y = z;
	}
	console.log(z);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7372
#!/usr/bin/env python3

import sys

DEBUG = False


def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep=" "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n = read(int)

    ans = 0
    for a in range(1, n + 1):
        ans += (n - 1) // a
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62808
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/15/20 20:19:02
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll n,k; cin>>n>>k;
  vector<int> P(n); for (auto& p:P) {cin>>p; p--;}
  vector<int> C(n); for (auto& c:C) cin>>c;
  vector<bool> vis(n);
  auto dfs = [&](auto f, int s, ll sum, vector<int>& path) {
    if (vis[s]) {
      return sum;
    }
    vis[s] = true;
    path.push_back(C[s]);
    return f(f, P[s], sum+C[s], path);
  };
  ll ans = -2e18;
  for (int s = 0; s < n; s++) {
    if (vis[s]) continue;
    vector<int> path;
    ll sum = dfs(dfs, s, 0, path);
    assert(!path.empty());
    ll m = path.size();
    if (m == 1) {
      ll score = sum > 0 ? k*sum : sum;
      ans = max(ans, score);
      continue;
    }
    vector<ll> cc(m*2);
    for (int i = 0; i < m*2; i++) {
      cc[i] = path[i%m];
      if (i > 0)
        cc[i] += cc[i-1];
    }
    if (sum > 0 and k/m > 0)
      ans = max(ans, sum*(k/m));
    for (int len = 1; len < m; len++) {
      if (len > k)
        break;
      ll bs = -2e18;
      for (int i = 0; i < m; i++) {
        ll cs = cc[i+len-1];
        if (i > 0)
          cs -= cc[i-1];
        bs = max(bs, cs);
      }
      if (sum > 0) {
        if (len <= k%m) {
          bs += sum*(k/m);
        } else {
          bs += sum*(k/m-1);
        }
      }
      ans = max(ans, bs);
    }
  }
  cout << ans << endl;

  return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

char souti(char a, char b) {
	if (a == 'T' and b == 'F') {
		return 'F';
	}
	return 'T';
}

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	vector<char> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	char ans = s[0];
	for (int i = 1; i < n; i++) {
		ans = souti(ans,s[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3272
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		String[] A = new String[N];
		String[] B = new String[M];

		for (int i = 0; i < N; i++) {
			A[i] = sc.next();
		}
		for (int i = 0; i < M;i++) {
			B[i] = sc.next();
		}

		for (int i = 0; i <= N-M; i++) {
			for (int j = 0; j <= N-M; j++) {
				boolean flag = true;
				for (int k = 0;k < M; k++) {
					for (int l =0; l < M; l++) {
						if (A[i+k].charAt(j+l) != B[k].charAt(l)) {
							flag = false;
						}
					}
				}
				if (flag) {
					System.out.println("Yes");
					System.exit(0);
				}
			}
		}
		System.out.println("No");
	}
}


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

using namespace std;
int main(){
	string s;
	cin>>s;
	string s1="";
	string s2="";
	int sum=0;
	for(int i=0;i<s.length();i++){
		s1=s[i]+s1;
		if(s1!=s2){
			sum++;
			s2=s1;
			s1="";
		}
	}

	cout<<sum;

} 


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

using namespace std;

int main()
{
    int n, M=200000000;
    string s;
    cin >> n >> s;
    int A[n+2], B[n+2];
    A[0] = 0;
    B[n+1] = 0;
    for (int i = 1; i <= n; i++)
    {
        A[i] = A[i-1];
        if (s[i-1] == '#')
        {
            A[i]++;
        }
    }
    A[n+1] = A[n];
    for (int i = n; i >= 1; i--)
    {
        B[i] = B[i+1];
        if (s[i-1] == '.')
        {
            B[i]++;
        }
    }
    B[0] = B[1];
    for (int i = 0; i <= n; i++)
    {
        M = min(M, A[i] + B[i+1]);
    }
    cout << M;
    return 0;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        ll A, B;
        cin >> N >> A >> B;
        vll P(N);
        rep(i, 0, N) cin >> P[i];
        sort(all(P));
        vector<bool> used(N);

        ll ans = 0;
        rep(i, 0, N) {
                rep(j, i+1, N) {
                        rep(k, j+1, N) {
                                if (not used[i] and not used[j] and not used[k]) {
                                        if (P[i] <= A and (A+1 <= P[j] and P[j] <= B) and P[k] >= B+1) {
                                                ++ans;
                                                used[i] = used[j] = used[k] = true;
                                        }
                                }
                        }
                }
        }

        cout << ans << endl;
}


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

int main() {
  int h, w;
  char c;
  cin >> h >> w;
  char a[h + 2][w + 2];

  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      a[i][j] = '#';
    }
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> c;
      a[i][j] = c;
    }
  }

  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll H, W;
    cin >> H >> W;
    string s[H];
    ll w_cnt = 0;
    for(auto &x : s) {
        cin >> x;
        for(auto &y : x) {
            if(y == '.') w_cnt++;
        }
    }
    ll dp[H][W];
    for(auto &x : dp) {
        for(auto &y : x) {
            y = INF;
        }
    }
    dp[0][0] = 1;
    queue<pair<ll, ll>> q;
    q.push({0, 0});
    ll dx[] = {0, 0, -1, 1}, dy[] = {-1, 1, 0, 0};
    while(!q.empty()) {
        auto now = q.front();
        q.pop();
        for(i = 0; i < 4; i++) {
            ll ddx = now.second + dx[i], ddy = now.first + dy[i];
            if(ddx >= 0 && ddx < W && ddy >= 0 && ddy < H) {
                if(dp[ddy][ddx] == INF && s[ddy][ddx]=='.') {
                    dp[ddy][ddx] = dp[now.first][now.second] + 1;
                    q.push({ddy, ddx});
                }
            }
        }
    }
    if(dp[H - 1][W - 1] == INF) {
        cout << -1 << endl;
    } else {
        cout << w_cnt - dp[H - 1][W - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 256