akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            List<Integer> list = new ArrayList<>();

            while (n > 0) {
                list.add((int) (n % 10));
                n /= 10;
            }
            int sum = (list.size() - 1) * 9 + list.get(list.size() - 1);

            boolean ok = true;
            for (int i = 0; i < list.size() - 1; ++i)
                if (list.get(i) != 9) {
                    ok = false;
                    break;
                }
            if (!ok) sum--;
            out.println(sum);
        }

    }
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin>>s;
  int n=s.length();
  ll ans=0;
  for(int i=0;i<s.length()/2;i++){
    if(s[i]!=s[n-i-1]) {
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		int sum=0;
		Scanner input=new Scanner(System.in);
		int human=input.nextInt();
		for(int i=1;i<=human;i++) {
			sum=sum+i;
		}
		System.out.println(sum);
	}
}

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



int main() {
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    
    ll b = a[0], ans = 0;
    for(int i = 1; i < n; i++) {
        if(b > a[i]) {
            ans += b - a[i];
        }
        else {
            b = a[i];
        }
    }
    
    cout << ans << endl;
    
    
    
    return 0;
}




Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;

struct edge { int to, id;};

vector<vector<edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
    int k = 1;
    rep(i,g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if(u == p) continue;
        if(k == c) ++k;
        ans[ei] = k; ++k;
        dfs(u,ans[ei],v);
    }
}

int main() {
    int n;
    cin >> n;
    g.resize(n);
    ans.resize(n);
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back((edge){b,i});
        g[b].push_back((edge){a,i});
    }
    dfs(0);
    int mx = 0;
    rep(i,n) mx = max(mx, int(g[i].size()));
    cout << mx << endl;
    rep(i,n-1) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 11028
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime> 
#define full(a) a.begin(), a.end()

#define sz(x) ((ll)(x).size())
#define ll long long
using namespace std;

ll inp() {
    ll n; cin >> n;
    return n;
}

void prntv(vector<ll> vec) {
    for (auto i : vec)cout << i << " ";
    cout << endl;
}
void solve() {
    ll x = inp(), k = inp(), d = inp();
    x = abs(x);
    ll temp = d * k;
    ll kart = x / k;
    if (x % k)kart++;
    if (d >= kart) {
        ll x1 = x % d;
        ll tm = (x - x1) / d;
        k -= tm;
        if (k % 2) {
            x1 -= d;
            x1 = abs(x1);
            cout << x1 << endl;
            return;
        }
        else {
            cout << x1 << endl;
            return;
        }

    }
    else{
        x -= (k * d);
        cout << x << endl;

    }
    
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //ll n; cin >> n;
    //while(n--)
        solve();

    return 0;
}

Measured memory_bytes: 3652
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;


fn main(){
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    // SSS => o
    // SSW => x
    // SWS => x
    // SWW => o
    // WWW => o
    
    while let Some(N) = sc.read1() {
        let s = sc.read::<String>();
        let s: Vec<i32> = s.chars()
            .map(|e| if e == 'o' { 1 } else { 0 })
            .collect();

        let mut found = false;
        for i in 0..4 {
            let mut cand = vec![0 as i32; N];
            cand[0] = i & 1;
            cand[1] = (i >> 1) & 1;

            //  j.......
            // 012345678(N-1)
            for j in 2..N {
                cand[j] = cand[j - 2] ^ cand[j - 1] ^ s[j - 1];
            }

            if s[0] == cand[N - 1] ^ cand[0] ^ cand[1] && s[N - 1] == cand[N - 2] ^ cand[N - 1] ^ cand[0] {
                for e in cand {
                    print!("{}", if e == 1 { "S" } else { "W" });
                }
                println!();
                found = true;
                break;
            }
        }

        if !found {
            println!("-1");
        }
    }
}

//=============================================================================

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

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

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

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


Measured memory_bytes: 4352
#include <stdio.h>

#define endl '\n'

int main()
{
    int n, i, o=0;
    scanf("%d", &n);

    while(n--)
    {
        scanf("%d", &i);
        o+=i&1;
    }

    o&1? printf("NO"): printf("YES");

    return 0;
}


