akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		char[] str = s.toCharArray();
		sc.close();

		int[] cnt = new int[n + 2];
		boolean flg = false;
		int idx = 0;
		for (int i = 0; i < n; i++) {
			if (flg) {
				if (str[i] == '.') {
					idx++;
					flg = !flg;
				}
			} else {
				if (str[i] == '#') {
					idx++;
					flg = !flg;
				}
			}
			cnt[idx]++;
		}
		if (idx % 2 == 0) {
			idx++;
		}

		int[] sum = new int[idx + 1];
		sum[0] = cnt[0];
		sum[1] = cnt[1];
		for (int i = 2; i <= idx; i++) {
			sum[i] = sum[i - 2] + cnt[i];
		}

		int ans = Integer.MAX_VALUE;
		for (int i = 0; i <= idx; i++) {
			if (i % 2 == 0) {
				int w = sum[idx - 1] - sum[i];
				int b = 0;
				if (i > 0) {
					b = sum[i - 1];
				}
				ans = Math.min(ans, w + b);
			} else {
				int w = sum[idx - 1] - sum[i - 1];
				int b = sum[i];
				ans = Math.min(ans, w + b);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 30000
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);

    bool overflow = false;

    ll res = 1LL;
    vector<ll> A(N);
    for(int i=0; i<N; i++) {
        scanf("%lld", &A[i]);
        if(A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    const ll LIM = 10000LL * 10000LL * 10000LL * 10000LL * 100LL;
    for(int i=0; i<N; i++) {
        overflow |= __builtin_mul_overflow(res, A[i], &res);
        overflow |= (res > LIM);
    }
    if(overflow) cout << -1 << endl;
    else cout << res << endl;
    return 0;
}


Measured memory_bytes: 4076
while True:
    h,w = map(int,input().split())
    if (h == 0) & (w == 0):
        break
    else:
        for i in range(w):
            print("#",end="")
        print( sep = '\n')
        for j in range( h-2 ):
            print("#",end="")
            for k in range(w-2):
                print(".",end="")
            print("#")
        for l in range(w):
            print("#",end="")
        print()
        print(sep = '\n')




Measured memory_bytes: 7004
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int main(void) {
  int x,y;
  scanf("%d%d", &x, &y);
  int res = 0;
  if(x == 1) res += 300000;
  if(x == 2) res += 200000;
  if(x == 3) res += 100000;
  if(y == 1) res += 300000;
  if(y == 2) res += 200000;
  if(y == 3) res += 100000;
  if(x == 1 && y == 1) res += 400000;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 888
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};
use std::collections::BTreeMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }
    a.sort();
    let mut nokori_kosuu: BTreeMap<usize, usize> = BTreeMap::new();
    for &ai in &a {
        if let Some(e) = nokori_kosuu.get_mut(&ai) {
            *e += 1;
        } else {
            nokori_kosuu.insert(ai, 1);
        }
    }
    let mut num_pairs = 0;
    for i in (0..n).rev() {
        let ai = a[i];
        if *nokori_kosuu.get(&ai).unwrap() == 0 {
            continue;
        }
        *nokori_kosuu.get_mut(&ai).unwrap() -= 1;
        let mut nibeki = 1;
        while nibeki <= ai {
            nibeki *= 2;
        }
        let aikata = nibeki - ai;
        if let Some(&c) = nokori_kosuu.get(&aikata) {
            if c != 0 {
                num_pairs += 1;
                *nokori_kosuu.get_mut(&aikata).unwrap() -= 1;
            }
        }
    }
    println!("{}", num_pairs);
}


Measured memory_bytes: 12804
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]

def calc(D, s, t):
  last = [0 for _ in range(26)]
 
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
    print(value)
calc(D, s, t)

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

using namespace std;

const int MOD = 998244353;

