akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
const int mod = 1000000007;
int main()
{
    ll s; cin >> s;
    ll dp[2010];
    rep(i, 3) dp[i] = 0;
    FOR(i, 3, s+1) {
        dp[i] = 1;
    }
    FOR(i, 1, s) {
        FOR(j, 3, s+1) {
            if (i + j > s) break;
            dp[i+j] += dp[i];
            dp[i+j] %= mod;
        }
    }
    cout << dp[s] << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e3+5;
const int M=2e4+5;
char a[N],b[N],c[N];
bool ab[M],ac[M],bc[M];
bool cal(char a,char b) {
	return a=='?'||b=='?'||a==b;
}
int main() {
    //freopen("in.txt","r",stdin);
	scanf("%s%s%s",a,b,c);
	int A=strlen(a),B=strlen(b),C=strlen(c);
	for(int i=0;i<A;i++) {
		for(int j=0;j<B;j++) {
			if(!cal(a[i],b[j])) ab[i-j+4000]=true;
		}
		for(int j=0;j<C;j++) {
			if(!cal(a[i],c[j])) ac[i-j+4000]=true;
		}
	}
	for(int i=0;i<B;i++) {
		for(int j=0;j<C;j++) {
			if(!cal(b[i],c[j])) bc[i-j+4000]=true;
		}
	}
	int ans=1e9;
	for(int i=-4000;i<=4000;i++) {
		for(int j=-4000;j<=4000;j++) {
			if(!ab[i+4000]&&!ac[j+4000]&&!bc[j-i+4000]) {
				int L=min(0,min(i,j)),R=max(A,max(B+i,C+j));
				ans=min(ans,R-L);
			}
		}
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
/*input

*/

#include<bits/stdc++.h>
using namespace std;
//#define int 					ll
#define ios	    				ios_base::sync_with_stdio(false); cin.tie(0)
#define hell 					1000000007
#define inf 					9e18

// Data Structures //
#define ull 					unsigned long long
#define ll 						long long
#define p_q 					priority_queue
#define pii         			pair<ll,ll>
#define vi          			vector<ll>
#define vii         			vector<pii>
#define mi          			map<ll,ll>
#define mii         			map<pii,ll>
// Functions //
#define pb 						push_back
#define ppb						pop_back
#define all(a)      			(a).begin(),(a).end()
#define gcd(a,b)    			__gcd((a),(b))
#define lcm(a,b)    			((a)*(b)) / gcd((a),(b))
#define mp 						make_pair
#define bs						binary_search
#define lb 						lower_bound
#define ub						upper_bound
#define F						first
#define S						second
#define take(a,n)				for(ll i=0;i<n;i++) cin>>a[i];
#define dbg(x) 					cout << #x << " = " << x << '\n'
#define endl					"\n"
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

#define N  1000005



void solve()
{
	ll n,w,k=0,t,cnt=0,prev=-1;
	cin>>n>>w;
	vi  wt(n),val(n);
	ll dp[n+1][w+1];
	memset(dp,0,sizeof(dp));
	
	//dbg(wt[0]);
	
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
	}
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(j-wt[i-1]>-1)
			{
				dp[i][j] = max(dp[i-1][j-wt[i-1]] + val[i-1], dp[i-1][j] );
			}
			else dp[i][j] = dp[i-1][j];
		}
	}
	cout<<dp[n][w]<<endl;
	
}


signed main()
{
	ios;
	ll n,tests=1,prev=0,i=0;

	//cin>>tests;
	while(tests--)
	{
		solve();
	}
	time
	return 0;
}


