akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(){
  int n,a,b,c,d;
  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
  char s[n+1];
  scanf("%s", s);
  int i;
  int space = 0;
  int max_space = 0;
  for(i=a-1;i<n;i++){
    if(s[i] == '#'){
      space = 0;
      if(i > 0 && s[i-1] == '#'){
        puts("No");
        return 0;
      }
    }else{
      if(i >= b - 2){
        space++;
        if(space > max_space){
          max_space = space;
        }
      }
    }
    //printf("i %d space %d max %d\n", i, space, max_space);
    if(i == d && d < c && max_space < 3){
      puts("No");
      return 0;
    }
    if(i >= c - 1 && i >= d - 1){
      puts("Yes");
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
bool ok(auto& G, auto& A, auto cur, auto pre) {
  auto s = 0;
  auto m = -1;
  for(auto nex: G[cur]) if(nex != pre) {
    if(!ok(G, A, nex, cur)) return false;
    s += A[nex];
    m = max(m, A[nex]);
  }
  if(cur == pre) {
    if(G[cur].size() == 1) return A[cur] == s;
    return 2*A[cur] == s;
  }
  if(m == -1) return A[cur] <= A[pre];
  if(s < A[cur]) return false;
  A[cur] = 2*A[cur] - s;
  return s-A[cur] <= 2*min(s-m, s/2);
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(auto& i: A) cin >> i;
  vector<vector<int>> G(N);
  for(auto i=1; i<N; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  cout << (ok(G, A, 0, 0) ? "YES" : "NO") << endl;
}


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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int H, W, N;
  cin >> H >> W;
  cin >> N;
  int nof_color[N+1];
  for(int i = 1; i < N+1; ++i) {
    cin >> nof_color[i];
  }
  int oneline[H*W];
  int index = 0;
  for(int i = 1; i < N+1; ++i) {
    for(int j = 0; j < nof_color[i]; ++j) {
      oneline[index] = i;
      ++index;
    }
  }
  int g[H][W];
  index = 0;
  for(int h = 0; h < H; ++h) {
    for(int tmp_w = 0; tmp_w < W; ++tmp_w) {
      int w = tmp_w;
      if(h%2) w = W - 1 - tmp_w;
      // g[h][w] = oneline[H*h + tmp_w];
      g[h][w] = oneline[index];
      ++index;
    }
  }
  for(int h = 0; h < H; ++h) {
    for(int w = 0; w < W; ++w) {
      if(w==W-1) COUTB(g[h][w]);
      else COUTS(g[h][w]);
    }
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

void solve()
{
    int n,k;
    cin>>n>>k;

    int cnt = 0;
    while( n > 0 )
    {
        cnt++;
        n /= k;
    }

    cout<<cnt<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(in.readLine());
        int H = Integer.parseInt(st.nextToken());
        int N = Integer.parseInt(st.nextToken());
        int[] A = new int[N];
        int[] B = new int[N];
        for (int i = 0; i < N; i++) {
            st = new StringTokenizer(in.readLine());
            A[i] = Integer.parseInt(st.nextToken());;
            B[i] = Integer.parseInt(st.nextToken());
        }
        int[] dp = new int[H+1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for (int i = 1; i <= H; i++) {
            for (int j = 0; j < N; j++) {
                if (A[j] > i) {
                    dp[i] = Math.min(dp[i], B[j]);
                } else {
                    dp[i] = Math.min(dp[i], dp[i - A[j]] + B[j]);
                }
            }
        }

        System.out.println(dp[H]);
    }

}

Measured memory_bytes: 23124
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int N; cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];

	map<int, int> dic;
	rep(i,N) dic[A[i]]++;
	vector<int> B;
	for (auto i : dic) B.emplace_back(i.second);
	sort(all(B));
	int M = B.size();
	vector<ll> C(M+1);
	rep(i,M) C[i+1] += C[i] + B[i];
	for (int i = 1; i <= N; ++i) {
		ll ok = 0;
		ll ng = N+1;
		while (ng - ok > 1) {
			ll mid = (ok+ng)/2;
			int k = lower_bound(all(B),mid) - B.begin();
			ll cnt = C[k] + mid*(M-k);
			if (cnt < mid*i) ng = mid;
			else ok = mid;
		}
		cout << ok << ln;
	}
}


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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

int a;
string s;

void solve() {
  cin>>a>>s;
  if(a>=3200) cout<<s<<endl;
  else cout<<"red"<<endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long int lli;
typedef long long ll;

int main(){
    double n; cin >> n;
    double t,a; cin >> t >> a;
    vector<double> h(n); rep(i,n) cin >> h[i];

    double ans_num;
    double min_tmp = inf;
    rep(i,n){
        double tmp = abs(a-(t-h[i]*0.006));
        if(min_tmp > tmp){
            ans_num = i+1;
            min_tmp = tmp;
        }
    }

    cout << ans_num << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string H = Console.ReadLine();

            int result0 = 0;
            int result1 = 0;
            string ans0 = "";
            string ans1 = "";

            if (H.Length < 2)
            {
                Console.WriteLine("0");
                return;
            }

            //for (int i = 0; i < H.Length; i++)
            //{
            //    if (i % 2 == 0)
            //    {
            //        ans0 += "0";
            //        ans1 += "1";
            //    }
            //    else
            //    {
            //        ans0 += "1";
            //        ans1 += "0";
            //    }
            //}

            for (int i = 0; i < H.Length; i++)
            {
                if(i % 2 == 0)
                {
                    if (H[i] != '0') result0++;
                    if (H[i] != '1') result1++;
                }
                else
                {
                    if (H[i] != '0') result1++;
                    if (H[i] != '1') result0++;
                }

            }
            if (result1 >= result0) Console.WriteLine(result0);
            else Console.WriteLine(result1);

        }
    }
}


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

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

    int K, X;
    cin >> K >> X;
    for (int i = max(X - K + 1, -1000000) ; i <= min(1000000, X + K - 1); i++) {
        if (i != max(X - K + 1, -1000000)) cout << " ";
        cout << i;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

const ll MOD = 1e9 + 7;

bool cmp(int x, int y) {
    return abs(x) > abs(y);
}

ll bm(ll b, ll p) {
    ll rt = 1;
    for (ll i = 1, j = b; i <= p; i <<= 1, j = j * j % MOD)
        if (p & i) rt = rt * j % MOD;
    return rt;
}

int main() {
    int n, k; cin >> n >> k;
    vi a(n);
    int cp = 0, cn = 0, c0 = 0;
    FOR(i, 0, n - 1) {
        cin >> a[i];
        if (a[i] == 0) c0++;
        else if (a[i] < 0) cn++;
        else cp++;
    }
    sort(a.begin(), a.end(), cmp);
    ll ans = 1;
    int mnp = k & 1, mxn = cn - (cn & 1);
    if (mxn + cp < k || cp < mnp) {
        if (c0) ans = 0;
        else {
            ROF(i, (int)a.size() - 1, (int)a.size() - k)
                ans = ans * a[i] % MOD;
        }
    }
    else {
        ll ln = 0, lp = 0;
        FOR(i, 0, k - 1) {
            ans = ans * a[i] % MOD;
            if (a[i] < 0) ln = a[i];
            else lp = a[i];
        }
        if (ans < 0) {
            ll mn = 0, mp = 0;
            ROF(i, (int) a.size() - 1, k) {
                if (a[i] < 0) mn = a[i];
                else mp = a[i];
            }
            if (lp == 0 || mp * lp > mn * ln) {
                ans = ans * bm(ln, MOD - 2) % MOD;
                ans = ans * mp % MOD;
            }
            else {
                ans = ans * bm(lp, MOD - 2) % MOD;
                ans = ans * mn % MOD;
            }
        }
    }
    cout << (ans + MOD) % MOD << endl;
}


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

int main(void){
    
    ll n, m, a, b, q=0;
    ll h[100009]={};
    ll x[100009]={};
    
    cin >> n >> m;
    
    for(ll i=1; i<=n; i++){
        
        cin >> h[i];
        
    }
    
    for(ll i=1; i<=m; i++){
        
        cin >> a >> b;
        
        if(h[a]<=h[b]){
            
            x[a] += 1;
            
        }
        
        if(h[a]>=h[b]){
            
            x[b] += 1;
            
        }
        
    }
    
    for(ll i=1; i<=n; i++){
        
        if(x[i]>=1){
            
            q += 1;
            // cout << i << endl;
            
        }
        
    }
    
    cout << n-q << endl;
    
    return 0;
    
}

Measured memory_bytes: 5240
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
    int n;
    cin >> n;
    int tt = 0;
    int xx = 0, yy = 0;
    rep(i, n) {
        int t, x, y;
        cin >> t >> x >> y;
        int k = abs(x - xx) + abs(y - yy) - (t - tt);
        if (k > 0 || abs(k) % 2) {
            cout << "No" << endl;
            return 0;
        }
        tt = t;
        xx = x;
        yy = y;
    }
    cout << "Yes" << endl;
    return 0;
}

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

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

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

constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<bool> same(N);
    for (int i=0; i<N; ++i) {
        int x, y;
        cin >> x >> y;
        same[i] = x == y;
    }

    for (int i=0; i<N-2; ++i) {
        if (same[i] && same[i+1] && same[i+2]) {
            cout << "Yes" << '\n';
            return;
        }
    }
    cout << "No" << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


class cumsum1d:  # 一次元累積和クラス
    def __init__(self, ls: list):
        '''
        1次元リストを受け取る
        '''
        from itertools import accumulate
        self.ls_accum = [0] + list(accumulate(ls))

    def total(self, i, j):
        # もとの配列lsにおける[i,j)の中合計
        return self.ls_accum[j] - self.ls_accum[i]


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc115/tasks/abc115_c
# maxとminが近い→ソートして端が近い
N, K = read_ints()
H, = read_col(N)
H.sort()
ans = 10**10
for i in range(N):
    j = i + K - 1  # K個選ぶ
    if j >= N:
        continue
    ans = min(ans, H[j] - H[i])
print(ans)


Measured memory_bytes: 33176
def digit(N, M):
    def f(j,k):
        if k==3: res = 1
        elif k==5: res = 2
        elif k==7: res = 4
        return j|res

    L = len(N)
    dp = [[[0] * M for i in range(L + 1)] for j in range(2)]

    dp[0][0][0] = 1
    for i in range(1,L):
        dp[1][i][0] = 1
    for i in range(L):
        for j in range(M):
            for k in [3,5,7]:
                if k < int(N[i]):
                    dp[1][i+1][f(j, k)] += dp[0][i][j] + dp[1][i][j]
                elif k == int(N[i]):
                    dp[0][i+1][f(j, k)] += dp[0][i][j]
                    dp[1][i+1][f(j, k)] += dp[1][i][j]
                else:
                    dp[1][i+1][f(j, k)] += dp[1][i][j]
    return dp[0][L][K] + dp[1][L][K]

###########################################################################

N = input().rstrip()
K = 7
M = K + 1                               # 状態数
print(digit(N, M))



Measured memory_bytes: 61776
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
ans=min(al)+min(bl)
for i in range(m):
    d,f,off=map(int,input().split())
    ans=min(ans,al[d-1]+bl[f-1]-off)
print(ans)

Measured memory_bytes: 18728
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n; cin >> n;
  vll aaa(3); REP(i, 3) cin >> aaa[i];
  vll bbb(3); REP(i, 3) cin >> bbb[i];
  vll a2b(3); REP(i, 3) a2b[i] = aaa[i] - bbb[i];
  vll b2a(3); REP(i, 3) b2a[i] = bbb[i] - aaa[i];
  vvll dp1(4, vll(n+1, 0));
  REP(i, 3) REP(j, n+1) {
    if (j < aaa[i]) dp1[i+1][j] = dp1[i][j];
    else dp1[i+1][j] = max(dp1[i][j], dp1[i+1][j-aaa[i]] + b2a[i]);
  }
  n += dp1[3][n];
  vvll dp2(4, vll(n+1, 0));
  REP(i, 3) REP(j, n+1) {
    if (j < bbb[i]) dp2[i+1][j] = dp2[i][j];
    else dp2[i+1][j] = max(dp2[i][j], dp2[i+1][j-bbb[i]] + a2b[i]);
  }
  n += dp2[3][n];
  printf("%lld\n", n);
  return 0;
}


Measured memory_bytes: 977024
import math
N = int(input())
N = math.factorial(N)
seed = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,
        47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103,
        107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163,
        167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227,
        229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
        283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353,
        359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421,
        431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487,
        491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569,
        571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631,
        641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
        709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787,
        797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859,
        863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
        947, 953, 967, 971, 977, 983, 991, 997]
