akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
	int N,L;
	int[] a;
	public void solve() {
		N = nextInt();
		L = nextInt();
		
		a = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
		}
		
		int front = -1;
		for(int i = 0;i < N - 1;i++){
			if(a[i] + a[i + 1] >= L){
				front = i;
				break;
			}
		}
		
		if(front == -1){
			out.println("Impossible");
			return;
		}
		
		ArrayList<Integer> ans = new ArrayList<Integer>();
		ans.add(front);
		for(int i = front - 1;i >= 0;i--){
			ans.add(i);
		}
		
		for(int i = front + 1;i < N - 1;i++){
			ans.add(i);
		}
		
		Collections.reverse(ans);
		out.println("Possible");
		for(int i : ans){
			out.println(i + 1);
		}
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
 
	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}
 
	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt() {
		return Integer.parseInt(next());
	}
 
	public long nextLong() {
		return Long.parseLong(next());
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 22764
n = int(input())
la = [10000]+[int(w) for w in input().split()]+[-1]

money = 1000

cheap = la[1]
for i in range(2, len(la)):
    if la[i] >= la[i-1]:
        cheap = min(cheap, la[i-1])
        continue
    if la[i-1] >= la[i-2]:
        kabu = money//cheap
        money += kabu*(la[i-1] - cheap)
        cheap = la[i]
    cheap = min(cheap, la[i])
print(money)


Measured memory_bytes: 9184
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <random>
 
using namespace std;
 
using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;
 
#define rep(i, n) for (i32 i = 0; i < (n); ++i)
#define repr(i, n) for (i32 i = ((n)-1); i >= 0; --i)
#define urep(i, n) for (u32 i = 0; i < (n); ++i)
#define urepr(i, n) for (u32 i = ((n)-1); i >= 0 && i < (n); --i)
#define all(v) v.begin(), v.end

int main() {
    i64 A, B;
    cin >> A >> B;
    if (A % 2 == B % 2) {
        printf("%lld\n", (A + B) / 2);
    } else {
        puts("IMPOSSIBLE");
    }
    return 0;
}


Measured memory_bytes: 256
import math

def v(a, b, t):
    if (b * math.tan(math.pi / 2 - t * math.pi / 180) <= a):
        return a * b * b * math.tan(math.pi / 2 - t * math.pi / 180) / 2
    else:
        return a * a * (b - a * math.tan(t * math.pi / 180) / 2)

a, b, x = map(int, input().split())
left = 0
right = 90
eps = 1e-7
for _ in range(1000):
    mid = (left + right) / 2
    if (v(a, b, mid) > x):
        left = mid
    else:
        right = mid
print(mid)



Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	int N, T;
	cin >> N >> T;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<int>V(N);
	V[0] = A[0];
	for (int i = 1; i < N; i++) {
		V[i] = min(A[i], V[i - 1]);
	}
	int d = 0;
	rep(i, N) {
		d = max(d, A[i] - V[i]);
	}
	int cnt = 0;
	rep(i, N) {
		if (A[i] - V[i] == d) {
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1024
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes) if b else print(no)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
n,m,x=n1()
ca=n3(n)
ans=9999999999

import itertools
book=list(itertools.product([0,1], repeat=n))
price=[]
for line in book:
    p=0
    for i in range(n):
        if line[i]==1:
            p+=ca[i][0]
            
    price.append(p)
for i in range(len(book)):
    t=book[i]
    s=[0]*m
    for j in range(n):
        if t[j]==1:
            s=[s[k]+ca[j][k+1] for k in range(m)]
    if len([y for y in s if y>=x])==m:
        ans=min(ans,price[i])
if ans==9999999999:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9908
#include <bits/stdc++.h>
#include <algorithm>
    
using namespace std;
    
int N;
int joias[100][2];
long long int pd[100][100001];
    
long long int mam(int i, int p){
    if (i == N || p == 0)
        return 0;
    
    if (pd[i][p] == -1){
        if (p >= joias[i][0])
            return pd[i][p] = max(joias[i][1] + mam(i + 1, p - joias[i][0]), mam(i + 1, p));
        return pd[i][p] = mam(i + 1, p);
    }
    return pd[i][p];
}
    
int main(){
    int W;
    
    scanf("%d %d", &N, &W);
    
    for (int i = 0; i < N; i++){
        memset(pd[i], -1, __SIZEOF_LONG_LONG__ * (W + 1));
    }
    
    for (int i = 0; i < N; i++){
        scanf("%d %d", &joias[i][0], &joias[i][1]);
    }
    
    printf("%lld\n", mam(0, W));
    
    return 0;
}

Measured memory_bytes: 78336
using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int S = int.Parse(Console.ReadLine());
            int h = S / 3600;
            int m = S % 3600;
            int s = m % 60;
            m = m / 60;
            Console.WriteLine("{0}:{1}:{2}", h, m, s);
        }
    }
}

Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long H, W;
  cin >> H >> W;
  if (H == 1 || W == 1)
    cout << 1 << '\n';
  else
    cout << (H * W + 1ll) / 2 << '\n';
  return 0;
}