Measured memory_bytes: 82516
#include<stdio.h>
int main(){
  int a,b,c,cnt;
  scanf("%d %d %d", &a, &b, &c);
  for(int i=1; i<=b; i++){
    if(c==(a*i)%b)
      cnt++;
  }
  if(cnt!=0){
    printf("YES\n");
  }
  else{
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128
a,b,q = list(map(int, input().split()))

s = [0]*a
t = [0]*b
x = [0]*q
for i in range(a):
    s[i] = int(input())
for i in range(b):
    t[i] = int(input())
for i in range(q):
    x[i] = int(input())
s.sort()
t.sort()

INT_MAX = 10**11

#print(s)
#print(t)
import bisect
def func(xi):
    i = bisect.bisect_left(s,xi)
    s_right = INT_MAX
    if i < len(s):
        s_right = s[i] - xi
    s_left = INT_MAX
    if i != 0:
        s_left = xi - s[i-1]
    j = bisect.bisect_left(t,xi)
    t_right = INT_MAX
    if j < len(t):
        t_right = t[j] - xi
    t_left = INT_MAX
    if j != 0:
        t_left = xi - t[j-1]
    #print(i,j,xi)
    #print(s_left,s_right,t_left,t_right)
    return min(max(s_right,t_right), max(s_left,t_left), min(s_left,t_right)*2+max(s_left,t_right), min(s_right,t_left)*2+max(s_right,t_left))

ans = map(func, x)
print("\n".join(map(str,ans)))


Measured memory_bytes: 111448
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  int n, l;

  cin >> n >> l;

  int sum = 0;
  for (int i = l; i < n+l; i++) {
    sum += i;
  }

  if (l < 0 && n+l > 0) {
    cout << sum << endl;
  } else if (l < 0) {
    cout << sum - (n+l-1) << endl;
  } else {
    cout << sum - l << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    string S;

    cin >> S;

    for(int i = 0; i <= 2; i++)
    {
        if(S[i] == 'o')
            n++;
    }

    cout << 700 + n*100;

    return 0;
}


Measured memory_bytes: 256
import * as fs from "fs"
const process = (a: string[]): string => {
  for (let i = 0; i < a.length - 1; i++) {
    if (a[i] === a[i + 1]) {
      return "Bad"
    }
  }
  return "Good"
}

const Main = (input: string): string => {
  const a: string[] = input.split("")
  const res = process(a) + ""
  console.log(res)
  return res
}
Main(fs.readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 7372
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        M: usize,
        ABC: [(usize,usize,u64); M],
    }
    let mut A = vec![vec![9999; N]; N];
    for i in 0..M{
        let (a,b,c) = ABC[i];
        A[a-1][b-1] = c;
        A[b-1][a-1] = c;
    }
    for k in 0..N{
        for i in 0..N{
            for j in 0..N{
                if i==j{
                    A[i][j] = 0;
                }else{
                    A[i][j] = min(A[i][j], A[i][k]+A[k][j]);
                }
            }
        }
    }
    let mut ans = 0;
    for i in 0..M{
        let (a,b,c) = ABC[i];
        let mut flg = true;
        for j in 0..N{
            if A[a-1][j] == A[b-1][j] + c{
                flg = false;
                break
            }
        }
        if flg{
            ans += 1;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200;

set <int> S;
vector <int> g[N];
int n, m, k, mod;
int a[N], dp1[N], dp2[N];
string ss;

void dfs1(int v, int p){
	int list = 1;
	for (auto to: g[v]){
		if (to != p){
			dfs1(to, v);
			list = 0;
		}
	}
	if (list){
		dp1[v] = 1;
		return;
	}
	dp1[v] = 1;
	for (auto to: g[v]){
		if (to != p){
			(dp1[v] *= dp1[to] + 1) %= mod; 
		}
	}
}

void dfs2(int v, int p){
	if (p == -1){
		dp2[v] = 1;
	}
	int pp = 1;
	for (auto to: g[v]){
		if (to != p){
			dp2[to] = pp;				
			(pp *= (dp1[to] + 1)) %= mod;
		}
	}
	reverse(all(g[v]));
	pp = 1;
	for (auto to: g[v]){
		if (to != p){
			(dp2[to] *= pp) %= mod;				
			(pp *= (dp1[to] + 1)) %= mod;
			(dp2[to] *= dp2[v]) %= mod;
			dp2[to]++;
			dp2[to] %= mod;
		}
	}
	for (auto to: g[v]){
		if (to != p){
			dfs2(to, v);
		}
	}
}

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> mod;
//	mod = 1e9;
	for (int i = 0; i < n - 1; i++){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs1(1, -1);
	dfs2(1, -1);
	int ans = 0;
	for (int i = 1; i <= n; i++){
		cout << (dp2[i] * dp1[i]) % mod << endl;
		//cout << i << " >> " << dp2[i]  << " " <<  dp1[i] << "\n";
	}
//	cout << ansl
	return 0;
}












Measured memory_bytes: 18688
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define rint register int
#define INF ((1 << 30) - 1)
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define Pair pair < int, int >
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i, k, j) for(rint i = (k); i >= (j); i--)
#define For(i, k, j) for(rint i = (k); i <= (j); i++)
#define Foe(i, u) for(rint i = lst[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
#define ull unsigned ll
const int P = 998244353; //
using namespace std;
inline void ckmax(int &a, int b) {a = max(a, b);}
inline void ckmin(int &a, int b) {a = min(a, b);}
inline void mulmod(int &a, int b) {a = 1ll * a * b % P;}
inline void addmod(int &a, int b) {int t = a + b; a = (t >= P ? t - P : t); }
inline int ksm(int a, int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline int inv(int a) {return ksm(a, P-2);}

inline void printarray(int *a, int n) {For(i, 1, n) fprintf(stderr, "%d ", a[i]); fprintf(stderr, "\n");}
namespace FastIO {
    const int SIZE=1<<16; char buf[SIZE], obuf[SIZE], str[64]; int bi=SIZE, bn=SIZE, opt;
    int read(char *s) {
        while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
        int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
    }
    bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n) return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
    void write(int x) {
        if(!x) obuf[opt++] = '0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
        if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}
    }
    void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}}
    void Fflush() { if (opt) fwrite(obuf, 1, opt, stdout); opt=0;}
};
const int MAXN = 305;
char s[MAXN]; 
int n, m, cnt, a[MAXN], sum[MAXN], f[MAXN][MAXN][MAXN]; // f[i][j][k] : 前 i 组，用了 j 个 1，操作了 k 次的方案数 
signed main()
{
    #ifndef ONLINE_JUDGE 
        file("pro");
    #endif
    FI(s + 1); FI(m); n = strlen(s + 1);
    ckmin(m, n); s[n + 1] = '0';
    For(i, 1, n + 1) {
    	if(s[i] == '0') cnt++;
    	else a[cnt + 1]++;
	}
	For(i, 1, cnt) sum[i] = sum[i - 1] + a[i];
	f[0][0][0] = 1;
	For(i, 1, cnt) {
		For(j, sum[i], sum[cnt]) {
			For(k, 0, m) {
				For(lst, 0, min(j, sum[cnt] - sum[i-1])) {
					if(max(0, lst-a[i]) <= k) addmod(f[i][j][k], f[i-1][j-lst][k-max(0,lst-a[i])]);
				}
			}
		}
	}
	int ans = 0;
	For(k, 0, m) {
		addmod(ans, f[cnt][sum[cnt]][k]);
	}
	cout << ans << endl;
    return FastIO::Fflush(), 0;
}
/*
Think twice :
mod ?
INF ?
n = 1 ?
long long ?
Fastio::Fflush() ?
*/


