akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var a=new int[3,3];
		a[0,0]=sc.I;
		a[0,1]=sc.I;
		a[1,1]=sc.I;
		a[2,1]=a[0,0]-a[1,1];
		a[2,2]=a[0,1]-a[1,1];
		a[0,2]=a[1,1]-(a[2,1]+a[2,2]);
		a[2,1]+=a[0,2];
		a[2,2]+=a[0,2];
		a[2,0]=a[0,1]+a[1,1]+a[2,1]-a[2,1]-a[2,2];
		a[1,0]=a[0,1]+a[1,1]+a[2,1]-a[0,0]-a[2,0];
		a[1,2]=a[0,1]+a[1,1]+a[2,1]-a[0,2]-a[2,2];
		for(int i = 0;i<3;i++) {
			for(int j = 0;j<3;j++) {
				Console.Write(a[i,j]);
				if(j!=2){Console.Write(" ");}
			}
			Console.WriteLine();
		}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13140
use proconio::input;

fn gcm(a: usize, b: usize) -> usize {
  if b == 0 {
    a
  } else {
    gcm(b, a % b)
  }
}

fn main() {
  input! {
    n: usize,
    mut vals: [usize;n]
  }
  
  if vals.len() == 2 {
    println!(
      "{}",
      if vals[0] < vals[1] {
        vals[1]
      } else {
        vals[0]
      }
    );
    return
  }
  
  vals.sort();
  let mut memo: Vec<usize> = vec![0;n];
  memo[n-1] = vals[n-1];
  let mut index = vals.len() - 2;
  loop {
    memo[index] = gcm(vals[index], memo[index+1]);
    if index == 0 { break }
    index -= 1;
  }
  
  let mut max = 1;
  let mut m = vals[0];
  for i in 1..n-1 {
    max = std::cmp::max(max, gcm(m, memo[i+1]));
    m = gcm(m, vals[i]);
  }
  max = std::cmp::max(max, gcm(vals[1], memo[2]));
  max = std::cmp::max(max, m);
  
  println!("{}", max);
}

Measured memory_bytes: 4432
import sys
N = int(input())
h = list(map(int, input().split()))
h[0] -= 1

for i in range(1, N-1):
    if h[i+1] - h[i] == -1:
        if h[i] == h[i-1]:
            print('No')
            sys.exit()
        else:
            h[i] -= 1
    elif h[i+1] - h[i] > -1:
        if h[i-1] != h[i]:
            h[i] -= 1
    else:
        print('No')
        sys.exit()
print('Yes')



Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<intt,intt>
#define mp make_pair
#define scn(x) scanf("%d",&x)
typedef long long intt;
using namespace std;
intt tree[200004*4];
intt lazy[200004*4];
vector<ii> op[200004];
intt dp[200004];
void updateRange(int node,int start,int endd,int l,int r,intt val)
{
    if(lazy[node]!=0)
    {
        tree[node]+=lazy[node];
        if(start!=endd)
        lazy[node*2]+=lazy[node],lazy[node*2+1]+=lazy[node];
        lazy[node] = 0;
    }
    if(start>endd||start>r||endd<l)
        return;
    if(start>=l&&endd<=r)
    {
        tree[node]+=val;
        if(start!=endd)
        lazy[node*2]+=val,lazy[node*2+1]+=val;
        return;
    }
    int mid=(start+endd)/2;
    updateRange(node*2,start,mid,l,r,val);
    updateRange(node*2+1,mid+1,endd,l,r,val);
    tree[node]=max(tree[node*2],tree[node*2+1]);
}
intt queryRange(int node,int start,int endd,int l,int r)
{
    if(start>endd||start>r||endd<l)
        return -1e18;
    if(lazy[node] != 0)
    {
        tree[node]+=lazy[node];
        if(start!=endd)
        lazy[node*2]+=lazy[node],lazy[node*2+1]+=lazy[node];
        lazy[node] = 0;
    }
    if(start>=l&&endd<=r)
     return tree[node];
    int mid=(start+endd)/2;
    intt p1 = queryRange(node*2,start,mid,l,r);
    intt p2 = queryRange(node*2+1,mid+1,endd,l,r);
    return max(p1,p2);
}
int main()
{

    int n,m;

    cin>>n>>m;
    int i;
    for(i=0;i<m;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        op[y].pb(mk(x,z));
    }
    intt mx=0;
    for(i=1;i<=n;i++)
    {
        int j;
        intt t=queryRange(1,0,n,1,i-1);
        if(t>0)
         updateRange(1,0,n,i,i,t);
        for(j=0;j<op[i].size();j++)
          updateRange(1,0,n,op[i][j].fr,i,op[i][j].sc);
    }
    for(i=1;i<=n;i++)
     mx=max(mx,queryRange(1,0,n,i,i));
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 22400
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double p=0.5*m+30*h;
  int q=6*m;
  double kakudo=min(360-abs(p-q),abs(p-q));
  double t=cos(kakudo*M_PI/180);
  cout<<fixed<<setprecision(15)<<sqrt(a*a+b*b-2*a*b*t)<<endl;
  return 0;
}