int main(){
    const int maxSize = 2000001;
	vector<long long> inv(maxSize);
	vector<long long> fact(maxSize);
	vector<long long> factInv(maxSize);
	for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1;
	for(int i=2;i<maxSize;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fact[i] = fact[i-1] * i % MOD;
		factInv[i] = factInv[i-1] * inv[i] % MOD;
	}
	auto comb = [&](int n, int r){
		if(n < r || r < 0) return 0LL;
		return fact[n] * factInv[n-r] % MOD * factInv[r] % MOD;
	};
    auto perm = [&](int n, int r){
        if(n < r || r < 0) return 0LL;
        return fact[n] * factInv[n-r] % MOD;
    };
    int N, M; cin >> N >> M;
    long long res = 0;
    for(int m=0;2*m<=M;m++){
        int m2 = M + m;
        int m1 = M - 2*m;
        if(m1 > N) continue;
        res = (res + comb(m2+N-1, N-1) * comb(N, m1)) % MOD;
        if(m1 > 0){
            res = (res + MOD - (comb(m2-M+N-2, N-2) * comb(N-1, m1-1)) % MOD * N % MOD) % MOD;
        }
        if(m2 >= M+1){
            res = (res + MOD - (comb(m2-M-1+N-1, N-1) * comb(N, m1)) % MOD * N % MOD) % MOD;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 47104
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g




n,k = map(int,input().split())

if k==1:
    print(0)
else:
    print(n-k)









Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double ans=0;
    while(n--)
    {
        double a;
        cin>>a;
        ans +=1.0/a;
    }
    ans = 1.0/ans;
    cout<<setprecision(16)<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,l;
  cin>>n>>m>>l;
  int a[n][m],b[m][l];
  for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin>>a[i][j];
  for (int i = 0; i < m; ++i) for (int j = 0; j < l; ++j) cin>>b[i][j];
  for (int i = 0; i < n; ++i){
    for (int j = 0; j < l; ++j){
      long long s=0;
      for (int k = 0; k < m; ++k) s+=(long long)a[i][k]*b[k][j];
      cout<<(j?" ":"")<<s;
    }
    cout<<endl;
  }
}


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

const int MOD = 1000000007;


int gcd(int a, int b) {
    if (b==0) return a;
   	else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}


int main(){
	ll A,B,C;
	cin>>A>>B>>C;
	
	if(A%2==1&&B%2==1&&C%2==1) cout<<min((min(A*B,B*C)),C*A)<<endl;
	else cout<<0<<endl;
	
	return 0;
}

Measured memory_bytes: 256
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let a: isize;
    let b: isize;
    let c: isize;
    let mut x: isize;
    let mut y: isize;
    let mut r = 0;
    input!(a, b, c, x, y);
    r += x * a + y * b;
    loop {
        let mut rbuf = r;
        if x > 0 {
            rbuf -= a;
            x -= 1;
        }
        if y > 0 {
            rbuf -= b;
            y -= 1;
        }
        rbuf += 2 * c;
        if rbuf >= r {
            break;
        }
        r = rbuf;
    }
    println!("{}", r);
}

Measured memory_bytes: 4352
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int A,B,C;
		A = nextInt();
		B = nextInt();
		C = nextInt();

		int res = Math.max(B+C-A,0);
		out.println(res);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int n;
  cin >> n;
  n %= 10;

  if(n == 0) cout << "pon" << endl;
  if(n == 1) cout << "pon" << endl;
  if(n == 2) cout << "hon" << endl;
  if(n == 3) cout << "bon" << endl;
  if(n == 4) cout << "hon" << endl;
  if(n == 5) cout << "hon" << endl;
  if(n == 6) cout << "pon" << endl;
  if(n == 7) cout << "hon" << endl;
  if(n == 8) cout << "pon" << endl;
  if(n == 9) cout << "hon" << endl;

  return 0;
}


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

