akhauriyash/Code-Regression huggingface dataset:
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            int ans=0;
            int ar[n+1];
            for(i=1;i<=n;++i)
            {
                cin>>ar[i];
                if(i%2 && ar[i]%2)
                    ++ans;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const ll mod = 1000000007;

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

    Graph G(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back(b);
    }

    int sv, tv;
    cin >> sv >> tv;
    sv--;  tv--;

    vector<vector<int>> dist(n, vector<int>(3, -1));  // dist[i][j] : 移動距離がmod3でjとなる頂点svから頂点iまでの最短距離
    queue<pair<int, int>> Q;

    dist[sv][0] = 0;
    Q.push(make_pair(sv, 0));
    while(!Q.empty()) {
        int v = Q.front().first;
        int c = Q.front().second;
        Q.pop();
        for(auto u : G[v]) {
            int nc = (c + 1)%3;
            if(dist[u][nc] != -1) {
                continue;
            }
            dist[u][nc] = dist[v][c] + 1;
            Q.push(make_pair(u, nc));
        }
    }

    int ans = dist[tv][0];
    if(ans != -1) {
        ans /= 3;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

int dp[64][100+1];

int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    string S; cin >> S;

    vector<int> hc;
    if (S[0] == '0') hc.push_back(0);
    char sc = S[0];
    int streak = 1;
    for (int i = 1; i < S.size(); ++i) {
        if (S[i] != sc) {
            hc.push_back(streak);
            streak = 1;
            sc = S[i];
        }
        else if (S[i] == sc) ++streak;
    }
    hc.push_back(streak);

    if (S.back() == '0') hc.push_back(0);

    for (int i = 0; i < hc.size(); ++i) {
        if (i > 0) hc[i] += hc[i - 1];
    }

    if ((2 * K + 1) >= hc.size()) {
        cout << hc.back() << endl;
    }
    else {
        int _K = 2 * K + 1;
        int ans = 0;
        for (int i = 0; i <= hc.size() - _K; i += 2) {
            ans = max(ans, hc[i + _K - 1] - (i > 0 ? hc[i - 1] : 0));
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1020
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors

p = make_divisors(n)
ans = float("inf")
for i in range(len(p)):
    if i < len(p) - 1:
        if p[i] * p[i+1] == n:
            ans = min(ans, p[i]-1+p[i+1]-1)
    if p[i] * p[i] == n:
        ans = min(ans, (p[i] - 1) * 2)
print(ans)


Measured memory_bytes: 3272
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
  int n, k; cin >> n >> k;
  if (n==k) return puts("1") * 0e1;
  int p[n]; for(int i=0; i<n; i++) cin >> p[i];
  int an = 1;
  set<int> s;
  for(int i=0; i<k; i++) {
    s.insert(p[i]);
  }
  for(int i=0; i<n-k; i++) {
    s.insert(p[i+k]);
    auto b=s.begin(), e=s.end(); e--;
    //cout << *b << " " << *e << " " << p[i] << " " << p[i+k] << endl;
    if (!(*b == p[i] && *e == p[i+k])) an++;
    s.erase(p[i]);
  }
  
  bool nt = false; int bf=-1, ct=0;
  for(int i=0; i<n; i++) {
    if (bf<p[i]) ct++; else ct=1; bf=p[i];
    if (ct==k) {nt=1;an--;}
  }
  
  cout << an+nt << endl;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=3e3+5;
const int mod=1e9+7;
const ll oo=1e18+5;


int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int h,a;
	cin>>h>>a;
	int add=0;
	if(h%a) add=1;
	cout<<h/a+add;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, M;
  cin >> N >> M;
  cout << ((100 * N + 1800 * M) << M) << "\n";
  // print();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PP pop_back()
#define ALL(x) x.begin(),x.end()
#define st first
#define nd second
#define sz(x) (int) x.size()
#define pii pair<int,int>
#define ii int,int
#define ll long long
#define lf double
#define llu long long unsigned
#define INPUT freopen("inp.in","r",stdin);
#define OUTPUT freopen("oup.out","w",stdout);
#define sag(x) 2*x+1
#define sol(x) 2*x
#define orta ((bas+son)/2)
#define set(x,y) memset(x,y,sizeof(x))
#define MIN3(x,y,z) min(min(x,y),z)
#define MAX3(x,y,z) max(max(x,y),z)
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define ROF(i,j,k) for(int i=j;i>=k;i--)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000007
#define inf 20000000000000
#define N 100005
using namespace std;
int n,w,a[N],pl;
int main() {
    cin>>n>>w;
    FOR(i,1,n) cin>>a[i];
    FOR(i,1,n-1) {
        if(a[i]+a[i+1]>=w) {
            pl=i;
            break ;
        }
    }
    if(!pl) cout<<"Impossible\n";
    else {
        cout<<"Possible\n";
        FOR(i,1,pl-1)
            cout<<i<<endl;
        ROF(i,n-1,pl)
            cout<<i<<endl;
    }
}


Measured memory_bytes: 1152
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	ll n, a, sum1 = 0, sum2 = 0, ans1 = 0, ans2 = 0, i;

	cin >> n;
	for(i = 0; i < n; i++){
		cin >> a;
		sum1 += a;
		sum2 += a;
		if(i % 2 == 0){
			if(sum1 < 1){
				ans1 += 1 - sum1;
				sum1 = 1;
			}
			if(sum2 > -1){
				ans2 += sum2 + 1;
				sum2 = -1;
			}
		}
		else{
			if(sum1 > -1){
				ans1 += sum1 + 1;
				sum1 = -1;
			}
			if(sum2 < 1){
				ans2 += 1 - sum2;
				sum2 = 1;
			}
		}
	}

	cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a * b / 2);
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

const long long MAX = 510000;  // 最大を決めておく
// fac…階乗、inv…逆数、finv…逆数の累積積
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理、先にやっておく
void nCr_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// nCrを計算する (前処理は忘れないように)
long long nCr(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

// ====================================================================

int main() {
  nCr_init();

  ll n, k;
  cin >> n >> k;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }

  sort(v.begin(), v.end());

  ll mi = 0, ma = 0;
  for (int i = 0; i < n; i++) {
    mi = (mi + nCr(n - (i + 1), k - 1) * v[i] % MOD) % MOD;
    ma = (ma + nCr(i, k - 1) * v[i] % MOD) % MOD;
  }
  cout << (MOD + ma - mi) % MOD << endl;
}


Measured memory_bytes: 12928
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int s = sc.nextInt();
        boolean ans = true;
        int count = 1;
      
        List<Integer> list = new ArrayList<Integer>();
        list.add(s);
        while(ans == true){
          if(s % 2 == 0){
            s = s / 2;
          }else{
            s = s * 3 + 1;
          }
          list.add(s);
           
          ans = (list.size() == new HashSet<>(list).size());
          count++;
        }
        
        
        
        System.out.println(count);
    }
}

Measured memory_bytes: 36784
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define ull unsigned long long
#define ll long long 
#define db double 
#define ldb long double
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
//#define mod 1000000007
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
const ldb PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899863;
const int INF = 1e9;
bool ok(string &s ,int l ,int r)
{
while(s[l]==s[r]) l++,r--;
return l>=r; 
}/*
ll por(ll a,int b)
{
ll res=1,M=998244353;
while(b)
{
if(b&1)
res=(res*a)%M;
a=(a*a)%M;
	b/=2;
}
return res;
}
void rev(vector<int>&arr,int l,int r)
{
    for(;l<r;l++,r--) swap(arr[l],arr[r]);
}
void solve()
{
// Dont apply return before taking all the input of particular test case
/* carry operation
int cr=1;
int y=k-1;
while(cr)
{
char op=str[y];
op++;
if(op<='9') cr=0;
else op='0';
str[y]=op;
y--;
}
return;
}
*/
void solve()
{
ll x,ans=0; cin>>x;
//x/=500;
ans=x/500;
ans*=1000;
x=x%500;
ans+=(x/5)*5;
cout<<ans;
return;
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	cin>>t;
while(t--)
{
solve();
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


int main() {
    string S;
    string T;
    
    


    cin >> S;
    cin >> T;

    long int change_num = S.length();

    for (int i = 0; i < S.length(); i++) {
        if (S[i] == T[i]) {
            change_num -= 1;
        }
    }

    cout << change_num << endl;
    
    return 0;
}



Measured memory_bytes: 3384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int cnt=0;
    while(n--){
        int a,b; cin >> a >> b;
        cnt=(a==b?cnt+1:0);
        if(cnt>=3){
            couty; return 0;
        }
    }
    coutn;
}

Measured memory_bytes: 3648
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, M = list(map(int, sys.stdin.buffer.readline().split()))
S = sys.stdin.buffer.readline().decode().rstrip()

# 後ろから貪欲
ans = []
S = S[::-1]

pos = [N + 1] * len(S)
p = N + 1
l = N
while p - l <= M and l >= 0:
    pos[l] = p
    l -= 1
p -= 1
while p >= 0:
    if S[p] == '1':
        p -= 1
        continue

    while p - l <= M and l >= 0:
        pos[l] = p
        l -= 1
    p -= 1

i = 0
while i < N:
    me = None
    for j in reversed(range(1, min(M + 1, pos[i] - i + 1))):
        if i + j < len(S) and S[i + j] == '0':
            me = j
            break
    if me is None:
        print(-1)
        exit()
    ans.append(me)
    i += me
print(*ans[::-1])


Measured memory_bytes: 10324
import collections
import heapq
import operator
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, k = ril()
ls = rils(n)
ls.sort(key=operator.itemgetter(1), reverse=True)
counter = collections.Counter()
ls0 = []
ls1 = []
base = 0
for i, (t, d) in enumerate(ls):
    if i < k:
        heapq.heappush(ls0, (d, t))
        counter[t] += 1
        base += d
    else:
        if t not in counter:
            heapq.heappush(ls1, (-d, t))

m = len(counter)
res = base + m**2

for i in range(k):
    ok = False
    while ls0:
        d, t = heapq.heappop(ls0)
        counter[t] -= 1
        if counter[t] > 0:
            base -= d
            ok = True
            break
    if not ok:
        break

    ok = False
    while ls1:
        d, t = heapq.heappop(ls1)
        if t not in counter:
            counter[t] += 1
            base += -d
            ok = True
            break
    if not ok:
        break

    res = max(res, base + (m + i + 1)**2)
print(res)

Measured memory_bytes: 40288
//#include <bits/stdc++.h>
#include <iostream>
#include <list>
#include <vector>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define DBG 0

#define MAXN 101
#define MAXW 100001
long a[MAXN][MAXW];

int main() {
  int n, W;
  cin >> n >> W;
  int w[MAXN];
  int v[MAXN];
  forr(i,0,n-1) {
    cin >> w[i] >> v[i];
    if (DBG) cout << w[i] << " ";
    a[i][0] = 0;
  }
  if (DBG) {
    cout << endl;
    forr(i,0,n-1) cout << v[i] << " ";
    cout << endl << n << " n|w " << W << endl;
  }

  forr(i,0,n-1)
  forr(j,0,W)
    a[i][j] = 0;
  a[0][w[0]] = v[0];

  forr(i,1,n-1) {
    forr(j,1,W) {
      if (a[i][j] < a[i-1][j])
        a[i][j] = a[i-1][j];
      if (DBG) {
        cout << "i " << i << " j " << j << " wi " << w[i]
             << " vi " << v[i] << " ai1j " << a[i-1][j]
             << " ai1jwi " << a[i-1][j+w[i]] << endl;
      }
      if (a[i-1][j] > 0 && j+w[i] <= W &&
          a[i-1][j]+v[i] > a[i-1][j+w[i]])
          a[i][j+w[i]] = a[i-1][j]+v[i];
    }
    if (a[i][w[i]] < v[i])
      a[i][w[i]] = v[i];
  }

  if (DBG) {
    forr(i,0,n-1) {
      forr(j,0,W) cout << a[i][j] << " ";
      cout << endl;
    }
  }

  long mx = -1;
  forr(j,1,W) if (a[n-1][j] > mx) mx = a[n-1][j];
  cout << mx;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
#include<cmath>
using namespace std;
int main()
{
    double a;
    cin>>a;
    double b=3.141592653589793238;
    cout<<fixed<<setprecision(21)<<2.0*a*b<<endl;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
const int maxn=5010;
int beg[maxn],tto[maxn<<1],nex[maxn<<1],e;
void putin(int s,int t){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
}
int dp[maxn][maxn];
int siz[maxn];
int f[maxn];
const int md=1e9+7;
int fac[maxn];
long long get_val(int x){
	return fac[x];
}
void solve(int u,int fa){
	for(int i=beg[u];i;i=nex[i]){
		if(tto[i]==fa) continue;
		solve(tto[i],u);
	}
	siz[u]=1,dp[u][1]=1;
	for(int i=beg[u];i;i=nex[i]){
		if(tto[i]==fa) continue;
		for(int j=0;j<=siz[u]+siz[tto[i]];j++)
			f[j]=0;
		for(int j=0;j<=siz[u];j++)
			for(int k=0;k<=siz[tto[i]];k++)
				f[j+k]=(f[j+k]+dp[u][j]*(long long)dp[tto[i]][k])%md;
		siz[u]+=siz[tto[i]];
		for(int j=0;j<=siz[u];j++)
			dp[u][j]=f[j];
	}
	for(int i=2;i<=siz[u];i+=2){
		dp[u][0]=(dp[u][0]-dp[u][i]*get_val(i)%md+md)%md;
//		if(i==4) printf("%d\n",C[i][i/2]%md*fac[i/2]%md);
	}
//	if(u==1) printf("%d\n",dp[1][4]);
}

int main(){
	int n;
	scanf("%d",&n);
	int s,t;
	for(int i=1;i<n;i++){
		scanf("%d%d",&s,&t);
		putin(s,t);
		putin(t,s);
	}
	fac[0]=1;
	for(int i=2;i<=n+1;i++)
		fac[i]=fac[i-2]*(long long)(i-1)%md;
	solve(1,-1);
	printf("%d\n",(md-dp[1][0])%md);
	return 0;
}

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

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

	vector<int> dp(h + 1, 1000000000);
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;

		for (int j = 1; j <= a; ++j) {
			if (h < j) {
				break;
			}
			dp[j] = min(dp[j], b);
		}
		for (int j = a + 1; j <= h; ++j) {
			dp[j] = min(dp[j], dp[j - a] + b);
		}
	}

	cout << dp[h] << endl;

	return 0;
}

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

ll mod = 1e9+7;

int main(){
    string S;
    cin >> S;
    int N = S.size();
    vector<vector<ll>> dp(N+1, vector<ll>(13, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        if (S[i] != '?') {
            int t = S[i] - '0';
            for (int j = 0; j <= 12; j++) {
                dp[i+1][(j*10+t)%13] = dp[i][j];
            }
        }
        else {
            for (int j = 0; j <= 12; j++) {
                for (int k = 0; k <= 9; k++) {
                    dp[i+1][(j*10+k)%13] += dp[i][j];
                }
            }
            for (int j = 0; j <= 12; j++) {
                dp[i+1][j] %= mod;
            }
        }
    }
    cout << dp[N][5] << endl;
    return 0;
}

Measured memory_bytes: 13696
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()
h = LI()
dp = [INF for _ in range(N)]
dp[0] = 0
for i in range(N-1):
    dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
    if i < N-2:
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]))
print(dp[-1])


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

