akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
ll H, W;
int calc(ll h, ll w) {
  ll ret = h;
  ll h1 = h / 3;
  ll h2 = h - h1;
  ll s1 = h1 * w;
  ll s2 = h2 * (w / 2);
  ll s3 = h * w - s1 - s2;
  ll v[3] = {s1, s2, s3};
  sort(v, v + 3);
  ret = min(ret, v[2] - v[0]);
  if (1) {
    ll h1 = h / 3 + 1;
    ll h2 = h - h1;
    ll s1 = h1 * w;
    ll s2 = h2 * (w / 2);
    ll s3 = h * w - s1 - s2;
    ll v[3] = {s1, s2, s3};
    sort(v, v + 3);
    ret = min(ret, v[2] - v[0]);
  }

  return ret;
}
int main() {
  cin >> H >> W;
  if ((H % 3) == 0 || (W % 3) == 0) {
    cout << 0 << endl;
    return 0;
  }

  int ret = min(H, W);
  ret = min({ret, calc(H,W), calc(W, H)});
  cout << ret << endl;
}


Measured memory_bytes: 256
import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

    N=int(input())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))[::-1]

    from itertools import accumulate


    AA = list(accumulate([0] + A))+[0]  # 累積和を格納したリスト作成
    BB = (list(accumulate([0] + B))+[0])[::-1]  # 累積和を格納したリスト作成

    sumlist=np.array(AA)+np.array(BB)
    print(max(sumlist))


resolve()

Measured memory_bytes: 18584
N = int(input())
A = list(map(int, (input().split())))
l = [0] * N
r = [0] * N
for i in range(N):
    if A[i] + i < N:
        l[A[i]+i] += 1
    if i - A[i] >= 0:
        r[i-A[i]] += 1
ans = 0
for i in range(N):
    ans += l[i]*r[i]
print(ans)

Measured memory_bytes: 32236
#include <iostream>
using namespace std;
#define ll long long