int main() {
  int K, S, ans;
  cin >> K >> S;
  for(int x=0; x<=K; x++) {
    for(int y=0; y<=K; y++) {
      if(S-x-y<=K&&0<=S-x-y) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    int n,m,a,b,c,d[2000][2000],INF=1e9,A[200001][3];
    cin>>n>>m;
    rep(i,n)rep(j,n) d[i][j]=INF;
    rep(i,m) cin>>a>>b>>c,d[a-1][b-1]=c,d[b-1][a-1]=c,A[i][0]=a-1,A[i][1]=b-1,A[i][2]=c;
    rep(i,n)rep(j,n)rep(k,n) d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
    int ans=0;
    rep(i,m) if(d[A[i][0]][A[i][1]]!=A[i][2]) ans++;
    cout<<ans;
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
    int n,a[100]={0};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int j=n-1;
    cout<<a[j];
    
    for(int i=0;i<n-1;i++){
        j=n-1-i;
        cout<<" "<<a[j-1];
    }
    cout<<endl;
    
}


Measured memory_bytes: 3080
#include<iostream>
using namespace std;
int main(){
    int n,m,i,j,a,k,b,l,p,q;
    cin>>n >>m;
    int ai[n][m];
    for(int t=1;t<=n;t++){
        for(int u=1;u<=m;u++){
            ai[t-1][u-1]=0;
        }
        
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            cin>>a;
            ai[i-1][j-1]=a;
        }
        
    }
    int bi[m];
    for(int u=1;u<=m;u++){
            bi[u-1]=0;
        
    
    }
    for(k=1;k<=m;k++){
        cin>>b;
        bi[k-1]=b;
    }
    int ci[n];
    for(int u=1;u<=n;u++){
        ci[u-1]=0;
    }
    for(l=1;l<=n;l++){
        for (p=1;p<=m;p++){
            ci[l-1]+=ai[l-1][p-1]*bi[p-1];
        }
    }
    for(q=1;q<=n;q++){
        cout<<ci[q-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int A[n], B[n], C[n];
    for(int i = 0; i < n;i++)
    {
        cin >> A[i] >> B[i] >> C[i];
    }    
    long long dp[n][3];
    dp[0][0] = A[0];
    dp[0][1] = B[0];
    dp[0][2] = C[0];
    for(int i = 1; i < n;i++)
    {
        dp[i][0] = A[i] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = B[i] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = C[i] + max(dp[i-1][1],dp[i-1][0]);
    }
    long long result = 0;
    for(int i = 0; i< 3;i++)
    {
        result = max(result, dp[n-1][i]);
    }
    cout << result << endl;
} 

Measured memory_bytes: 3712
import java.util.Scanner;

//CatChecker
public class Main{

	char[] s;
	int id;
	char get(){
		return s[id++];
	}
	
	void f(){
		char ch = get();
		if(ch!='m'){
			id--; return;
		}
		f();
		ch = get();
		if(ch!='e'){
			id--; return;
		}
		f();
		ch = get();
		if(ch!='w'){
			id--; return;
		}
		return;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		s = (sc.next()+"$").toCharArray();
		id = 0;
		f();
		System.out.println(s[id]=='$'?"Cat":"Rabbit");
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>N;
    vec h(N);
    rep(i,N) cin>>h[i];
    ll canw = 0, ans = 0;
    rep(i,N){
        if(canw < h[i]) ans += h[i] - canw;
        canw = h[i];
    }
    cout<<ans<<endl;
}


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

int mojikazoeru(string a,char b){
  int l=a.size();
  int ikutu = 0;
  for(int i=0;i<l;i++){
    if(a[i] == b) ikutu++;
  }
  return ikutu;
}

int main(){
  string s;
  cin >>s;
  int ans=mojikazoeru(s,'o');
  cout << 700+100*ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 500010;
int n, q;
char s[N];
int BIT[N][26];
int lowbit(int x) {
	return x & (-x);
}
void add(int x, int c, int v) {
	while (x <= n) {
		BIT[x][c] += v;
		x += lowbit(x);
	}
}
int ask(int x, int c) {
	int ret = 0;
	while (x) {
		ret += BIT[x][c];
		x -= lowbit(x);
	}
	return ret;
}
int main() {
	cin >> n;
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i++) {
		add(i, s[i] - 'a', 1);
	}
	cin >> q;
	while (q--) {
		int opt;
		cin >> opt;
		if (opt == 1) {
			int x;
			char c;
			cin >> x >> c;
			add(x, s[x] - 'a', -1);
			s[x] = c;
			add(x, s[x] - 'a', 1);
		} else {
			int x, y;
			cin >> x >> y;
			int ans = 0;
			for (int i = 0; i < 26; i++) {
				ans += (ask(y, i) - ask(x - 1, i) > 0);
			}
			cout << ans << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 55012
function Main(input) {
    var S = input[0];
    var length = S.length - 2;

    var F = S.charAt(0);
    var L = S.charAt(S.length - 1);
    console.log(F + length + L);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
/* Life is all about calculated risks.
    But man am I bad at math. */

#include <bits/stdc++.h> 
#define ll long long int
#define INF (ll)1e12
#define MOD 1000000007

#define DEBUG(x) cerr<<"> "<< #x << ':' <<x<<endl;

using namespace std;

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

    ll n,m;
    cin>>n>>m;

    cout<<(n*(n-1))/2 + (m*(m-1))/2<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

string s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    string las;
    int ans = 0;
    string cur;
    for(auto &i : s){
        cur += i;
        if(cur == las) continue;
        ans++;
        las = cur;
        cur = "";
    }
    cout << ans << endl;
}


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

typedef long long ll;

int a[200005],num[200005];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (int i = 1; i <= k; i++)
	{
		ll tot = 0;
		int flag = 0;
		for (int j = 1; j <= n; j++) num[j] = 0;
		for (int j = 1; j <= n; j++)
		{
			num[max(1,j-a[j])] ++;
			num[min(j+a[j]+1,n+1)] --;
		}
		for (int j = 1; j <= n; j++)
		{
			tot += num[j];
			if( tot != n ) flag = 1;
			a[j] = tot;
		}
		if( flag == 0 ) break;
	}
	for (int i = 1; i <= n; i++)
	{
		cout << a[i];
		if( i == n ) cout << '\n';
		else cout << ' ';
	}
	return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0, inf = 0;
  map<int, map<int, map<int, int>>> m;
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
    int ta = b / 2 + c / 2;
    int tb = a / 2 + c / 2;
    int tc = b / 2 + a / 2;
    a = ta;
    b = tb;
    c = tc;
    if (m[a][b][c]) {
      inf = 1;
      break;
    }
    m[a][b][c] = 1;
    ans++;
  }
  if (inf) cout << -1 << '\n';
  else cout << ans << '\n';
}


Measured memory_bytes: 3612
////
////  main.cpp
////  L2-005
////
//
#include <cstring>
#include <vector>
#include <iostream>
#include <unordered_map>
#include<algorithm>
#include <set>
#include <list>
#include<stdio.h>
using namespace std;
int main(){
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin>>K;
    cout<<a[K-1]<<endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    
    cout << a*b/2 << endl;
 
    
    return 0;
}



Measured memory_bytes: 256
import numpy as np
limit = 10**5
def Eratosthenes(limit):
	is_prime = np.full(limit+1, True)
	is_prime[:2] = False
	for p in range(2,limit+1):
		if p**2 > limit:
			break
		if is_prime[p]:
			is_prime[p**2::p] = False

	return is_prime

is_prime = Eratosthenes(limit)

fullfill = np.zeros(limit+1,np.int32)

for p in range(limit+1):
	if p*2+1 > limit:
		break
	elif is_prime[p] and is_prime[2*p-1]:
		fullfill[2*p-1] = 1

ans = np.cumsum(fullfill)

Q = int(input())
A = []
for _ in range(Q):
	l,r = map(int, input().split())
	A.append(ans[r]-ans[l-1])

print(*A)

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

const int N = 200005, Tlg = 36;
const long long inf = 1e17;
int n, t, x, y, ni, m, fp;
vector<pair<long double, pair<int, int> > > v;
vector<int> ve;
long long dp[N][Tlg], nb[N];
bool bn;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> t;
	for(int i = 0; i <= n; ++i) {
		if(i) cin >> x >> y;
		else x = 1000000001, y = 0;
		if(x) v.push_back({(long double)x / (y + 1), {x, y}});
		else ve.push_back(y);
	}
	m = v.size(); --m;
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for(int i = 1; i < Tlg; ++i) dp[0][i] = -1;
	for(int i = 1; i < v.size(); ++i) {
		for(int j = 1; j < Tlg; ++j) {
			dp[i][j] = min((dp[i - 1][j - 1] == -1 ? inf : (dp[i - 1][j - 1] + 1 + (dp[i - 1][j - 1] + 1) * v[i].second.first + v[i].second.second)), (dp[i - 1][j] == -1 ? inf : dp[i - 1][j]));
			if(dp[i][j] > t) dp[i][j] = -1;
			//if(dp[i][j] == inf) dp[i][j] = -1;
		}
	}
	sort(ve.begin(), ve.end());
	for(int i = 0; i < ve.size(); ++i) {
		++ni;
		nb[ni] = nb[ni - 1] + 1 + ve[i];
	}
	for(int i = 0; i < Tlg; ++i) {
		if(dp[m][i] != -1) {
			for(int j = 0; j <= ni; ++j) {
				if(dp[m][i] + nb[j] <= t) {
					fp = max(fp, i + j);
				}
			}
		}
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 64360
n = int(input())
a = list(map(int, input().split())) + [10**9]
b = [0] + a

if  all(a[k] >= b[k] for k in range(n + 1)):
    print(0)
    exit()

s = [0] * n
for i in range(1, n):
    if a[i - 1] - a[i] >= 1:
        s[i] = a[i - 1] - a[i]
        a[i] = a[i - 1]
print(sum(s))


Measured memory_bytes: 33176
n = int(input())
h = list(map(int, input().split()))
dp = [10 ** 9] * n
dp[0] = 0
for i in range(1, n):
    for j in range(max(i - 2, 0), i):
        dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]))
print(dp[-1])

Measured memory_bytes: 20556
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n:i64 = read();
    let mut an = read_vec::<i64>();
    let res = an.into_iter().fold(0,|ans,x| ans + solve(x, 0));
    println!("{}",res );
}

fn solve(x:i64,ans:i64)-> i64{
    if x % 2 != 0{
        ans
    } else {
        solve(x/2, ans+1)
    }
}

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	xy := make([]int, 0)
	xy2 := make([]int, 0)
	for i := 0; i < n; i++ {
		x := getNextInt(scanner)
		y := getNextInt(scanner)
		xy = append(xy, x+y)
		xy2 = append(xy2, x-y)
	}
	sort.Ints(xy)
	sort.Ints(xy2)
	ans := xy[n-1] - xy[0]
	if ans < xy2[n-1]-xy2[0] {
		ans = xy2[n-1] - xy2[0]
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 14844
#include <iostream>

int main()
{
  int n, m, x, c[20], a[20][20], i, j, tmin;
  int num, r[20], k, total;

  std::cin >> n >> m >> x;
  for (i = 0; i < n; i++)
  {
    std::cin >> c[i];
    for (j = 0; j < m; j++)
    {
      std::cin >> a[i][j];
    }
  }

  num = 1;
  for (i = 0; i < n; i++)
  {
    num = num * 2;
  }
  // std::cout << num << std::endl;
  int ans = 100000000;
  int level[20];
  for (int pattern = 0; pattern < num; pattern++)
  {
    int cost = 0;
    for (int j = 0; j < m; j++)
    {
      level[j] = 0;
    }
    for (int i = 0; i < n; i++)
    {
      if ((pattern >> i) & 1)
      {
        cost += c[i];
        for (int j = 0; j < m; j++)
        {
          level[j] += a[i][j];
        }
      }
    }
    bool ok = true;
    for (int j = 0; j < m; j++)
    {
      if (level[j] < x)
      {
        ok = false;
      }
    }
    if (ok)
    {
      ans = std::min(ans, cost);
    }
  }
  if (ans == 100000000)
  {
    std::cout << -1 << std::endl;
  }
  else
  {
    std::cout << ans << std::endl;
  }
}

Measured memory_bytes: 3640
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      while(n >= k){
      	n = n-k;
      }
      if(n == 0) System.out.println(0);
      else System.out.println(1);
    }
}


Measured memory_bytes: 21844
N = int(input())
Range = []
for _ in range(N):
    X,L = map(int,input().split())
    Range.append([X-L,X+L])
counter = N
Range = sorted(Range,key=lambda x : x[1])
for i in range(1,N):
    if  Range[i - 1][1] > Range[i][0] :
        Range[i][1] = Range[i-1][1]
        counter -=1
print(counter)


Measured memory_bytes: 22104
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

//gcd(int)
int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

int main() {
    int N;
    cin >> N;
    // B[i]:A[0]～A[i]  のgcd
    // C[i]:A[i]～A[N-1]のgcd
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    B[0] = A[0];
    C[N - 1] = A[N - 1];
    for (int i = 1; i < N; i++)
    {
        B[i] = gcd(B[i - 1], A[i]);
        C[N - i - 1] = gcd(C[N - i], A[N - i - 1]);
    }
    int M = 0; //求める最大値
    // 1つ選んで好きな数字に変える → 1つ選んでその数字以外のgcd
    // 選ぶ1つを探索
    for (int i = 0; i < N; i++)
    {
        if (i == 0) {
            // 左端
            M = max(M, C[1]);
        }
        else if (i == N - 1) {
            // 右端
            M = max(M, B[N - 2]);
        }
        else {
            M = max(M, gcd(B[i - 1], C[i + 1]));
        }
    }
    cout << M << endl;
    getchar(); getchar();
    return 0;
}

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

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

  int r,t;
  for(int i = 0;i < n;i++){
    cin >> r >> t;

    if(r % 100 == 0){
      cout << r/100 + 5*(t/30);
      if(t % 30 != 0){
        cout << " " << r/100+5*(t/30+1);
      }
      cout << endl;
    }else{
      cout << r/100   + 5*(t/30)   << " ";
      cout << r/100+1 + 5*(t/30);
      if(t % 30 != 0){
        cout << " " << r/100   + 5*(t/30+1) << " ";
        cout << r/100+1 + 5*(t/30+1);
      }
      cout << endl;

    }
  }

  return 0;
}




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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

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

  double d;
  while (IN(d), d >= 0) {
    string s = "";

    for (double i = 128; i > 0.06; i /= 2) {

      if (d >= i) {
        s += '1';
        d -= i;
      }
      else s += '0';

      if (i == 1) s += '.';
    }

    OUTL(d ? "NA" : s);
  }

  return 0;
}



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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, int> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