int main() {
    int a,b; cin>>a>>b;
    if (a==1){
        if (b==1) cout<<"Draw";
        else cout<<"Alice";
        return 0;
    }
    else if (b==1){
        if (a==1) cout<<"Draw";
        else cout<<"Bob";
        return 0;
    }
    else if (a>b) cout<<"Alice";
    else if (a==b) cout<<"Draw";
    else cout<<"Bob";
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int N;
    cin >> N;
    ll cnt = 0;
    rept(i, 1, N+1) {
        if (i % 3 != 0 && i % 5 != 0) cnt += i;
    }
    cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val (q, h, s, d) = readLine()!!.split(" ").map(String::toLong)
    val n = readLine()!!.toLong()
    var qq = 4 * n
    var hq = 0L
    var sq = 0L
    var dq = 0L

    if (2 * q >= h && qq >= 2) {
        hq = qq / 2
        qq -= (qq / 2) * 2
    }

    if (2 * h >= s && hq >= 2) {
        sq = hq / 2
        hq -= (hq / 2) * 2
    }

    if (4 * q >= s && qq >= 4) {
        sq = qq / 4
        qq -= (qq / 4) * 4
    }

    if (2 * s >= d && sq >= 2) {
        dq = sq / 2
        sq -= (sq / 2) * 2
    }

    if (4 * h >= d && hq >= 4) {
        dq = hq / 4
        hq -= (hq / 4) * 4
    }

    if (8 * q >= d && qq >= 8) {
        dq = qq / 8
        qq -= (qq / 8) * 8
    }
    
    println(q * qq + h * hq + s * sq + d * dq)
}

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