_sum = 1
#{5: 249, 3: 498, 2: 994, 13: 81, 11: 98, 7: 164, 41: 24, 757: 1, 61: 16, 23: 44, 73: 13, 547: 1, 17: 61, 193: 5, 19: 54, 37: 27, 67: 14, 661: 1, 47: 21, 109: 9, 433: 2, 29: 35, 59: 16, 31: 33, 271: 3, 683: 1, 103: 9, 307: 3, 71: 14, 313: 3, 83: 12, 43: 23, 431: 2, 181: 5, 97: 10, 769: 1, 577: 1, 491: 2, 151: 6, 53: 18, 107: 9, 229: 4, 523: 1, 131: 7, 277: 3, 601: 1, 79: 12, 157: 6, 167: 5, 89: 11, 179: 5, 191: 5, 101: 9, 613: 1, 421: 2, 113: 8, 227: 4, 239: 4, 241: 4, 367: 2, 251: 3, 127: 7, 883: 1, 263: 3, 541: 1, 137: 7, 139: 7, 853: 1, 439: 2, 149: 6, 761: 1, 311: 3, 163: 6, 499: 2, 997: 1, 337: 2, 673: 1, 173: 5, 347: 2, 349: 2, 709: 1, 359: 2, 733: 1, 373: 2, 383: 2, 197: 5, 199: 5, 397: 2, 409: 2, 619: 1, 829: 1, 419: 2, 211: 4, 643: 1, 443: 2, 223: 4, 457: 2, 233: 4, 467: 2, 937: 1, 479: 2, 727: 1, 503: 1, 257: 3, 787: 1, 269: 3, 281: 3, 563: 1, 283: 3, 293: 3, 587: 1, 599: 1, 919: 1, 317: 3, 967: 1, 647: 1, 659: 1, 331: 3, 991: 1, 353: 2, 719: 1, 743: 1, 379: 2, 389: 2, 401: 2, 827: 1, 839: 1, 863: 1, 877: 1, 887: 1, 449: 2, 911: 1, 461: 2, 463: 2, 947: 1, 971: 1, 487: 2, 983: 1, 509: 1, 521: 1, 557: 1, 569: 1, 571: 1, 593: 1, 607: 1, 617: 1, 631: 1, 641: 1, 653: 1, 677: 1, 691: 1, 701: 1, 739: 1, 751: 1, 773: 1, 797: 1, 809: 1, 811: 1, 821: 1, 823: 1, 857: 1, 859: 1, 881: 1, 907: 1, 929: 1, 941: 1, 953: 1, 977: 1}
for i in seed:
    if N % i == 0:
        cnt = 1
        for j in range(1,N // i + 1):
            if N % i ** j == 0:
                cnt += 1
            else:
                _sum *= cnt
                _sum %= (1e9 + 7)
                break
            if j == N // i:
                _sum *= cnt
                _sum %= (1e9+7)
print(int(_sum % (1e9+7)))

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222





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



  cin >> s;

  if (s[5] != '1') {
    if (s[6] == '1' || s[6] == '2' || s[6] == '3' || s[6] == '4') ok = false;
    else ok = true;
  }
  else ok = true;

  if (ok) cout << "TBD" << endl;
  else cout << "Heisei" << endl;


  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


int main()
{
	ll N;
	std::string S;
	cin >> N >> S;

	ll maxLen = 0;
	for (ll i = 0; i < N-1; i++) {

		for (ll j = i + 1; j < N; j++) {

			if (i != 0) {
				if (S[i - 1] == S[j - 1]) continue;
			}

			ll k;
			for (k = 0; i+k < j; k++) {
				char cik = S[i + k];
				char cjk = S[j + k];
				if (cik != cjk) break;
			}
			maxLen = MAX(maxLen, k);
		}
	}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1 << 30;
// const ll INF = 1LL << 62;
// --------------------------------------------------------


/**
 * @brief Union Find class.
 * 
 * @details "Path compression" and "Union by rank" are used.
 * @see <https://en.wikipedia.org/wiki/Disjoint-set_data_structure>
 */
class UnionFind {
    public:
        /**
         * @brief Construct a new Union Find object.
         * 
         * @param N Number of node.
         */
        UnionFind(int N) {
            _N = N;
            _make_set();
        }

        int find(int x) {
            if (_parent[x] != x) {
                _parent[x] = find(_parent[x]);
            }
            return _parent[x];
        }

        void unite(int x, int y) {
            int x_root = find(x);
            int y_root = find(y);

            if (x_root == y_root) return;

            int x_rank = _rank[x_root];
            int y_rank = _rank[y_root];
            if (x_rank > y_rank) {
                _parent[y_root] = x_root;
                _size[x_root] += _size[y_root];
            } else if (x_rank < y_rank) {
                _parent[x_root] = y_root;
                _size[y_root] += _size[x_root];
            } else {
                _parent[y_root] = x_root;
                _rank[x_root] += 1;
                _size[x_root] += _size[y_root];
            }
        }

        bool same_set(int x, int y) { return find(x) == find(y); }

        int size(int x) { return _size[find(x)]; }


    private:
        int _N;
        vector<int> _parent, _rank, _size;

        void _make_set() {
            _parent = vector<int>(_N + 1);
            iota(_parent.begin(), _parent.end(), 0);
            _rank = vector<int>(_N + 1, 0);
            _size = vector<int>(_N + 1, 1);
        }

};


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

    int N, Q; cin >> N >> Q;
    auto uf = UnionFind(N);
    REP(_, Q) {
        int t, u, v; cin >> t >> u >> v;
        u++; v++;
        if (t == 0) {
            uf.unite(u, v);
        } else {
            cout << (uf.same_set(u, v) ? 1 : 0) << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 5504
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int n,cnt=0;
  char s[100010];
  scanf("%s",s);
  n=strlen(s);
  for(int i=1;i<n;i++)
    if(s[i]!=s[i-1])
      cnt++;
  printf("%d\n",cnt);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
#from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7

n,m=MI()
As=LI()
for i in range(n):
    As[i]*=-1
    
#print(As)

heapify(As)
for i in range(m):
    mn=heappop(As)
    mn=(abs(mn)//2)*(-1)
    heappush(As,mn)

print(-sum(As))

Measured memory_bytes: 14636
#include <iostream>
#include <algorithm>
#include <string>

static const int MAX = 100;

int h, w;
int V[MAX][MAX];

using namespace std;

int main() {
  string c;
  
  cin >> h >> w;
  for(int i=0; i < h; i++) {
    cin >> c;
    for(int j=0; j < w; j++) {
      if(c[j] == 'c')
        V[i][j] = 0;
      else
        V[i][j] = -1;
    }
  }

  for(int i=0; i < h; i++) {
    for(int j=0; j < w-1; j++) {
      if(V[i][j] != -1 && V[i][j+1] != 0) {
        V[i][j+1] = V[i][j] + 1;
      }
    }
  }

  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cout << V[i][j];
      if(j != w-1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    
     ll L,R;
  
     cin >>L >>R;
  
	if(R-L>=2019) 
    cout<<"0";
	else {
		ll ans=0x3f3f3f3f;
		for(int i=L;i<=R;i++)
			for(int j=i+1;j<=R;j++)
			ans=min(ans,1ll*i*j%2019);
		cout<<ans;
	}
	return 0;
}

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

using namespace std;
#define ll long long
int mod=1e9+7;

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

    int h, w;
    cin >> h >> w;
    char cr[h][w];
    for(int i=0;i<h;i++){
        cin>>cr[i];
    }
    vector<vector<ll>> dp(h, vector<ll>(w));
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int i2 = i; i2 <= i+1; ++i2) {
                int j2=j;
                if(i2==i){
                    j2=j+1;
                }
                if(i2<h&&j2<w&&cr[i2][j2]!='#'){
                    dp[i2][j2]+=dp[i][j];
                    if(dp[i2][j2]>mod){
                        dp[i2][j2]-=mod;
                    }
                }
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 1000000007

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (b <= c || a >= d) {
        cout << 0;
    } else {
        if (a > c) {
            swap(a, c);
            swap(b, d);
        }
        cout << min(b, d) - c;
    }

    return 0;
}

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

int main() {
    int ans=1;
    int n;
    cin>>n;
    int b;
    cin>>b;
    int ma=b;
    for(int i=1;i<n;i++){
        cin>>b;
        if(b>=ma){
            ans++;
            ma=b;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# AGC013A - Sorted Arrays
def main():
    n = int(input())
    a = tuple(map(int, input().rstrip().split()))
    
    A, x = [a[0]], a[0]
    A_app = A.append
    for i in a[1:]:
        if i != x:
            A_app(i)
            x = i
    A_app(0)
    
    ans, cur = 0, A[0]
    flg = A[0] <= A[1]  # flg: increasing (1)
    for i, j in enumerate(A[1:-1], start=1):
        if flg:  # increasing
            if j < cur:
                ans += 1
                flg = A[i] <= A[i + 1]
        else:  # decreasing
            if j > cur:
                ans += 1
                flg = A[i] <= A[i + 1]
        cur = j
    print(ans + 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14608
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

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

	int N=in();
	vector<int> A(N),C(N,-1),D;
	REP(i,N){
		A[i] = in();
	}
	for(int i=N-1,ei=N/2;i>=ei;i--){
		if(A[i]==1){
			C[i] = 1;
			D.emplace_back(i+1);
		}
		else C[i] = 0;
	}
	for(int i=N/2-1;i>=0;i--){
		int sum = 0;
		int step = i+1;
		for(int j=i+step;j<N;j+=step){
			sum += C[j];
		}
		int mod = sum%2;
		if(A[i]==mod){
			C[i] = 0;
		}
		else{
			C[i] = 1;
			D.emplace_back(i+1);
		}
	}

	if(D.empty()){
		cout << 0 << endl;
	}
	else{
		cout << D.size() << endl;
		for(int i=0,ei=D.size();i<ei;i++){
			cout << D[ei-i-1] << ' ' << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3320
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  ld a,b;
  cin >> a >> b;

  for(int i=1;i<=10000000;i++){
    ld cur = i;
    int x = cur*(0.08);
    int y = cur*(0.1);
    if(x==a && y==b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

return 0;
}
///....


Measured memory_bytes: 256
def is_kaibun(s):
    for i,c in enumerate(s):
        if c != s[len(s)-i-1]:
            return False
        if i > len(s)//2:
            break
    return True


s = input()
ans = "Yes"
if not is_kaibun(s):
#    print("S is not kaibun")
    ans ="No"
if not is_kaibun(s[0:(len(s)-1)//2]):
#    print("S-1 is not kaibun")
    ans ="No"
if not is_kaibun(s[(len(s)+3)//2-1:]):
#    print("S+3 is not kaibun")
    ans ="No"
print(ans)


Measured memory_bytes: 3060
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N, K;
 
  N %= K;

  return min((ll)N, abs((ll)K-N));
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  int a, b;
  cin >> a >> b;

  int ans = 0;
  for (int i = a; i <= b; i++) {
    if ((i / 10000) == (i % 10) && ((i / 1000) % 10)  == ((i / 10) % 10)) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  string s;
  int k;
  cin >> s >> k;
  vector<string> S(k);
  for(int i = 0;i < k;i++){
    S.at(i) = "zzzzz";
  }
  int n = s.size(),num = 0;
  for(int i = 1;i <= n;i++){
    for(int j = 0;j < n - i + 1;j++){
      string cur = s.substr(j,i);
      num++;
      bool no = true;
      for(int l = 0;l < k;l++){
        if(S.at(l) == cur){
          no = false;
        }
      }
      if(cur < S.at(k-1) && no == true){
        S.at(k-1) = cur;
        sort(S.begin(),S.end());
      }
    }
  }
  cout << S.at(k-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 100000000000000
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

struct edge { int to, cap, rev; };

vector<edge> vec[110];
bool used[110];
int a, b;

void add_edge(int from, int to, int cap) {
	vec[from].push_back(edge{ to, cap, (int)vec[to].size() });
	vec[to].push_back(edge { from, 0, (int)vec[from].size() - 1 });
}

int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < vec[v].size(); i++) {
		edge &e = vec[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				vec[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, INF);
		if (f == 0)return flow;
		flow += f;
	}
}

signed main() {
	cin >> a >> b;
	for (int i = 0; i < b; i++) {
		int p, q, r; cin >> p >> q >> r;
		add_edge(p, q, r);
	}
	cout << max_flow(0, a - 1) << endl;
}


Measured memory_bytes: 3248
/*https://atcoder.jp/contests/dp/tasks/dp_d*/
#include <bits/stdc++.h>
#include <sstream> 
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define pi 2*acos(0.0)
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repe(i,a,b) for(ll i=a;i<=b;++i)
#define CPrint(c)  for(auto i:(c)) { cout<<i<<" "; } nl 
#define eb   emplace_back
#define ef   emplace_front
#define pb   push_back
#define pf   push_front
#define popb pop_back
#define popf pop_front
#define mp   make_pair
#define sz(a) int((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
//Allows to traverse any type of macro
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
//debuggers
#define trace2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define trace3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define trace4(w,x,y,z) cout<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<ll,ll> pll;
const int INF = 1e5+5;
string convertInt(int number){stringstream ss;ss << number;return ss.str();}
int convertString(string s){int num;stringstream sstr(s);sstr>>num;return num;}
int main()
{
	ll n,w;
	cin >> n >> w;
	vector<ll>weight(n);
	vector<ll>v(n);
	vector<ll> dp(w+1);

	rep(i,0,n)
	{
		cin >> weight[i] >> v[i];
		/*0 up iteration dp[0]->dp[3]. since i iterate up dp[3]->dp[6] would occur*/
		/*dp[0*->dp[3]->dp[6]//if we are allowed to take the weight multiple times a single loop*/
		for(int j=w - weight[i];j>=0;j--)
		{
			dp[j+weight[i]] = max(dp[j+weight[i]],dp[j]+v[i]);
		}
	}
	cout << *max_element(dp.begin(),dp.end())<<endl;
}

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

using namespace std;

#define int long long
#define MP make_pair
#define F first
#define S second
#define pi pair<int,int> 
#define sz(s) ((int)s.size())
#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)

const unsigned mod = 1e9 + 7;
const unsigned N = 5e5 + 4;

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

  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << ' ' << b << ' ' << c << '\n';




  
  assert(numeric_limits<int>::max() >= 1e18);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <limits.h>

using namespace std;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    cin >> N >> C;

    int D[C][C];
    for (int i=0; i<C; ++i) {
        for (int j=0; j<C; ++j) {
            cin >> D[i][j];
        }
    }

    int c[N][N];
    for (int i=0; i<N; ++i) {
        for (int j=0; j<N; ++j) {
            cin >> c[i][j];
            --c[i][j];
        }
    }

    int d[3][C];
    for (int i=0; i<3; ++i) {
        for (int cc=0; cc<C; ++cc) {
            int sum = 0;
            for (int j=0; j<N; ++j) {
                for (int k=(i+3-j%3)%3; k<N; k+=3) {
                    sum += D[c[j][k]][cc];
                }
            }
            d[i][cc] = sum;
        }
    }

    long long min = LLONG_MAX;
    for (int i=0; i<C; ++i) {
        for (int j=0; j<C; ++j) {
            for (int k=0; k<C; ++k) {
                if (i != j && j != k && k != i) {
                    int x = d[0][i] + d[1][j] + d[2][k];
                    if (x < min) {
                        min = x;
                    }
                }
            }
        }
    }

    cout << min << endl;
    return 0;
}


Measured memory_bytes: 1280
#include<cstdio>
#include<algorithm>
using namespace std;
long long w[65536], P[16][16], res[65536];
int n;
int main() {
	int i, j, k;
	scanf("%d", &n);
	for (i = 0; i < n; i++)for (j = 0; j < n; j++)scanf("%lld", &P[i][j]);
	for (i = 0; i < (1 << n); i++) {
		long long s = 0;
		for (j = 0; j < n; j++) {
			for (k = j + 1; k < n; k++) {
				if ((i >> j) & 1) {
					if ((i >> k) & 1) {
						s += P[j][k];
					}
				}
			}
		}
		w[i] = s;
	}
	for (i = 0; i < (1 << n); i++) {
		int mask = i;
		for (int j = mask; j; j = (j - 1)&mask) {
			res[i] = max(res[i], w[j] + res[i^j]);
		}
	}
	printf("%lld\n", res[(1 << n) - 1]);
}

Measured memory_bytes: 1152
N = int(input())
A = list(map(int, input().split()))

a = "APPROVED"
d = "DENIED"

even = 0
chk = 0
for i in A:
    if i % 2 == 0:
        even += 1
        if i%3 == 0 or i%5 == 0:
            chk += 1

if even == chk:
    print(a)
else:
    print(d)

Measured memory_bytes: 3064
def solve():
  S = int(input())
 
  if S == 10 ** 18:
    print('0 0 0 1000000000 1000000000 0')
  else:
    LIMIT = 10 ** 9
    a = S % LIMIT
    b = (S - a) // LIMIT + 1
    c = LIMIT - a
    print('0 0 1 1000000000 ' + str(b) + ' ' + str(c))
 
solve()

Measured memory_bytes: 2940