struct Item {
    ll weight, value;
};

int main() {
    int n;
    ll w;
    cin >> n >> w;
    vector<Item> items(n);
    rep(i, n) cin >> items[i].weight >> items[i].value;

    vector<map<ll, ll>> dp(n + 1);

    auto set = [&](int i, ll weight, ll value) {
        if (weight > w) return;
        if (dp[i].find(weight) == dp[i].end()) dp[i][weight] = value;
        else
            cmax(dp[i][weight], value);
    };
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        Item item = items[i];
        for (auto &e : dp[i]) {
            set(i + 1, e.first, e.second);
            set(i + 1, e.first + item.weight, e.second + item.value);
        }
    }

    ll ans = 0;
    for (auto e:  dp.back()) {
        cmax(ans, e.second);
    }
    cout << ans << endl;

}


Measured memory_bytes: 6400
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

void add_edge(VVI& graph, int u, int v){
  graph[u].push_back(v);
  graph[v].push_back(u);
}

bool dfs(VVI& biG, VI& match, int v, vector<bool>& used){
  used[v] = true;
  for(int i=0;i<biG[v].size();++i){
	int u = biG[v][i], w = match[u];
	if(w < 0 || (!used[w] && dfs(biG, match, w, used))){
	  match[v] = u;
	  match[u] = v;
	  return true;
	}
  }
  return false;
}