void program(); 
int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    program();
}

#define INF 0x7fffffffffffffff
#define UINF 0xffffffffffffffff
#define MOD 1000000007

#define int long long
#define unsigned unsigned long long
#define double long double

#define endl "\n"

int pow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

class UF{
public:
    int n;
    vector<int> par, sz;
    UF(int size) : n(size), par(size), sz(size){
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }
    void join(int x, int y){
        if ((x = find(x)) == (y = find(y))) return;
        if (sz[y] < sz[x]) std::swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        sz[x] = 0;
    }
    int find(int x){ return par[x] = (x == par[x] ? x : find(par[x])); }
    bool connected(int x, int y){ return find(x) == find(y); }
};

template<class Iter> void _print_range(ostream& o, Iter s, Iter e){
    for(;s != e;s++) o << *s << " ";
} 
template<class T> std::ostream& operator<<(ostream& o, const std::vector<T> &ds)
{
    _print_range(o,ds.begin(),ds.end()); 
    return o;
}
template<class T> std::ostream& operator<<(ostream& o, const std::set<T> &ds)
{
    _print_range(o,ds.begin(),ds.end()); 
    return o;
}
template<class T, class U> std::ostream& operator<<(ostream& o, const std::pair<T,U> &ds)
{
    o << "<" << ds.first << "," << ds.second << ">" << endl;
    return o;
}
template<typename ...Args>
void print(Args&&... args) {
    for(auto&& x: {args...})
        cout << x << " ";
    cout << endl;
}