Measured memory_bytes: 4112
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main() {
    int n, m;
    scanf("%d %d", &m, &n);
    int sum = 0;
    while (n--) {
        int tt; scanf("%d", &tt);
        sum += tt;
    }
    if (sum > m) printf("-1\n");
    else printf("%d\n", m - sum);
}

Measured memory_bytes: 1716
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <numeric>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

// consts
int MOD = 1000000007;  // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a

ld f(int n) {
    if (n == 1) return 1.0;
    return f(n - 1) * (ld)n;
}

int main() {
    int n, x, y;
    cin >> n;
    vector<pii> v;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y;
        v.emplace_back(make_pair(x, y));
    }
    vector<ld> ds;
    vector<int> p;
    for (int i = 0; i < n; ++i) p.emplace_back(i);
    do {
        ld d = 0.0;
        for (int i = 0; i < n - 1; ++i) {
            int j = p[i];
            int k = p[i+1];
            ld x0 = v[j].first;
            ld y0 = v[j].second;
            ld x1 = v[k].first;
            ld y1 = v[k].second;
            d += sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1));
        }
        ds.emplace_back(d);
    } while (next_permutation(p.begin(), p.end()));
    ld m = 0;
    ld acc = accumulate(ds.begin(), ds.end(), m);
    std::cout << std::setprecision(15);
    cout << acc / f(n) << endl;
    return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long N = input.nextLong();
		long M = input.nextLong();
		long tempN = 0; long cnt = 0;
		if (N%2==1) tempN=N/2+1;
		else tempN=N/2;
		for (int i = 0; i < M; i++) {
			if (i%2==0) cnt+=tempN;
			else cnt+=(N-tempN);
		}
		if (N==1||M==1) System.out.println(1);
		else System.out.println(cnt);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    rep(i, h)rep(j, w) cin >> a[i][j];

    vector<vector<int>> ans;

    rep(i, h){
        rep(j, w){
            if(j==w-1){
                if(i!=h-1 and a[i][j]%2){
                    a[i][j]--;
                    a[i+1][j]++;
                    ans.push_back({i+1, j+1, i+2, j+1});
                }
            }else{
                if(a[i][j]%2){
                    a[i][j]--;
                    a[i][j+1]++;
                    ans.push_back({i+1, j+1, i+1, j+2});
                }
            }
        }
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl;
    return 0;
}

Measured memory_bytes: 9904
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int bubble_sort(vi a)
{
	int res = 0;
	while (true)
	{
		bool update = false;
		rep(i, sz(a)-1)
		{
			if (a[i] > a[i + 1])
			{
				swap(a[i], a[i + 1]);
				update = true;
				res++;
			}
		}
		if (!update)break;
	}
	return res;
}

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

	int a, b;
	cin >> a >> b;
	if (a <= b)
	{
		rep(i, b)cout << a;
	}
	else
	{
		rep(i, a)cout << b;
	}
	el;
	return 0;
}


Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int a[102] = {0};

int main()
{
	int N = 0;
	scanf("%d", &N);

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

	int ans = 0;
	for (i = 1; i < N+1; i++) {
		if ((i%2 != 0) && (a[i]%2 != 0)) {
			ans++;
		}
	}
	printf("%d\n", ans);
	//yesno(ans);
	//okng(ans);
	return 0;
}