int bipartite_matching(VVI& biG, VI& match){
  int res = 0;
  int V = SZ(biG);
  fill(ALL(match), -1);
  for(int v=0;v<V;++v){
	if(match[v] < 0){
	  vector<bool> used(V, false);
	  if(dfs(biG, match, v, used))
		++res;
	}
  }
  return res;
}

int dist(PII& p1, PII& p2){
  int dx = p1.first - p2.first;
  int dy = p1.second - p2.second;
  return dx*dx+dy*dy;
}

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

  int N, M;
  while(cin>>N>>M,N){
	vector<PII> tr(N), base(M);
	VI vs(N);
	REP(i,N) cin >> tr[i].first >> tr[i].second >> vs[i];
	REP(i,M) cin >> base[i].first >> base[i].second;

	double lb = 0., ub = 1e9;
	REP(tt,100){
	  double mid = (lb + ub) / 2.;
	  VVI G(N+M);
	  REP(i,N) REP(j,M){
		if(sqrt(dist(tr[i], base[j])) <= mid*vs[i]){
		  add_edge(G, i, N+j);
		}
	  }
	  VI m(N+M);
	  if(bipartite_matching(G, m) == M)
		ub = mid;
	  else
		lb = mid;
	}
	cout << fixed << setprecision(9) << lb << endl;
  }
  
  return 0;
}

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

