akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using UL=unsigned int;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(UL i=0; i<(n); i++)

template<class T>
using nega_queue = priority_queue<T,vector<T>,greater<T>>;

struct Edge{ UL u,v; UL c; int d; UL r; };

UL N,M;
Edge J[2000];
vector<UL> E[100];

UL F;
int fAns = 0;
UL fD[100];
UL fPE[100];
UL fP[100]={};

void fDijkstra(){
 rep(i,N) fD[i]=fPE[i]=~0u;
 nega_queue<pair<UL,pair<UL,UL>>> Q; Q.push({0,{0,~0u}});
 while(Q.size()){
  UL d=Q.top().first;
  UL p=Q.top().second.first;
  UL pre=Q.top().second.second;
  Q.pop();
  if(fD[p]!=~0u) continue;
  fD[p]=d;
  fPE[p]=pre;
  for(UL j:E[p]){
   if(J[j].c==0)continue;
   Q.push({d+J[j].d+fP[p]-fP[J[j].v],{J[j].v,j}});
  }
 }
 rep(i,N) fP[i]+=fD[i];
}

void flow(){
 fDijkstra();
 if(fD[N-1]==~0u){ F=0; fAns=-1; return; }
 UL p=N-1;
 UL c=F;
 while(p!=0){
  c=min(c,J[fPE[p]].c);
  p=J[fPE[p]].u;
 }
 p=N-1;
 while(p!=0){
  J[fPE[p]].c-=c;
  J[J[fPE[p]].r].c+=c;
  fAns += (int)c * J[fPE[p]].d;
  p=J[fPE[p]].u;
 }
 F-=c;
}

int main(){
 scanf("%u%u%u",&N,&M,&F);
 rep(i,M){
  UL u,v,c; int d; scanf("%u%u%u%d",&u,&v,&c,&d);
  E[u].push_back(i);
  E[v].push_back(M+i);
  J[i]=Edge{u,v,c,d,M+i};
  J[M+i]=Edge{v,u,0,-d,i};
 }

 while(F) flow();

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

 return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i,l,r) for(int i=(l);i<(r);i++)
#define forb(i,r,l) for(int i=(r);i>(l);i--)
#define log2i(x) 32 - __builtin_clz((x)) - 1
#define log2ll(x) 64 - __builtin_clzll((x)) - 1
#define Pi acos(-1.0)
#define sz(x) (int)x.size()
#define pw(x,y) trunc(exp(log((x))*(y)))
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int N = 2e5+7;
const ll M = 998244353;
int t,n, R[N], T[4*N];
ll dp[N]={1};
ii a[N]={{INT_MAX,0}};

void build(int idx, int l, int r) {
    if(l==r) T[idx]=R[l]=1e9+7;
    else {
        int k=2*idx, mid=(l+r)>>1;
        build(k,l,mid);
        build(k+1,mid+1,r);
    }
}

void update(int idx, int l, int r, int x, int v) {
    if(r<x||l>x) return;
    if(l==r) T[idx]=R[x]=v;
    else {
        int k=2*idx, mid=(l+r)>>1;
        update(k,l,mid,x,v);
        update(k+1,mid+1,r,x,v);
        T[idx]=min(T[k],T[k+1]);
    }
}

int get(int idx, int l, int r, int u, int v) {
    if(r<u||l>v) return 1e9+7;
    if(u<=l&&r<=v) return T[idx];
    else {
        int k=2*idx, mid=(l+r)>>1;
        return min(get(k,l,mid,u,v),get(k+1,mid+1,r,u,v));
    }
}