Measured memory_bytes: 1728
#include <stdio.h>
int main(void){
    // Your code here!
    char s[3];
    int i,flaga=0,flagb=0,flagc=0;
    
    
    scanf("%s",s);
    for(i=0;i<3;i++){
        if(s[i]=='a'){
        flaga++;
        }
        else if(s[i]=='b'){
        flagb++;
        }
        else{
            flagc++;
        }
    }
    
    if(flaga==1&&flagb==1&&flagc==1){
        printf("Yes");
    }
    else{
        printf("No");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

ll modadd(ll x, ll y) {
    return ((x + y) % mod + mod) % mod;
}

ll modminus(ll x, ll y) {
    return (x - y + mod) % mod;
}

ll dp[2][10010][110];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string K;
    ll D;
    cin >> K >> D;
    ll len = K.size();
    dp[0][0][0] = 1;
    REP(i, 0, len) {
        ll dig = (ll)K[i] - (ll)'0';
        REP(j, 0, D) {
            REP(k, 0, 10) {
                dp[1][i + 1][(j + k) % D] = modadd(dp[1][i + 1][(j + k) % D], dp[1][i][j]);
            }
            dp[0][i + 1][(j + dig) % D] = modadd(dp[0][i + 1][(j + dig) % D], dp[0][i][j]);
            REP(k, 0, dig) {
                dp[1][i + 1][(j + k) % D] = modadd(dp[1][i + 1][(j + k) % D], dp[0][i][j]);
            }
        }
    }
    // REP(i, 0, len + 1) {
    //     REP(j, 0, D) {
    //         cout << dp[0][i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // REP(i, 0, len + 1) {
    //     REP(j, 0, D) {
    //         cout << dp[1][i][j] << " ";
    //     }
    //     cout << endl;
    // }
    ll ans = modminus(modadd(dp[0][len][0], dp[1][len][0]), 1);
    cout << ans << endl;
}


Measured memory_bytes: 17536
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl a,b,x;
    cin >> a >> b >> x;
    intl cnt = 0;
    cnt += (b / x);
    cnt -= ((a-1) / x);
    if((!a)&&(x != 1))cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($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, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

/// Ported from ACL.
/// Computes \sum_{i = 0}^{n - 1} floor((a * i + b) / m).
fn floor_sum(n: i64, m: i64, mut a: i64, mut b: i64) -> i64 {
    let mut ans = 0;
    if a >= m {
        let q = a / m;
        ans += (n - 1) * n / 2 * q;
        a -= q * m;
    }
    if b >= m {
        let q = b / m;
        ans += n * q;
        b -= q * m;
    }
    let y_max = (a * n + b) / m;
    let x_max = y_max * m - b;
    if y_max == 0 {
        return ans;
    }
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    ans
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        nmab: [(i64, i64, i64, i64)],
    }
    for (n, m, a, b) in nmab {
        puts!("{}\n", floor_sum(n, m, a, b));
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);++i)
const int M=1e9+7;
int main(void){string s,t;cin>>s>>t;long long a=0,c=0,n=s.length(),m=t.length(),x;vector<set<int>>v(26);rep(i,26)v[i].insert(M);rep(i,n)v[s[i]-'a'].insert(i+1);rep(i,m){x=t[i]-'a';c=*v[x].upper_bound(c);if(c==M)++a,c=*v[x].begin();if(c==M){cout<<-1;return 0;}}cout<<a*n+c;return 0;}


Measured memory_bytes: 8512
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) += (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

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

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

int k;
string s;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s >> k;
    for (int i = 0; i < sz(s); i += k)
        cout << s[i];
}

Measured memory_bytes: 256
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
ans = 0
di0 = {}
di1 = {}
for i in s:
  if(not i in di0):
    di0[i]=1
    di1[i]=0
  else:
    di0[i]+=1
for i in t:
  if(not i in di1):
    di1[i]=1
  else:
    di1[i]+=1
for i in di0:
  ans = max(di0[i]-di1[i],ans)
print(ans)

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

vector<int> e[N];
int dfs(int u,int v){
	int r=0;
	for(auto x:e[v]){
		if(x!=u)r=r^(1+dfs(v,x));
	}
	return r;
}