Measured memory_bytes: 3620
#coding:utf-8
ans = [0] * 4

for i in range(3):
  a, b = map(int, input().split())
  ans[a-1] += 1
  ans[b-1] += 1
  
for i in ans:
  if i >= 3:
    print("NO")
    exit()

print("YES")
  


Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i, s, n) for (ll(i) = (s); (i) < (n); ++(i))
#define rep(i, n) reps(i, 0, n)
#define reptr(i, n) for (ll(i) = (n); (i) >= 0; --(i))
#define All(x) (x).begin(), (x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll, ll>
#define pi pair<int, int>
#define mp make_pair
#define pb push_back
const ll MOD = 1e9 + 7;
const ll INF = 1e10 + 1;
using namespace std;
#define NOT_EXIST -1

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

signed
main()
{
  int N, M;
  cin >> N >> M;
  vector<int> p(M);
  vector<vector<int> > s(M);
  rep(i, M) {
	  int k;
	  cin >> k;
	  rep(j,k){
		  int tmp;
		  cin >> tmp;
		  tmp--;
		  s[i].pb(tmp);
	  }
  }
  rep(i, M) { cin >> p[i]; }

  ll ans = 0;
  for(int i=0;i<(1<<N);i++){
  	bool flag = true;
  	for(int j=0;j<M;j++){
  		int num = 0;
  		for(int k=0;k<s[j].size();k++){
  			if( i&(1<<s[j][k] ) ){
  				num++;
  			}
  		}
  		if(num%2 != p[j]) flag = false;
  	}
  	if(flag) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll N; cin >> N;
    map<string, ll> S;
    REP(i, N) {
        string s; cin >> s;
        S[s]++;
    }
    cout << "AC x " << S["AC"] << "\n";
    cout << "WA x " << S["WA"] << "\n";
    cout << "TLE x " << S["TLE"] << "\n";
    cout << "RE x " << S["RE"] << "\n";
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <map>

#define ll long long int
#define MAX 1000000

using namespace std;

int main(void)
{

	int a, b, c, d;
	int ab, cd;
	cin >> a >> b >> c >> d;

	ab = a * b;

	cd = c * d;

	if (ab >= cd) {
		cout << ab << endl;
	}
	else {
		cout << cd << endl;
	}


	return (0);
}




Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	v = readline() |> split |> parseMap
	s = sum(v)
	ans = 0
	for i in 1:k
		for j in 0:i>>1
			z = i-j
			if z<=n
				for l in 0:z
					a = Int[]
					for o in 1:l
						push!(a,v[o])
					end
					for o in 1:z-l
						push!(a,v[n+1-o])
					end
					a = sort(a)
					sa = sum(a)
					for o in 1:j
						sa-=a[o]
					end
					ans = max(ans,sa)
				end
			end
		end
	end
	println(ans)
end

main()

Measured memory_bytes: 155312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int count=0;

		for(int i=Math.max(a, b);i>=1;i--) {
			if(a%i==0&&b%i==0) {
				count++;
			}
			if(count==k) {
				System.out.println(i);
				break;
			}
		}
	}
}

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

inline bool inrange(int x, int y) {
  return (0<=x&&x<8) && (0<=y&&y<8);
}

//string F[8];
char F[8][9];
bool used[8][8];
int turn;

bool debug;