int pos(int p, int x) {
    int l=0, r=p;
    while(l<r) {
        int mid=(l+r)>>1;
        if(a[mid].fi<x) r=mid;
        else l=mid+1;
    }
    return l;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
#endif
    fastIO;
    cin >> n;
    forw(i,1,n+1) cin >> a[i].fi >> a[i].se;
    sort(a,a+n+1,greater<ii>());
    build(1,0,n);
    update(1,0,n,0,n);
    forw(i,1,n+1) {
        update(1,0,n,i,min(get(1,0,n,pos(i,a[i].fi+a[i].se),i),i));
        dp[i]=(dp[i-1]+dp[R[i]-1])%M;
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> ans{a, b, c};
    sort(ans.begin(), ans.end());
    cout << ans[2] * 10 + ans[1] + ans[0] << endl;
}

Measured memory_bytes: 256
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X Fi
#define Y Se

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef double D;

/* const */
const int INF = 999999999;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* class */
class P {
  public:
    D x, y;
    P(D x, D y) { this->x = x; this->y = y; }
    P operator+ (P a) { return P(this->x + a.x, this->y + a.y); }
    P operator- (P a) { return P(this->x - a.x, this->y - a.y); }
};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
inline D dot(P a, P b) { return a.x * b.x + a.y * b.y; }
inline D cross(P a, P b) { return a.x * b.y - a.y * b.x; }
template <typename T> void print(T x) { std::cout << x << '\n'; }
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

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

  int a = in(), b = in();
  if (a > 0 && b > 0) {
    print("Positive");
  } else if (max(a, b) >= 0 && min(a, b) <= 0) {
    print("Zero");
  } else if (abs(a - b) % 2 == 0) {
    print("Negative");
  } else {
    print("Positive");
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    long long n;
    long long x;
    long long m;
    vector<int> beforeCycle;
    int beforeCycleSize = 0;
    long long beforeCycleSum = 0;
    int cycleSize;
    long long totalSum = 0;

    cin >> n >> x >> m;

    vector<int> remainderIndices(m, -1);

    while (remainderIndices[x] == -1) {
        beforeCycle.push_back(x);

        remainderIndices[x] = beforeCycleSize++;
        beforeCycleSum += x;
        x = x * x % m;
    }

    cycleSize = beforeCycleSize - remainderIndices[x];

    if (n <= cycleSize) {
        for (int i = 0; i < n; i++) {
            totalSum += beforeCycle[i];
        }
    } else {
        long long cycleSum = 0;
        
        for (int i = remainderIndices[x]; i < beforeCycleSize; i++) {
            cycleSum += beforeCycle[i];
        }

        totalSum = beforeCycleSum;
        n -= beforeCycleSize;
        totalSum += (n / cycleSize) * cycleSum;
        n %= cycleSize;

        for (int i = 0; i < n; i++) {
            totalSum += beforeCycle[remainderIndices[x] + i];
        }
    }

    cout << totalSum << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M);
    int l = 0, r = INF;
    REP(i, M) {
        cin >> L.at(i) >> R.at(i);
        chmax(l, L[i]);
        chmin(r, R[i]);
    }

    if (r - l + 1 > 0) {
        cout << r - l + 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        c: [[usize; 3]; 3],
    }

    let mut tmp1 = 0;
    let mut tmp2 = 0;
    let mut tmp3 = 0;
    for i in 0..3 {
        for j in 0..3 {
            if i==0 {
                tmp1 += c[i][j];
            } else if i==1 {
                tmp2 += c[i][j];
            } else {
                tmp3 += c[i][j];
            }
        }
    }

    let mut tmp4 = 0;
    let mut tmp5 = 0;
    let mut tmp6 = 0;
    for j in 0..3 {
        for i in 0..3 {
            if j==0 {
                tmp4 += c[i][j];
            } else if j==1 {
                tmp5 += c[i][j];
            } else {
                tmp6 += c[i][j];
            }
        }
    }
    if (((tmp1 as i64) - (tmp2 as i64)).abs() % 3 == 0
     && ((tmp2 as i64) - (tmp3 as i64)).abs() % 3 == 0
     && ((tmp1 as i64) - (tmp3 as i64)).abs() % 3 == 0
     && ((tmp4 as i64) - (tmp5 as i64)).abs() % 3 == 0
     && ((tmp5 as i64) - (tmp6 as i64)).abs() % 3 == 0
     && ((tmp4 as i64) - (tmp6 as i64)).abs() % 3 == 0) {
        println!("Yes");
    } else {
        println!("No");
    }
    
}