int main(){
	int n;
	cin>>n;
	for (int i = 0; i < n-1; i++){
		int x,y;
		cin>>x>>y;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	if(dfs(0,1))cout<<"Alice"<<endl;
	else cout<<"Bob"<<endl;
	return 0;
}


Measured memory_bytes: 19712
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
long int n,k_max,a,sum,total;
long int arr[] =  {};
vector <long int> Array;
int main(){
    cin>>n>>k_max;
      
    for (int i=0;i<n;i++){
        cin>>a;
          Array.push_back(a);
          sum+=a;
    }
    if (k_max>=n){
        cout<<0;
        return 0;
    }
    sort(Array.begin(), Array.end(), greater<long int>());
    for (int i=0;i<k_max;i++){
        total += Array[i];
    }
      sum -= total;
      cout<<sum;
}

Measured memory_bytes: 2420
#include<stdio.h>
int main()
{
    int a,b,c,d,i,e=0,f;
    scanf("%d %d",&a,&b);
    if(a>b)
    {
        for(i=1;i<=a;i++)
        {
            c=a-i;
            d=b-i;
            if(c==d||c==-1*d)
            {
               e++;
               f=i;
               break;
            }

        }

    }
    else
    {
         for(i=1;i<=b;i++)
        {
            c=a-i;
            d=b-i;
            if(c==d||c==-1*d)
            {
                e++;
                f=i;
                break;
            }

        }

    }
    if(e==0)
        printf("IMPOSSIBLE\n");
    else
        printf("%d\n",f);

}


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

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

  vector<int> l(n);
  rep(i,n) cin >> l[i];

  int ans = 0;
  rep(i,n) rep(j,n) rep(k,n) {
    if (i < j && j < k) {
      //同じ線を選ばない条件設定
      if (l[i] == l[j]) continue;
      if (l[i] == l[k]) continue;
      if (l[k] == l[j]) continue;
      //三角形が作成できる条件
      if ((ll)l[i]+l[j]+l[k] <= max({l[i],l[j],l[k]})*2) continue;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
    ll n, ans = 0;
    cin >> n;
    rep(i, n) ans += i;
    cout << ans << endl;
}

Measured memory_bytes: 256
w = input()
# index, count = np.unique(list(w), return_counts=True)
d = {}
for c in w:
    if c in d.keys():
        d[c] += 1
    else:
        d.setdefault(c, 1)
for i, j in d.items():
    if j % 2 == 1:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main(){
  string s;
  
  while(getline(cin,s)){
  
  rep(i,26){
    rep(j,s.size()){
      if(s[j]!=' ' && s[j]!='.'){
        if(s[j]!='z') s[j]++;
        else s[j]='a';
      }
    }
    if(s.find("the") != string::npos || s.find("this") != string::npos || s.find("that") != string::npos){
      break;
    }
  } 
  
  cout<<s<<endl;
  }
    
  return 0;
}


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

static int H, W;
static char c_list[51][51];

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

void solve()
{
	for (int y = 0; y < H; ++y)
	{
		for (int x = 0; x < W; ++x)
		{
			if (c_list[y][x] == '#') continue;
			
			int c = 0;
			for (int i = 0; i < 8; ++i)
			{
				int x_ = x + dx[i];
				int y_ = y + dy[i];

				if (x_ < 0 || W-1 < x_) continue;
				if (y_ < 0 || H-1 < y_) continue;

				if (c_list[y_][x_] == '#')
					c++;
			}

			c_list[y][x] = ('0' + c);
		}
	}
}

int main(int argc, char **argv)
{
	cin >> H >> W;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
			cin >> c_list[i][j];
	}
	solve();

	for (int y = 0; y < H; ++y)
	{
		for (int x = 0; x < W; ++x)
		{
			std::cout << c_list[y][x];
		}
		std::cout << std::endl;
	}
}


Measured memory_bytes: 256
'use strict';
const input = require("fs").readFileSync("/dev/stdin", "utf8");
let l = [];
for (let i=0;i<input.length-2;i++) {
  let r = Number(input.substr(i, 3));
  l.push(Math.abs(r - 753));
}
console.log(Math.min.apply(null,l));

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

int main(){
  int d,g;
  cin>>d>>g;
  g/=100;
  int ans=114514;
  vector<int> p(d);
  vector<int> c(d);
  for(int i=0;i<d;i++){
    cin>>p.at(i)>>c.at(i);
    c.at(i)/=100;
  }
  for (int tmp = 0; tmp < (1 << 10); tmp++) {
    bitset<10> s(tmp);
    int curpoint=0;
    int curquestion=0;
    stack<int> q;
    for(int i=0;i<d;i++){
      if(s.test(i)){
        curpoint+=(i+1)*p.at(i)+c.at(i);
        curquestion+=p.at(i);
      }
      else{
        q.push(i+1);
      }
    }
    if(curpoint>=g){
      ans=min(ans,curquestion);
    }
    else{
      while(q.size()){
        int r=q.top();
        q.pop();
        if(curpoint+r*(p.at(r-1)-1)<g){
          curpoint+=r*(p.at(r-1)-1);
          curquestion+=p.at(r-1)-1;
        }
        else{
          curquestion+=(g-curpoint+r-1)/r;
          ans=min(ans,curquestion);
          break;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;

template<typename T=int>
bool isPrime(T n) {
    if (n < 2) { return false; }
    for (int i = 2; i * i <= n; i++) { if (n % i == 0) { return false; }}
    return true;
}

int main(void) {
    int x;
    cin >> x;
    for (int i = x; i <= 1e6; ++i) {
        if (isPrime(i)) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
# coding:utf-8

import sys
import itertools

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, a, b, c = LI()
A = [a, b, c]
K = [II() for _ in range(n)]

ans = INF
for x in itertools.product([0, 1, 2, 3], repeat=n):
    s = set(x)
    if 0 not in s or 1 not in s or 2 not in s:
        continue
    T = [0] * 3
    cnt = 0
    for i, n in enumerate(x):
        if n == 3:
            continue
        if T[n]:
            cnt += 1
        T[n] += K[i]

    # print(T, cnt)
    tmp = cnt * 10
    for i in range(3):
        tmp += abs(T[i] - A[i])

    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 47852
n, p = map(int, input().split())
A = list(map(int, input().split()))
o = 0
for a in A:
	if a % 2:
		o += 1
e = n - o
if o == 0 and p == 1:
	print(0)
else:
	print(2**e * 2**max(0, o - 1))

Measured memory_bytes: 38256
import itertools as it
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

P = it.permutations([i for i in range(1,n+1)],n)

a = 0
b = 0
cnt = 1
if p==q:
  print(0)
  exit()
for i in P:
  if p==i:
    a = cnt
    cnt +=1
  elif q==i :
    b = cnt
    cnt +=1
  else:
    cnt +=1
ans = abs(a-b)
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={0,31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
ll a,b,c;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b>>c;
	if(b*c>=a)cout<<"Yes";
	else cout<<"No";
	return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  string S;
  cin >> A >> B >> S;
  bool b = true;
  for(int i = 0; i < A; i++) {
    if(S.at(i) == '-') {
      b = false;
    }
  }
  if(S.at(A) != '-') {
    b = false;
  }
  for(int i = A + 1; i < A + B + 1; i++) {
    if(S.at(i) == '-') {
      b = false;
    }
  }
  if(b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x

def gcds(x):
    ans = x[0]
    for i in x:
        ans = gcd(ans, i)
    return ans


n, X = map(int,input().split())
x = [int(i) for i in input().split()]

bx = X
tmp = [0 for _ in range(n)]
for i in range(n):
    tmp[i] = abs(x[i] - bx)
    bx = x[i]
print(gcds(tmp))


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#define assert(...)
#endif

using namespace std;

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(){
#define int ll
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  sort(all(a));
  int x = a[n-1] / 2, y;

  if(n % 2 == 0)
    y = x;
  else
    y = x + 1;

  int l = *(upper_bound(all(a),x) - 1);
  int r = *lower_bound(all(a), y);
  if(r == a[n-1]){
    r = l;
    y = x;
  }
  dump(x,l,y,r);
  cout << a[n-1] << " ";
  if(abs(l - x) < abs(r - y)) cout << l;
  else cout << r;
  cout << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<ctype.h>

int main(void)
{
	char str;

	while (1)
	{
		scanf("%c", &str);

		if (isupper(str))
			str = tolower(str);
		else
			str = toupper(str);
		printf("%c", str);
		if ((str == '\n') || (str == '\0'))
			break;
	}

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
string S;
  cin>>N>>S;
  bool nazo=true;
if(N%2==0 && S.substr(0,N/2)==S.substr(N/2,N)){
nazo=true;
}
  else{
  nazo=false;
  }
  if(N==1){
  nazo=false;
  }
  if(nazo){
  cout<<"Yes";
  }
  else{
  cout<<"No";
  }
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,m,tmp;
bool cant[1000010];
long long dp[1000010];
int main(){
    cin>>n>>m;
    while(m--){
        scanf("%d",&tmp);
        cant[tmp]=1;
    }
    dp[0]=1;
    if(!cant[1]) dp[1]=1;
    for(int i=2;i<=n;i++){
        if(!cant[i]) dp[i]=(dp[i-1]+dp[i-2])%mod;
    }
    cout<<dp[n];
}


Measured memory_bytes: 3072
#include <stdio.h>

int main() {
	int inSecond;
	int hours, minutes, seconds;
	
	scanf("%d", &inSecond);
	
	if (inSecond < 0 || inSecond > 86401) {
		printf ("error\n");
		return 0;
	}
	
	hours = inSecond / 3600;
	inSecond = inSecond % 3600;
	minutes = inSecond / 60;
	seconds = inSecond % 60;
	
	printf("%d:%d:%d\n", hours, minutes, seconds);
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,cnt;
	scanf("%d%d%d",&a,&b,&c);
	cnt=a*100+b*10+c;
	if(cnt%4==0) printf("YES");
	else printf("NO");
	printf("\n");
    return 0;
}


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

using namespace std;

vector<pair<long long,long long> > soin(long long x){
    vector<pair<long long,long long> > vp;
    long long i,j;
    for(i = 2;i*i <= x;i++){
        if(x % i == 0){
            for(j = 0;x % i == 0;j++) x /= i;
            vp.push_back(make_pair(i,j));
        }
    }
    if(x > 1) vp.push_back(make_pair(x,1));
    return vp;
}
int main(){
    long long n,p;
    long long i,j;
    cin >> n >> p;
    vector<pair<long long,long long> > s = soin(p);
    long long a = 1;
    for(i = 0;i < s.size();i++){
        for(j = n;j <= s[i].second;j+=n){
            a *= s[i].first;
        }
    }
    cout << a << endl;
}


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


void solve(long long N, long long M)
{
    cout<<N*(N-1)/2+M*(M-1)/2<<endl;
}

int main()
{
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
  "os"
  "bufio"
)

func main() {
  var div int64 = 1000000007
  sc := bufio.NewScanner(os.Stdin)
  buf := make([]byte, 100001)
  sc.Buffer(buf, 100001)

  sc.Scan()
  s := sc.Text()

  dp := make([]int64, 13)
  dp[0] = 1
  mul := 1

  for i := 0; i < len(s); i++ {
    digit := 0
    ndp := make([]int64, 13)
    any := 0
    if s[len(s) - 1 - i] == '?' {
      any = 1
    } else {
      digit = int(s[len(s) - 1 - i] - '0')
    }
    for j := 0; j < 10; j++ {
      if any == 0 {
        j = digit
      }
      for k := 0; k < 13; k++ {
        ndp[(mul * j + k) % 13] += dp[k]
        ndp[(mul * j + k) % 13] %= div
      }
      if any == 0 {
        break
      }
    }
    mul = mul * 10 % 13
    dp = ndp
  }
  fmt.Println(dp[5])
}


Measured memory_bytes: 6528
from collections import Counter


class UnionFind:
    def __init__(self, n):
        self.v = [-1] * n

    def find(self, x):
        if self.v[x] < 0:
            return x
        else:
            self.v[x] = self.find(self.v[x])
            return self.v[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        else:
            if self.v[x] > self.v[y]:
                x, y = y, x
            self.v[x] += self.v[y]
            self.v[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.v[self.find(x)]


def main():
    import sys

    input = sys.stdin.readline

    h, w = map(int, input().split())
    s = [input().rstrip() for _ in range(h)]

    d = (1, 0), (-1, 0), (0, 1), (0, -1)

    uf = UnionFind(h * w * 2)
    for r in range(h):
        for c in range(w):
            id_ = (r * w + c) + (h * w if s[r][c] == '#' else 0)
            for dr, dc in d:
                nr = r + dr
                if nr < 0 or h <= nr:
                    continue
                nc = c + dc
                if nc < 0 or w <= nc:
                    continue
                if s[nr][nc] == s[r][c]:
                    continue
                nid = (nr * w + nc) + (h * w if s[nr][nc] == '#' else 0)
                uf.unite(id_, nid)

    for r in range(h):
        for c in range(w):
            id_ = (r * w + c) + (h * w if s[r][c] == '#' else 0)
            uf.find(id_)
            # 葉の親が更新されていなかったために、連結成分の大きさが小さく判定されていた

    checked = [False] * (h * w * 2)
    ctr_dot = Counter(uf.v[:h * w])
    ctr_sharp = Counter(uf.v[h * w:])

    ret = 0
    for r in range(h):
        for c in range(w):
            id_ = (r * w + c) + (h * w if s[r][c] == '#' else 0)
            root = uf.find(id_)

            if checked[root]:
                continue

            checked[root] = True

            dot = ctr_dot[root]
            sharp = ctr_sharp[root]

            if root < h * w:
                dot += 1
            else:
                sharp += 1

            ret += dot * sharp

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72696
# C
def gcd(a,b):
    if a<b: a,b = b,a
    r = a % b
    while(r!=0):
        a,b = b,r
        r = a%b
    return b

def nonDivided(n,s,t):
    if not n > 0:
        return 0
    else:
        lcm = int(s/gcd(s,t)*t)
        return n-n//s-n//t+n//lcm

if __name__=='__main__':
    A,B,C,D = map(int,input().split())
    print(nonDivided(B,C,D)-nonDivided(A-1,C,D))

Measured memory_bytes: 3064
#!/usr/bin/env python3
# %%
stdin = open(0)
import numpy as np

# %%
data = np.fromstring(stdin.read(), np.int64, sep=' ')

# %%
X = data[1:]
costs = []
for p in range(101):
    costs.append(np.sum((X-p)**2))

# %%
answer = min(costs)
print(answer)

# %%


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

int main() {
  int n; cin >>n;
  if(n<2)cout<<1<<endl;
  else if(n<4)cout<<2<<endl;
  else if(n<8)cout<<4<<endl;
  else if(n<16)cout<<8<<endl;
  else if(n<32)cout<<16<<endl;
  else if(n<64)cout<<32<<endl;
  else if(n<128)cout<<64<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t W,H;
    cin >> W >> H;
    int64_t x = W * H;
        if(W == 1 || H == 1){
            cout << 1 << endl;
        }
        else{
            cout << (x+1)/2 << endl;
        }
    return 0;
}


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

using namespace std;

int main() {
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    int k;
    cin >> k;
    sort(v.begin(), v.end());
    int sum = v[2];
    for (auto i=0; i < k; ++i) {
        sum *= 2;
    }
    sum += v[0] + v[1];
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[200009],b[200009];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=n;i>=1;i--) {
		int sum=0;
		for(int j=2;i*j<=n;j++) sum+=b[i*j];
		sum%=2;
		if(sum==a[i]) b[i]=0;
		else b[i]=1;
	}
	for(int i=1;i<=n;i++)
		if(b[i]) m++;
	printf("%d\n",m);
	for(int i=1;i<=n;i++)
		if(b[i]) printf("%d ",i);
	return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>

int ball[3] = {1, 0, 0};

void temp(int a, int b) {
  int t = ball[a];
  ball[a] = ball[b];
  ball[b] = t;
}

int main(void) {
  char change1, change2;
  int t1, t2;

  while (scanf("%c,%c", &change1, &change2) != EOF) {
    switch(change1) {
    case 'A': t1 = 0; break;
    case 'B': t1 = 1; break;
    case 'C': t1 = 2; break;
    }
    switch(change2) {
    case 'A': t2 = 0; break;
    case 'B': t2 = 1; break;
    case 'C': t2 = 2; break;
    }
    
    temp(t1, t2);
    change1 = 0;
    change2 = 0;
    t1 = 0;
    t2 = 0;
  }
  if (ball[0]) printf("A\n");
  else if (ball[1]) printf("B\n");
  else printf("C\n");

  return 0;
}

Measured memory_bytes: 524
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    i64 K, A, B;
    read(K, A, B);

    if (A >= B - 2) {
        print(K + 1);
    } else {
        i64 rest = K - A + 1;
        if (rest % 2 == 0) {
            const i64 b2m = rest / 2 - 1;
            const i64 m2b = rest / 2;
            print((B * m2b) - (A * b2m));
        } else {
            const i64 b2m = rest / 2;
            const i64 m2b = rest / 2;
            print(B * m2b - (A * (b2m - 1)) + 1);
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

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

typedef long long ll;

int main() {
	/*int a, b, c;
	cin >> a >> b >> c;
	int ans;
	if (a - b > c)ans = 0; else ans = c - a + b;
	cout<<ans;*/


	int N;
	cin >> N;
	int ans = 0;
	int i, j = 10;
	for (i = 1; i <=N;i++) {
		if (i >= j / 10 && i < j)ans++;
		else {
			i = 10 * i - 1;
			j *= 100;
		}
	}
	cout << ans;


	/*int N;
	cin >> N;
	vector<int>h(N + 1);
	rep(i, N)cin >> h[i + 1];
	rep(i, N) {
		if (h[i + 1] > h[i])h[i + 1]--;
		if (h[i + 1] < h[i]) {
			cout << "No"; return 0;
		}
	}
	cout << "Yes";*/



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,x,y,z;
  cin>>n>>x>>y>>z;
  vector<vector<ll>> dp(n+1,vector<ll>((1ll<<(x+y+z-1))+10,0));
  ll mask=(1ll<<(x+y+z-1))-1;
  ll ng=0;
  ng|=(1<<(x+y+z-1));
  ng|=(1<<(y+z-1));
  ng|=(1<<(z-1));
  dp[0][0]=1;
  rep(i,n){
    rep(S,1<<(x+y+z-1)){
      if((S & ng)==ng) continue;
      FOR(j,1,11){
        ll T=(S<<j) | (1<<(j-1));
        if((T & ng)==ng) continue;
        T&=mask;
        (dp[i+1][T]+=dp[i][S])%=mod;
      }
    }
  }
  ll ans=1;
  rep(i,n) (ans*=10)%=mod;
  rep(i,1<<(x+y+z-1)) (ans-=dp[n][i])%=mod;
  cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 21888
import java.util.*;

public class Main {
 public static void main(String args[]) {
  Scanner sc = new Scanner(System.in);
  String s = sc.nextLine();
  char[] sArray = s.toCharArray();
  int count = 0;
  for(int i = 0; i < sArray.length - 1; i++) {
       if(i != 0) {
            count++;
       }
  }
  System.out.println(String.valueOf(sArray[0]) + count + String.valueOf(sArray[sArray.length - 1]));
 }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

long long f(long long n, long long b) {
  long long sum = 0;
  while (n > 0) {
    sum += n % b;
    n /= b;
  }
  return sum;
}

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  long long n, s;
  std::cin >> n >> s;
  if (n < s) { std::printf("-1\n"); std::exit(EXIT_SUCCESS); }
  if (n == s) { std::printf("%lld\n", n + 1); std::exit(EXIT_SUCCESS); }

  for (int b = 2; b <= (int)sqrt(n); ++b) {
    if (f(n, b) == s) {
      std::printf("%d\n", b);
      std::exit(EXIT_SUCCESS);
    }
  }

  long long min_b = 1000000000000ll;
  for (int p = (int)sqrt(n); p >= 1; --p) {
    auto q = s - p;
    if ( (n - q) % p != 0 ) continue;
    auto b = (n - q) / p;
    if ( f(n, b) != s ) continue;

    min_b = std::min(min_b, b);
  }
  if (min_b == 1000000000000ll) {
    std::printf("-1\n");
  } else {
    std::printf("%lld\n", min_b);
  }
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256