#define debug(x) cout << "DEBUG    " <<  #x << ": " << x << endl;

#define fr(i, a, b) for(int i = a; i != (b); i += (a<b ? 1 : -1))
#define rep(i, a) for(decltype(a) i = 0; i < (a); i++)

#define trav(x, a) for(auto& x : a)
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define vi vector<int>
#define si set<int>
#define pii pair<int,int>

#define N 100005
int n,m;
vi gra[N];
int dp[N];

int dfs(int x){
    if(dp[x]) return dp[x];
    int mx = 1;
    for(auto nxt: gra[x])
        mx = max(mx, 1+dfs(nxt));
    return dp[x] = mx;
}

void program(){
    cin>>n>>m;
    rep(i,m){
        int u,v;
        cin>>u>>v;
        gra[--u].pb(--v);
    }
    rep(i,n) dfs(i);
    cout<<*max_element(dp,dp+N)-1<<endl;
}

/*
WA:
-bounds on loops
-truncating
-intialization
-0 vs 1 indexing

TLE:
-might need unordered_set/map
-infinite while loop

Stuck:
-bruteforce?
-reduce dimensionality with problem contraints?
*/


Measured memory_bytes: 8576
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, const char * argv[]) {
    while(1){
        vector<int> G[100];
    int a,b;
    while(1){
        if(!(cin >> a >> b)){
            return 0;
        }
        if(a==0 && b==0){break;}
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (G[0].size()%2 == 1 && G[1].size()%2 ==1){
        int c = 0;
        for(int i=0; i<100; i++){
            if(G[i].size()%2 == 1){
                c++;
            }
        }
        if(c==2){
            cout << "OK" << endl;
        }
        else{
            cout << "NG" << endl;
            
        }
    }
    else{
        cout << "NG" << endl;
    }
    }
    return 0;
}

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

int main(void){
   int N;
   cin>>N;
   int A,B;
   cin>>A>>B;
   vector<int> P(N);
   for(int i=0;i<N;i++){
      cin>>P[i];
   }
   int result[3]={0};
   for(int i=0;i<N;i++){
      if(P[i]<=A) result[0]++;
      else if(A+1<=P[i]&&P[i]<=B) result[1]++;
      else result[2]++;
   }
   cout<<min(result[0],min(result[1],result[2]))<<endl;
   return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
  int n;
  scanf("%d",&n);
  long unsigned int a;
  long unsigned int c = 1;
  long unsigned int count = 0;
  scanf("%ld", &a);
  count = a-1;
  for(int i=1;i<n;i++){
    scanf("%ld",&a);
    if(c+1==a)
      c=a;
    else if(c+1<a){
      count += a/(c+1);
      if(a%(c+1)==0) count--;
    }
  }
  printf("%ld\n",count);


  return EXIT_SUCCESS;
}


Measured memory_bytes: 128
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

class Node {
    Integer id;
    Node parent;
    Node left;
    Node right;
}

class Main {
    static Map<Integer, Node> nodes = new HashMap<>();
    static Node root;

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

        for (int i = 0; i < n; i++) {
            Integer id = sc.nextInt();
            Integer leftId = sc.nextInt();
            Integer rightId = sc.nextInt();
            Node node = createNode(id);
            node.left = createChildrenNode(node, leftId);
            node.right = createChildrenNode(node, rightId);
        }
        Node root = findRoot();
        System.out.println("Preorder");
        System.out.println(preParse(root));
        System.out.println("Inorder");
        System.out.println(inParse(root));
        System.out.println("Postorder");
        System.out.println(postParse(root));
    }

    public static String preParse(Node node) {
        if (node == null) {
            return "";
        }
        return " " + node.id + preParse(node.left) + preParse(node.right);
    }

    public static String inParse(Node node) {
        if (node == null) {
            return "";
        }
        return inParse(node.left) + " " + node.id + inParse(node.right);
    }

    public static String postParse(Node node) {
        if (node == null) {
            return "";
        }
        return postParse(node.left) + postParse(node.right) + " " + node.id;
    }

    public static Node createChildrenNode(Node node, Integer childrenId) {
        if (childrenId == -1) {
            return null;
        }
        Node childrenNode = createNode(childrenId);
        childrenNode.parent = node;
        return childrenNode;
    }

    public static Node createNode(Integer id) {
        Node node = nodes.get(id);
        if (node == null) {
            node = new Node();
            node.id = id;
            node.parent = null;
            nodes.put(id, node);
        }

        return node;
    }

    public static Node findRoot() {
      return nodes.values().stream().filter(node -> node.parent == null).collect(Collectors.toList()).get(0);
    }
}



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

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	int sa=b-a;
	if(sa>x) cout << "dangerous" << endl;
	if(sa<=x && sa>0) cout << "safe" << endl;
	if(sa<=0) cout << "delicious" << endl;
}