using namespace std;
using ll = long long;

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

    string s;cin >> s;
    int F = stoi(s.substr(0,2));
    int S = stoi(s.substr(2,2));
    bool f1 = false;
    if(1 <= F && F <= 12)f1 =true;
    bool f2 = false;
    if(1 <= S && S <= 12)f2 =true;
    if(f1 && f2){
        cout<<"AMBIGUOUS"<<endl;
    }else
    if(f1){
        cout<<"MMYY"<<endl;
    }else
    if(f2){
        cout<<"YYMM"<<endl;
    }else{
        cout<<"NA"<<endl;
    }

}


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

namespace ABC070_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var A = int.Parse(input[0]);
            var B = int.Parse(input[1]);
            var C = int.Parse(input[2]);
            var D = int.Parse(input[3]);


            if (B <= D && B >= C)
            {
                if (A >= C)
                {
                    Console.WriteLine(B - A);
                    return;
                }
                else
                {
                    Console.WriteLine(B - C);
                    return;
                }
            }
            else if (D < B && D >= A)
            {
                if (C >= A)
                {
                    Console.WriteLine(D - C);
                    return;
                }
                else
                {
                    Console.WriteLine(D - A);
                    return;
                }
            }
            Console.WriteLine(0);
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int a; cin >> a;
    int ans = a + a*a + a*a*a;
    cout << ans << endl;
    return 0;
}

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