Measured memory_bytes: 30472
import java.io.*;
class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int i,j,k;
		int ways; 
		
		while(true){
			ways=0;
			String[] num=br.readLine().split(" ");
			int n=Integer.parseInt(num[0]);
			int x=Integer.parseInt(num[1]);
			if(n==0&&x==0){
				break;
			}
			for(i=1;i<=n;i++){
				for(j=1;j<i;j++){
					for(k=1;k<j;k++){
						if((i+j+k)==x){
							ways++;
						}
					}
				}
			}
			sb.append(ways+"\n");
		}
		System.out.print(sb);
	}
}

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

int main() {
  int N,
      num,
  	  result = 0,
  	  array[200] = {};
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> num;
    
    while (num % 2 == 0) {
      num /= 2;
      array[i] += 1;
    }
  }
  
  result = array[0];
  
  for (int i = 0; i < N; i++) {
    if (array[0] > array[i] && i != 0) {
    result = array[i];
    }
  }
  
  cout << result << endl;
}


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

using namespace std;




int main() {

	int count = 0;
	int N, A;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> A;
		if (A % 2 == 1) {
			count += 1;
		}

	}

	if (count % 2 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> p(n);

    rep(i,n) cin >> p[i];
    int ans = 0;

    rep(i,n){
        if(p[i] == i+1){
            if(i == n-1){
                swap(p[i],p[i-1]);
                ans++;
            }
            else{
                swap(p[i],p[i+1]);
                ans++;
            }
        }
    }

    cout << ans << endl;

}

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

using namespace std;

const int inf = 1e9;
int h, w, k, x1, Y1, x2, y2, mx[] = {0, 1, 0, -1}, my[] = {1, 0, -1, 0};
string mp[100005];

struct node
{
    int x, y, v;
}q[5000005];

int main() 
{
    cin >> h >> w >> k >> x1 >> Y1 >> x2 >> y2; 
    for (int i = 1; i <= h; i++) cin >> mp[i]; 
    int d[h + 10][w + 10]; 
    for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) d[i][j] = inf;
    d[x1][Y1] = 0;
    int l = 1, r = 1;
    node x;
    x.x = x1;
    x.y = Y1;
    x.v = 0;
    q[1] = x;
    while(l <= r)
    {
        node x = q[l++];
        if (x.v != d[x.x][x.y]) continue;        
        if (x.x == x2 && x.y == y2) 
        {
            cout << d[x2][y2] << endl;
            return 0;
        }
        for (int i = 0; i < 4; i++) 
        {
            for (int j = 1; j <= k; j++) {
                int nx = x.x + j * mx[i], ny = x.y + j * my[i];
                if (nx >= 1 && nx <= h && ny >= 1 && ny <= w && mp[nx][ny - 1] == '.')
                {
                    if (d[nx][ny] > d[x.x][x.y] + 1)
                    {
                        d[nx][ny] = d[x.x][x.y] + 1;
                        node xx;
                        xx.x = nx;
                        xx.y = ny;
                        xx.v = d[nx][ny];
                        q[++r] = xx;
                    }
                    if (d[nx][ny] <= d[x.x][x.y]) break;
                }
                else break;
            }
        }
    }
    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 18368
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int n;
vi b;