Measured memory_bytes: 3612
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner s = new Scanner(System.in);
    String str = s.next();
    if(str.charAt(2)==str.charAt(3)&&str.charAt(4)==str.charAt(5))
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

      

Measured memory_bytes: 21716
cnt=0
while True:
    cnt+=1
    W=int(input())
    if W==0:
        break
    n=int(input())
    dp=[0]*(W+1)
    for i in range(n):
        v,w=map(int,input().split(','))
        for j in range(W,w-1,-1):
            dp[j]=max(dp[j],dp[j-w]+v)
    wgt=0
    for i in range(W+1):
        if max(dp)==dp[i]:
            wgt=i
            break
    print("Case {0}:".format(cnt))
    print(max(dp))
    print(wgt)

Measured memory_bytes: 7692
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int ans[1000], a, b, c, d, n, m, i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a >> b;
		ans[i] = a * 60 + b;
	}
	cin >> m;
	for (i = 0; i < m; i++) {
		cin >> c >> d;
		ans[i + n] = c * 60 + d;
	}
	sort(ans, ans + m + n);
	for(i=0;i<m+n;i++){
		a = ans[i] / 60;
		b = ans[i] % 60;
		if (ans[i] == ans[i + 1]) {
			i++;
		}
		if (i == m + n - 1 && b<10) {
			printf("%d:0%d\n", a, b);
		}
		else if (i == m + n - 1 && b >= 10) {
			printf("%d:%d\n", a, b);
		}
		else if (b < 10) {
			printf("%d:0%d ", a, b);
		}
		else {
			printf("%d:%d ", a, b);
		}
	}
	
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
// string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n>>k;
  ll a[n+1];
  for (ll i = 1; i <= n; ++i)
  {
  cin>>a[i];
  }
  for (ll i = 1; i <= n; ++i)
  {  
    for(ll j= n+1;j>i;j--)
    {    
      ll tot = i + (n - j+1);
      if(tot>k)
        break;
      c =0;
      ll rem = k - tot;
      std::vector<ll> v;
      
      for (x = 1; x <=i ; ++x)
      {
        v.pb(a[x]);
        c+=a[x];
       
      }
   //   c(c);
      for (x = j; x <=n ; ++x)
      {
        v.pb(a[x]);
        c+=a[x];
      }
    sort(v.begin(), v.end());
    for(ll it : v)
    {
        if(it>=0)
          break;
        if(rem==0)
          continue;
        rem--;
        c -=it;
    }
   //   cout<<rem<<" ";c(c);
    ans = max(c,ans);
    }
    //c("");
  }
  cout<<ans<<"\n";
}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


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

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(-a+b<=0)cout<<"delicious"<<endl;
    else if(-a+b<=x)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;