Measured memory_bytes: 1704
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1!=m2)cout << 1;
    else cout << 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
int n,m;
cin >> n >> m;
if(n==m)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int a, b; cin >> a >> b;
    if (a < 10 && b < 10) cout << a * b << endl;
    else cout << -1 << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N, K;
    cin >> N >> K;
    cout << ((N + 1) / 2 >= K ? "YES" : "NO") << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    int N;
    cin >> N;
    int length[N];
    REP (i, N) {
        cin >> length[i];
    }
    sort(length, length+N, greater<int>());

    ll ans = 0;
    for (int a = 0; a < N-2; a++) {
        for (int b = a+1; b < N-1; b++) {
            int l = b, r = N;
            while (r - l > 1) {
                int m = (r-l)/2 + l;
                if (length[a] < length[b] + length[m] &&
                    length[b] < length[m] + length[a] &&
                    length[m] < length[a] + length[b]) {
                    l = m;
                } else {
                    r = m;
                }
            }
            ans += l - b;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],b[100005],ans;
inline int read()
{
    int p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;
}
int main(){
	n=read();
	for(int register i=1;i<=n+1;i++){
		a[i]=read();
	}
	for(int register i=1;i<=n;i++){
		b[i]=read();
	}
	for(int i=1;i<=n;i++){
		if(a[i]>=b[i]){
			ans+=b[i];
			a[i]-=b[i];
			b[i]=0;
		}else{
			ans+=a[i];
			b[i]-=a[i];
			a[i]=0;
		}
		if(a[i+1]>=b[i]){
			ans+=b[i];
			a[i+1]-=b[i];
			b[i]=0;
		}else{
			ans+=a[i+1];
			b[i]-=a[i+1];
			a[i+1]=0;
		}
//		cout<<ans<<endl;
	}
	cout<<ans;
}

Measured memory_bytes: 1920
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
long long n,N,i,x,Q,p,l,r,last,j;
long long a[150008],b[150008];
long long q[150008][30][2];
long long ans[150008];
int main()
{
	//freopen("1.in","r",stdin);
	//freopen("zty.out","w",stdout);
	scanf("%lld %lld",&N,&Q);
	a[n=1]=N;
	for(i=1;i<=Q;i++)
	{
		scanf("%lld",&x);
		while(a[n]>=x)n--;
		a[++n]=x;
	}
	q[1][0][1]=a[1];
	b[n]=1; 
	for(i=n;i>=2;i--)
	{
		p=a[i];last=i-1;
		while(p>=a[1])
		{
			l=1;r=last;
			while(l!=r)
			{
				if(a[(l+r+1)/2]<=p)l=(l+r+1)/2;
				else r=(l+r+1)/2-1;
			}
			b[l]+=p/a[l]*b[i];
			p=p%a[l];last=l;
		}
		q[i][0][1]=p;
	}
	for(i=n;i>=1;i--)
	{
		//for(j=1;j<=q[i][0][0];j++)
		//  b[q[i][j][0]]+=q[i][j][1]*b[i];
		ans[q[i][0][1]]+=b[i];
	}
	for(i=N;i>=1;i--)
	  ans[i]+=ans[i+1];
	for(i=1;i<=N;i++)
	  printf("%lld\n",ans[i]); 
	return 0;
} 
/*
5 5 
1 2 0 4 5 

8
9
19
22
27
*/

Measured memory_bytes: 54528
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a, b);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, s; cin>>n>>s;
	vector<int> vec(n);
	ll dp[s+1] = {};
	ll ans = 0;
	for(int i = 0; i < n; i++){
		cin>>vec[i];
		dp[0]++;
		dp[0] %= 998244353;
		if(vec[i] <= s && dp[s - vec[i]]) ans = (ans + dp[s - vec[i]]*(n-i)) % 998244353;
		for(int j = s; j >= 0; j--){
			if(j + vec[i] <= s){
				dp[j + vec[i]] = (dp[j + vec[i]] + dp[j]) % 998244353;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define reg register
using namespace std;
string a;
int x,y,ans;
int main()
{
    cin>>a;
    for(reg int i=0;i<a.length();i++)
    if(x==y)
	{
		x++;
		if(a[i]=='p')ans--;
	}  
    else
	{
		y++;
		if(a[i]=='g')ans++;
	}        
    printf("%d\n",ans);                     
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
int a[105][105];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);

    for(int i=1;i<=k;i++){
        int num,t;
        scanf("%d",&num);
        for(int j=1;j<=num;j++){
            scanf("%d",&t);
            a[t][i]=1;
        }
    }

    int res=n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(a[i][j]==1){
                res--;
                break;
            }
        }
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int c = 0;
		boolean flag = true;
		if (s.charAt(0) != 'A') {
			flag = false;
		}
		for(int i = 2; i < s.length() - 1; i++) {
			if(s.charAt(i) == 'C') {
				c++;
			}
			else if (Character.isUpperCase(s.charAt(i))) {
				flag = false;
				break;
			}
		}
		if (Character.isUpperCase(s.charAt(1))) {
			flag = false;
		}
		if (Character.isUpperCase(s.charAt(s.length() - 1))) {
			flag = false;
		}

		if (flag && c == 1) {
			System.out.println("AC");
		}else {
			System.out.println("WA");
		}

	}

}