int N;
int K;

const int INF = 1e9 + 5;

int main() {

    cin >> N;
    cin >> K;

    vector <int> heights(N);

    for (int& height : heights) {
        cin >> height;
    }


    vector <int> dp(N, INF);

    dp[0] = 0;

    for (int i = 0; i < N; i++) {


        for (int j = 1; j<= K; j++) {
        if (i + j < N)
            dp[i + j] = min(dp[i + j], dp[i] + abs(heights[i +j] - heights[i]));
        }
    }

    cout << dp[N - 1];
}

Measured memory_bytes: 4044
//
// Created by hide on 2020/05/15.
//

//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define PRINT(message) cout<<message<<endl //10^5:配列の最大のrange(素数列挙などで使用)

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
//#define PB push_back //vectorヘの挿入
//#define MP make_pair //pairのコンストラクタ
//#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素
int D, G;
int answer = std::numeric_limits<int>::max();
vector<int> p, c;

unordered_map<int, int> mp;

int main(){
    int n;
    cin>>n;
    int a[n+2];
    a[0]=0;
    a[n+1]=0;
    FOR(i,0,n) cin>>a[i+1];
    int sum[n+2];
    sum[0]=0;
    FOR(i,0,n+1){
        sum[i+1]=sum[i]+abs(a[i+1]-a[i]);
    }

    int sum2[n+2];
    sum2[0]=0;
    FOR(i,0,n+1){
        sum2[i+1]=sum2[i]+abs(a[n+1-i]-a[n-i]);
    }

    FOR(i,1,n+1){
        cout<<sum[i-1]+sum2[n-i]+abs(a[i-1]-a[i+1])<<endl;
    }
}

Measured memory_bytes: 2432
x,y,a,b,c=map(int,input().split())
la=list(map(int,input().split()))
lb=list(map(int,input().split()))
lc=list(map(int,input().split()))
la=sorted(la,reverse=True)
lb=sorted(lb,reverse=True)
lc=sorted(lc,reverse=True)
for i in range(a-x):
    la.pop(-1)
for j in range(b-y):
    lb.pop(-1)
l=[]
for ii in range(x):
    l.append(la[ii])
for jj in range(y):
    l.append(lb[jj])
for kk in range(c):
    l.append(lc[kk])
l=sorted(l,reverse=True)
print(sum(l[0:x+y]))


Measured memory_bytes: 120044
#include <iostream>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

using State=vector<stack<int>>;
struct Scene{
	State state;
	int prev_from;
	int prev_to;
	int count;
	Scene(State state, int prev_from, int prev_to, int count) : 
		state(state), prev_from(prev_from), prev_to(prev_to), count(count){}
};

void enqueue(queue<Scene>& scene, Scene& s, int from, int to){
	if(s.prev_from==to && s.prev_to==from) return;
	if(s.state[from].empty()) return;
	if(!s.state[to].empty() && s.state[from].top()<s.state[to].top()) return;
	State t;
	copy(s.state.begin(), s.state.end(), back_inserter(t));
	t[to].push(t[from].top()); t[from].pop();
	scene.push(Scene(t, from, to, s.count+1));
}

void dump(Scene& s){
	cout << "--------------------------------------------------\n";
	cout << s.prev_from << "|" << s.prev_to << "|" << s.count << "\n";
	State t;
	copy(s.state.begin(), s.state.end(), back_inserter(t));
	while(!t[0].empty()){ cout << t[0].top() << ", "; t[0].pop(); } cout << "\n";
	while(!t[1].empty()){ cout << t[1].top() << ", "; t[1].pop(); } cout << "\n";
	while(!t[2].empty()){ cout << t[2].top() << ", "; t[2].pop(); } cout << "\n";
	cout << "--------------------------------------------------\n";
}

int solve(State init, int m){
	queue<Scene> scene;
	scene.push(Scene(init, -1, -1, 0));
	while(!scene.empty()){
		auto s=scene.front();
		//dump(s);
		if(s.state[1].empty() && (s.state[0].empty() || s.state[2].empty())){
			return s.count;
		}
		if(s.count>m) return -1;
		enqueue(scene, s, 0, 1);
		enqueue(scene, s, 1, 0);
		enqueue(scene, s, 1, 2);
		enqueue(scene, s, 2, 1);
		scene.pop();
	}
	return -1;
}