int main(){
   //int n; cin>>n;
   string s,t; cin>>s>>t;
   bool ans=false;
   int tri=0;
   
   REP(i,s.size()-t.size()+1){
      int count=0;
     REP(j,t.size()){
       if(s[i+j]==t[j]||s[i+j]=='?')count++;
      }
    if(count==t.size()){
         ans=true;
         tri=i;
    }
   }
   
	 REP(i,t.size())s[tri+i]=t[i];
   REP(i,s.size())if(s[i]=='?')s[i]='a';
  
   if(ans)cout<<s<<endl;
   else cout<<"UNRESTORABLE"<<endl;
   
} 


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

int main()
{
    long k, a, b; cin>>k>>a>>b;
    if (a+1>=b) {
        cout<<1+k<<endl;
        return 0;
    }
    long t=min(k, a-1);
    long res=1+t;
    k-=t;
    if (k<=1) {
        cout<<res+k<<endl;
        return 0;
    }
    auto m=k/2;
    cout<<m*b-(m-1)*a+k%2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <vector>
using namespace std;
enum Query
{
    push = 0,
    randomAccess = 1,
    pop = 2,
};

int main()
{
    // vector<int> A(800000);
    int A[800000];
    int query;
    int d, x;
    int q;
    cin >> q;
    //初めは必ず値の挿入からはじまるので。
    cin >> query >> d >> x;
    A[400000] = x;
    // cerr << A[400000] << endl;
    int end = 400001; //今の末尾
    int top = 399999; //今の先頭
    while (q - 1)
    {
        cin >> query;
        if (query == push) //挿入
        {
            cin >> d >> x;
            if (d == 0)
            {
                //先頭に追加
                A[top] = x;
                // cerr << top << endl;
                // cerr << A[top] << endl;
                top--;
            }
            else if (d == 1)
            {
                //末尾に追加
                A[end] = x;
                // cerr << end << endl;
                // cerr << A[end] << endl;
                end++;
            }
        }
        else if (query == randomAccess) //出力
        {
            int p;
            cin >> p;
            // cerr << top << endl;
            cout << A[top + 1 + p] << endl;
        }
        else if (query == pop) //削除
        {
            int d;
            cin >> d;
            if (d == 0)
            {
                //先頭を削除
                top++;
                // cerr << top << endl;
            }
            else if (d == 1)
            {
                //末尾を削除
                end--;
                // cerr << end << endl;
            }
        }
        q--;
    }
}


Measured memory_bytes: 4660
#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;

typedef long long ll;
typedef long double ld;
typedef array<ll,2> pll;
const ll NMAX=100005;
ll h[NMAX],dp[NMAX];
int main()
{
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>h[i];
        if(i>1)
            dp[i]=2e9;
        if(i>2)
            dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
        if(i>1)
            dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[n];
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll x, y; cin >> x >> y;

    ll ans = 1;
    for(ll i = x; i <= y / 2; i*=2) {
        ll tmp = i, cnt = 1;
        while(1){
            tmp *= 2;
            if(y < tmp) break;
            cnt++;
        }
        if(cnt < ans) break;
        else ans = cnt;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
n = int(input())
p_list = list(map(int, input().split()))

count = 0

for i in range(1,n-1):
  p_i_minus = p_list[i-1]
  p_i = p_list[i]
  p_i_plus = p_list[i+1]
  
  if p_i_minus < p_i < p_i_plus or p_i_plus < p_i < p_i_minus:
    count += 1
    
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <thread>///////////////////

#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;

//int N, Y;
int mode = 0;

//tuple<int, int, int> calc(int A, int B, int C) {}



int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int ans = 0;
	if (K >= A) {
		ans += A;
		if (K - A >= B) {
			if (K - A - B > 0 ) {
				ans += (K - A - B)*(-1);
			}
		}
		
	}
	else {
		ans += K;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main() {
    int binary[8];
    binary[0] = 1;
    for (int i = 1; i < 8; i++) {
        binary[i] = binary[i - 1] * 2;
    }
    int n;
    cin >> n;
    for (int i = 0; i < 8; i++) {
        if (n < binary[i]) {
            cout << binary[i - 1] << endl;
            return 0;
        }
    }
}


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

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final int l = in.nextInt();
            final int r = in.nextInt();
            int count = 0;
            for (int i = l; i <= r; i++) {
                StringBuilder sb = new StringBuilder();
                sb.append(String.valueOf(i));
                if (sb.toString().equals(sb.reverse().toString())) count++;
            }
            out.println(count);
        }

    }
}



Measured memory_bytes: 38356
#include <stdio.h>

int main(void)
{
	int t, s, f;
	int n;
	int sum ;
	
	while (1){
		sum = 0;
		scanf("%d", &t);
		if (t > 0){
			scanf("%d", &n);
			while (n != 0){
				scanf("%d %d", &s, &f);
				sum += f - s;
				n--;
			}
		}
		else {
			break;
		}
		
		if (sum >= t){
			printf("OK\n");
		}
		else {
			printf("%d\n", t - sum);
		}
	}
	return (0);
}

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

int main() {
    int L, R, d;
    cin >> L >> R >> d;

    int count = 0;
    for(int i=L; i<=R; i++) {
        if(i%d==0) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
int main(){
    REP(i, 9) REP(j, 9)
        cout << i+1 << "x" << j+1 << "=" << (i+1) * (j+1) << endl;
    return 0;
}

Measured memory_bytes: 1112
n = int(input())
a = list(map(int, input().split()))
count = 0

for i in range(n-1):
    min_j = i
    for j in range(i+1, n):
        if a[j] < a[min_j]:
            min_j = j
    if min_j != i:
        a[i], a[min_j] = a[min_j], a[i]
        count += 1

print(*a)
print(count)


Measured memory_bytes: 5604
def isOnBoard(x,y):
    return 0<=x<8 and 0<=y<8
for dataset in xrange(input()):
    raw_input()
    board=[0]*8
    for i in xrange(8):
        board[i]=map(int,raw_input())
    x,y=input(),input()
    dx=[-3,-2,-1,0,0,0,1,2,3,0,0,0]
    dy=[0,0,0,-3,-2,-1,0,0,0,1,2,3]
    stack=[(x-1,y-1)]
    board[y-1][x-1]=0
    while stack:
        x,y=stack.pop()
        for i in xrange(len(dx)):
            if isOnBoard(x+dx[i],y+dy[i]):
                if board[y+dy[i]][x+dx[i]]==1:
                    board[y+dy[i]][x+dx[i]]=0
                    stack.append((x+dx[i],y+dy[i]))
    print "Data {}:".format(dataset+1)
    print "\n".join(["".join(map(str,line)) for line in board])

Measured memory_bytes: 4272
#include <iostream>
#include <map>

using namespace std;

int main()
{
	int N,A,ans = 0;

	cin >> N;

	map<int, int>mp;

	for (int n = 0; n < N; n++) {
		cin >> A;

		if (!mp[A]) {
			mp[A] = 1;
			ans++;
		}
		else {
			mp[A] = 0;
			ans--;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int a[3][3], f[3][3];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (a[j][k] == b) {
                    f[j][k] = 1;
                }
            }
        }
    }
    int res = 0;
    for (int i = 0; i < 3; i++) {
        bool f1 = true, f2 = true;
        for (int j = 0; j < 3; j++) {
            if (!f[i][j]) {
                f1 = false;
            }
            if (!f[j][i]) {
                f2 = false;
            }
        }
        res |= f1;
        res |= f2;
    }
    res |= (f[0][0] && f[1][1] && f[2][2]);
    res |= (f[2][0] && f[1][1] && f[0][2]);
    if (res) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    return arr

z = factorization(int(input()))
i = 1
ans = 0
flag = True
while flag:
    flag2 = False
    for j in range(len(z)):
        if z[j][1] >= i:
            z[j][1] -= i
            ans += 1
            flag2 = True

    i += 1
    if flag2 == False: flag = False
print(ans)


Measured memory_bytes: 9476
#include <queue>
#include <iostream>

int main() {
  int N, M;
  std::cin >> N >> M;
  std::priority_queue<int> Q;
  for (int i = 0; i < N; i++) {
    int a;
    std::cin >> a;
    Q.push(a);
  }
  for (int i = 0; i < M; i++) {
    const int a = Q.top();
    Q.pop();
    Q.push(a / 2);
  }
  long long s = 0;
  while (!Q.empty()) {
    s += static_cast<long long>(Q.top());
    Q.pop();
  }
  std::cout << s << std::endl;
  return 0;
}


Measured memory_bytes: 892
// Problem : A - K-City
// Contest : AtCoder - AtCoder Beginner Contest 069
// URL : https://atcoder.jp/contests/abc069/tasks/abc069_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n,m;cin>>n>>m;
cout<<(n-1)*(m-1);
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=11000;
const int inf=0x3f3f3f3f;
const int mod=1000000007;

int n;
double f[Maxn],p;

signed main() {
//	freopen("test.in","r",stdin);
	read(n);
	f[0]=1;
	for(int i=1;i<=n;i++) {
		scanf("%lf",&p);
		for(int j=i;j>=1;j--) f[j]=(f[j]*(1.0-p)+f[j-1]*p);
		f[0]*=1.0-p;
	}
	double ans=0;
	for(int i=n/2+1;i<=n;i++) ans+=f[i];
	printf("%.10lf",ans);
	return 0;
}



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

int main(){
  int n;
  int a[200005];
  cin >> n;
  rep(i, n)cin >> a[i];
  int prev = a[0];
  ll ans = 0;
  for(int i=1;i<n;i++){
    int now = max(0, prev-a[i]);
    ans += now;
    prev = a[i]+now;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4412
import sys


def input():
    return sys.stdin.readline().strip()


K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(K + A[0])
Diff = [y - x for x, y in zip(A, A[1:])]
answer = K - max(Diff)
print(answer)


Measured memory_bytes: 26444
import java.util.*;
class Main
{
  public static void main(String args[])
  {
	Scanner sc = new Scanner(System.in);
	int t=sc.nextInt();
	int min=sc.nextInt();
	int temp=0;
	for(int i=0; i<(t-1); i++){
		int k=sc.nextInt();
		if(k<min){
		  min=k;
		  temp++;}
	}
	System.out.println(temp+1);
  }
}

Measured memory_bytes: 64912