int main()
{
	ll A, B;
	cin >> A >> B;

	ll tempB = B;
	ll max = 1;
	while (1<tempB) {
		tempB /= 2;
		max++;
	}

	ll ret = 0;
	ll r2 = 1;
	ll c = 2;
	for (ll i = 0; i < max; ++i) {
		ll count = 0;
		ll a1 = A / c;
		ll b1 = B / c;

		ll a2 = A % c;
		if (a2 < c / 2) {
			a2 = c / 2;
		}

		if (a1 == b1) {
			ll b2 = B % c;
			count += b2 - a2 + 1;
		}
		else {
			count += c - a2;
			count += (b1 - a1 - 1) * (c / 2);
			ll b2 = B % c;
			if (c / 2 <= b2) {
				count += b2 - c / 2 + 1;
			}
		}

		if (count % 2 == 1) {
			ret += r2;
		}
		r2 *= 2;
		c *= 2;
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
n,*a=map(int,open(0).read().split())
ans=-99999999999999999999
mini=a[0]
for i in range(n-1):
    if a[i]<mini:
        mini=a[i]
    if a[i+1]-mini>ans:
        ans=a[i+1]-mini
print(ans)


Measured memory_bytes: 28228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fr first
#define sc second
void solve(){
    string s; 
    cin>>s; 
    if(s[0]=='7' or s[1]=='7' or s[2]=='7')cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    for (int i = 1; cin >> x, x; ++i) printf("Case %d: %d\n", i, x);
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
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; }

int main() {
  string s, t; cin >> s >> t ;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != t.at(i))
      cnt ++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3852
S = list(input())

if S.count('R') == 0:
    ans = 0
elif S.count('R') == 1:
    ans = 1
elif S.count('R') == 3:
    ans = 3
elif S.count('R') == 2:
    if S[1] == 'R':
        ans = 2
    else:
        ans = 1

print(ans)

Measured memory_bytes: 9112
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int n,k;
    cin>>n>>k;
    
    vector<int> h(n);
    REP(i,n){
        cin>>h.at(i);
    }

    int sum=0;
    REP(i,n){
        if(h.at(i)>=k) sum++;
    }
    cout<<sum<<endl;

    // cout << ans << endl;
    return 0;
}

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

int main(void)
{
	int n, r;
	while (cin >> n >> r, n && r){
		vector <int> card, tmp;
		// いちばんさいしょ＝いちばんうえ
		for (int i = n; 0 < i; i--){
			card.push_back(i);
		}
		/*
		for (int i = 0; i < n; i++){
			cout << card[i] << " ";
		}
		puts("");
		*/
		int p, c;
		while (r--){
			cin >> p >> c;
			for (int i = p; i < p+c; i++){
				tmp.push_back(card[i-1]);
			}
			for (int i = 0; i < p-1; i++){
				tmp.push_back(card[i]);
			}
			for (int i = p+c-1; i < n; i++){
				tmp.push_back(card[i]);
			}
			card = tmp;
			/*
			for (int i = 0; i < n; i++){
				cout << card[i] << " ";
			}
			puts("");
			*/
			tmp.clear();
		}
		cout << card[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string a,b,s;
int x,y;
int main(void){
    cin>>a>>b>>x>>y>>s;
    if(a==s){
        cout<<x-1<<" "<<y<<endl;
    }else{
        cout<<x<<" "<<y-1<<endl;
    }
    
}


Measured memory_bytes: 256
#include<cstdio>
int n, K, Mod = 1000000007, D[2010][2010];
int main(){
    int i, j, k;
    scanf("%d%d",&n,&K);
    D[0][n+1] = 1;
    for(i=1;i<=K;i++){
        int s = D[i-1][n+2-i];
        for(j=n+1-i;j>=1;j--){
            s = (s + D[i-1][j])%Mod;
            D[i][j] = s;
        }
    }
    int r = (D[K][1]-D[K-1][1]+Mod)%Mod;
    for(i=1;i<n-K;i++)r=r*2%Mod;
    printf("%d\n",r);
}

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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

int dp[100500];
int h[100500];

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    forn(i, n)
        cin >> h[i];

    dp[0] = 0;
    forlr(i, 1, n)
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), i >= 2 ? dp[i - 2] + abs(h[i] - h[i - 2]) : int(1e9 + 5000));

    cout << dp[n - 1];

    return 0;
}

Measured memory_bytes: 1024
import sys
from collections import defaultdict

n, *mabs = map(int, sys.stdin.buffer.read().split())
MOD = 998244353
base = 10 ** 18 % MOD
base_costs = [base]
for i in range(n - 1):
    base_costs.append(base_costs[-1] * base % MOD)
graphs = []
i = 0
for _ in range(3):
    m = mabs[i]
    i += 1
    j = i + 2 * m
    parents = [set() for _ in range(n)]
    for a, b in zip(mabs[i:j:2], mabs[i + 1:j:2]):
        a -= 1
        b -= 1
        if a > b:
            a, b = b, a
        parents[a].add(b)
    grundy = [0] * n
    weights = defaultdict(int)
    for v in range(n - 1, -1, -1):
        pgs = {grundy[p] for p in parents[v]}
        for g in range(m + 1):
            if g not in pgs:
                grundy[v] = g
                weights[g] += base_costs[v]
                break

    for g in weights:
        weights[g] %= MOD

    graphs.append(dict(weights))
    i = j

ans = 0
graph_x, graph_y, graph_z = graphs
for gx, cx in graph_x.items():
    for gy, cy in graph_y.items():
        gz = gx ^ gy
        if gz in graph_z:
            ans = (ans + cx * cy * graph_z[gz]) % MOD
print(ans)


Measured memory_bytes: 88204
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

bool uruu(int year){
 if (year % 4 == 0) {
   if (year % 100 == 0) {
     if (year % 400 == 0) {
         return true;
     } else {
         return false;
     }
   } else {
       return true;
   }
 } else {
     return false;
 }   
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> month = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    vector<vector<int>> G(14, vector<int> (10));
    vector<int> t = {6,2,5,5,4,5,6,3,7,6};
    for(int i=0; i<14; i++){
        G[i] = t;
    }
    vector<vector<int>> _(7);
    _[0] = {0,2,3,5,6,7,8,9};
    _[1] = {0,4,5,6,8,9};
    _[2] = {0,1,2,3,4,7,8,9};
    _[3] = {2,3,4,5,6,8,9};
    _[4] = {0,2,6,8};
    _[5] = {0,1,3,4,5,6,7,8,9};
    _[6] = {0,2,3,5,6,8,9};
    int N;
    cin >> N;
    int K;
    cin >> K;
    set<pair<int,int>> se;
    for(int i=0; i<K; i++){
        int a,b;
        cin >> a >> b;
        if(se.count(P(a,b))) continue;
        for(int j=0; j<_[b].size(); j++){
            G[a][_[b][j]]--;
        }
        se.insert(P(a,b));
    }
    vector<ll> time_num(50,0);
    for(int i=0; i<24; i++){
        for(int j=0; j<60; j++){
            for(int k=0; k<60; k++){                
                int sum = 0;
                sum += G[8][i/10];
                sum += G[9][i%10];
                sum += G[10][j/10];
                sum += G[11][j%10];
                sum += G[12][k/10];
                sum += G[13][k%10];
                time_num[sum]++;
            }
        }
    }
    // for(int i=0; i<50; i++){
    //     cout << time_num[i] << "\n";
    // }
    ll ans = 0;
    for(int y=0; y<10000; y++){
        for(int m=1; m<=12; m++){
            bool uru = (m==2 and uruu(y));
            for(int d=1; d<=month[m]+uru; d++){
                int sum = 0;
                int year = y;
                sum += G[0][year/1000];
                year %= 1000;
                sum += G[1][year/100];
                year %= 100;
                sum += G[2][year/10];
                sum += G[3][year%10];
                sum += G[4][m/10];
                sum += G[5][m%10];
                sum += G[6][d/10];
                sum += G[7][d%10];
                if(sum > N) continue;
                if(N-sum > 50) continue;
                ans += time_num[N-sum];
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
// slope decreases, query point increases, query for minimum
struct Line {
  int64_t k, b;
  Line() = default;
  Line(int64_t k, int64_t b) : k(k), b(b) {}
  int64_t at(int64_t x) { return k * x + b; }
};
long double inter(const Line& x, const Line& y) {
  return (long double) (x.b - y.b) / (y.k - x.k);
}
const int MX = 200 * 1000 + 7;
Line st[MX];
int stp = 0, opt = 0;
void add(const Line& l) {
  while (stp >= 2 && inter(st[stp - 2], l) <= inter(st[stp - 2], st[stp - 1]))
    stp--;
  opt = max(0, min(opt, stp - 1));
  st[stp++] = l;
}
int64_t gt(int64_t x) {
  while (opt + 1 < stp && st[opt + 1].at(x) < st[opt].at(x))
    opt++;
  return st[opt].at(x);
}
int main() {
  int n;
  int64_t C;
  cin >> n >> C;
  vector<int> h(n);
  for (int &i : h) cin >> i;
  vector<int64_t> dp(n, 0);
  add(Line(-2 * h[0], (int64_t) h[0] * h[0]));
  for (int i = 1; i < n; ++i) {
    dp[i] = gt(h[i]) + C + (int64_t) h[i] * h[i];
    add(Line(-2 * h[i], dp[i] + (int64_t) h[i] * h[i]));
  }
  cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 8804
# -*- coding: utf-8 -*-

from queue import PriorityQueue

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]
  counts = [0 for _ in range(N)]
  edges = [[] for _ in range(N)]

  maxP = 0

  A = [0 for _ in range(N-1)]
  B = [0 for _ in range(N-1)]

  for i in range(N-1):
    A[i], B[i] = readInts()
    a, b = A[i] - 1, B[i] - 1
    counts[a] += 1
    counts[b] += 1
    if counts[a] > counts[maxP]:
      maxP = a
    if counts[b] > counts[maxP]:
      maxP = b

    edges[a].append(b)
    edges[b].append(a)

  c = readInts()
  c.sort(reverse=True)
  cursor = 0
  ans = [0 for _ in range(N)]

  visited = [False for _ in range(N)]

  queue = PriorityQueue()
  queue.put( (-1 * counts[maxP], maxP) )
  while not queue.empty():
    _, n = queue.get()
    ans[n] = c[cursor]
    cursor += 1
    visited[n] = True

    for p in edges[n]:
      if not visited[p]:
        queue.put( (-1 * counts[p], p) )

  s = 0
  for i in range(N-1):
    a, b = A[i] - 1, B[i] - 1
    s += min(ans[a], ans[b])

  print(s)
  print(" ".join(map(str, ans)))

if __name__ == "__main__":
  main()


Measured memory_bytes: 8172
let () = Scanf.scanf "%d\n" @@ fun n ->
  let ts = Array.init n @@ fun _ ->
    Scanf.scanf "%d " @@ fun t -> t in
  let sum_ts = Array.fold_left ( + ) 0 ts in
  Scanf.scanf "%d\n" @@ fun m ->
    let pxs = Array.init m @@ fun _ -> 
      Scanf.scanf "%d %d\n" @@ fun p x -> p, x in
    Array.iter (fun (p, x) ->
      Printf.printf "%d\n" @@ sum_ts + x - ts.(p - 1)) pxs


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
bool used[26];
int cnt = 0;
void clear(){
    cnt = 0;
    for(int i = 0; i < 26; i++) used[i] = false;
}

vector<int> v[26];
int dp[200005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string A;
    cin >> A;
    int cur = 1;
    dp[A.size()] = 0;
    for(int i = A.size()-1; i >= 0; i--){
        dp[i] = cur;
        if(!used[A[i]-'a']){
            cnt++;
            used[A[i]-'a'] = true;
        }
        if(cnt == 26){
            cur++;
            clear();
        }
    }
    for(int i = 0; i < A.size(); i++){
        v[A[i]-'a'].push_back(i);
    }
    for(int i = 0; i < 26; i++){
        v[i].push_back(A.size());
    }
    string ans;
    // cout << cur << endl;
    // for(int i = 0; i <= A.size(); i++){
    //     cout << dp[i] << ' ';
    // }
    // cout << endl;
    int idx = -1;
    while(cur > 0){
        for(int i = 0; i < 26; i++){
            char c = 'a'+i;
            auto p = upper_bound(v[i].begin(), v[i].end(), idx);
            if(dp[*p] < cur){
                // cout << *p << ' ' << cur << endl;
                ans += c;
                idx = *p;
                cur--;
                break;
            }
        }
    }
    cout << ans << endl;
}

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


using namespace std;



const int MAXN = 2000 + 23;













int n, dp[MAXN * 3][MAXN], m;



int main() {
	cin >> n >> m;
	dp[0][0] = 1;
	for (int i = 1; i <= n * 3; i++)
		for (int j = 0; j <= n; j++)
			dp[i][j] = (dp[i - 1][j] + ((i > 1 && j)? 1ll * (i - 1) * dp[i - 2][j - 1]: 0ll) + ((i > 2 && j)? 1ll * (i - 1) * (i - 2) * dp[i - 3][j - 1]: 0ll)) % m;
	cout << accumulate(dp[n * 3], dp[n * 3] + n + 1, 0ll) % m;
	return 0;
}

Measured memory_bytes: 47616
// AOJ 1085: Spellcasters
// 2017.8.19 bal4u@uu
// 2017.11.11 

#include <stdio.h>
#include <string.h>

int c[105];

char buf[20], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, S, s;
	int i, j, ans;

	while (fgets(p=buf, 20, stdin) && *p != '0') {
		memset(c, 0, sizeof(c));
		i = n = getint(), p++, S = getint();
		while (i--) {
			fgets(p=buf, 10, stdin);
			c[getint()]++;
		}
		for (ans = i = 0; i < S; i++) {
			if (!c[i]) continue;
			if ((i << 1) <= S) ans += (c[i] * (c[i]-1)) >> 1;

			for (s = 0, j = i + 1; j < S; j++) if (c[j] && i + j <= S) s += c[j];
			if (s > 0) ans += c[i] * s;
		}
		printf("%d\n", n*(n-1) / 2 - ans);
	}
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if((abs(a - b) <=d &&abs(c - b)<= d)||(abs(c - a) <= d)) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
l=[0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820] 
ans=0
from bisect import bisect_right as bl
from math import floor
for i in range(2,floor(n**(1/2))+1):
    if n%i:continue
    cnt=0
    while n%i==0:
        cnt+=1
        n//=i
    ind=bl(l,cnt)
    if ind==1:ans+=1
    else:
        ans+=ind-1
if n!=1:
    ans+=1
print(ans)

Measured memory_bytes: 9492
n, x, y = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
yy = (a[-1]-y).abs
if n == 1
	puts yy
	exit
end
nn = (a[-2]-a[-1]).abs
puts [yy,nn].max

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
bool flag1,flag2;
int i;
string s;
int main()
{
	flag1=false;
	flag2=false;
	cin>>s;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			flag1=true;
		}
		if(flag1&&s[i]=='F')
		{
			flag2=true;
			break;
		}
	}
	if(flag1&&flag2)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	int next(int[] h, int idx) {
		for (int i = idx; i < h.length; i++) {
			if (h[i] != 0) {
				return i;
			}
		}
		return -1;
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}

		int ans = 0;
		int idx = 0;
		while (true) {
			idx = next(h, idx);
			if (idx == -1) {
				break;
			}

			while (h[idx] > 0) {
				ans++;
				for (int i = idx; i < n && h[i] > 0; i++) {
					h[i]--;
				}
			}
		}

		out.println(ans);

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    string s;
    int number_count[200000] = {0};
    int ball_number = 0;
    int number_variety = 0;
    int zero_count = 0;
    cin >> ball_number >> number_variety;
    for(int i = 0; i < ball_number ; i++)
    {
        int ball = 0;
        cin >> ball;
        number_count[ball]++;
    }
    sort(number_count, number_count + 200000);
    int i=0;
    while (number_count[i] == 0)
    {
        zero_count++;
        i++;
    }
    int now_variey = 200000 - zero_count;
    int change_count = 0;
    for(i = 0; now_variey > number_variety; i++)
    {
        change_count += number_count[zero_count + i];
        number_count[200000 - 1] += number_count[zero_count + i];
        now_variey--;
    }
    cout << change_count << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
long long int arr[100005][3];
long long int dp[1000005][3];
long long int n;
long long int max(long long int a,long long int b)
{
    if(a>=b)
    return a;
    else
    {
        return b;
    }
    
}
long long int happy(long long int n)
{
    for(long long int i=n-1;i>=0;i--)
    {
        for(long long int j=0;j<3;j++)
        {
            if(i==n-1)
            dp[i][j]=arr[i][j];
            else
            {
            if(j==0)
            {
                dp[i][j]=arr[i][j]+max(dp[i+1][1],dp[i+1][2]);
            }

             if(j==1)
            {
                dp[i][j]=arr[i][j]+max(dp[i+1][0],dp[i+1][2]);
            }

             if(j==2)
            {
                dp[i][j]=arr[i][j]+max(dp[i+1][1],dp[i+1][0]);
            }
            }
        }
    }
}
int main()
{
    long long int n;
    scanf("%lld",&n);
    for(long long int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            scanf("%lld",&arr[i][j]);
        }
    }
    happy(n);
    long long int ans;
    if((dp[0][0]>=dp[0][1])&&(dp[0][0]>=dp[0][2]))
    ans=dp[0][0];

    else if((dp[0][1]>=dp[0][0])&&(dp[0][1]>=dp[0][2]))
    ans=dp[0][1];
    
    else
    {
        ans=dp[0][2];
    }
    printf("%lld",ans);
}

Measured memory_bytes: 7552
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];

  static int dp[101010][2];
  dp[0][0] = 0;
  dp[0][1] = -INF;

  for (int i = 0; i < N; i++) {
    dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
    dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]);
  }

  cout << dp[N][0] << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main()
{
    int n;
    scanf(" %d", &n);

    vector<int> p(n);
    vector<int> pos(n);
    rep(i,n)
    {
        scanf(" %d", &p[i]);
        --p[i];

        pos[p[i]] = i;
    }

    vector<int> da(n-1),db(n-1);
    rep(i,n-1)
    {
        int d = pos[i+1]-pos[i];
        if(d<0)
        {
            da[i]=1;
            db[i]=abs(d)+1;
        }
        else
        {
            da[i]=abs(d)+1;
            db[i]=1;
        }
    }

    vector<int> a(n),b(n);
    a[0] = 1;
    rep(i,n-1) a[i+1] = a[i]+da[i];
    b[n-1] = 1;
    for(int i=n-1; i>0; --i) b[i-1] = b[i]+db[i-1];

    rep(i,n) printf("%d%c", a[i]," \n"[i==n-1]);
    rep(i,n) printf("%d%c", b[i]," \n"[i==n-1]);
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
class UnionFindTree {
	int[] parent; //インデックスにとノードを対応させ、そのルートノードのインデックスを格納	
	int[] rank; //parentと同様に、木の高さを格納
	int[] size;
	public UnionFindTree(int n) {
		this.parent = new int[n];
		this.rank = new int[n];
		this.size = new int [n];
		for (int i = 0; i < n; i++) {
			makeSet(i);
		}
	}
	
	public void makeSet(int i) {
		parent[i] = i;
		rank[i] = 0; //集合の高さ
		size[i] = 1;
	}
	
	public void union(int x, int y) {
		int xRoot = find(x);
		int yRoot = find(y);
		
		//xが属する木の方が大きい場合
		if (rank[xRoot] > rank[yRoot]) { 
			parent[yRoot] = xRoot; //yの親をxに更新 
			size[xRoot] += size[yRoot];
								   
		} else if(rank[xRoot] < rank[yRoot]) {
			parent[xRoot] = yRoot;
			size[yRoot] += size[xRoot];
			
		} else if (xRoot != yRoot){
			parent[yRoot] = xRoot;
			size[xRoot] += size[yRoot];
			rank[xRoot]++; //同じ高さの木がルートの子として着くから大きさ++;
		}
	}
	
	//引数の属する木のルートのidを返す
	public int find(int i) {
		if (i != parent[i]) {
			parent[i] = find(parent[i]);
		}
		return parent[i];
	}
	
	//同じ木に属しているか
	public boolean same(int x, int y) {
		return find(x) == find(y);
	}
	
	//木のsize取得
	public int getsize(int i) {
		return size[find(i)];
	}
 
}
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Set<Integer> set = new HashSet<Integer>();
		UnionFindTree tree = new UnionFindTree(n);
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			tree.union(a, b);
		}
		for(int i = 0 ; i < n; i++) {
			tree.find(i);
			set.add(tree.parent[i]);
		}
		System.out.println(set.size()-1);
	}
}