int main(){
	while(true){
		int n, m; cin >> n >> m;
		if(n==0 && m==0) break;
		State s;
		for(int i=0; i<3; ++i){
			s.push_back(stack<int>());
			int x; cin >> x;
			for(int j=0; j<x; ++j){
				int y; cin >> y;
				s[i].push(y);
			}
		}
		cout << solve(s, m) << "\n";
	}
	return 0;
}




Measured memory_bytes: 3132
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;

long long sum(long long x) {
  long long ret = 0;
  while(x > 0) {
    ret += x % 10;
    x /= 10;
  }
  return ret;
}

int main() {
  long long n;
  cin >> n;
  if(n % sum(n) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[][][] house = new int[4][3][10];
		for (int i = 0; i < house.length; i++) {
			for (int j = 0; j < house[0].length; j++) {
				for (int k = 0; k < house[0][0].length; k++) {
					house[i][j][k] = 0;
				}

			}
		}

		String line1 = sc.nextLine();
		int n = Integer.parseInt(line1);

		for (int i = 0; i < n; i++) {
			String line2 = sc.nextLine();
			String[] array = line2.split(" ");
			int b = Integer.parseInt(array[0]) - 1;
			int f = Integer.parseInt(array[1]) - 1;
			int r = Integer.parseInt(array[2]) - 1;
			int v = Integer.parseInt(array[3]);

			house[b][f][r] += v;

		}

		for (int i = 0; i < house.length; i++) {
			for (int j = 0; j < house[0].length; j++) {
				for (int k = 0; k < house[0][0].length; k++) {
					System.out.print(" " + house[i][j][k]);
				}
				System.out.println();
			}
			if (i < house.length - 1) {
				System.out.println("####################");

			}
		}

	}

}

Measured memory_bytes: 27256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define IO ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
using namespace std;

int n;

int main()
{
	IO
	cin>>n;
	cout<<round(sqrt(2*n-1))<<endl;

	return 0;
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

    ll n;
    cin >> n;
    ll power = 1;
    int mod = int(1e9 + 7);

    for(int i=1; i<=n; i++){
        power = (i * power) % mod;
        //さきに掛け算してoverflowを検知しないとダメ
    }

    cout << power << endl;

}

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


int main()
{
    string s;
    cin >> s;
    int n = s.size();
    vector<char>v;
    for(int i = 0; i < n; i++){
        if(s[i] == 'B' && !v.empty()){
            v.pop_back();
        }else if(s[i] != 'B'){
            v.push_back(s[i]);
        }
    }
    for(int i = 0; i < v.size(); i++){
        cout << v[i];
    }
}

Measured memory_bytes: 256
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int dist(int a,int b,int x,int y) {
  if (a == b) {
    return 0;
  }
  if ((a == x && b == y) || (b == x && a == y)) {
    return 1;
  }
  if (abs(b - a) == 1) {
    return 1;
  }
  int ax=dist(a, x, x, y);
  int ay=dist(a, y, x, y);
  int xb=dist(x, b, x, y);
  int yb=dist(y, b, x, y);
  return min(min(abs(b-a), ax+yb+1), min(ax+xb, ay+yb));
}

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

  int n, x, y;
	cin >> n >> x >> y;
  map<int,int> num;
  int dp[n][n];
  for(int i=1; i<=n-1; i++) {
    for(int j=i+1; j<=n; j++) {
      if (i == j) {
        dp[i-1][j-1] = 0;
      } else if ((i == x && j == y) || (j == x && i == y)) {
        dp[i-1][j-1] = 1;
      } else if (j - i == 1) {
        dp[i-1][j-1] = 1;
      } else {
        if (j < x || i > y) {
          dp[i-1][j-1] = j-i;
        } else if (x <= j && j <= y) {
          int tmp;
          if (i < x) {
            tmp = x-i+y-j+1;
          } else {
            tmp = i-x+y-j+1;
          }
          dp[i-1][j-1] = min(j-i, tmp);
        } else if (i < x && j > y) {
          dp[i-1][j-1] = x-i+1+j-y;
        } else if (i >= x && j > y) {
          dp[i-1][j-1] = min(j-i, i-x+1+j-y);
        }
      }
      num[dp[i-1][j-1]]++;
    }
  }
  for(int i=1; i<=n-1; i++) {
    cout << num[i] << "\n";
  }
}


Measured memory_bytes: 16000