int dx, dy;
int dfs(int x, int y, char me, int cnt) {

  x += dx, y += dy;
  if(!inrange(x, y)) { return 0; }
  if(F[y][x] == '.') { return 0; }
  if(F[y][x] == me) {
    return cnt;
  }
  used[y][x] = 1;
  int r = dfs(x, y, me, cnt+1);
  if(r == 0) { used[y][x] = 0; }
  return r;
}

#define DREP(i, a, b, c, d)                                 \
  for(int i=turn&1?a:c; turn&1?i>=b:i<=d; turn&1?i--:i++)

int main() {
  /*
  rep(i, 8) rep(j, 8){
    cin >> F[i][j];
  }
  //  */
  rep(i, 8) cin >> F[i];
  
  int ucnt = 0;
  for(turn=0; turn<=64; turn++) {
    int pl;
    bool u[8][8] = {};
    int mx = 0;
    DREP(i, 7, 0, 0, 7)
      DREP(j, 7, 0, 0, 7) {
      if(F[i][j] == '.') {
        rep(a, 8) rep(b, 8) used[a][b] = 0;
        used[i][j] = 1;
        int r = 0;
        for(dy=-1; dy<2; dy++) for(dx=-1; dx<2; dx++) {
          if(dx == 0 && dy == 0) { continue; }
          r += dfs(j, i, "ox"[turn&1], 0);
        }            
        
        if(mx < r) {
          memcpy(u, used, sizeof u);
          mx = r;
          pl = turn&1;
        }
        
      }
    }
    if(mx > 0) {
      rep(i, 8) rep(j, 8)
        if(u[i][j]) { F[i][j] = "ox"[pl]; }
      
      ucnt = 0;
    }
    else {
      if(ucnt) { break; }
      ucnt ++;
    }
  }
  
  rep(i, 8) {
    rep(j, 8) {
      cout << F[i][j];
    }
    cout << endl;
  }
  
  return 0;
}

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

typedef pair <int, int> pii;

const int MaxN = 200000 + 5;
const int MaxH = 200000 + 5, MaxW = 200000 + 5;

int N, H, W;
int X[MaxN], Y[MaxN];
int dp[MaxN];
vector <int> vec[MaxW];

void init() {
    scanf("%d %d %d", &H, &W, &N);
    for (int i = 1; i <= N; ++i)
        scanf("%d %d", &X[i], &Y[i]);
}