int main() {
  scan(n);
  b.resize(n);
  scan(b);
  rep (i, n) {
    if (b[i] > i+1) {
      print(-1);
      return 0;
    }
  }
  vi a(n, 0);
  rep (i, n) {
    for (int j = n-1; j >= 0; --j) {
      if (b[j] - a[j] == 1) {
        print(b[j]);
        FOR (k, j, n) {
          a[k] += 1;
        }
        break;
      }
    }
  }

  return 0;
}


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

const int N = 8; //クイーンの数
bool Board[N][N]; //チェス盤
int row[N]; //その行は襲撃されるか,クイーンの置いてある列を記録
bool col[N]; //その列は襲撃されるか
bool dpos[2*N]; //左下方向の列は襲撃されるか
bool dneg[2*N]; //右下方向の列は襲撃されるか

#define SAFE true
#define NOT_SAFE false

void PrintBoard(){
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            //クイーンが置かれている行が列と同じでなければ関数を抜ける(1行に2つ置けない)
            //ここで初期値として与えられたクイーンの盤以外表示されなくなる
            if(Board[i][j] == true){
                if(row[i] != j) return;
            }
        }
    }
    //ちゃんとした答え
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cout << (row[i] == j ? "Q" : ".");
        }
        cout << endl;
    }

}

void rec(int i){
    //N行目に来たらすべてのクイーンをおくことができたので出力
    if(i == N){
        PrintBoard();
        return;
    }

    for(int j = 0; j < N; j++){
        //i行j列目が襲撃されるならクイーンを置けない
        if( col[j] == NOT_SAFE or
            dpos[i + j] == NOT_SAFE or
            dneg[i - j + N - 1] == NOT_SAFE
        ) continue;

        //順番に置いていく
        row[i] = j;dneg[i - j + N - 1] = dpos[i+j] = col[j] = NOT_SAFE;
        //次の行を探す
        rec(i+1);
        //クイーンを取り除く
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = SAFE;
        
    }    
}

signed main(){
    for(int i = 0; i < N; i++){
        row[i] = -1;
        col[i] = SAFE;
        for(int j = 0; j < N; j++){
            Board[i][j] = false;
        }
    }
    for(int i = 0; i < 2 * N; i++)
        dneg[i] = dpos[i] = SAFE;


    int k;
    cin >> k;
    for(int i = 0; i < k; i++){
        int r,c;
        cin >> r >> c;
        Board[r][c] = true;
    }

    rec(0);

    return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();

		if (N==1 && M ==1) {
			System.out.println(1);
			return;
		}
		if (N==1) {
			System.out.println(M-2);
			return;
		}
		if (M==1) {
			System.out.println(N-2);
			return;
		}
		System.out.println((N-2)*(M-2));
	}
}


Measured memory_bytes: 23764
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A, B, C = input().split()

    if A[-1] == B[0] and B[-1] == C[0]:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61924
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	map<string , ll> mp;
	mp["SUN"]=7;mp["MON"]=6;mp["TUE"]=5;mp["WED"]=4;
	mp["THU"]=3;mp["FRI"]=2;mp["SAT"]=1;
	string str ;
	cin>> str ;
	cout<<mp[str]<<endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
lack=0
num=[]
count=0
c=0
if sum(a)<sum(b):
    print(-1)
    
else:
    for i in range(n):
        if b[i]>a[i]:
            lack+=b[i]-a[i]
            count+=1
        if b[i]<a[i]:
            num.append(a[i]-b[i])
    if count!=0:
       num.sort(reverse=True)
       for i in range(len(num)):
           c+=num[i]
           count+=1
           if c>=lack:
            break
    print(count)

Measured memory_bytes: 18356
h, w = gets.split.map(&:to_i)

if h % 3 == 0 || w % 3 == 0
  puts 0
  exit
end

result = []

def calc h, w, h1, w1
  h2, w2 = h, w
  if h == h1
    w2 = w - w1
  else
    h2 = h - h1
  end
  a = h1 * w1
  if h2 % 2 == 0 || w2 % 2 == 0
    return (a - h2 * w2 / 2).abs
  end

  b1 = h2 / 2 * w2
  c1 = (h2.to_f / 2).ceil * w2
  b2 = w2 / 2 * h2
  c2 = (w2.to_f / 2).ceil * h2
  abc1 = [a, b1, c1]
  abc2 = [a, b2, c2]
  return [abc1.max - abc1.min, abc2.max - abc2.min].min
end

h11 = (h.to_f / 3).ceil
w11 = w
result.push(calc(h, w, h11, w11))

h21 = (h.to_f / 3).floor
w21 = w
result.push(calc(h, w, h21, w21))

h31 = h
w31 = (w.to_f / 3).ceil
result.push(calc(h, w, h31, w31))

h41 = h
w41 = (w.to_f / 3).floor
result.push(calc(h, w, h41, w41))