Measured memory_bytes: 2172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args){

		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			String buf = br.readLine();
			StringTokenizer st=new StringTokenizer(buf," ");
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());

			int max ;
			int mid ;
			int min ;

			if(a <= b ){
				if(b <= c){
					max = c;
					mid = b;
					min = a;
				}else if(c <= a){
					max = b;
					mid = a;
					min = c;
				}else{
					max = b;
					mid = c;
					min = a;
				}
			}else{
				if(a <= c){
					max = c;
					mid = a;
					min = b;
				}else if(c <= b){
					max = a;
					mid = b;
					min = c;
				}else{
					max = a;
					mid = c;
					min = b;
				}
			}
			System.out.println(min + " "+ mid + " "+ max);
		} catch(IOException e) {
			System.err.println(e);
		}

	}
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    VVI dp(n + 1, VI(m + 1, 0));
    vector<VP> prev(n + 1, VP(m + 1));
    FOR(i, 1, n)FOR(j, 1, m) {
        if(s[i - 1] == t[j - 1]) {
            dp[i][j] = dp[i - 1][j - 1] + 1;
            prev[i][j] = P(i - 1, j - 1);
        } else {
            if(dp[i - 1][j] > dp[i][j - 1]) {
                dp[i][j] = dp[i - 1][j];
                prev[i][j] = P(i - 1, j);
            } else {
                dp[i][j] = dp[i][j - 1];
                prev[i][j] = P(i, j - 1);
            }         
        }
    }
    
    string ans;
    P next_p = P(n, m);
    int cnt = dp[next_p.first][next_p.second];
    do {
        int i = next_p.first;
        next_p = prev[next_p.first][next_p.second];
        if(cnt > dp[next_p.first][next_p.second]) ans += s[i - 1];
        cnt = dp[next_p.first][next_p.second];
    } while(dp[next_p.first][next_p.second] > 0);
    reverse(ALL(ans));
    cout << ans << ln;
    return 0;
}


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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62LL)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  ll N, A, B;
  cin >> N >> A >> B;
  
  if (A > B || (N == 1 && B - A > 0)) {
    cout << 0 << endl;
    return 0;
  }

  if (N <= 2 || A == B) {
    cout << 1 << endl;
    return 0;
  }

  cout << (N - 2) * (B - A) + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
 
public class Main {
    public static void main(String... args) throws IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringBuilder sb = new StringBuilder();
        while (true) {
            final String line = br.readLine();
            final int index = line.indexOf(" ");
            final int x = Integer.parseInt(line.substring(0, index));
            final int y = Integer.parseInt(line.substring(index+1, line.length()));
            if (x == 0 && y == 0) break;
            sb.append(x < y ? x + " " + y : y + " " + x).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 26160
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    for (int i = 0; i < n.length(); i++) {
        if (n[i] == '1') n[i] = '9';
        else n[i] = '1';
    }

    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<set>
using namespace std;

set<int> s[100000+5];
int a[100000+5], p[100000+5];

int find(int x)
{
    if(a[x]==-1) return x;
    a[x]=find(a[x]);
    s[a[x]].insert(p[x]);
    return a[x];
}

void un(int x,int y)
{
    int fx=find(x);
    int fy=find(y);
    if(fx!=fy)
        {
            if(s[fx].size()<s[fy].size()) swap(fx,fy);
            a[fy]=fx;
            s[fx].insert(s[fy].begin(),s[fy].end());
        }
}

int main()
{
    int n, m, t;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&p[i]);
        s[i].insert(p[i]);
    }
    memset(a,-1,sizeof(a));
    for(int i=1;i<=m;i++)
    {
        int x, y;
        scanf("%d %d",&x,&y);
        un(x,y);
    }
    t=0;
    for(int i=1;i<=n;i++)
    {
        if(s[find(i)].count(i)) t++;
    }
    printf("%d\n",t);
}


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

#define f(n) (g((n)/100)*2+g((n)%100))
#define g(n) (1<=(n)&&(n)<=12)

int main()
{
  int n;
  cin >> n;
  cout << (string[]){"NA","YYMM","MMYY","AMBIGUOUS"}[f(n)] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	auto start = high_resolution_clock::now(); 

	int n, w;
	cin >> n >> w;
	vector<ll int> wt(n), v(n);
	for(int i = 0 ; i < n ; i++)
		cin >> wt[i] >> v[i];

	vector<ll int> prev(w+1, 0), curr(w+1, 0);
	for(int i = 0 ; i < n ; i++){
		for(int j = 0; j <= w; j++){
			if(j >= wt[i])
				curr[j] = max(v[i] + prev[j - wt[i]], prev[j]);
		}
		prev = curr;
	}

	ll int maxv = -1;
	for(int i = 0 ; i < w+1; i++){
		maxv = max(maxv, curr[i]);
	}

	cout << maxv;
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
ll a,b;
void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>a>>b;
  if(a>b) cout<<a-1<<endl;
  else cout<<a<<endl;

}
int main(){
  solve();
  return 0;
}


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

