akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
int c[210]={-1};
string s[210];
vector<int> G[210];


void solve(){
    cin >> n;
    rep(i,n){
        cin >> s[i];
        c[i]=-1;
    }
    rep(i,n){
        rep(j,n){
            if (s[i][j]=='1') G[i].push_back(j);
        }
    }
    queue<P> que;
    que.push(P(0,1)); 
    c[0]=1;
    int ans=0;
    rep(i,n){
        rep(j,n){
            c[j]=-1;
        }
        queue<P> que;
        que.push(P(i,1)); 
        c[i]=1;
    while(!que.empty()){
        int s=que.front().first,k=que.front().second;que.pop();
        //cout << s << " " << k << endl;
        for(int t:G[s]){
            //cout << t << endl;
            if (c[t]!=-1){
                 if (abs(c[t]-c[s])!=1) {
                     cout << -1 << endl;
                     return;
                 }
                 else continue;
            }
            c[t]=k+1;
            que.push(P(t,k+1));
        }
    }
    
    rep(i,n){
        //cout << i << endl;
        ans=max(ans,c[i]);
    }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 512
n = int(input())
abc = []
for i in range(n):
    s = str(input())
    abc.append(s)

print('AC x {}'.format(abc.count('AC')))
print('WA x {}'.format(abc.count('WA')))
print('TLE x {}'.format(abc.count('TLE')))
print('RE x {}'.format(abc.count('RE')))


Measured memory_bytes: 16160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	long long power[n],sum=0;
	for(int i=0;i<n;i++)
		cin>>power[i];
	sort(power,power+n);
	for(int i=0;i<n-k;i++)
		sum+=power[i];
	cout<<sum;
}

Measured memory_bytes: 1792
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

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

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int N,M;
    int K;
    vector<int> A,B;

    cin>>N>>M>>K;

    for(int i=0;i<N;i++){
        int Ai;
        cin>>Ai;
        A.push_back(Ai);
    }

    for(int i=0;i<M;i++){
        int Bi;
        cin>>Bi;
        B.push_back(Bi);
    }

    int sA=0;
    int sB=0;
    int sumt=0;
    for(int i=0;i<M;i++){
        if(sumt+B[i]>K) break;
        sB++;
        sumt+=B[i];
    }

    int ans=sB;

    for(int i=0;i<N;i++){
        sA++;
        sumt+=A[i];
        for(int j=sB-1;j>=0;j--){
            if(sumt<=K) break;
            sB--;
            sumt-=B[j];
        }
        if(sumt>K) break;
        ans=max(ans,sA+sB);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7484
p=int(input())
k=list(map(int,input().split()))
if 0 in k:
    print(0)
else:
    t=k[0]
    for e in range(1,len(k)):
        t = t * k[e]
        if t > 10**18:
          break
    if t > 10**18:
        print(-1)
    else:
        print(t)

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

struct Drink {
    ll a;
    ll b;
};

bool cmp(const Drink &a, const Drink &b) {
    return (a.a < b.a);
}

int main() {
    ll n, m;
    ll ans = 0;
    
    cin >> n >> m;
    vector<Drink> d(n);
    
    for (ll i = 0; i < n; i++) {
        cin >> d[i].a >> d[i].b;
    }
    
    sort(d.begin(), d.end(), cmp);
    
    for (ll i = 0; i < n; i++) {
        if (m > d[i].b) {
            ans += d[i].a * d[i].b;
            m -= d[i].b;
        }
        else {
            ans += d[i].a * m;
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;

class Problem_C
{
  public static void Main(string[] args)
  {
    var grid = new int[3][];
    for (var i = 0; i < 3; i++) grid[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
    if (grid[0][0] + grid[1][1] + grid[2][2] == grid[0][1] + grid[1][2] + grid[2][0]
        && grid[0][0] + grid[1][1] + grid[2][2] == grid[0][2] + grid[1][0] + grid[2][1])
    {
      Console.WriteLine("Yes");
    }
    else
    {
      Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 13396
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


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


def main():
    N = int(input())

    que = queue.Queue()
    que.put(('a', ord('a')))

    while not que.empty():
        res, m = que.get()
        if len(res) < N:
            for i in range(ord('a'), min(ord('z'), m + 1) + 1):
                que.put((res + chr(i), max(m, i)))
        elif len(res) == N:
            print(res)
        else:
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 19808
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let D = read![[i64]];

    let mut sum = 0_i64;

    for i in 0..N {
        for j in i + 1..N {
            sum += D[i] * D[j];
        }
    }

    println!("{}", sum)
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll N;
    cin >> N;
    if (N%10==2 || N%10==4 || N%10==5 || N%10==7 || N%10==9) {
        cout << "hon" << endl;
    } else if (N%10==0 || N%10==1 || N%10==6 || N%10==8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}



Measured memory_bytes: 3040
from heapq import heapify, heappush, heappop

N, M = map(int, input().split())

Q = [-int(x) for x in input().split()]
heapify(Q)

for i in range(M):
    a = -heappop(Q)
    heappush(Q, -(a//2))

ans = 0
for i in range(N):
    ans += -heappop(Q)

print(ans)

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int s, w; cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n, a;
	cin >> n;
	vector<int> rabbits(n);
	for (int i = 0; i < n; ++i) {
		cin >> a;
		// 0-indexed
		--a;
		rabbits[i] = a;
	}
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		int crush = rabbits[i];
		if (rabbits[crush] == i) ++cnt;
	}
	cout << cnt / 2 << endl;
	return 0;
}

Measured memory_bytes: 640
/*input
a
aa
*/

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

int main() {
  string s, t;
  cin >> s >> t;
  t = t.substr(0, (int)t.size()-1);
  if (s == t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

vector<ll> v;

// n自身はvectorに入らないので注意！
void enum_div(ll n)//nの約数を列挙
{
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			v.push_back(i);
			if(i!=1 && i*i!=n)
			{
				v.push_back(n/i);
			}
		}
	}
}

ll digitnum(ll n){
  int res = 0;
  ll num = n;
  while(num>0){
    num /= 10;
    ++res;
  }
  return res;
}

int main(void){
  ll x; cin >> x;
  enum_div(x);
  ll ans = 1001001001;
  for(auto y: v){
    chmin(ans,max(digitnum(y),digitnum(x/y)));
  }
  cout << ans << endl;


}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#define N 400005
using namespace std;
const int Mod = 1e9 + 7;

int n, m, vis[N], fac[N], inv[N];
int tot = 1, fir[N], nxt[N << 1], to[N << 1];
vector<int> G[N];

inline void addE(int u, int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

int now[N], top, deg[N], fa[N], sz[N];

void predfs(int u, int p, int &e, int &x, int &y) {
    now[++top] = u, vis[u] = 1;
    for (int i = fir[u], v; i; i = nxt[i], ++e) {
        v = to[i]; if (v == p) continue;
        if (vis[v]) x = u, y = v;
        else predfs(v, u, e, x, y);
    }
}

void dfs(int u, int p, int b) {
    fa[u] = p;
    for (int i = fir[u]; i; i = nxt[i])
        if (to[i] != p && to[i] != b)
            dfs(to[i], u, b);
}

int getsz(int u, int p) {
    int res = 1; sz[u] = 1;
    for (int i = 0, v; i < (int) G[u].size(); ++i) {
        v = G[u][i];
        if (v == p) continue;
        res = 1ll * res * getsz(v, u) % Mod;
        sz[u] += sz[v];
    } res = 1ll * res * inv[sz[u]] % Mod;
    return res;
}

inline int solve(int x, int y) {
//    cout << x << " # " << y << endl;
    dfs(x, y, x);
//    for (int i = 1; i <= top; ++i)
//        cout << now[i] << " " << fa[now[i]] << endl;
    for (int i = 1; i <= top; ++i)
        G[now[i]].clear(), deg[now[i]] = 0;
    for (int i = 1; i <= top; ++i) {
        int u = now[i];
        for (int j = fir[u]; j; j = nxt[j])
            if (to[j] < fa[u]) G[u].push_back(to[j]), ++deg[to[j]];//, cout << u << " " << to[j] << endl;
    } int res = 1;
    for (int i = 1; i <= top; ++i)
        if (!deg[now[i]]) res = 1ll * res * getsz(now[i], now[i]) % Mod;
    return res;
}

int main() {
    cin >> n, m = n << 1;
    for (int i = 1, u, v; i <= m; ++i)
        scanf("%d%d", &u, &v),
        addE(u, v + n), addE(v + n, u);

    fac[0] = fac[1] = inv[1] = 1;
    for (int i = 2; i <= m; ++i) {
        fac[i] = 1ll * fac[i - 1] * i % Mod;
        inv[i] = 1ll * inv[Mod % i] * (Mod - Mod / i) % Mod;
    }

    int ans = fac[m];

    for (int u = 1; u <= m; ++u) {
        if (vis[u]) continue;
        int num, x, y;
        top = num = x = y = 0;
        predfs(u, 0, num, x, y);
        if (num != top * 2) 
            return puts("0"), 0;
        ans = 1ll * ans * (solve(x, y) + solve(y, x)) % Mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 33152
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,H;
vector <int > a,b;





int main()
{

	cin >> N >> H;

	a.resize(N);
	b.resize(N);
	REP(i,N){
		cin >> a[i] >> b[i];
	}

	sort(b.begin(),b.end());
	sort(a.begin(),a.end());

	int ans = 0;
	RREP(i,N){
		if(a[N-1]>b[i]) break;
		H-=b[i];
		ans++;
		if(H<=0){
			cout << ans;
			return 0;
		}
	}

	cout << ans+(int)ceil((double)H/a[N-1]) << endl;

}





Measured memory_bytes: 1024
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
v_1 = v[0:n:2]
v_2 = v[1:n:2]
count_1 = dict(Counter(v_1))
count_2 = dict(Counter(v_2))

# 同じ値かチェック
v1 = sorted(count_1.items(), key=lambda x:x[1], reverse=True)
v2 = sorted(count_2.items(), key=lambda x:x[1], reverse=True)


def calc(l):
    if len(l) == 1:
        return l[0][1]
    else:
        return l[0][1] - l[1][1]
    
    
if v1[0][0] == v2[0][0]:
    
    if calc(v1) > calc(v2):
        s1 = v1[0][0]
        if len(v2) == 1:
            s2 = s1 + 1
        else:
            s2 = v2[1][0]
    else:
        s2 = v2[0][0]
        if len(v1) == 1:
            s1 = s2 + 1
        else:
            s1 = v1[1][0]
else:
    s1 = v1[0][0]
    s2 = v2[0][0]

ans = n - v_1.count(s1) - v_2.count(s2)
print(ans)


Measured memory_bytes: 26844
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Heap heap = new Heap();
        int i =0, k;
        String action;
        while(!(action= in.next()).equals("end")){
            if(action.equals("insert")){
                k = Integer.parseInt(in.next());
                heap.insert(k);
            }
            else{
                System.out.println(heap.extract());
            }
        }
    }
}
class Heap {
    private int[] heap;
    private int i;
    Heap(){
        this.heap = new int[2000001];
        this.i =0;
    }
    public void insert(int k){
        this.i++;
        this.heap[this.i]=k;
        int pos = i;
        while(pos>1 && heap[pos]>heap[pos/2]){
            int temp = heap[pos];
            heap[pos] = heap[pos/2];
            heap[pos/2] = temp;
            pos /= 2;
        }
    }
    public int extract(){
        int answ;
        if(this.i==1){
            answ = this.heap[1];
            this.i--;
         }
        else {
            answ = this.heap[1];
            this.heap[1] = this.heap[(this.i)];
            this.i--;
            heapfy();
         }
        return answ;
    }
    private void heapfy(){
        int i = 1,j, n=this.i;
        boolean isHeap = false;
        while(!isHeap && i<=n/2) {
            j= i*2;
            if(j<n && heap[j+1]>heap[j]) j++;
            if(heap[j]>heap[i]){
                int temp = heap[i];
                heap[i] = heap[j];
                heap[j] = temp;
                i =j;
            }
            else {
                isHeap=true;
            }

        }
    }
}


Measured memory_bytes: 301668
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <complex>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
  int from, to, cost;
  bool operator < (const edge& e) const { return cost < e.cost; }
  bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

struct huku
{
  int x,y,z;
};
int D,N;
int dp[205][205];
int d[205];
huku h[205];

int solve(int i, int j)
{
  if(dp[i][j] >=0) return dp[i][j];
  if(i==D) return 0;
  int res = 0;
  if(i==0)
  {
    REP(k,N)
    {	
      if(d[i]>=h[k].x&&d[i]<=h[k].y) res = max(res,solve(i+1,k));
    }
  }
  else
  {
    REP(k,N)
    {
      if(d[i]>=h[k].x&&d[i]<=h[k].y) res = max(res,solve(i+1,k)+abs(h[k].z-h[j].z));
    }
  }
  return dp[i][j] = res;
}

int main()
{
  MS(dp,-1);
  cin>>D>>N;
  REP(i,D) cin>>d[i];
  REP(i,N)
  {
    int a,b,c;cin>>a>>b>>c;
    huku t = {a,b,c};
    h[i] = t;
  }
  cout<<solve(0,0)<<endl;

  return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N;
    cin >> N;
    vector<vector<int>> a(N, vector<int>(N));
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            cin >> a[i][j];
        }
    }

    vector<ll> score(1 << N, 0);
    for(int mask = 0; mask < 1 << N; ++mask){
        for(int i = 0; i < N; ++i){
            if(mask >> i & 1){
                for(int j = 0; j < i; ++j){
                    if(mask >> j & 1)   score[mask] += a[i][j];
                }
            }
        }
    }

    constexpr ll inf = 1e+18;
    vector<ll> dp(1 << N);
    dp[0] = 0;
    for(int mask = 1; mask < 1 << N; ++mask){
        dp[mask] = score[mask];
        for(int subset = mask; subset > 0; subset = (subset - 1) & mask){
            chmax(dp[mask], dp[subset] + dp[mask ^ subset]);
        }
    }

    cout << dp[(1 << N) - 1] << endl;
}

Measured memory_bytes: 4256
n = int(input())
blist = list(map(int, input().split()))

is_incomp = False
ans = []
while True:
  now = None
  for i, b in enumerate(blist):
    if i + 1 == b:
      now = (i+1, b)
  if now is None:
    is_incomp = True
    break
  else:
    ans.append(now[0])
    del blist[now[0]-1]
    if not blist:
      break

if is_incomp:
  print(-1)
else:
  print(*ans[::-1], sep='\n')


Measured memory_bytes: 39024
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000000 ;
    const int MAX = 999999999;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    int s;
    void solve()
    {
    	cin>>n>>k>>s;
    	fo(i,0,k)
    	cout<<s<<" ";
    	if(s!=MAX)
    	fo(i,k,n)
    	cout<<MAX<<" ";
    	else
    	fo(i,k,n)
    	cout<<MOD<<" ";

        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
      {
        
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        
        // cin>>t;while(t--)
        solve();
        
      return 0;
      }

Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> k(n);
        for(int i=0; i<n; ++i)
            cin >> k[i];

        string s;
        cin >> s;
        for(unsigned i=0; i<s.size(); ++i){
            int a;
            if('a' <= s[i] && s[i] <= 'z')
                a = s[i] - 'a';
            else
                a = s[i] - 'A' + 26;

            a += 52 - k[i%n];
            a %= 52;

            if(a < 26)
                cout << (char)('a' + a);
            else
                cout << (char)('A' + a - 26);
        }
        cout << endl;
    }
}

Measured memory_bytes: 1204
#include<iostream>
#include<cstdio>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,a,b;
int main()
{
	n=read();a=read();b=read();
	if(1LL*a*b<n||a+b-1>n) return 0*puts("-1");
	for(int i=n-a+1;i<=n;++i) printf("%d ",i);
	int left=n-a-(b-1);
	for(int i=2,la=n-a;i<=b;++i)
	{
		int len=1+min(left,a-1);
		left-=len-1;la-=len;
		for(int j=1;j<=len;++j) printf("%d ",la+j);	
	}
	return 0;
}



Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int dp[1002][1002];
const int mod = 1e9+7;
int rec(vector<string>&grid, int i, int j, int &h, int &w){
	int ans = 0;
	if (i == h-1 and j == w-1){
		return 1;
	}
	else if (i == h or j == w){
		return 0;
	}
	else if (grid[i][j] == '.'){
		if(dp[i][j] != -1){
			return dp[i][j];
		}
		ans += (rec(grid, i+1, j, h, w)+rec(grid, i, j+1, h, w))%mod;
		// cout << "y";
	}
	return dp[i][j] = ans;
}

int main() {
	int h, w;
	cin >> h >> w;
	vector<string>grid;
	memset(dp, -1, sizeof(dp));
	for(int i = 0; i < h; i++){
		string s;
		cin >> s;
		grid.push_back(s);
	}
	cout << rec(grid, 0, 0, h, w) << "\n";
	return 0;
}


Measured memory_bytes: 8676
#define SORT(v) sort(v.begin(), v.end())
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <algorithm>
#include <cstdarg>
#include <cstdio>
#include <numeric>

// #include "ane.cpp"

#define INF (int)1e9
#define INFLL (long long)1e18
#define NMAX 200
#define MMAX 200
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> p;
typedef long long ll;

ll N,M,K,a,b,C,D,E;
int dp[NMAX][MMAX] = {};

static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

ll ans = 0;

void solve(){
    // 解答アルゴリズム
    if (abs(b-a) <= N)
    {
        ans = 0;
        return;
    }
    if (a < b)
    {
        ans = b - a - N;
    }else{
        ans = a - b - N;
    }
}
void debug(){
    // デバッグ用出力
}
void answer(){
    // 解答出力
    printf("%lld\n", ans);
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法

    Fill(dp, -1);

    scanf("%lld%lld%lld", &N,&a, &b);
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();

    return 0;
}


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

int main() {
  int N;
  cin >> N;
 
  vector<int> a(N);
  
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int Alice = 0, Bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0)
      Alice += a.at(i);
    else
      Bob += a.at(i);
  }
  
  cout << Alice - Bob << endl;
}

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

struct UnionFind {
  vector<int> par;
  vector<int> rank;

  UnionFind(int n):par(n),rank(n){

    rep(i,n){
      par[i]=i;
      rank[i]=0;
    }
  }

  int find(int x){
    if(par[x]==x){
      return x;
    }else{
      return par[x]=find(par[x]);
    }
  }

  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;

    if(rank[x]<rank[y]){
      par[x]=y;
    }else{
      par[y]=x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }

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

};

struct edge{int u,v,cost;};
struct ver{int p,x,y;};
bool comp(const edge& es1, const edge& es2){
  return es1.cost<es2.cost;
}
bool compX(const ver& v1, const ver& v2) {
	return v1.x < v2.x;
}
bool compY(const ver& v1, const ver& v2) {
	return v1.y < v2.y;
}
int E,n;
edge es[200000];
ver ve[100000];
ll kruskal(){
  ll res=0;
  sort(es,es+E,comp);
  UnionFind uni(E);
  rep(i,E){
    if(!uni.same(es[i].u,es[i].v)){
      uni.unite(es[i].u,es[i].v);
      res+=es[i].cost;
    }
  }
  return res;
}

int main() {
  cin>>n;
  rep(i,n){
    int a,b;
    cin >> a >>b;
    ve[i]={i,a,b};
  }
  E=2*(n-1);
  sort(ve,ve+n,compX);
  rep(i,n){
    es[i]={ve[i].p,ve[i+1].p,abs(ve[i].x -ve[i + 1].x) };
  }
  sort(ve,ve+n,compY);
  rep(i,n){    
    es[n-1+i]={ve[i].p,ve[i+1].p,abs(ve[i].y -ve[i + 1].y)};
  }
  ll ans=kruskal();
  cout << ans<<endl;
}

Measured memory_bytes: 8276
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    string str;

    cin >> str;

    int ans = 0;
    for (int i = 0; i < str.length(); i++) {

        if (str[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 4010;
char s[N];
int flag[2*N];
int n;
ll cal(char a,char b,char c){
	ll nowa=0,ret=0;
	memset(flag,0,sizeof(flag));
	for(int i = 1; i <= n; i++){
		if(s[i]==a) nowa++,flag[i]=1;
		else if(s[i]==b){
			for(int j = i+1; j <= n; j++)
			if(s[j]==c){
				ret+=nowa;
				if(2*i-j>0)
				if(flag[2*i-j]) ret--;
			}
		}
	}
	return ret;
}
int main(){
	scanf("%d %s",&n,s+1);
	ll sum = 0;
	sum+=cal('R','G','B');
	sum+=cal('R','B','G');
	sum+=cal('B','G','R');
	sum+=cal('B','R','G');
	sum+=cal('G','R','B');
	sum+=cal('G','B','R');
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 3820
import sys

readline = sys.stdin.buffer.readline

N = int(readline())
A = list(map(int, readline().split()))

c = 1
ans = 1

if N == 0:
    if A[0] == 1:
        print(1)
        sys.exit()
    else:
        print(-1)
        sys.exit()

# 数える
A = A[::-1]

cnt = A[0]
c = A[0]

can = [A[0]]

for i in range(1, N + 1):
    c += A[i]

    if c > 2**(N - i):
        c = 2**(N - i)

    cnt += c
    can.append(c)

can = can[::-1]
A = A[::-1]

for i in range(1, N + 1):
    if can[i] > (can[i - 1] - A[i - 1]) * 2:
        can[i] = (can[i - 1] - A[i - 1]) * 2

print(sum(can) if A[-1] == can[-1] else -1)


Measured memory_bytes: 671572
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans, mx, mn, flag, sum, cnt;



int main(){
	ll n;
	cin>>n;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			for(int k=1; k<=n; k++){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}

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

#define make make_pair 
#define fi first 
#define se second 
const int MAXN = 200001;
vector<pair<int,int> > Task;
int li = 2e9;
bool able;
int main()
{
    int i,n;
    scanf("%d",&n);
    for(i = 1;i <= n;i++)
    {
    	int A,B;
    	scanf("%d %d",&A,&B);
		Task.push_back(make(B,A));
	}
	sort(Task.begin(),Task.end());
	for(i = n - 1;i >= 0;i--)
	{
		int B = Task[i].fi,A = Task[i].se;
		if(li < B) li -= A;
		else li = B - A;
		if(li < 0)
		{
			able = 1;
			break;
		}
	}
	if(able) printf("No");
	else printf("Yes");
    return 0;
}

Measured memory_bytes: 2420
s = int(input())

count = 1
n = s
check = 0
list = [s]


for i in range(30000):
        if n % 2 == 0:
            n = n / 2
            list.append(n)
        else:
            n = n*3 + 1
            list.append(n)
        
        count = count + 1
        list.sort()
        for j in range(len(list) - 1):
            if list[j] ==list[j+1]:
                check = 1
                break
            
        if check == 1:
            break
        


print(count)



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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll n, m;
ll p[100100], y[100100];
vector<pair<ll,ll>> pvec[100100];
string id[100100];
char buff[20];

int main(void)
{
  cin >> n >> m;
  REP(i, m) {
    cin >> p[i] >> y[i];
    pvec[p[i]].push_back(make_pair(y[i], i));
  }
  REP1(i, n) {
    sort(pvec[i].begin(), pvec[i].end());
  }
  
  REP1(i, n) {
    ll j = 0;
    for(auto ci:pvec[i]) {
      j++;
      //      printf("[%lld] %lld %lld\n", i, ci.first, ci.second);
      sprintf(buff, "%06lld%06lld", i, j);
      id[ci.second] = buff;
    } 
  }
  REP(i, m) {
    cout << id[i] << endl;
  }
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    string s, t;
    cin >> s >> t;

    auto sSize = s.size();
    auto tSize = t.size();

    int reqRef = sSize - tSize + 1;

    int ans = 10000;

    for(int i = 0; i < reqRef; i++){
        int tmp = 0;
        for(int j = 0; j < tSize; j++){
            auto sChar = s[i + j];
            auto tChar = t[j];
            if(sChar != tChar) tmp++;
        }
        ans = min(ans, tmp);
    }

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


Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	cs := make([]int, n-1)
	ss := make([]int, n-1)
	fs := make([]int, n-1)
	for i := range cs {
		fmt.Scan(&cs[i], &ss[i], &fs[i])
	}

	for i := range cs {
		t := 0
		for j := i; j < n-1; j++ {
			if ss[j] > t {
				t = ss[j]
			} else {
				t = ((t-1)/fs[j] + 1) * fs[j]
			}
			t += cs[j]
		}
		fmt.Println(t)
	}
	fmt.Println(0)
}


Measured memory_bytes: 512
#include <stdio.h>
main(){
  int i,n,a[8],j,x,m,mm,b[8],max[8],min[8],maxx,minn;
  scanf("%d",&mm);
  for(m=0;m<mm;m++){
    scanf("%d",&n);
    x=10000000;
    for(i=7;i>=0;i--){
      a[i]=n/x;
      n-=a[i]*x;
      x/=10;
    }

    for(i=0;i<8;i++) b[i]=a[i];

    for(i=7;i>=0;i--){
      max[i]=-1;
      for(j=0;j<8;j++){
	if(a[j]>max[i]){
	  max[i]=a[j];
	  x=j;
	}
      }
      a[x]=-1;
    }

   for(i=7;i>=0;i--){
      min[i]=10;
      for(j=0;j<8;j++){
	if(b[j]<min[i]){
	  min[i]=b[j];
	  x=j;
	}
      }
      b[x]=10;
    }

   x=10000000;
   maxx=0;
   minn=0;
    for(i=7;i>=0;i--){
      maxx+=max[i]*x;
      minn+=min[i]*x;
      x/=10;
    }
    printf("%d\n",maxx-minn);
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdlib>
#include <cstdio>
#define MOD 998244353
typedef long long ll; 
inline ll quick_pow(ll a, int n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}
ll fact[300005], inv[300005], dp[300005], ans; 
inline ll C(int n, int m)
{
	if (n == -1 && m == -1)
		return 1; 
	if (n < m || m < 0)
		return 0; 
	return fact[n] * inv[m] % MOD * inv[n - m] % MOD;
}
inline void work(int n, int m, char *a, char *b, char *c, char *d)
{
	int x = 0, y = 0, z = 0, w = 0;
	for (int i = 0; i < n; i++)
	{
		x += a[i] == '1';
		y += b[i] == '1';
	}
	for (int i = 0; i < m; i++)
	{
		z += c[i] == '1';
		w += d[i] == '1';
	}
	if (!x && !y && !z && !w)
	{
		puts("1");
		exit(0);
	}
	z = w = 0;
	for (int i = 0; i < m; i++)
	{
		dp[i] = i ? dp[i - 1] : 0;
		if (c[i] == '1' || d[i] == '1')
			(dp[i] += C(z + w + x - 1, x - 1)) %= MOD;
		if (c[i] == '1' && d[i] == '1')
			(dp[i] <<= 1) %= MOD;
		z += c[i] == '1';
		w += d[i] == '1';
	}
	z = w = 0;
	for (int i = m - 1; i >= 0; i--)
	{
		if (c[i] == '1' || d[i] == '1')
			(ans += dp[i] * C(z + w + y - 1, y - 1)) %= MOD;
		z += c[i] == '1';
		w += d[i] == '1';
	}
}
char a[300005], b[300005], c[300005], d[300005]; 
int main()
{
	// freopen("CF17-QA-E.in", "r", stdin);
	fact[0] = inv[0] = 1;
	for (int i = 1; i <= 3e5; i++)
	{
		fact[i] = fact[i - 1] * i % MOD;
		inv[i] = quick_pow(fact[i], MOD - 2);
	}
	int n, m;
	scanf("%d%d%s%s%s%s", &n, &m, a, b, c, d);
	work(n, m, a, b, c, d);
	work(m, n, c, d, a, b);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    vector<pii> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i].first >> A[i].second;
        A[i].second++;
    }

    auto cmp = [&](pii &a, pii &b) -> bool {
        return (a.first == b.first ? a.second > b.second : a.first < b.first);
    };
    sort(A.begin(), A.end(), cmp);

    vector<int> rmin1(N + 1, INT_MAX), rmin2(N + 1, INT_MAX);
    for (int i = 0; i < N; ++i)
        rmin1[i + 1] = min(rmin1[i], A[i].second);
    for (int i = N - 1; i >= 0; --i)
        rmin2[i] = min(rmin2[i + 1], A[i].second);

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int rmin = min(rmin1[i], rmin2[i + 1]);
        int lmax = 0;
        if (i > 0)
            lmax = max(lmax, A[i - 1].first);
        if (i < N - 1)
            lmax = max(lmax, A[N - 1].first);
        int tmp = max(rmin - lmax, 0) + (A[i].second - A[i].first);
        ans = max(ans, tmp);
    }

    for (int i = 1; i < N; ++i) {
        int tmp = max(rmin1[i] - A[i - 1].first, 0);
        tmp += max(rmin2[i] - A[N - 1].first, 0);
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int in = sc.nextInt();
		long result = 1L;
		
		for (int i = in; i >=1; i--){
			result *= i;
		}
		System.out.println(result);
		
		sc.close();
	}
}

Measured memory_bytes: 17160
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w, h, n;
  cin >> w >> h >> n;
  bool s[w][h];
  for (int i = 0; i < w; ++i) {
    for (int j = 0; j < h; ++j) {
      s[i][j] = false;
    }
  }
  for (int i = 0; i < n; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      for (int j = 0; j < x; ++j) {
        for (int k = 0; k < h; ++k) {
          s[j][k] = true;
        }
      }
    } else if (a == 2) {
      for (int j = x; j < w; ++j) {
        for (int k = 0; k < h; ++k) {
          s[j][k] = true;
        }
      }
    } else if (a == 3) {
      for (int j = 0; j < w; ++j) {
        for (int k = 0; k < y; ++k) {
          s[j][k] = true;
        }
      }
    } else {
      for (int j = 0; j < w; ++j) {
        for (int k = y; k < h; ++k) {
          s[j][k] = true;
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < w; ++i) {
    for (int j = 0; j < h; ++j) {
      if (!s[i][j]) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n-1];
    for (auto &ai:a) {
        cin >> ai;
        ai--;
    }
    for (auto &bi:b)
        cin >> bi;
    for (auto &ci:c)
        cin >> ci;
    int prev = -100, sum=0;
    for (auto ai:a) {
        sum += b[ai];
        if (ai == prev + 1)
            sum += c[prev];
        prev = ai;
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            String S = in.next();
            String T = in.next();

            int count = 0;
            for (int i = 0; i < S.length(); i++) {
                if (S.charAt(i) == T.charAt(i)) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}


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

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    ball_count = int(input())
    robotB_position = int(input())
    positions = list(map(int, input().split()))

    total_length = 0

    for i in range(ball_count):
        if positions[i] < abs(robotB_position - positions[i]):
            total_length += 2 * positions[i]
        else:
            total_length += 2 * abs(robotB_position - positions[i])

    print(total_length)


Measured memory_bytes: 3060
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   

int main(){
    std::ios::sync_with_stdio(false);

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

}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N; cin >> N;
    int res = 0;
    int cnt = 0;
    int prev = -1;
    for(int i=0;i<N;i++){
        int a; cin >> a;
        if(a != prev){
            res += cnt/2;
            cnt = 1;
        } else {
            ++cnt;
        }
        prev = a;
    }
    res += cnt/2;
    cout << res << endl;
}

Measured memory_bytes: 256
h, w, k  = map(int, input().split())

puyo_orig = [list(map(int, list(input()))) for _ in range(h)]

import copy
mx = 0
for i1 in range(1,h):
    for i2 in range(w):
        puyo = copy.deepcopy(puyo_orig)
        for l in range(i1,0,-1):
            puyo[l][i2] = puyo[l-1][i2]
        puyo[0][i2]=0
        p = 0
        fin = 0
        turn = 0
        while fin==0:
            fin = 1
            for i in range(1,h):
                cnt = 1
                for j in range(1, w):
                    if puyo[i][j-1] == puyo[i][j] and puyo[i][j]>0:
                        cnt += 1
                    else:
                        if cnt>=k:
                            p += cnt * puyo[i][j-1] * 2**turn
                            for l in range(i,0,-1):
                                puyo[l][j-cnt:j] = puyo[l-1][j-cnt:j]
                            puyo[0][j-cnt:j] = [0]*cnt
                            fin = 0
                        cnt = 1
                    if j==w-1:
                        if cnt>=k:
                            p += cnt * puyo[i][j-1] * 2**turn
                            for l in range(i,0,-1):
                                puyo[l][j-cnt+1:j+1] = puyo[l-1][j-cnt+1:j+1]
                            puyo[0][j-cnt+1:j+1] = [0]*cnt
                            fin = 0
            turn += 1
        if p>mx:
            mx=p
            
print(mx)


Measured memory_bytes: 56924
#include <bits/stdc++.h>
#define MAXN 100100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

ll n, a, b, g[MAXN], ans;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++){
    	cin >> g[i];
    	if(i == 0) continue;
    	ans += min(b, a * (g[i] - g[i - 1]));
    }
    cout << ans;
}

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

#include <algorithm>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main()
{
    ll ans = 1000;
    int N;
    cin >> N;
    int A[N + 1];
    // int grad[N];

    rep(i, N) cin >> A[i];
    A[N] = 0;

    ll stock = 0;
    rep(i, N - 1)
    {
        if (A[i] < A[i + 1])
        {
            ll cnt = ans / A[i];
            ans -= cnt * A[i];
            stock += cnt;
        }
        else if (A[i] > A[i + 1])
        {
            ans += stock * A[i];
            stock = 0;
        }
    }
    ans += stock * A[N - 1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














ll N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	ll ans = infl;
	rep(i, 1, 1010101) if (N % i == 0) chmin(ans, i + N / i - 2);
	cout << ans << endl;
}







Measured memory_bytes: 256
s = input()

dp = [0] * 2019
dp2 = [0] * 2019
ans = 0
for i in s:
    i = int(i)

    for j in range(2019):

        dp2[(10*j + i) % 2019] += dp[j]
    dp2[i] += 1
    dp = dp2[:]
    dp2 = [0] * 2019
    # print(dp)
    ans += dp[0]

print(ans)

Measured memory_bytes: 100196