warn result.inspect
puts result.min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
LL a[N],b[N],n,lw,pw,sw,huj;
pll w;
string S;
void bin(int l,int p) {
    while(l<p) {
        int sr=(l+p)/2;
        cout<<sr<<endl;
        cin>>S;
        if(S[0]=='V') exit(0);
        if(S[0]=='M') sw=1;
        else sw=2;
        if((sr-l)%2==1&&sw==lw) p=sr, pw=sw;
        else if((p-sr)%2==1&&sw==pw) l=sr, lw=sw;
        else if((p-sr)%2==0&&sw!=pw) l=sr, lw=sw;
        else if((sr-l)%2==0&&sw!=lw) p=sr, pw=sw;
    }
}
int32_t main(void) {
    cin>>n;
    cout<<"0"<<endl;
    cin>>S;
    if(S[0]=='V') return 0;
    if(S[0]=='M') lw=1;
    else lw=2;
    cout<<n/2<<endl;
    cin>>S;
    if(S[0]=='V') return 0;
    if(S[0]=='M') pw=1;
    else pw=2;
    if(lw==pw) huj++;
    if(n%4==1) huj++;
    if(huj%2==0) {
        swap(lw,pw);
        bin(n/2,n);
    }
    else bin(0,n/2);
}


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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x  (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

const int N=2e5+5;
int h[N],a[N];
LL tree[N],dp[N];

LL query(int idx){
    LL sum=0;
    for(; idx>0; idx-=idx & (-idx))
        sum=max(tree[idx],sum);
    return sum;
}
void update(int idx,LL val,int n){
    for(; idx<=n; idx+=idx & (-idx))
        tree[idx]=max(val,tree[idx]);
}

int main()
{
    int n;
    cin >> n;
    FOR(i,1,n) cin >> h[i];
    FOR(i,1,n) cin >> a[i];
    LL ans=0;
    for(int i=1;i<=n;i++){
        dp[i]=query(h[i]-1)+a[i];
        update(h[i],dp[i],n);
        ans=max(ans,dp[i]);
    }
    cout << ans;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<stdlib.h>

int compare_int_big(const void *a,const void *b){
    return *(int *)b - *(int *)a;
}

int compare_int_small(const void *a,const void *b){
    return *(int *)a - *(int *)b;
}

int main(void){
    int N;
    int X[101];
    int sum=0,avg=0;
    int ans1=0,ans2=0;

    scanf("%d",&N);

    for(int i=0;i<N;i++){
        scanf("%d",&X[i]);
        sum+=X[i];
    }

    avg = sum/N;

    for(int i=0;i<N;i++){
        ans1 += (X[i]-avg)*(X[i]-avg);
    }
    
    avg+=1;

    for(int i=0;i<N;i++){
        ans2 += (X[i]-avg)*(X[i]-avg);
    }

    printf("%d",(ans1<ans2)?ans1:ans2);

    return 0;
}

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

int N,M;
int par[123456];
int con;
int getpar(int x){
	if(x==par[x])return x;
	return par[x]=getpar(par[x]);
}
bool same(int u,int v){
	return getpar(u)==getpar(v);
}
void unite(int u,int v){
	u=getpar(u);
	v=getpar(v);
	if(!same(u,v)){
		par[u]=v;
		getpar(u);
		getpar(v);
		--con;
	}
}

int main() {
	cin>>N>>M;
	for(int i=0;i<N;++i){
		par[i]=i;
	}
	con=N;
	for(int j=0;j<M;++j){
		int x,y,z;
		cin>>x>>y>>z;
		z%=2;
		x--;y--;
		unite(x,y);
	}
	cout<<max(1,con)<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int m,n,cnt=1,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
    }
    sort(aa,aa+n);
    rep(i,n){
        if(cnt!=0&&1000000000000000000/cnt<aa[i]){
            cout<<-1;
            return 0;
        }
        cnt*=aa[i];
    }
    cout<<cnt;
}

Measured memory_bytes: 11292
N, M = map(int, input().split())
lists = [list(map(str, input().split())) for i in range(M)]
# print(lists)

dict_ac = {i:0 for i in range(N)}
dict_wa = {i:0 for i in range(N)}
# print(dict_ac)
# print(dict_wa)
number = True
index = 0
for i, j in lists:

    if j == "WA":
        i = int(i) - 1
        if dict_ac[i] == 0:
            dict_wa[i] += 1

    elif j == "AC":
        if i not in dict_ac.keys():
            i = int(i) - 1
            dict_ac[i] = 1


# print("AC", dict_ac)
# print("WA", dict_wa)


for i in dict_wa.keys():
    if dict_ac[i] == 0:
        dict_wa[i] = 0
    else:
        continue

# print("AC", dict_ac)
# print("WA", dict_wa)

print(sum(dict_ac.values()), sum(dict_wa.values()))

Measured memory_bytes: 56460
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;

using namespace std;

int main()
{
    long long int a, b, n;
    cin >> a >> b >> n;
    if (b - 1 <= n)
    {
        cout << floor((a * (b - 1)) / b) - a * floor((b - 1) / b) << endl;
    }
    else
    {
        cout << floor(a * (n) / b) - a * floor(n / b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {

    ll N;
    cin >> N;

    vector<ll>p(N + 1);
    vector<bool> x(N + 2);

    p[0] = 0;
    x[0] = false;

    rep(i, N) {
        cin >> p[i + 1];
        if (i + 1 == p[i + 1]) {
            x[i] = true;
        }
        else {
            x[i] = false;
        }
    }

    ll count = 0, tmp;

    rep(i, N + 1) {
        if (x[i] == true) {
            count++;
            x[i + 1] = false;
        }
    }

    cout << count;

    return 0;
}

Measured memory_bytes: 3612
// x1+x2 = 3
// x2+x3 = 8
// x3+x4 = 7
//
// x1+8-x3 = 3
// x1-x3 = 3-8
//
// x1-(7-x4) = 3-8
// x1+x4 = 3-8+7

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    
    int s = 0;
    for (int i = 0; i < N; i++) {
      s += i%2 == 0 ? A[i] : -A[i];
    }

    int[] x = new int[N];
    x[0] = s/2;
    for (int i = 1; i < N; i++) {
      x[i] = A[i-1]-x[i-1];
    }
    StringBuilder ans = new StringBuilder();
    for (int i = 0; i < N; i++) {
      ans.append(2*x[i]).append(" ");
    }
    
    System.out.println(ans.toString());
  }
}

Measured memory_bytes: 55912
#include<stdio.h>
int main()
{
  int a,i,b,c,d=0,e;
  scanf("%d%d",&a,&c);
  int ar[a];
  for(i=0;i<a;i++)
  {
    scanf("%d",&ar[i]);
  d=d+ar[i];
  }
  b=ar[0];
  for(i=0;i<a;i++)
  {
      if(b>ar[i])
      {
          b=ar[i];
      }
  }
  if(d==c)
  {
      printf("%d\n",a);
  }
    else if(d<c)
    {
        e=(c-d)/b;
        printf("%d\n",a+e);
            }
    return 0;
}


Measured memory_bytes: 1724
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
string s;
int a,b;
void print(){
	for(int i=a;i<=b;i++){
		cout<<s[i];
	}
	cout<<endl;
}
void rev(){
	while(a<b){
		swap(s[a],s[b]);
		a++;b--;
	}
}
void rep(string &tmp){
	s.replace(a,b-a+1,tmp);
}
int main()
{
//#ifdef DEBUG
//	freopen("in", "r", stdin);
////	freopen("out", "w", stdout);
//#endif
	
	s.clear();
	cin>>s;
	int n;
	cin>>n;
	string t;
	while(n--){
		cin>>t;
		cin>>a>>b;
		switch(t[2]){
			case'i'://print
				print();
				break;
			case'v'://reverse
				rev();
				break;
			case'p'://replace
				string tmp;
				cin>>tmp;
				rep(tmp);
				break;
				
		}
		
	}
	//insert code above
	return 0;
}
//1_9_d.cc

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

int findSomeOfDigits(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int n;
  cin >> n;
  int f = findSomeOfDigits(n);
  if(n % f == 0) cout << "Yes";
  else cout << "No";
}




Measured memory_bytes: 256
var
 a,b,c,i,j,k,x,s:longint;
begin
 readln(a);
 readln(b);
 readln(c);
 readln(x);
  for i:=0 to a do
   for j:=0 to b do
    for k:=0 to c do
     if i*500+j*100+k*50=x then inc(s);
     writeln(s);
end.

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int takahashi = 0;
	if (a <= b) takahashi += a;
	else takahashi += a - 1;
	cout << takahashi << endl;
	return 0;
}

Measured memory_bytes: 3532
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; 
  cin>>n;
  vector<int> p(n);
  rep(i,n)cin >>p[i];
  ll ans=0;
  rep(i,n-1){
    if(p[i]==i+1){
      swap(p[i],p[i+1]);
      ans++;
      i++;
    }
  }
  if(p[n-1]==n)ans++;
  cout <<ans<<endl;
}