using namespace std;

int c[101], n, k;

int func(int p, int q)
{
  int mx = 1, t;
  for(int i = 0; i < k; ++i) mx *= c[i];

  t = mx;
  for(int i = p+k; i <= q; ++i){
    t /= c[i-k];
    t *= c[i];
    mx = max(t, mx);
  }

  return mx;
}

int func()
{
  int mx = 1, t;

  for(int i = 0; i < n-k+1; ++i){
    t = 1;
    for(int j = 0; j < k; ++j) t *= c[i+j];
    mx = max(t, mx);
  }

  return mx;
}

int main()
{
  int cmx, s, t, p, q;

  while(cin>>n>>k && n+k){
    cmx = 1;
    for(int i = 0; i < n; ++i) cin >> c[i];

    t = 1;
    cmx = func();
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
	if(i == j) continue;
	swap(c[i], c[j]);
	// p = max(j-k, 0);
	// q = min(j+k, n);
	// t = max(t, func(p, q));
	t = max(t, func());
	swap(c[i], c[j]);
      }
    }


    if(t < cmx) cout << "NO GAME" << endl;
    else cout << (t-cmx) << endl;
  }

  return 0;
}

Measured memory_bytes: 864
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

string s;

ll sum(int l, bool plus, ll tmp, ll sm) {
    ll ans = 0;
    if (plus) {
        sm += tmp + s[l] - '0';
        tmp = 0;
    } else {
        tmp += s[l] - '0';
        tmp *= 10;
    }
    if (l == s.size() - 2) {
        ans = sm + tmp + s[s.size() - 1] - '0';
    } else {
        ans += sum(l + 1, true, tmp, sm);
        ans += sum(l + 1, false, tmp, sm);
    }
    return ans;
}