Measured memory_bytes: 60752
import heapq
n,m=map(int,input().split())
A=list(map(int,input().split()))
hq=[]
for i in A:
  heapq.heappush(hq,-i)
for _ in range(m):
  m=-((-heapq.heappop(hq))//2)
  heapq.heappush(hq,m)
print(-sum(hq))

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

int main()
{
	cin.tie(nullptr); ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;

	int p;
	vector<double> a(n);
	rep(i, n) {
		cin >> p;
		a[i] = (p + 1.0) / 2.0;
	}

	double sum = 0;
	rep(i, k) sum += a[i];

	double ans = sum;
	for (int i = k; i < n; i++) {
		sum = sum - a[i - k] + a[i];
		ans = max(ans, sum);
	}

	cout << to_string(ans) << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main(void)
{
	char a[10001];
	int len,i,s,z;
	while(scanf(" %s",a)!=EOF)	{
		s=0;
		z=0;
		len=strlen(a);
		for(i=0;i<len;i++){
			if(a[i]=='J' && a[i+1]=='O' && a[i+2]=='I'){
				s++;
			}
			if(a[i]=='I' && a[i+1]=='O' && a[i+2]=='I'){
				z++;
			}
		}
		printf("%d\n",s);
		printf("%d\n",z);
	}
	return 0;
}

Measured memory_bytes: 980
//36
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int paper[10][10]={{}};
  for(int x,y,s;((cin>>x).ignore()>>y).ignore()>>s;){
    static const int dx[]={0,1,0,-1};
    static const int dy[]={1,0,-1,0};
    if(s==1){
      paper[y][x]++;
      for(int i=0;i<4;i++){
	int ny=y+dy[i];
	int nx=x+dx[i];
	if(0<=ny&&ny<10&&0<=nx&&nx<10){
	  paper[ny][nx]++;
	}
      }
    }else{
      for(int i=-1;i<=1;i++){
	for(int j=-1;j<=1;j++){
	  int ny=y+i;
	  int nx=x+j;
	  if(0<=ny&&ny<10&&0<=nx&&nx<10){
	    paper[ny][nx]++;
	  }
	}
      }
      if(s==3){
	for(int i=0;i<4;i++){
	  int ny=y+dy[i]*2;
	  int nx=x+dx[i]*2;
	  if(0<=ny&&ny<10&&0<=nx&&nx<10){
	    paper[ny][nx]++;
	  }
	}
      }
    }
  }
  cout<<count(paper[0],paper[0]+100,0)<<endl<<*max_element(paper[0],paper[0]+100)<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

  vector<int> a(n + 1);
  rep(i, n + 1) cin >> a[i];
  vector<int> b(n);
  rep(i, n) cin >> b[i];

  ll ans = 0;
  rep(i, n) {
    int d0 = min(a[i], b[i]);
    ans += d0;
    a[i] -= d0;
    b[i] -= d0;

    int d1 = min(a[i + 1], b[i]);
    ans += d1;
    a[i + 1] -= d1;
    b[i] -= d1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int GCM(int a, int b)
{

    int x, y;

    if(a > b)
        y = b;
    else
        y = a;

    while(y) {
        if(a % y == 0 && b % y == 0){
            x = y;
            break;
        }
        y--;
    }

    return x;
}

int main(void)
{

    int w, h, c, k, p;

    scanf("%d %d %d", &w, &h, &c);

    p = GCM(w, h) * GCM(w, h);
    k = w * h;

    printf("%d\n", (k / p) * c);

    return 0;
}

Measured memory_bytes: 596
def main():
    k, s = map(int, input().split())
    ans = 0
    for x in range(k+1):
        for y in range(k+1):
            z = s - (x + y)
            if z >= 0 and z <= k:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()



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

int main() {
  int n;
  cin >> n;
  
  int tmp = 0;
  if (n / 100 == 7) tmp = 1;
  n %= 100;
  if (n / 10 == 7) tmp = 1;
  n %= 10;
  if (n == 7) tmp = 1;
  
  if (tmp == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3596
import numpy as np
N, M = map(int, input().split())
list_coStu = []
list_coChe = []
for i in range(N):
    list_coStu.append(list(map(int, input().split())))
for i in range(M):
    list_coChe.append(list(map(int, input().split())))

#calc distance

for iS in range(len(list_coStu)):
    coStu = np.array(list_coStu[iS])
    min_iC = 0
    d = 4 * 10**8 + 1
    for iC in range(len(list_coChe)):
        coChe = np.array(list_coChe[iC])
        dif = coChe - coStu
        dist = np.sum(np.abs(dif))
        if dist < d:
            min_iC = iC
            d = dist
    print(min_iC + 1)


Measured memory_bytes: 12408
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define R 1000000007
#define DBG 1
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

#define MAXN 100000
int a[MAXN];

using mint = modint998244353;
mint m10(10);
mint mi9 = mint(1)/9;
struct S{
    mint value;
    int size;
};
using F = int;
const F ID = int(2e9);
S op(S a, S b){ return
   { a.value*m10.pow(b.size)+b.value, a.size+b.size}; }
   //{ a.value*mint(10).pow(b.size)+b.value, a.size+b.size}; }
S e(){ return {0, 0}; }
S mapping(F f, S x){
    //if(f != ID) x.value = ((mint(10).pow(x.size)-1)/9) * f;
    if(f != ID) x.value = (m10.pow(x.size)-1)*mi9 * f;
    return x;
}
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }

int main(){
    int n,q;
    cin >> n >> q;
    std::vector<S> v(n, {1, 1});
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
    for(int i=0; i<q; i++) {
      int l,r,d;
      cin >> l >> r >> d;
      seg.apply(l-1,r,d);
      cout << seg.prod(0,n).value.val() << endl;
    }
}


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

int main(void){
  string s; 
  cin >>s;
  
  int len = s.size();
  rep(i,0,len){
    if(i%2==0) cout <<s.at(i);
  }
  
  cout<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

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


int solve( int x ){
    if( x == 0 )return 1;
    if( x < 0 )return 0;

    rep(i,6){
        return solve( x - 100 - i );
    }
}

int dp[ 100000 ];
int main(){
    int n;
    string s;
    cin >> n >> s;

    vector<int> r(n) ,g(n) ,b(n);
    rep(i , n){
        if( s[i] == 'R' )r[i]++;
        if( s[i] == 'G' )g[i]++;
        if( s[i] == 'B' )b[i]++;

        if( i != 0 )r[i] += r[i-1];
        if( i != 0 )g[i] += g[i-1];
        if( i != 0 )b[i] += b[i-1];
    }


    ll res = 0;
    rep(i , n){
        for(int j = i+1; j < n; j++){
            if( s[i] == s[j] )continue;

            if( s[i] != 'R' && s[j] != 'R' ){
                
                if( 2 * j - i >= n){
                    res += r[n-1] - r[j];
                }

                else {
                    res += r[2*j-i-1] - r[j] + r[n-1] - r[2*j-i];
                }

            }

            if( s[i] != 'G' && s[j] != 'G' ){
                
                if( 2 * j - i >= n){
                    res += g[n-1] - g[j];
                }

                else {
                    res += g[2*j-i-1] - g[j] + g[n-1] - g[2*j-i];
                }
                
            }

            if( s[i] != 'B' && s[j] != 'B' ){
                
                if( 2 * j - i >= n){
                    res += b[n-1] - b[j];
                }

                else {
                    res += b[2*j-i-1] - b[j] + b[n-1] - b[2*j-i];
                }
                
            }

            //cout << res << endl;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    int h1, m1, h2, m2, k;
    while(cin>>h1>>m1>>h2>>m2>>k){
        ll ans=0;
        ans=h2*60+m2-h1*60-m1;
        if(ans<0){
        	ans+=60*24;
        }
        // cout<<k<<endl;
        ans-=k;
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i, n) for(int i=1; i<(n); ++i)
using namespace std;
typedef long long ll;
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;

    cin >> N;

    char charas[N];

    rep(i, N)
    {
        cin >> charas[i];
    }

    int counter = 0;

    rep(i, N)
    {
        if (charas[i] == 'A' && charas[i+1] == 'B' && charas[i+2] == 'C')
        {
             ++counter;
        }
    }

    cout << counter;
 
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
LRm = [list(map(int, input().split())) for _ in range(M)]
min_n = 0
max_n = N
for l, r in LRm:
    min_n = max(min_n, l)
    max_n = min(max_n, r)
print(max(max_n-min_n+1, 0))


Measured memory_bytes: 27332
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;




int main(void) {
  ll a[3][3];
  ll f[3][3]={};
  ll N;
  ll i, j, k;
  
  for(i=0; i<3; i++) {
    for(j=0; j<3; j++) {
      cin >> a[i][j];
    }
  }
  
  cin >> N;
  for(k=0; k<N; k++) {
    ll b;
    cin >> b;
    
    for(i=0; i<3; i++) {
      for(j=0; j<3; j++) {
        if(a[i][j]==b) f[i][j]=1;
      }
    }
  }
  
  
  for(i=0; i<3; i++) {
    ll flag=1;
    for(j=0; j<3; j++) {
      if(f[i][j]==0) flag=0;
    }
    
    if(flag) {
      pt("Yes");
      return 0;
    }
    
  }
  
  for(i=0; i<3; i++) {
    ll flag=1;
    for(j=0; j<3; j++) {
      if(f[j][i]==0) flag=0;
    }
    
    if(flag) {
      pt("Yes");
      return 0;
    }
  }
  
  if(f[0][0]+f[1][1]+f[2][2]==3) {
    pt("Yes");
    return 0;
  }
  
  if(f[0][2]+f[1][1]+f[2][0]==3) {
    pt("Yes");
    return 0;
  }
  
  pt("No");
  return 0;
  
}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	int flag = 0;
	string a;
	cin >> a;
	for (char c : a) {
		if (c == '7') {
			flag = 1;
			break;
		}
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


}

Measured memory_bytes: 3624
#include <stdio.h>

#define LEN 20

int main(void) {

    int i;
    int n;
    int p[LEN];
    int count;

    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
        scanf("%d", &p[i]);
    }

    count = 0;
    for ( i = 1; i < n-1; i++ ) {
        if ( p[i-1] < p[i] && p[i] < p[i+1] ) {
            count++;
        } else if ( p[i-1] > p[i] && p[i] > p[i+1] ) {
            count++;
        }
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
	      Scanner sc = new Scanner(System.in);
	      int A = sc.nextInt(); //red
	      int B = sc.nextInt(); //green
	      int C = sc.nextInt(); //blue
	      String isClear = "No";
	      
	      int count = sc.nextInt();
	      
	      
	      for(int i = 0; i < count; i++) {
	    	  if(B > A * 2) {
	    		  A *= 2;
	    	  }else if(C > B * 2) {
	    		  B *= 2;
	    	  }else {
	    		  C *= 2;
	    	  }

	      }
	      
	      if((B > A) && (C > B)) {
	    	  isClear = "Yes";
	      }
	      
	      System.out.println(isClear);


	}
}


Measured memory_bytes: 35656
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
const int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
#define INF 0x3f3f3f3f
template<typename T>
void read(T &x)
{
    char ch=getchar();
    int f=1;
    for (x=0;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());
    if (ch=='-') f=-1,ch=getchar();
    for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
    x*=f;
}
int n,m,k,ans,x,y;
char mp[810][810];
bool vis[810][810];
queue<PII> q;
queue<int> dp;
char getopt()
{
	char ch=getchar();
	while (ch!='#'&&ch!='.'&&ch!='S') ch=getchar();
	return ch;
}
int calc(int x,int y)
{
	if (min(min(x-1,n-x),min(y-1,m-y))==0) return 0;
	return (min(min(x-1,n-x),min(y-1,m-y))-1)/k+1;
}
void bfs(int x,int y,int deep)
{
	q.push(make_pair(x,y));
	vis[x][y]=1;
	dp.push(0);
	while (!q.empty())
	{
		PII tmp=q.front();
		q.pop();
		int h=dp.front();
		dp.pop();
		if (h>k) continue;
		ans=min(ans,calc(tmp.first,tmp.second));
		for (int i=0;i<4;i++)
		{
			int newx=tmp.first+dir[i][0];
			int newy=tmp.second+dir[i][1];
			if (newx>=1&&newx<=n&&newy>=1&&newy<=m&&mp[newx][newy]=='.'&&!vis[newx][newy])
			{
				vis[newx][newy]=1;
				q.push(make_pair(newx,newy));
				dp.push(h+1);
			}
		}
	}
}
int main()
{
	read(n),read(m),read(k);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
		{
			mp[i][j]=getopt();
			if (mp[i][j]=='S')
				x=i,y=j;
		}
	ans=INF;
	bfs(x,y,0);
	printf("%d",ans+1);
	return 0;
} 

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    partial class Program
    {
        static void Main(string[] args)
        {
			//↓

            var kx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var k = kx[0];
            var x = kx[1];

            var min = x - k + 1;
            var max = x + k - 1;

            for (int i = min; i <= max; i++)
            {
                if (i >= -1000000 && i <= 1000000)
                {
                    Console.Write(i);
                    Console.Write(" ");
                }
            }


			//↑
        }
	}
}

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <deque>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, S2 = 1e7 * 2, MOD = 1e9 + 7, INF = 1e9 * 1e9 + 100;

vector<ll> pr, suf;

int main() {
    fastInp;

    ll n;
    cin >> n;
    pr.push_back(0);
    suf.push_back(0);

    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        ll q = 0;
        if (s[i] != 'E') q = 1;
        pr.push_back(pr.back() + q);
    }

    for (int i = n - 1; i >= 0; i--) {
        ll q = 0;
        if (s[i] != 'W') q = 1;
        suf.push_back(suf.back() + q);
    }

    reverse(suf.begin(), suf.end());

    ll ans = INT64_MAX;

    for (int i = 0; i < n; i++) {
        ans = min(ans, pr[i] + suf[i + 1]);
    }

    cout << ans;

    return 0;
}



Measured memory_bytes: 11908
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int cnt = 1;
		int temp = N;
		ArrayList<Integer> list = new ArrayList<Integer>();
		list.add(N);
		boolean flg = true;
		while(flg){
			if(temp%2 == 0){
				cnt++;
				temp /=2;
				if(list.contains(temp)){
					break;
				}else{
					list.add(temp);
				}
			}else{
				cnt++;
				temp = 3*temp +1;
				if(list.contains(temp)){
					break;
				}else{
					list.add(temp);
				}
				
			}
		}
		System.out.println(cnt);		
    }
}

Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(z) for(int i=1;i<=z;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define mod  1000000007
#define cl(n,m) (int)(ceil(double(n)/double(m)))
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int dp[100005][3]  , a[100005];
signed main(){
	int n ;
	cin>>n ;
	f(n) cin>>a[i] ;
	dp[2][0] = a[1] + a[2] ;
	dp[2][1] = - a[1] - a[2] ;
	for(int i=3 ;i<=n ;i++){
		dp[i][0] = max( dp[i-1][0] , dp[i-1][1] )  + a[i] ;
		dp[i][1] = max( dp[i-1][1] + 2*a[i-1] , dp[i-1][0] - 2*a[i-1]) - a[i]; 
		//cout<< dp[i][0] << " " << dp[i][1]<<endl ;
	}
	cout<<max( dp[n][0] , dp[n][1]) ;
}

Measured memory_bytes: 3328
n, y = list(map(int, input().split()))

for a in range(0, n+1):
    for b in range(0, n-a+1):
        c = n-(a+b)
        if (10000*a + 5000*b + 1000*c) == y:
            print(a, b, c)
            exit()

print(-1, -1, -1)


Measured memory_bytes: 2940