void solve() {
    for (int i = 1; i <= N; ++i)
        vec[Y[i]].push_back(X[i]);
    for (int i = 1; i <= W; ++i) sort(vec[i].begin(), vec[i].end());

    dp[1] = 1;
    for (int i = 1; i < W; ++i) {
        int j = i + 1;
        auto beg = lower_bound(vec[j].begin(), vec[j].end(), dp[i] + 1);
        if (beg == vec[j].end()) dp[j] = dp[i] + 1;
        else {
            int worst = dp[i] + 1;
            for (; beg != vec[j].end(); ++beg) {
                if (*beg == worst) worst++;
                else break;
            }
            dp[j] = worst;
        }
    }

    int ans = H;
    for (int i = 1; i <= N; ++i) {
        int x = X[i], y = Y[i];
        if (x > dp[y]) ans = min(ans, x - 1);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 11136
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S: Vec<char> = sc.chars();
    let mut ans = 0;
    let mut cnt = 0;
    for i in 0..S.len() {
        if S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T' {
            cnt += 1;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    println!("{}", ans);
}


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

int64_t H[300+10];

int main() {


    int N=0;
    int K=0;
    ll ans=1LL<<60;
    cin >> N;
    cin >> K;
    if(N==K) {
        std::cout << "0"; 
        return 0;
    }
    ll dp[K+1][N+1];
    
    for(int i=1; i<=N;i++){
        cin >> H[i];
    }
    for(int i=0; i<K+1; i++){
        for(int j=0; j<N+1; j++){
            dp[i][j]=1LL<<60;
        }
    }

    dp[K][0]=0;

    for(int i=0; i<=N; i++){
        for(int j=K; j>=0; j--){
            for(int y=j; y>=0; y--){
                if(i+(K+1)-y>N) continue;
                int diff = H[i+(K+1)-y]-H[i+K-j];
                diff = max(diff,0);
                dp[y][i+(K+1)-y]=min(dp[y][i+(K+1)-y],dp[j][i+K-j]+diff);
                if(i+(K+1)-y>=K-y+(N-K)) ans = min(ans, dp[y][i+(K+1)-y]);
            }
        }
    }
    std::cout << ans;
    return 0;
}


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

int main(){
  int n;
  std::cin >> n;
  ll ans=0;
  for (int i = 1; i <=n; i++) {
    if(i%3==0 || i%5==0)continue;
    ans+=i;
  }
  std::cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main ()
{
	int n, i=0, minn=200001, pas=0;
	cin>>n;
	int a[n+1];
	for(i=1; i<=n; i++){
		cin>>a[i];
	}
	for(i=1; i<=n; i++){
		if(a[i]<minn){
			minn=a[i];
			pas++;
		}
	}
	cout<<pas;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = scan.nextInt();
		}
		int min = Integer.MAX_VALUE;

		if (x[0] >= 0) {
			System.out.println(x[k-1]);
			return;
		}
		if (x[n-1] < 0) {
			System.out.println(Math.abs(x[n-k]));
			return;
		}
      
		for (int i = 0; i < n-k+1; i++) {
			if (x[i+k-1] < 0) {
				int ans = Math.abs(x[i]);
				if (ans < min) min = ans;
			}
			else if (x[i] < 0 && x[i+k-1] >= 0) {
				int ans1 = Math.abs(x[i])*2 + x[i+k-1];
				int ans2 = x[i+k-1]*2 + Math.abs(x[i]);
				int ans = Math.min(ans1, ans2);
				if (ans < min) min = ans;
			}
			else if (0 <= x[i]) {
				int ans = x[i+k-1];
				if (ans < min) min = ans;
			}
		}
		System.out.println(min);
	}
}


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

#define ll long long
#define pb push_back
#define mp make_pair

void solve() {

	char c;
	cin >> c;
	if(c >= 'a' and c<='z')cout << 'a' << endl;
	else cout << 'A' << endl;

    


}


int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    ll T;
    T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }




}


Measured memory_bytes: 3608
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    double power2 = Math.pow(a, 2);
    double power3 = Math.pow(a, 3);
    int sum = a + (int)power2 + (int)power3;
    System.out.println(sum);
  }
}

Measured memory_bytes: 35560
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;
typedef pair<ll,int> P;