int main() {
    cin >> s;
    ll ans;
    if (s.size() == 1)
        ans = s[0] - '0';
    else
        ans = sum(0, true, 0, 0) + sum(0, false, 0, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, k = map(int, input().split())
check = [0]*(n)
for _ in range(k):
    d = int(input())
    a = readints()
    # print(d)
    # print(a)
    for i in range(d):
        check[a[i]-1] = a[i]
cnt = 0
for i in range(len(check)):
    if check[i] == 0:
        cnt += 1
print(cnt)


Measured memory_bytes: 69092
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N;
    cin >> N;

    ll a;
    ll ans = 0;
    rep(i, N){
        cin >> a;
        ans += a - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1e9 + 7;
int main(){
    ll n, m;
    cin >> n >> m;
    ll po = 0, yo = 0;
    for(ll i = 0; i < n; i++){
        ll x;
        cin >> x;
        x *= (2 * i - n + 1);
        po += x;
        if(po < 0) po += -po / MOD * MOD + (-po % MOD ? MOD : 0);
        po %= MOD;
    }
    for(ll i = 0; i < m; i++){
        ll y;
        cin >> y;
        y *= (2 * i - m + 1);
        yo += y;
        if(yo < 0) yo += -yo / MOD * MOD + (-yo % MOD ? MOD : 0);
        yo %= MOD;
    }
    cout << po * yo % MOD << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define mii map<lli,lli>
#define msi map<string,lli>
#define pii pair<lli,lli> 
#define vi vector<lli> 
#define vvi vector< vector<lli> >
#define sz(x) (lli)x.size()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX1 998244353
#define MAX2 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define input(data,n,command) for(lli i=0;i<n;i++){lli tmp;cin>>tmp;data.pb(tmp);command}
#define sort_asc(a) sort(a.begin(),a.end());
//#define sort_desc(a) sort(a.begin(),a.end(),greater<lli>());
#define display(a) for(lli i = 0 ;i<a.size();i++){cout<<a[i]<<" ";} cout<<endl;
#define rep(i,a,b) for(lli i = a;i < b;i++)
#define endl "\n"

//Written By MUDIT BHARDWAJ...
/*--------------------------------------------------------------------*/
//vector<pair<lli,lli>>adj[300010];

lli solve()
{
    //start from here
    lli n;
    cin>>n;
    double d;
    cin>>d;
    lli ans = 0;
    rep(i,0,n)
    {
        double x,y;
        cin>>x>>y;
        double temp = (x*x) + (y*y);
        temp = sqrt(temp);
        if(temp <= d)
        {
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

int main()
{
    ios
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    lli T=1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}
/*-----------------------------------------------------------------------*/

Measured memory_bytes: 3852
# -*- coding: utf-8 -*-
"""
A - 753

"""
import sys
from sys import stdin
input = stdin.readline


def solve():
    X = int(input())
    return 'YES' if X in [7, 5, 3] else 'NO'


def main(args):
    ans = solve()
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

struct Restraunt{
    int Number;
    int score;
    char Name[16];
}info[100];

int main(void){
    int i,j,k,l;
    
    int N,result,index;
    struct Restraunt temp;
    
    for(i = 0;i < 100;i++){
        info[i].Number = i + 1;
    }
    scanf("%d",&N);
    
    for(i = 0;i < N;i++){
        scanf("%15s %d",info[i].Name,&info[i].score);
    }
    
    for(i = 0;i < N;i++){
        for(j = i + 1;j < N;j++){
            if(strcmp(info[i].Name, info[j].Name) >= 0){
                temp = info[i];
                info[i] = info[j];
                info[j] = temp;
            }
        }
    }
    
    for(i=0;i < N - 1;i++){
        if(strcmp(info[i].Name, info[i+1].Name) == 0){
            k = i + 1;
            while(k < N && strcmp(info[k].Name, info[i].Name) == 0){
                k++;
            }
            for(j = i;j < k;j++){
                for(l = j + 1;l < k;l++){
                    if(info[j].score < info[l].score){
                        temp = info[j];
                        info[j] = info[l];
                        info[l] = temp;
                    }
                }
            }
        }
    }
   
    for(i = 0;i < N;i++){
        printf("%d\n",info[i].Number);
    }
    
    return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  V<int>  v(5);
  rep(i,0,5)cin>>v[i];

  rep(i,0,5){
    if(v[i]==0){
      cout<<i+1<<ENDL;
      return 0;
    }
  }
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

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

using namespace std;

#define N 301
int n, mat[N][N], dirt[N][N], rmat[N][N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            cin >> mat[i][j];
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++)
            dirt[i][j] = -1;
        dirt[i][i] = 0;
    }
    long long tot = 0;
    bool ook = true;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++) {
            int ok = 1;
            for (int k = 1; k <= n; k++)
                if (k != i && k != j) {
                    if (mat[i][k] + mat[j][k] < mat[i][j]) {
                        ok = -1;
                        break;
                    } else if (mat[i][k] + mat[j][k] == mat[i][j])
                        ok = 0;
                }
            if (ok == 1)
                tot += mat[i][j];
            else if (ok == -1) {
                ook = false;
                break;
            }
        }
    if (!ook) {
        cout << -1 << endl;
    } else {
        cout << tot << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
long long sum = 0;

typedef pair<int, int> Pa;
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    rep(i, s.size()){
        if(s.compare(t) == 0){
            cout << "Yes";
            return 0;
        }
        s = s[s.size()-1] + s;
        s = s.substr(0, s.size()-1);
    }
    cout << "No";
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り　0:ON　1:OFF

		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				if(system==0) param.add(sc.next());
				if(system==1) param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}

	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		
		System.out.println(param.get(0).replaceAll(","," "));
	}
}

Measured memory_bytes: 24148
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <string>
#include <iostream>
#include <numeric>
#include <set>

using namespace std;
#define MAX 1000000000
 
int main(){
    int N, K;
    vector<pair<int, int>> sushi;

    cin >> N >> K;
    int kind = 0;
    int temp1, temp2;
    for (int i = 0; i < N; i++){
        cin >> temp1 >> temp2;
        pair<int, int> tempP = make_pair(temp2, temp1);
        sushi.push_back(tempP);        
    }
    sort(sushi.begin(), sushi.end(), std::greater<pair<int, int>>());
    set<int> temp;
    for(int i = 0; i < N; i++){
        if (temp.end() == temp.find(sushi[i].second)){
            temp.insert(sushi[i].second);
            sushi[i].second = 1;
        }else{
            sushi[i].second = 0;
        }
    }
    vector<long long int> ans;
    long long int cnt = 0;
    ans.push_back(0);
    for (int i = 0; i < K; i++){
        ans[0] += sushi[i].first;
        if (sushi[i].second == 1){
            cnt++;
        }
    }
    ans[0] += (cnt * cnt);
    int index = 0;
    int cnt2 = K;
    int ii = 0;
    for (int i = K -1; i >= 0; i--){
        if (sushi[i].second == 1){
            continue;
        }
        for(ii = cnt2; ii < N; ii++){
            if(sushi[ii].second == 1){
                ans.push_back(ans[index] - (cnt * cnt) - sushi[i].first + sushi[ii].first + ((cnt + 1) * (cnt + 1)));
                cnt++;
                index++;
                break;
            }          
        }
        cnt2 = ii + 1;
    }
    cout << *max_element(ans.begin(), ans.end()) << endl;
    return 0;
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
struct point
{
	int ds;
	int ps;
}pnt[5000005];
int rk;
bool cmp(point a,point b)
{
	return a.ps<b.ps;
}
int main()
{
	int N,L,T;
	cin>>N>>L>>T;
	for(int i=0;i<N;i++)
	{
		cin>>pnt[i].ps>>pnt[i].ds;
	}
	for(int i=0;i<N;i++)
	{
		if(pnt[i].ds==1) pnt[i].ps+=T;
		else pnt[i].ps-=T;
		rk+=(pnt[i].ps/L);
		if(pnt[i].ps<0&&pnt[i].ps%L)
		{
			rk--;
		}
		pnt[i].ps%=L; 
		pnt[i].ps=(pnt[i].ps+L)%L;
		
	}
	rk%=N;
	rk=(rk+N)%N;
	sort(pnt,pnt+N,cmp);
	for(int i=rk;i<N;i++)
	{
		cout<<pnt[i].ps<<endl;
	}
	for(int i=0;i<rk;i++)
	{
		cout<<pnt[i].ps<<endl;
	}
	return 0;
}


Measured memory_bytes: 4376
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int n = 0;
    for (int x = a; b >= x; x++){
        if (c % x == 0){
            n++;
        }
    }
    cout << n << endl;
            

}


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

int main(){
	int n,k;
  	int now = 1;
  	cin >> n >> k;
  	for(int i = 0; i<n; i++) {
      if(now < k) {
        now *=2;
      } else {
       	now += k; 
      }
    }
	cout << now << endl;
	
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

const int MAX = 1e6 + 10;

int main() {
  ll n;
  cin >> n;
  vector<int> div(MAX, 0);
  rep(i, n) {
    int x;
    cin >> x;
    div[x]++;
  }

  for (int i = 1; i < MAX; i++) {
    if (div[i] == 0) continue;
    for (int j = i + i; j < MAX; j += i) div[j] = 0;
  }

  int ans = 0;
  for (int i = 1; i < MAX; i++) {
    if (div[i] == 1) ans++;
  }

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


Measured memory_bytes: 7220
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def main():
#    h,w,a,b = map(int, input().split())
    h,w,k=map(int,input().split())
    s=[]

    a = [[0] * w for i in range(h)]
    for i in range(h):
        s.append(list(input()))
    temp=1
    new=0
    p=[]
#    print(a)
    for i in range(h):
        for j in range(w):
            if s[i][j]==".":
                a[i][j]=temp
            elif s[i][j]=="#" and new!=0:
                temp+=1
                a[i][j]=temp
            else:
                a[i][j]=temp
                new=1
        if new==1:
            temp+=1
        else:
            p.append(i)
        new=0

#    print(p)
    if p:
        for i in p:
            for j in range(w):
                if i !=0 and i!= h-1:
                    pp=i
                    while 1>0:
                        pp+=1
                        if pp in p:
                            continue
                        elif pp==h:
                            while 1>0:
                                pp-=1
                                if pp in p:
                                    continue
                                else:
                                    break
                        else:
                            break
                        break
                    a[i][j]=a[pp][j]
                elif i==h-1:
                    a[i][j]=a[i-1][j]
                else:
                    break
    if 0 in p and h>=2:
        for i in range(w):
            a[0][i]=a[1][i]

#    print(s)
    for i in range(h):
        print(*a[i])


if __name__ == "__main__":
    main()

Measured memory_bytes: 8272
/** @Date    : 2017-09-02 19:00:48
  * @FileName: A.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoungEarlf@gmail.com)
  * @Link    : https://github.com/
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;


int vis[N];
int a[N];
int main()
{
	int n;
	while(cin >> n)
	{
		MMF(vis);
		for(int i = 0; i < n; i++)
		{
			scanf("%d", a + i);
			vis[a[i]]++;
			vis[a[i] - 1]++;
			vis[a[i] + 1]++;
		}
		int ma = 0;
		for(int i = 0; i < N; i++)
		{
			ma = max(vis[i], ma);
		}
		cout << ma << endl;
	}
    return 0;
}

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

using namespace std;

int main()
{
  int M, N, D;
  bitset< 626 > matrix[625];

  while(cin >> M >> N >> D, M) {
    for(int i = 0; i < N * M; i++) {
      int d;
      cin >> d;
      matrix[i][N * M] = d;
    }

    for(int i = 0; i < N; i++) {
      for(int j = 0; j < M; j++) {
        for(int k = 0; k < N; k++) {
          for(int l = 0; l < M; l++) {
            matrix[i * M + j][k * M + l] = abs(i - k) + abs(j - l) == D;
          }
        }
        matrix[i * M + j][i * M + j] = 1;
      }
    }

    for(int i = 0; i < N * M; i++) {
      int pos = -1;
      for(int j = i; j < N * M; j++) {
        if(matrix[j][i]) pos = j;
      }
      if(pos == -1) continue;
      swap(matrix[pos], matrix[i]);
      for(int j = 0; j < M * N; j++) {
        if(i != j && matrix[j][i] == 1) matrix[j] ^= matrix[i];
      }
    }
    bool flag = true;
    for(int i = 0; i < M * N; i++) {
      if(matrix[i][M * N] && !matrix[i][i]) flag = false;
    }
    cout << flag << endl;
  }
}

Measured memory_bytes: 3020
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;

    if (a + k - 1 < b - k + 1) {
        for (int i = a; i <= a + k - 1; ++i) {
            cout << i << endl;
        }
        for (int i = b - k + 1; i <= b; ++i) {
            cout << i << endl;
        }
    } else {
        for (int i = a; i <= b; ++i) {
            cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let mut c: Vec<Vec<char>> = Vec::new();
    for _i in 0..2 {
        let s: String = sc.read();
        c.push(to_chars(s));
    }
    let mut ok: bool = true;
    for i in 0..3 {
        ok &= c[0][i] == c[1][2 - i];
    }
    if ok {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int x = 0;
    int[] color = new int[8];
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      if (a >= 3200) {
        x++;
      } else {
        color[a/400]++;
      }
    }

    int noone = 0;
    for (int i = 0; i < 8; i++) {
      if (color[i] == 0) {
        noone++;
      }
    }
    
    int min = Math.max(8 - noone, 1);
    int max = 8-noone+x;
    
    System.out.println(min + " " + max);
  }
}

Measured memory_bytes: 21204
n, m = map(int, input().split())
l = list(map(int, input().split()))

if n >= m:
  print(0)
  exit()

l.sort()
d = [0]*(m-1)
for i in range(m-1):
  d[i] = l[i+1] - l[i]

d.sort()

print(sum(d[0:(m-n)]))

Measured memory_bytes: 53032
#include <stdio.h>
#include <math.h>
#include <limits.h>

int main(){

	int i, j, k, t;
	int n;
	int a[1000000], g[1000000];
	int cnt, m, v;

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


	// g = g[i+1] + pow(3,i)
	g[0]=1; m=1; i=0;
	while( g[i] <= n ){
		i++; m++;
		g[i] = pow(3,i) + g[i-1];
	}

	printf( "%d\n", m-1 );
	for( i=m-2; i>=0; i-- ) 
		printf( "%d%c", g[i], i!=0?' ':'\n' );


	//
	cnt=0;
	for( i=m-2; i>=0; i-- ){
		for( k=g[i]; k<n; k++ ){
			v = a[k];
			j = k - g[i];

			while( j>=0 && a[j]>v ){
				a[j+g[i]] = a[j];
				j = j - g[i];
				cnt++;
			}
	
			a[j+g[i]] = v;

		}
	}
	
	printf( "%d\n", cnt );


	//
	for( i=0; i<n; i++ ) 
		printf( "%d\n", a[i] );

	return 0;

}

Measured memory_bytes: 5280
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;

int main()
{
	int32_t W, H, N;
	cin >> W >> H >> N;

	vector<vector<bool>> is_white;
	is_white.resize(H);
	for (int32_t i = 0; i < H; i++) {
		is_white[i].resize(W);
		std::fill(is_white[i].begin(), is_white[i].end(), true);
	}

	for (int32_t n = 0; n < N; n++) {
		int32_t x, y, a;
		cin >> x >> y >> a;

		for (int32_t h = 0; h < H; h++) {
			for (int32_t w = 0; w < W; w++) {
				switch (a) {
				case 1:
					if (w < x)
						is_white[h][w] = false;
					break;
				case 2:
					if (w >= x)
						is_white[h][w] = false;
					break;
				case 3:
					if (h < y)
						is_white[h][w] = false;
					break;
				case 4:
					if (h >= y)
						is_white[h][w] = false;
					break;
				}
			}
		}
	}

	int32_t res = 0;
	for (int32_t h = 0; h < H; h++) {
		for (int32_t w = 0; w < W; w++) {
			if (is_white[h][w])
				res++;
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long MAX;
    if(a >= 0){
        if(c >= 0){
            MAX = b * d;
        }
        else if(c < 0 && d >= 0){
            MAX = b * d;
        }
        else{
            MAX = a * d;
        }
    }
    else if(a < 0 && b >= 0){
        if(c >= 0){
            MAX = b * d;
        }
        else if(c < 0 && d >= 0){
            MAX = max(b * d, a * c);
        }
        else{
            MAX = c * a;
        }
    }
    else if(a < 0 && b < 0){
        if(c >= 0){
            MAX = b * c;
        }
        else if(c < 0 && d >= 0){
            MAX = a * c;
        }
        else{
            MAX = c * a;
        }
    }

    cout << MAX << endl;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> victim(n, 1);
  for (int i = 0; i < k; i++) {
    int m;
    cin >> m;
    while (m--) {
      int a;
      cin >> a;
      victim[a-1] = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    ans += victim[i];
  cout << ans << endl;
}


Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int sum = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			sum += Math.min(Math.abs(k - x), x) * 2;
		}
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br =
            new BufferedReader(new InputStreamReader(System.in), 1);
        String is = br.readLine();
        String[] sp = is.split(" ");

        int a = Integer.parseInt(sp[0]);
        int b = Integer.parseInt(sp[1]);
        int d =a/b;
        int r = a%b;
        double f = (double)a/(double)b;
        String fs = String.format("%.8f", f);

        System.out.println(d + " " + r + " "+ fs);
    }
}

Measured memory_bytes: 24760
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let l: i64 = input();
    let r: i64 = input();
    const MOD: i64 = 1000000007;

    let mut dp = vec![vec![vec![vec![0; 2]; 2]; 2]; 62];
    dp[61][0][0][0] = 1;
    for i in (0..61).rev() {
        let lb = l >> i & 1;
        let rb = r >> i & 1;
        for j in 0..2 {
            for k in 0..2 {
                for l in 0..2 {
                    for x in 0..2 {
                        for y in 0..2 {
                            if x == 1 && y == 0 {
                                continue;
                            }
                            if j == 0 && lb == 1 && x == 0 {
                                continue;
                            }
                            let nextj = if lb == 0 && x == 1 { 1 } else { j };
                            if k == 0 && rb == 0 && y == 1 {
                                continue;
                            }
                            let nextk = if rb == 1 && y == 0 { 1 } else { k };
                            if l == 0 && x != y {
                                continue;
                            }
                            let nextl = if x == 1 && y == 1 { 1 } else { l };
                            dp[i][nextj][nextk][nextl] += dp[i + 1][j][k][l];
                            dp[i][nextj][nextk][nextl] %= MOD;
                        }
                    }
                }
            }
        }
    }

    let mut ans = 0i64;
    for j in 0..2 {
        for k in 0..2 {
            for l in 0..2 {
                ans += dp[0][j][k][l];
                ans %= MOD;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352