Measured memory_bytes: 3736
#include <stdio.h>
#include <stdlib.h>

#define MAX(a, b)   ((a)>(b)?(a):(b))

void
solver(long a, long b, long k)
{
    long ra, rb;

    if (a>k) {
        ra = a - k;
        rb = b;
    }
    else {
        ra = 0;
        rb = MAX(0, b - (k - a));
    }
    printf("%ld %ld\n", ra, rb);
}

int
main(int argc, char *argv[])
{
    long A, B, K;

    scanf("%ld%ld%ld", &A, &B, &K);
    solver(A, B, K);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
long gcd(long x,long y){return y?gcd(y,x%y):x;}
int main(){
    long a,b,g,ans=1L;
    cin>>a>>b;
    g=gcd(a,b);
    for(long i=2L;i*i<=g;i++)if(g%i==0){ans++;while(g%i==0)g/=i;}
    cout<<ans+(g!=1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int x [902];
int syu[30];
int main() {
	int answer = 0;
	int itizi = 2;
	int kari = 0;
	cin >> x[0];
	cin >> x[1];
	for (int i = 2;kari<x[0];i += 1)
	{
		cin >> x[i];
		if (itizi==i)
		{
			itizi += x[i]+=1;
		}
		else if (itizi-1==i)
		{
			kari += 1;
			syu[x[i]] += 1;
		}
		else
		{
			syu[x[i]] += 1;
		}
	}
	for (int i = 1;i<=x[1];i += 1)
	{
		if (syu[i] == x[0])
		{
			answer += 1;
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+500;
int a[N];
int lis[N];
int falg1[N],falg2[N];
ll quick(ll a,ll b,ll mod) {
	int ans=1%mod;
	a%=mod;
	while(b) {
		if(b&1)ans=ans*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return ans%mod;
}
int main() {
	int n;
	scanf("%d",&n);
	int sum=0;
	for(int i=1; i<=n; ++i) {
		scanf("%1d",&a[i]);
		sum+=a[i];
	}
	if(sum>1) {
		ll cut0=0,cut2=0;
		for(int i=1; i<=n; ++i) {
			if(a[i]==1) {
				cut0=(cut0+quick(2,n-i,sum-1))%(sum-1);
				cut2=(cut2+quick(2,n-i,sum+1))%(sum+1);
			}
		}
		for(int i=1; i<=n; ++i) {
			ll ans=0;
			int cut=1;
			if(a[i]==0) {
				ans+=cut2;
				ans=(ans+quick(2,n-i,sum+1))%(sum+1);
			} else {
				ans+=cut0;
				ans=(ans-quick(2,n-i,sum-1)+(sum-1))%(sum-1);
			}
			while(ans>0) {
				ans=ans%__builtin_popcount(ans);
				cut++;
			}
			printf("%d\n",cut);
		}
	} else if(sum==0) {
		for(int i=1; i<=n; ++i) {
			printf("1\n");
		}
	} else {
		for(int i=1; i<=n; i++) {
			if(a[i]==1) {
				printf("0\n");
			} else {
				if(a[n]==1||i==n)printf("2\n");
				else printf("1\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4540
n = int(input())
l = sorted(map(int, input().split()))
c = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] != l[j] != l[k] and l[i] + l[j] > l[k]:
                c += 1
print(c)

Measured memory_bytes: 9184
#include <iostream>

typedef long long ll;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);

  int N;  std::cin >> N;
  std::cout << (1000 - (N % 1000)) % 1000 << "\n";
  

  return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>

int main()
{
  int arr[10000];
  int count=0;
  int n;
  int a=0;
  scanf("%d", &n);
  arr[count] = n;
  count++;
  while(n != 0)
    {
      scanf("%d", &n);
      arr[count] = n;
      count++;
    }
  while(a+1 < count)
    {
      printf("Case %d: %d\n", a+1, arr[a]);
      a++;
    }
  return 0;
}


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

int main() {
	vector<int> v;
	int t = 0;
	for (int i = 0; i < 5; ++i) {
		int tmp;
		cin >> tmp;
		if (tmp % 10 == 0) {
			t += tmp;
		} else {
			v.push_back(tmp);
		}
	}
	sort(v.begin(), v.end(), [](const int& x, const int& y){return x % 10 > y % 10;});
	for (size_t i = 0; i < v.size(); ++i) {
		t += v[i];
		if (t % 10 != 0 && i != v.size() -1) t = ((t / 10) + 1) * 10;
	}
	cout << t << endl;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int>a(M);
  if (N >= M) cout << 0 << endl;
  else {
    for (int i = 0; i < M; i++) cin >> a[i];
    sort(a.begin(), a.end());
    vector<int>dif(M - 1);
    for (int i = 0; i < M - 1; i++) {
      dif[i] = a[i + 1] - a[i];
    }
    sort(dif.begin(), dif.end(), greater<int>());
    int ans = 0;
    for (int i = N - 1; i < M - 1; i++) ans += dif[i];
    cout << ans << endl;
  }
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
	/*
	偶数 2N
	・N,N,0
	・N,x,y (x,y != 0)
	・N + 1 以上,x,y
	奇数 2N+1
	・N + 1 以上,x,y
	をそれぞれ３倍。
	*/

	int N;
	cin >> N;
	vector<int>A(N);
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sum += A[i];
	}
	mint ans = 1;
	for (int i = 0; i < N; ++i) {
		ans *= 3;
	}
	vector<vector<mint>> dp(N + 1, vector<mint>(2 * sum + 1));
	dp[0][0] = 1;
	vector<vector<mint>> dp2(N + 1, vector<mint>(2 * sum + 1));
	dp2[0][0] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= sum; ++j) {
			dp[i + 1][j + A[i]] += dp[i][j];
			dp[i + 1][j] += dp[i][j] * 2;

			dp2[i + 1][j + A[i]] += dp2[i][j];
			dp2[i + 1][j] += dp2[i][j];
		}
	}

	for (int i = sum / 2 + 1; i <= sum; ++i) {
		ans -= mint(3)*dp[N][i];
	}
	if (0 == sum % 2) {
		ans -= (mint)3 * dp2[N][sum / 2];
		ans -= (mint)3 * (dp[N][sum / 2] - (mint)2 * dp2[N][sum / 2]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 849112
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it = (c).begin(); it != (c).end(); it++)
#define I first
#define O second

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 1000;

int calc(int, int);

int main(void){
    for(int n, res; cin >> n, n; cout << res << endl){
        pii god = mp(INF, 0);
        vi ent(N), ttl(N);
        string cur_d;

        while(n--){
            int h = 0, m = 0, p;
            char e;
            string MD, in;
            cin >> MD >> in >> e >> p;

            rep(i, 2) h += (in.at(i) - '0') * (int)pow(10., 1. - i);
            rep(i, 2) m += (in.at(i + 3) - '0') * (int)pow(10., 1. - i);

            if(MD != cur_d){
                cur_d = MD;
                god = mp(INF, 0);
            }
            int cur = calc(h, m);
            if(e == 'I'){
                if(p) ent[p] = cur;
                else{
                    COUNT(i, N - 1){
                        if(ent[i] && god.O != INF){
                            int del = god.O - max(god.I, ent[i]);
                            if(del > 0) ttl[i] += del;
                            ent[i] = cur;
                        }
                    }
                    
                    god.I = cur;
                    god.O = INF;
                }
            }
            else{
                if(p){
                    int del = min(god.O, cur) - max(god.I, ent[p]);
                    if(del > 0) ttl[p] += del;
                    ent[p] = 0;
                }
                else god.O = cur;
            }
        }
        res = *max_element(ALL(ttl));
    }

    return 0;
}

int calc(int h, int m){
    return 60 * h + m;
}

Measured memory_bytes: 1244
import math
N = int(input())
XY = [[int(x) for x in input().split()] for _ in range(N)]
s = 0
for i in range(N):
    for j in range(i+1, N):
        xi, yi = XY[i]
        xj, yj = XY[j]
        s += (math.sqrt((xi-xj)**2 + (yi-yj)**2))
print(2*s/N)


Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
  int n;
  cin>>n;
  vi h(n);
  rep(i,n)cin>>h[i];
  vi dp(n);
  dp[1]=abs(h[1]-h[0]);
  Rep(i,2,n)dp[i]+=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  cout<<dp[n-1];
}


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

void insertionSort(int A[], int N)
{
  int v, j;
  for(int i = 1; i < N; i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    for(int k = 0; k < N; k++)
      if(k)
	cout << " " << A[k];
      else
	cout << A[k];
    cout << endl;
  }
}
  
int main()
{
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++)
    cin >> A[i];
  for(int i = 0; i < N; i++)
    if(i)
      cout << " " << A[i];
    else
      cout << A[i];
  cout << endl;
  insertionSort(A, N);
}

Measured memory_bytes: 1164
import java.util.Scanner;

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

		int n = sc.nextInt();
		int y = sc.nextInt();

		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n - i; j++) {
				int k = n - i - j;
				if (10000 * i + 5000 * j + 1000 * k == y) {
					System.out.println(i + " " + j + " " + k);
					return;
				}
			}
		}

		System.out.println("-1 -1 -1");
	}

}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int a[MAX_N],b[MAX_N];

int main(){
  int N; cin >> N;
  rep(i,N) scanf("%d",a+i);
  copy(a,a+N,b);
  sort(b,b+N);
  int ans = 0;
  rep(i,N){
    int ind = int(lower_bound(b,b+N,a[i])-b);
    if(i%2==1 && ind%2==0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
    int N, K, d, index;
    int A[101] = {0};
    int ans=0;
    scanf("%d%d",&N,&K);
    for(int i=0;i<K;i++){
        scanf("%d",&d);
        for(int j=0;j<d;j++){
            scanf("%d",&index);
            A[index-1]++;
        }
    }
    for(int i=0;i<N;i++){
        if(A[i]==0){
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;
typedef long long LL;

int main(void) {
	double r, g, ans;
	cin >> r >> g;

	cout << (g * 2) - r << endl;
	return 0;
}

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

int main(){
double x, y;   
int i;
char array[3];
std::string str;  //  string 型のオブジェクト str の宣言
for ( i= 0;i<3 ; i++){
    cin >> str;
    array[i] = str[0];
}
cout << array[0]<<array[1]<<array[2];
return 0;
}

Measured memory_bytes: 256