int main(){
  int A,P;
  cin>>A>>P;

  cout<<(A*3+P)/2<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int n , x , t;
  scanf("%d %d %d",&n ,&x, &t);

  int ans;
  if(n%x == 0){
    ans = t*(n/x);
  }

  else{
    ans = t *(n/x +1); 
  }

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

  return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    int ori_i;
    for(int i=1; i<=n; i++){
        if(i%3 == 0){
            cout << " " << i;
        }else{
            ori_i = i;
            while(true){
                if(ori_i % 10 == 3){
                    cout << " " << i;
                    break;
                }else{
                    if(ori_i / 10 == 0){
                        break;
                    }else{
                        ori_i /= 10;
                    }
                }
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3112
#include<stdio.h>

#include<algorithm>

using namespace std ;


#define MAX_N 100


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

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

		num[ i ] = -a ;
	}

	sort( num ,num + N ) ;

	int cnt = 0 ;
	for( i = 1 ; i <= N ; ++i )
	{
		if( -num[ i - 1 ] >= i )
		{	++cnt ;	}
	}

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

	return 0 ;
}


Measured memory_bytes: 2752
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[2000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    sort(a, a + n);
    int sol = 0;
    for (int i = 0; i < n; ++i)
    {
        int j = i + 1, k = i + 2;
        while (j < n)
        {
            while (k < n && a[k] < a[i] + a[j])
                k++;
            
            sol += k - j - 1;
            ++j;
        }
    }
    cout << sol;
}


Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
int n , op[ N ];
LL vl[ N ] , sv[ N ] , ans , ev[ N ];
void init(){
  n = getint();
  for( int i = 1 ; i <= n ; i ++ ){
    if( i > 1 ){
      char c[ 9 ]; scanf( "%s" , c );
      if( c[ 0 ] == '-' )
        op[ i ] = 1;
    }
    vl[ i ] = getint();
    sv[ i ] = sv[ i - 1 ] + vl[ i ];
    if( op[ i ] ) ans -= vl[ i ];
    else ans += vl[ i ];
    ev[ i ] = ans;
  }
}
void solve(){
  int lst = -1;
  for( int i = n ; i >= 1 ; i -- )
    if( op[ i ] ){
      if( lst != -1 ){
        LL tans = ev[ i - 1 ] - ( sv[ lst - 1 ] - sv[ i - 1 ] ) +
                                ( sv[ n ] - sv[ lst - 1 ] );
        //printf( "%d %lld %d %lld %lld %lld\n" , i , tans , lst , ev[ i - 1 ] , sv[ lst ] - sv[ i - 1 ] , sv[ n ] - sv[ lst - 1 ] );
        ans = max( ans , tans );
      }
      lst = i;
    }
  printf( "%lld\n" , ans );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){
    string N; cin >> N;
    for(ll i = 0; i < N.length(); i++){
        if(N[i] == '1') N[i] = '9';
        else if(N[i] == '9') N[i] = '1';
    }
    cout << N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e18;

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

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


int main()
{
	ll n;
	cin>>n;
	ll a[n]={0};
	ll x;
	for(int i=1;i<n;i++)
	{
		cin>>x;
		a[x-1]++;
	}
	for(int i=0;i<n;i++)
	{
		cout<<a[i]<<" ";
	}
}


Measured memory_bytes: 5152
function Main(input) {
    input = input.split(" ");
    
  	var a = Number(input[0]);
	var b = Number(input[1]);
    var ans = a+b;
  	ans = Math.max(a-b, ans);
  	ans = Math.max(a*b, ans);
    if(ans==-0) ans = 0;
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29560
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner cin = new Scanner(System.in);
        int x = cin.nextInt();
        if(x == 3 || x == 5 || x == 7)
            System.out.println("YES");
        else System.out.println("NO");
    }
}

Measured memory_bytes: 21844
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                 \
  sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(    \
            c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) cerr << boolalpha << i;
  ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
  sim dor(const c &) { ris; }
#endif
}
;
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define memo(dp, val) memset(dp, val, sizeof(dp))
#define NINJA                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define all(a) a.begin(), a.end()
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define dloop(i, n) for (int i = n - 1; i >= 0; i--)
#define iii tuple<int, int, int>
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int, int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 2010;
int s;
int dp[mxn];

int32_t main() {
  NINJA;

  cin >> s;

  dp[0] = 1;

  for (int i = 3; i <= s; i++) {
    for (int j = i - 3; j >= 0; j--) {
      dp[i] = (dp[i] + dp[j]) % mod;
    }
  }

  cout << dp[s] << endl;

  return 0;
}

Measured memory_bytes: 3604
#pragma GCC optimize "O3"

#define F first
#define S second

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

constexpr int N = 200000;

int n, k, cnt[N+1];

int main() {
  scanf("%d %d", &n, &k);
  for(int i = 0; i < n; ++i) {
    int x; scanf("%d", &x);
    ++cnt[x];
  }
  int nz = count_if(cnt+1, cnt+N+1, [](int i) { return i; });
  sort(cnt+1, cnt+N+1);
  int i = 1, ans = 0;
  while(nz > k) {
    while(cnt[i] == 0)
      ++i;
    --nz;
    ans += cnt[i];
    ++i;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void)
{
    vector<string> s(3);
    cin >> s[0] >> s[1] >> s[2];

    int count[3];
    for(int i = 0; i < 3; i++) count[i] = 0;

    int player = 0; 

    while (1)
    {
        if(count[player] == s[player].size()) break;
        char card = s[player][count[player]];
        count[player]++;

        player = card - 'a';
    }

    cout << char('A' + player) << endl;
    
    return 0;
}

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

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

// rep
//------------------------------------------
#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()
#define DEBUG(x) cerr << #x << ": " << x << '\n'


VI l(10010);
VI r(10010);

int n, m;
signed main()
{
      cin >> n >> m;
      l.resize(m);
      r.resize(m);
      REP(i, m){
          cin >> l[i] >> r[i];
      }  
      sort(ALL(l));
      sort(ALL(r));

      cout << max(min(n, r.front() - l.back() + 1), 0LL) << endl;
}

Measured memory_bytes: 1920
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int x = 0;
		int y = 0;
		int anc = 99999999;
		for(int i = 1;i <= a-1;i++){
			x = i / 100000 + ((i % 100000) / 10000) + ((i % 10000) / 1000) + ((i % 1000) / 100) + ((i % 100) / 10) + (i % 10);
			y = a - i;
			x = x + y / 100000 + ((y % 100000) / 10000) + ((y % 10000) / 1000) + ((y % 1000) / 100) + ((y % 100) / 10) + (y % 10);
			if(x < anc) anc = x;
		}
		System.out.println(anc);
	}
}