Measured memory_bytes: 23252
#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> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  
  vector<int> right(N);
  vector<int> left(N);
  
  for(int i=1; i<N; i++) left.at(i) = max(left.at(i-1), A.at(i-1));
  for(int i=N-2; i>=0; i--) right.at(i) = max(right.at(i+1), A.at(i+1));
  
  rep(i, N) cout << max(left.at(i), right.at(i)) << endl;
  
  return 0;
}




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

int main() {
  uint64_t N;
  std::cin >> N;
  std::vector<uint64_t> a(N);
  for (unsigned i = 0; i < N; ++i) {
    std::cin >> a[i];
  }
  uint64_t max = std::numeric_limits<uint64_t>::max() / 4;
  uint64_t min = 0;
  auto ok = [&](uint64_t k) -> bool {
    uint64_t kk = 0ull;
    for (auto &i : a) {
      if (i + k > N - 1) {
        kk += (i + k - N) / (N + 1) + 1;
      }
      if (kk > k) {
        return false;
      }
    }
    return true;
  };
  while (max - min > 2) {
    auto k = (max + min) / 2;
    bool b = false;
    for (unsigned i = 0; i < N; ++i) {
      if (k >= i) {
        auto bb = ok(k - i);
        if (bb) {
          b = true;
          break;
        }
      }
    }
    if (b) {
      max = k + 1;
    } else {
      min = k + 1;
    }
  }
  if (ok(min + 1)) std::cout << (ok(min) ? min : min + 1) << std::endl;
  else std::cout << min << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  vi H(N);
  cin >> H;
  vi dp(N,INF);
  dp[0] = 0;
  dp[1] = abs(H[0]-H[1]);
  rep(i, 2, N){
    chmin(dp[i], dp[i-2] + abs(H[i] - H[i - 2]));
    chmin(dp[i], dp[i-1] + abs(H[i] - H[i - 1]));
  }
  cout << dp[N - 1] << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 1792
S = list(input())
N = len(S)
M = (N-1)//2
S1 = S[:(N-1)//2]
S2 = S[(N+1)//2:]
S2.reverse()
S11 = S1[:M//2]
S12 = S1[M//2 + M%2:]
S12.reverse()

if S1 == S2 and S11 == S12:
    print('Yes')
else:
    print('No')

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

using namespace std;

int main() {
  string s; cin >> s;
  int g=0,p=0,ans=0;
  for(int i=0;i<s.size();++i) {
    if(s[i]=='g') {
      if(g>p) p++,ans++;
      else g++;
    } else {
      if(g>p) p++;
      else g++,ans--;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int x,k;
  cin >> k >> x;
  for(int i=x-k+1; i<=x+k-1; i++){
    cout << i << " ";
  }
  cout << endl;
  return 0;
}


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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e6 + 7;
const int N = 2e5 + 7;
const int M = 20;
const int mod = 998244353;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;

void solve1()
{
    int n,m;
    cin >> n >> m;
    vector < int > v(n + 1);
    vector < int > ans(n + 1 , -1);
    vector < pair < int , int > > g;
    for( int i = 0; i < m; i++ ){
        int x,y;
        cin >> x >> y;
        g.push_back({x , y});
        if( (ans[x] != -1 && ans[x] != y) || ( x == 1 && y == 0 && n != 1 ) ){
            cout << "-1";
            return;
        }
        ans[x] = y;
    }
    string res = "";
    for( int i = 1; i <= n; i++ ){
        if( ans[i] == -1 )ans[i] = 0;
        res += (char)(ans[i] + '0');
    }
    if( (int)res.size() > 1 && res[0] == '0' )res[0] = '1';
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;


int main(){
  	std::string str;
  	std::cin>>str;
  
  	int cnt = 0;
  	const int size = str.size();
  	for (int i=0; i<size/2; i ++){
      	if (str[i] != str[size-1-i])
          	cnt ++;     
    }
  	std::cout<<cnt;
  
  
  
 	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#define mod 3.1415926535897932384626
using namespace std;
typedef long long ll;
int a[200005]={0};
int b[200005]={0};
  int main()
  {   int i,n;
      cin>>n;
      for(i=2;i<=n;i++)
         { cin>>a[i];
           b[a[i]]++;
       }
       for(i=1;i<=n;i++)
       cout<<b[i]<<endl;
   }

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

int main() {
   int k;
   cin >> k;
   if(k%2){
      cout << (k/2)*(k+1)/2;
   }else{
      cout << (k/2)*(k/2);
   }
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

const int MN = 2020;
int n;
vector<int> g[MN];

int dfs(int p, int b, int k, int dps = 0) {
    int ans = 0;
    if (dps >= k) ans++;
    for (int d : g[p]) {
        if (d == b) continue;
        ans += dfs(d, p, k, dps+1);
    }
    return ans;
}
int main() {
    int k;
    cin >> n >> k;
    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = n;
    for (int i = 0; i < n; i++) {
        int co = 0;
        for (int s: g[i]) {
            co += dfs(s, i, k/2);
        }
        ans = min(ans, co);
    }
    for (int s = 0; s < n; s++) {
        for (int t: g[s]) {
            int co = dfs(s, t, (k+1)/2)+dfs(t, s, (k+1)/2);
            ans = min(ans, co);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
k, m = map(int, input().split())
for i in range(k):
  ans = list(map(int, input().split()))
  ans.pop(0)
  if i == 0:
    same = ans
  else:
    ans_set = set(ans)
    same_set = set(same)
    same = list(ans_set & same_set)
print('{}'.format(len(same)))

Measured memory_bytes: 3060
// JavaProgram.cpp
// Author : Priydarshi Singh (@dryairship)
// One cat just leads to another. One bug leads to two others.

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

// I like my types defined.
typedef long long           ll;
typedef pair<int, int>      pii;
typedef pair<ll, ll>        pll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef vector<pii>         vii;
typedef vector<pll>         vll;
typedef set<int>            si;
typedef map<string, int>    msi;
typedef map<int, int>       mii;

// Traditional science is all about finding "hashtag define"s.
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n, c)        for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define fill1(a)            memset(a, -1, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

// When you realize MOD > INF...
int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const ll LINF    =          1e18;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

// I'D SPAM. Hehe.
ll gcdEx                    (ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;} 
ll x1,y1,gcd=gcdEx          (b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)         {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
ll modD(ll a, ll b)         {return (modI(b,MOD)*(a%MOD))%MOD;}
ll modS(ll a, ll b)         {return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;} y=y>>1; x=(x*x)%MOD;} return r;}
ll modA(ll a, ll b)         {return ((a%MOD)+(b%MOD))%MOD;}
ll modM(ll a, ll b)         {return ((a%MOD)*(b%MOD))%MOD;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[105];
int dp[200005];

void solve(int TEST_CASE){
    int n, k;
    cin >> n >> k;
    fr(i,n) cin >> a[i];
    fill(dp);
    fr(i,k){
        if(dp[i]) continue;
        fr(j,n){
            dp[i+a[j]]=1;
        }
    }
    if(dp[k]) cout << "First";
    else cout << "Second";
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    int h[100000];
    for(int i=0;i<n;i++)cin>>h[i];
    int dp[100000];
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=2000000000;
        for(int j=1;j<=k&&0<=i-j;j++){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;
}


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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  while (cin >> n) {
    int count = 0;
    for (int a = 0; a < 10; a ++) {
      for (int b = 0; b < 10; b ++) {
        for (int c = 0; c < 10; c ++) {
          for (int d = 0; d < 10; d ++) {
            if (a + b + c + d == n) {
              count += 1;
            }
          }
        }
      }
    }
    cout << count << endl;
  }
}


Measured memory_bytes: 3176
N = int(input())
K = int(input())
x = list(map(int,input().split())) 

Ans = 0

for i in range(N):
	p = abs(x[i])
	q = abs(K - x[i])
	if p >= q :
		Ans += 2 * q
	if p < q:
		Ans += 2 * p

print(Ans)

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

using namespace std;

const int MAXN=1e3+10;

int n,k,a[MAXN],ans=0;

int main() {
	cin>>n>>k;
	for(int i=1; i<=n; ++i) cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1; i<=k; ++i) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

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

class E
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

		int g = Gcd(h[0], h[1]), a = h[0] / g, b = h[1] / g;
		var s0 = ExtendedEuclid(a, b);
		var s = new[] { s0, new[] { s0[0] + b, s0[1] - a }, new[] { s0[0] - b, s0[1] + a } }
			.OrderBy(r => Math.Abs(r[0]) + Math.Abs(r[1]))
			.ThenBy(r => r[0] - r[1])
			.First();
		Console.WriteLine(string.Join(" ", s));
	}

	static int Gcd(int a, int b) { for (int r; (r = a % b) > 0; a = b, b = r) ; return b; }

	static long[] ExtendedEuclid(long a, long b)
	{
		if (b == 1) return new[] { 1, 1 - a };
		long r;
		var q = Math.DivRem(a, b, out r);
		var t = ExtendedEuclid(b, r);
		return new[] { t[1], t[0] - q * t[1] };
	}
}



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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	ll n;
	cin >> n;
	
	string ans="";
	while(n){
		ans += char('a' + (n-1)%26);
		n = (n-1) / 26;
	}
	reverse(all(ans));
	
	cout << ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3652
#include"bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = b - 1; i >= a; i--)
#define RREP(i, n) RFOR(i, 0, n)
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define rrep(i, a, b) for (auto i = a; i > b; i--)
#define range(i, a, b) (a <= i && i < b)
#define ll long long
#define fi first
#define fs first
#define se second
#define sc second
//#define int long long
using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
typedef pair<int, int> P;

int n;
vec dp;

void solve() {
	vector<P> a(n);
	int sum1 = 0, sum2 = 0;
	REP(i, n) cin >> a[i].fs >> a[i].sc, sum1 += a[i].fs, sum2 += a[i].sc;

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

	if (sum1 >= a.back().fs * 2) {
		cout << sum1 + sum2 << endl;
		return;
	}

	int k = a.back().fs * 2 - sum1;
	vec dp(k + 1, 0);
	dp[0] = 1;

	REP(i, n - 1) {
		RREP(j, k) {
			if (j + a[i].sc <= k) dp[j + a[i].sc] |= dp[j];
		}
	}

	int mx = 0;
	REP(i, k + 1) if (dp[i]) mx = i;

	cout << a.back().fs * 2 + sum2 - mx << endl;
}

int main() {
	while (cin >> n, n) solve();
}


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;


string S;
ll ans;
int ssize;
vector<int> nums;

ll calc(vector<bool> b){
  ll ret=0;
  ll weight = 1;
  for(int i=ssize-1;i>=0;i--){
    ret += nums[i]*weight;
    if(i!=0 && b[i-1]) weight*= 10;
    else weight = 1;
  }
  return ret;
}

ll dfs(vector<bool> b){
  ll ret=0;
  if((int)b.size() == ssize-1){
    return calc(b);
  }
  else{
    vector<bool> b1 = b;
    vector<bool> b2 = b;
    b1.pb(false);
    b2.pb(true);
    ret += dfs(b1);
    ret += dfs(b2);
  }
  return ret;
}

int main(){
  cin >> S;
  ssize = (int)S.size();
  rep(i,ssize){
    nums.pb(S[i]-'0');
  }
  vector<bool> b;
  ans = dfs(b);
  cout << ans << endl;
  return 0;
}


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

int main(int argc, char **argv) {
    int count = 0;
    std::string s;

    std::cin >> s;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '1') {
            count++;
        }
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template <class T> void out(const T &val) { cout << val << endl; }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int a;
    sf(a);
    bool ok = false;
    for (int i =1 ; i <= 9; ++i) {
        for (int j =1 ; j <= 9; ++j) {
            if (i * j == a) {
                ok = true;
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;

int main() {

	Int p, q, r;
	cin >> p >> q >> r;

	cout << min({ p + q, p + r, q + r }) << endl;

}

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

class AtCoder {
  static void Main() {
    var input = Console.ReadLine().Trim().Split(' ');
    var A = int.Parse(input[0]);
    var B = int.Parse(input[1]);
    
    if(A >= 10 || B >= 10) {
      Console.WriteLine(-1);
    } else {
      Console.WriteLine(A * B);
    }
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 33003;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;
ll n,s;
ll fun(ll i,ll temp)
{
    ll sum =0,r=0;
    while(temp>0)
    {
        r += temp%i;
        temp = temp/i;
    }
    return r;
}
int main(){

cin>>n>>s;
if(n==s){

cout<<n+1;
return 0;}
if(s>n)
{
	cout<<"-1";
	return 0;
}
for(ll i=2;i*i<=n;i++)
{
	if(fun(i,n)==s)
	{
		cout<<i;
		return 0;
	}
}
ll k=sqrt(n);
rep(i,k+1,1)
{
	ll x=s-i;
	ll y=(n-x)/i;
	if(x>=0&&(n-x)%i==0&&i<y&&x<y)
	{
		cout<<y;
		return 0;
	}

}
cout<<-1;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	s := scanString()

	ans := 0

	for i := 0; i < 1000; i++ {
		a := []int{i/100,i%100/10,i%10}
		cnt := 0
		for i := 0; i < n; i++ {
			num := int(s[i]-'0')
			if a[cnt] == num {
				cnt++
			}

			if cnt == 3 {
				ans++
				break
			}
		}
	}

	fmt.Fprintln(wr, ans)
}


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

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

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

	int n, num;
	cin >> n >> num;

	int ans = num;

	for(int i = 0; i < n; ++i) {
		int in, out;
		cin >> in >> out;
		num += in - out;

		if(num < 0) {
			ans = 0;
			break;
		}

		chmax(ans, num);
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
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; }

int main() {
  ll n,k;
  cin >> n >> k;
  
  vector<ll> v(n);
  rep(i, n)
    cin >> v.at(i);
  
  ll ans=0;
  rep(i, n){
    if(v.at(i) >= k)
      ans++;
  }
  cout << ans << endl;
}

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

int main(void) {

	//??\???
	int x, y;
	cin >> x >> y;

	int a, b;
	if(x > y) {
		a = x;
		b = y;
	} else {
		a = y;
		b = x;
	}

	while(a >= b) {
		int tmp1 = a % b;
		int tmp2 = b;

		//cout << "tmp " << tmp1 << " " << tmp2 << endl;

		if(tmp1 > tmp2) {
			a = tmp1;
			b = tmp2;
		} else {
			a = tmp2;
			b = tmp1;
		}
		//cout << "ab " << a << " " << b << endl;

		if(b==0)	break;
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define eps 1e-12
const double Pi = acos(-1);
int a, b, x;
int main()
{
	scanf("%d%d%d", &a, &b, &x);
	double l = 0, r = 90;
	while (l + eps < r)
	{
		double mid = (l + r) / 2;
		double s = mid / 180 * Pi;
		double l1 = tan(s) * a, l2 = (1 / tan(s)) * b, v;
		if (l1 < b)
			v = 0.5 * (b + b - l1) * a * a;
		else
			v = 0.5 * b * a * l2;
		if (v > x)
			l = mid;
		else
			r = mid;
	}
	printf("%.12lf\n", l);
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [a, b, c, d] <- readIntList
  print $ max (a * b) (c * d)


Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <list>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int>a(n);
	list<int>b;
	bool f = true;
	if(n%2 == 0){
		f = true;
	}else{
		f = false;
	}
	for(int i=0; i<n; ++i){
		int tmp;
		cin >> tmp;
		if(f){
			b.push_back(tmp);
		}else{
			b.push_front(tmp);
		}
        if(f) f=0;
        else f=1;
	}

	for(auto x : b){
		cout << x << " ";
	}

	cout << endl;
    return 0;
}

Measured memory_bytes: 10388
#include <iostream>
#include <string>
#include <utility>
using namespace std;
int toNumber(char c){
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	}
	return 0;
}
int main()
{
	int n, sa, sb, k, r, i;
	string a, b;
	int sum[100] = {};
	cin >> n;
	while (n--){
		cin >> a >> b;
		if (a.size() < b.size()) swap(a, b);
		sa = a.size();
		sb = b.size();
		if (sa > 80){
			cout << "overflow\n";
			continue;
		}
		k = i = 0;
		for (; i < sa; ++i){
			if (i < sb) k = toNumber(a[sa - 1 - i]) + toNumber(b[sb - 1 - i]) + k;
			else 		k = toNumber(a[sa - 1 - i]) + k;
			r = k % 10;
			k = k / 10;
			sum[i] = r;
		}
		if (0 != k) sum[i] = k;
		else --i;
		if (i >= 80){
			cout << "overflow\n";
			continue;
		}
		for (int d = i; d >= 0; --d)
			cout << sum[d];
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string str1;
    cin >>str1;
    int q,a,b;
    string str2, str3;
    cin>>q;
    
    for(int i=0; i<q; i++){
        cin >>str2 >>a >>b;
        if(str2 == "print"){
            cout <<str1.substr(a, b-a+1) <<endl;
        }else if(str2 == "reverse"){
            string str4 = str1.substr(a,b-a+1);
            reverse(str4.begin(), str4.end());
            str1 = str1.substr(0,a) + str4 + str1.substr(b+1, str1.size()-a-1); 
        }else{
            cin >>str3;
            str1 = str1.substr(0,a)+ str3 + str1.substr(b+1, str1.size()-a-1);
        }
    }
}


Measured memory_bytes: 3216
n,m=map(int,input().split())
ab=[]
for i in range(n):
    a_,b_=map(int,input().split())
    ab.append([a_,b_])
ab.sort(key=lambda x:x[0] )
i=-1
t=0
ans=0
while t < m:
    i+=1
    t+=ab[i][1]
    ans+=ab[i][0]*ab[i][1]
ans -= (t-m) * ab[i][0]
print(ans)

Measured memory_bytes: 21224
#include <bits/stdc++.h>
using namespace std;
#pragma region Macros
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W,K; cin >> H >> W >> K;
    vector<string> S(H); cin >> S;
    int ans=0;
    for (int mask1=0;mask1<(1<<H);++mask1){
        for (int mask2=0;mask2<(1<<W);++mask2){
            int cnt=0;
            for (int i=0;i<H;++i){
                for (int j=0;j<W;++j){
                    if ((mask1&1<<i)&&(mask2&1<<j)){
                        cnt+=(S[i][j]=='#');
                    }
                }
            }
            ans+=(cnt==K);
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){

    int n, k; cin >> n >> k;
    vector<int> a(n + 1, 0LL);
    vector<int> b(n + 1, 0LL);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        b[i] = max(0LL, a[i]);
        a[i] += a[i - 1];
        b[i] += b[i - 1];
    }

    int ans = 0;
    for(int l = 1; l <= n; l++){
        int r = l + k - 1;
        if(r > n) continue;
        ans = max(ans, b[l - 1] + b[n] - b[r] + max(0LL, a[r] - a[l - 1]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792