Measured memory_bytes: 23124
while True:
 S=raw_input()
 if S=='0':break
 m=[1]+[0 for i in range(10)]
 d=A=0
 e=1
 S=reversed(S)
 for c in S:
  d=(d+int(c)*e)%11  
  if int(c)!=0:A+=m[d]
  m[d]+=1
  e*=-1
 print A


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

ll gcd(ll a, ll b) {
    ll t = a % b;
    if (t == 0) return b;
    return gcd(b, t);
}

int main() {
    ll a, b; cin >> a >> b;
    ll g = gcd(a, b);

    vector<pair<ll, ll>> res;
    for (ll i = 2; i * i <= g; ++i) {
        if (g % i != 0) continue;
        ll num = 0;
        while (g % i == 0) {
            num++;
            g /= i;
        }
        res.push_back(make_pair(i, num));
    }
    if (g != 1) res.push_back(make_pair(g, 1));

    cout << res.size() + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int N;

int main() {
    cin >> N;
    int tmp, mn = N + 1, cnt = 0;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        if (tmp < mn) {
            cnt++;
            mn = tmp;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = [A[0]]
for i in range(1,N):
    B.append(B[-1]+A[i])
from collections import Counter
from math import factorial
L = Counter(B)
ans = 0
for key,value in L.items():
    if key == 0:
        ans += value
        if value > 1:
            ans += factorial(value)//(factorial(value-2)*factorial(2))
    else:
        if value > 1:
            ans += factorial(value)//(factorial(value-2)*factorial(2))
print(ans)

Measured memory_bytes: 41460
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N;
set<int> adj[MX];
bool pa[MX];
queue<int> todo;

void rEdge(int a, int b) {
    adj[a].erase(b), adj[b].erase(a);
}

void makePa(int x, int y) {
    pa[x] = pa[y] = 1;
    rEdge(x,y);
    for (int i: adj[y]) {
        rEdge(y,i);
        if (sz(adj[i]) == 1) todo.push(i);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    F0R(i,N-1) {
        int a,b; cin >> a >> b;
        adj[a].insert(b), adj[b].insert(a);
    }
    
    FOR(i,1,N+1) if (sz(adj[i]) == 1) todo.push(i);
    while (sz(todo)) {
        int x = todo.front(); todo.pop();
        if (pa[x]) continue;
        if (sz(adj[x]) == 0) {
            cout << "First";
            exit(0);
        }
        int y = *adj[x].begin();
        makePa(x,y);
    }
    
    FOR(i,1,N+1) if (!pa[i]) {
        cout << "First";
        exit(0);
    }
    
    cout << "Second";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 14592
n = int(input())
sdict = {}
for i in range(n):
    w = input()
    _w = ''.join(sorted(w))
    if _w not in sdict.keys():
        sdict[_w] = 1
    else:
        sdict[_w] += 1

def nc2(n):
    return int(n * (n-1) / 2)

n_dup = sum([nc2(val) for val in sdict.values() if val > 1])
print(int(n_dup))


Measured memory_bytes: 17892
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main() {
    int A, B;

    cin >> A >> B;

    int C = 1, cnt = 0;
    while(C < B) {
        cnt++;
        C += A - 1;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <ios>
#include <sstream>
#include <cstdio>

#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <regex>
#include <utility>

#include <cstddef>
#include <cstdint>
#include <cfloat>
#include <limits>

#include <array>
#include <bitset>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <valarray>
#include <vector>


#define UNS(ns) using namespace ns
#define USG(a, b) using a = b
#define FOR(i, a, b) for(itr i{a}; i < (b); ++i)
#define RFOR(i, a, b) for(itr i{(b)-1};i >= (a); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) std::begin(a), std::end(a)
#define TYPE(t) decltype(t)
#define _IT ::iterator
#define UN unsigned
#define INF std::numeric_limits<double>::infinity()

template<typename T>
inline bool in_range(T const &lower, T const &a, T const &upper){ return lower < a && a < upper;}


namespace fst{
  using i8 = std::int_fast8_t;  using i16 = std::int_fast16_t;
  using i32 = std::int_fast32_t;  using i64 = std::int_fast64_t;
  using u8 = std::uint_fast8_t; using u16 = std::uint_fast16_t;
  using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t;
}
namespace lst{
  using i8 = std::int_least8_t;  using i16 = std::int_least16_t;
  using i32 = std::int_least32_t;  using i64 = std::int_least64_t;
  using u8 = std::uint_least8_t; using u16 = std::uint_least16_t;
  using u32 = std::uint_least32_t; using u64 = std::uint_least64_t;
}

using namespace std;
using namespace fst;

using itr = i32;


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

  i32 N;

  cin >> N;

  vector<i32> L(2*N);

  for(auto& li : L) cin >> li;

  sort(ALL(L));

  i32 sum{};

  for(i32 i{}; i < 2 * N; i += 2)
    sum += L[i];


  cout << sum;




  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int H1,H2,M1,M2,K;
	
	scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);
	
	int sum1 = (H1*60) + M1;
	int sum2 = (H2*60) + M2;
	
	int sum3 = sum2 - sum1;
	 
	printf("%d", sum3 - K);
	
	return 0;
}

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

int main() {
    int a,b;
    cin>>a>>b;
    printf("%d %d\n",a*b, 2*(a+b));
    
    return 0;
    
   
}



Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		System.out.println(String.format("%d %d %d", z, x, y));
	}
}

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

int main() {
    long long H, W; cin >> H >> W;
    if(H == 1 || W == 1) cout << 1 << '\n';
    else cout << ((H + 1) / 2) * ((W + 1) / 2) + (H / 2) * (W / 2) << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int array[] = new int[N];

		int chocolate = 0;

		for(int i = 0; i < N; i++) {
			array[i] = sc.nextInt();
			chocolate += (D-1)/array[i];
		}
		chocolate += X + N;
		System.out.println(chocolate);
	}

}


Measured memory_bytes: 20820
# abc113_b.py
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
lowest = 10**9
ans = 0
for i in range(N):
    tmperture = abs(A-(T-H[i]*0.006))
    if abs(tmperture) < lowest:
        ans = i + 1
        lowest = tmperture
print(ans)

Measured memory_bytes: 3064
import math
n, k = map(int, input().split())
arr = list(map(int, input().split()))

max_length = max(arr)
low = 1
high = max_length - 1

while low <= high:
  mid = (low + high) //2
  cnt = 0
  for i in range(n):
    cnt += math.ceil(arr[i]/mid) - 1
  if cnt > k:
    low = mid + 1
  else:
    high = mid -1
    max_length = mid

print(max_length)


Measured memory_bytes: 104204
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int mod = 1000000007;

int main(){
    ll n;
    cin>>n;
    vector<pair<ll,ll>> k(n);
    rep(i,n){
        cin>>k[i].second>>k[i].first;
    }
    sort(k.begin(),k.end(),greater<pair<ll,ll>>());
    ll t=k[0].first;
    bool f=true;
    rep(i,n){
        t = min(k[i].first,t);
        if(t<k[i].second){
            f=false;
            break;
        }else{
            t -= k[i].second;
        }
    }
    if(t<0) f=false;
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3328
import sys
from functools import reduce
from fractions import gcd
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False

def ddprint(x):
  if DBG:
    print(x)

def fac2(x):
    r = 0
    while x%2==0:
        x //= 2
        r += 1
    return r

n,m = inm()
a = inl()
b = [x//2 for x in a]
r = fac2(a[0])
for i in range(1,n):
    if fac2(a[i]) != r:
        print(0)
        exit()
lc = reduce(lambda x,y: (x*y)//gcd(x,y), b, 1)
print(m//lc - m//(2*lc))


Measured memory_bytes: 89580
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}
/*
 Atcoder 100~200点代
 アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
//void solve(){ ll A,B,C; cin >> A >> B >> C; if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;} if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;} if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;} cout << "NO" << endl; return ; }
// https://abc043.contest.atcoder.jp/tasks/abc043_a
//void solve(){ ll N; cin >> N; cout << N*(N+1)/2 << endl; }
// https://abc044.contest.atcoder.jp/tasks/abc044_a
//void solve(){ll N,K,X,Y;cin>>N>>K>>X>>Y; cout<<X*min(N,K)+Y*max(0LL,N-K)<<endl;}
// https://abc045.contest.atcoder.jp/tasks/abc045_a
//void solve(){ll a,b,h;cin>>a>>b>>h;cout<<(a+b)*h/2<<endl;}
// https://abc046.contest.atcoder.jp/tasks/abc046_a
//void solve(){ ll a,b,c; cin >> a >> b >> c; set<ll> s; s.insert(a); s.insert(b); s.insert(c); cout << s.size() << endl; }
// https://abc047.contest.atcoder.jp/tasks/abc047_a
//void solve(){ll a,b,c;cin>>a>>b>>c;if(a==b+c||b==a+c||c==a+b)cout<<"Yes"<<endl;else cout<<"No"<<endl;}
// https://abc048.contest.atcoder.jp/tasks/abc048_a
//void solve(){string s1,s2,s3;cin>>s1>>s2>>s3;cout<<"A"<<s2[0]<<"C"<<endl;}
// https://abc049.contest.atcoder.jp/tasks/abc049_a
void solve(){char c;cin>>c;string s="aiueo";if(s.find(c)!=string::npos)cout<<"vowel"<<endl;else cout<<"consonant"<<endl;}
// https://abc050.contest.atcoder.jp/tasks/abc050_a
//void solve(){}
// https://abc051.contest.atcoder.jp/tasks/abc051_a
//void solve(){}
// https://abc052.contest.atcoder.jp/tasks/abc052_a
//void solve(){}
// https://abc053.contest.atcoder.jp/tasks/abc053_a
//void solve(){}
// https://abc054.contest.atcoder.jp/tasks/abc054_a
//void solve(){}

// Main function
int main(void) {cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

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

    int n; cin >> n;
    vector<ll> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    ll sum = accumulate(arr.begin(), arr.end(), 0LL);
    // if (arr[0] == *max_element(arr.begin(), arr.end())){
    //     cout << sum << endl;
    //     for (int i = 0; i < n-1; i++) cout << 0 << endl;
    //     return 0;
    // }

    vector<ll> ans(n);

    vi high(n, n);
    stack<int> stk;
    for (int i = n-1; i >= 0; i--){
        while (!stk.empty() && arr[stk.top()] <= arr[i]){
            stk.pop();
        }

        if (!stk.empty())
            high[i] = stk.top();
        stk.push(i);
    }
    //debug(high);
    vi chain = {0};
    while (high[chain.back()] != n) chain.push_back(high[chain.back()]);
    //debug(chain);

    int m = (int)chain.size();
    chain.push_back(n);
    priority_queue<ll> pq;
    ll carry = 0;
    for (int i = m-1; i > 0; i--){
        int x = chain[i];
        for (int j = chain[i+1]-1; j > x; j--) pq.push(arr[j]);
        ll nxt = arr[chain[i-1]], d = arr[x] - nxt;
        carry++;
        ans[x] += carry * d;
        while (!pq.empty() && pq.top() >= nxt) {
            ans[x] += pq.top() - nxt;
            carry++;
            pq.pop();
        }
    }
    ans[0] = sum - accumulate(ans.begin(), ans.end(), 0LL);
    for (ll x : ans)
        cout << x << endl;
}


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

long long MOD=1000000007;

int main(){
	long long N,K;
	cin >> N >> K;
	long long ans=0;
	
	for(long long k=K;k<=N+1;k++){
		long long add=(N*(N+1)/2)-((N-k)*(N-k+1)/2)-(k*(k-1)/2)+1;
		add%=MOD;
		ans+=add;
		ans%=MOD;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628