akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,k) = get!(usize, usize);
    let s = get!(String).chars().collect::<Vec<_>>();

    for i in 0..n {
        if i == k-1 {
            print!("{}", (s[i] as u8 - 'A' as u8 + 'a' as u8) as char);
        } else {
            print!("{}", s[i]);
        }
    }
    println!("");
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  int a, b;
  string s;
  while (cin >> a >> b >> s) {
    int c = count(s.begin(), s.end(), '-');
    replace(s.begin(), s.end(), '-', ' ');
    istringstream sin(s);
    string x, y;
    sin >> x >> y;
    cout << ((c == 1 && x.size() == a && y.size() == b) ? "Yes" : "No") << endl;
  }
  
  return 0;
}


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

using namespace std;
int X,N,K;
int A[2000010]{};
bool B[2000010]{};
vector <int> C;
int main()
{
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A,A+N);
  int ans=0;
  for(int i=0;i<K;i++){
    ans+=A[i];
  }
  cout<<ans;
  return 0;
}





Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
int N,Q;
ll s;
vector<ll> students;
ll scores[1000005];
typedef pair<ll,ll> pll;
priority_queue<pair<ll,ll> > pq;
priority_queue<pair<ll,ll> > pq2;
bool whichpq=true;

ll check(ll r)
{
  ll ret=0;
  if(whichpq)
    {
      auto firstit=upper_bound(students.begin(),students.end(),pq.top().first);
      ret+=(students.end()-firstit);
      while(!pq.empty())
	{
	  pll tmp=pq.top();pq.pop();
	  pq2.push(tmp);
	  auto itr=lower_bound(students.begin(),students.end(),tmp.first-r);
	  if(!pq.empty())
	    {
	      auto itl=upper_bound(students.begin(),students.end(),pq.top().first);
	      ll dif=itr-itl;
	      ret+=max(0LL,dif);
	    }
	  else
	    {
	      auto itl=upper_bound(students.begin(),students.end(),-1);
	      ll dif=itr-itl;
	      ret+=max(0LL,dif);
	    }
	}
      whichpq=false;
    }
  else
    {
      auto firstit=upper_bound(students.begin(),students.end(),pq2.top().first);
      ret+=(students.end()-firstit);
      while(!pq2.empty())
	{
	  pll tmp=pq2.top();pq2.pop();
	  pq.push(tmp);
	  auto itr=lower_bound(students.begin(),students.end(),tmp.first-r);
	  if(!pq2.empty())
	    {
	      auto itl=upper_bound(students.begin(),students.end(),pq2.top().first);
	      ll dif=itr-itl;
	      ret+=max(0LL,dif);
	    }
	  else
	    {
	      auto itl=upper_bound(students.begin(),students.end(),-1);
	      ll dif=itr-itl;
	      ret+=max(0LL,dif);
	    }
	}
      whichpq=true;
    }
  return ret;
}

ll binary_search(ll le,ll ri,ll x)
{
  ll mid=(le+ri)/2;
  while(ri-le>1)
    {
      mid=(le+ri)/2;
      if(check(mid)>x)
	{
	  le=mid;
	}
      else
	{
	  ri=mid;
	}
    }
  return ri;
}

int main(void)
{
  cin >> N >> Q;
  for(int i=0;i<N;i++)
    {
      cin >> s;
      students.push_back(s);
      scores[i+1]=s;
    }
  sort(students.begin(),students.end());
  for(int i=0;i<Q;i++)
    {
      string command;
      ll x;
      cin >> command >> x;
      if(command=="ADD")
	{
	  if(whichpq)
	    {
	      pq.push(pll(scores[x],x));
	    }
	  else
	    {
	      pq2.push(pll(scores[x],x));
	    }
	}
      else if(command=="CHECK")
	{
	  if(x==N)
	    {
	      cout << 0 << endl;
	    }
	  else if((pq.empty() && pq2.empty()) || check(1e12)>x)
	    {
	      cout << "NA" << endl;
	    }
	  else
	    {
	      cout << binary_search(-1,1e9+1,x) << endl;;
	    }
	}
      else if(command=="REMOVE")
	{
	  if(whichpq)
	    {
	      while(!pq.empty())
		{
		  pll tmp=pq.top();
		  pq.pop();
		  if(tmp.second!=x) pq2.push(tmp);
		}
	      whichpq=false;
	    }
	  else
	    {
	      while(!pq2.empty())
		{
		  pll tmp=pq2.top();
		  pq2.pop();
		  if(tmp.second!=x) pq.push(tmp);
		}
	      whichpq=true;
	    }
	}
    }
  return 0;
}



Measured memory_bytes: 18724
// Created by kashi on 21-07-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss<p2.ss;
}


int32_t main() {
    int n,d;
    cin>>n>>d;
    vector<pair<int,int>>v;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        v.pb(mp(x,y));
    }
    int count=0;
    for(int i=0;i<v.size();i++){
        if(sqrt(pow(v[i].ff,2)+pow(v[i].ss,2)) <=d)
            count++;
    }
    cout<<count<<endl;
}

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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 1e7 + 5;

int f[N];


int (((((main)))))() <%
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

    int n; cin >> n;
    using ll = long long;
    ll ans = 0;
    for (int x = 1; x <= n; x++) {
        for (int y = x; y <= n; y += x)
            f[y]++;

        ans += (ll)x * f[x];
    }

    cout << ans << endl;

	return 0;
%>

Measured memory_bytes: 42676
N=int(input())
s=input()
first=[-1 for i in range(10)]
last=[-1 for i in range(10)]
for i in range(len(s)):
    k=int(s[i])
    if first[k]==-1: first[k]=i
    last[k]=i

dic=set()
for i in range(10):
    for j in range(10):
        f=first[i]
        l=last[j]
        if f!=-1 and f+1<l:
            for k in range(f+1,l):
                dic.add(str(i)+s[k]+str(j))

print(len(dic))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1e18
int n;
set<int>st;
int x;
int ans=1;
signed main(){
	cin>>n;
	x=n;
	st.insert(n);
	while(1){
		ans++;
		if(x%2==0){
			x/=2;
			if(st.count(x)){
				cout<<ans<<endl;
				return 0;
			}
			st.insert(x);
		}
		else{
			x=x*3+1;
			if(st.count(x)){
				cout<<ans<<endl;
				return 0;
			}
			st.insert(x);
		}
	}
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

readline = stdin.buffer.readline

INF = 10 ** 10

K = int(readline())

results = []

def dfs(A):
    if len(A) > 10:
        return

    if A:
        results.append(int("".join(A)))

    if len(A) >= 1:
        n = int(A[-1])
        for i in [str(n-1), str(n), str(n+1)]:
            if int(i) < 0 or int(i) > 9:
                continue
            A.append(i)
            dfs(A)
            A.pop()
    else:
        for i in range(1, 10):
            A.append(str(i))
            dfs(A)
            A.pop()
            

dfs([])

results.sort()
print(results[K-1])

Measured memory_bytes: 101576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;cin>>n;
    bool flag = false;

    REP(i,1,10)
    {
        if (n%i==0 && n/i<=9)
        {
            flag = true;
            break;
        }
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{   
    
    public void Slove()
    {
        var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if(inputs.Any(x => (x & 1) == 0))
        {
            Console.WriteLine(0);
        }
        else
        {
            long min = new long[]
            {
                (long)inputs[0] * inputs[1],
                (long)inputs[0] * inputs[2],
                (long)inputs[1] * inputs[2],
            }.Min();
            Console.WriteLine(min);
        }
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 13524
import java.util.Scanner;

/**
 * B - Uneven Numbers
 * 整数 N が与えられます。
 * N 以下の正の整数のうち、(先頭に 0 をつけずに十進法で表記したときの) 桁数が奇数であるようなものの個数を求めてください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 確認する数値
        int n = sc.nextInt();
        int result = 0;

        for( int i = 1; i <= n; i++ ) {
            if( String.valueOf( i ).length() % 2 != 0 ) {
                result++;
            }
        }

        System.out.println( result );

        sc.close();
    }
}

Measured memory_bytes: 28372
var
n,a,b,i,t,x,s:longint;
begin
readln(n,a,b);
s:=0;
for i:=1 to n do
  begin
    t:=i;
    x:=0;
    while t>0 do
      begin
        x:=x+(t mod 10);
        t:=t div 10;
      end;
    if (x>=a)and(x<=b) then s:=s+i;
  end;
writeln(s);
end.

Measured memory_bytes: 128
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	ll n, m, k;
	scanf("%ld %ld %ld", &n, &m, &k);
	V a(1+n, 0), b(1+m, 0);
	REP(i, 1, n+1) scanf("%ld", &a[i]);
	REP(i, 1, m+1) scanf("%ld", &b[i]);
	REP(i, 0, n) a[i+1] += a[i];
	REP(i, 0, m) b[i+1] += b[i];

	ll ans = 0;
	REP(i, 0, n+1){
		if(a[i]>k) break;
		ll pos = std::upper_bound(ALL(b), k-a[i]) - b.begin();
		ans = std::max(ans, i+pos-1);
	}
	printf("%ld\n", ans);
	return 0;
}



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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    int M = min(A, B);
    REP(i,M){
        int d = M - i;
        if(A % d == 0 && B % d == 0) K--;
        if(K==0){
            cout << d << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int H, W;
	cin >> H >> W;

	vector<int> count(30);
	for (auto i = 0; i < H; ++i)
	{
		string a;
		cin >> a;
		for (auto j = 0; j < W; ++j)
		{
			++count[a[j] - 'a'];
		}
	}

	auto result = true;
	auto x = W;
	auto y = H;
	if (W % 2 > 0)
	{
		--x;
	}
	if (H % 2 > 0)
	{
		--y;
	}
	auto num = x * y / 4;
	for (auto i = 0; i < count.size(); ++i)
	{
		auto temp = count[i] / 4;
		if (temp > num)
		{
			temp = num;
		}
		num -= temp;
		count[i] -= temp * 4;
		if (num == 0)
		{
			break;
		}
	}

	if (num > 0)
	{
		result = false;
	}
	else
	{
		num = (W - x) * H / 2 + (H - y) * W / 2;
		for (auto i = 0; i < count.size(); ++i)
		{
			auto temp = count[i] / 2;
			if (temp > num)
			{
				temp = num;
			}
			num -= temp;
			count[i] -= temp * 2;
		}

		if (num > 0)
		{
			result = false;
		}
	}

	if (result)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv){
  int N, M, C;
  cin >> N >> M >> C;
  int A[N][M];
  int B[M];
  for(int cnt0=0; cnt0 < M; cnt0++) cin >> B[cnt0];
  for(int cnt0=0; cnt0 < N; cnt0++) 
    for(int cnt1=0; cnt1 < M; cnt1++) cin >> A[cnt0][cnt1];
  int ans = 0;
  for(int cnt0=0; cnt0 < N; cnt0++){
    int tmp = 0;
    for(int cnt1=0; cnt1 < M; cnt1++) tmp += A[cnt0][cnt1]*B[cnt1];
    if(tmp+C > 0) ans++;
  }
  cout << ans << endl;
  return 0;

}

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

int a[200010];
int n;
int tam,dem;

int main()
{
    tam=1;
    cin>>n;
    for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            if(a[i]==tam)
            {
                tam++;
                dem++;
            }
        }
    if(!dem)    cout<<"-1";
    else
        cout<<n-dem;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int a,b,t; cin >> a >> b >> t;
    
    cout << t/a * b << ln;
    return 0;
}

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

long long gcd(long long a,long long b){
	return b==0 ? a : gcd(b,a%b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

int main(){
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long l = (a-1)/c + (a-1)/d - (a-1)/lcm(c,d);
	long long h = b/c + b/d - b/lcm(c,d);
	cout<<b-a+1-(h-l)<<endl;
	return 0;
}


Measured memory_bytes: 256
mod BIT {
    use std::clone::Clone;
    use std::convert::From;
    use std::ops::{Add, AddAssign, Sub};

    #[derive(Clone, Debug)]
    pub struct BIT<T> {
        array: Vec<T>,
    }

    impl<T> BIT<T>
    where
        T: Add + Sub + Clone + Copy + From<u8> + AddAssign,
    {
        pub fn new(size: usize) -> BIT<T> {
            let v: Vec<T> = vec![T::from(0u8); size + 1];
            Self { array: v }
        }
        pub fn add(&mut self, mut i: usize, x: T) {
            let n = self.array.len();
            while i <= n {
                self.array[i] += x;
                i += i & i.wrapping_neg();
            }
        }
    }

    pub trait Sum<T, U> {
        fn sum(&self, i: T) -> U;
    }

    impl<T> Sum<usize, T> for BIT<T>
    where
        T: Add + Sub + Clone + Copy + From<u8> + AddAssign,
    {
        fn sum(&self, mut i: usize) -> T {
            if i == 0 {
                return T::from(0u8);
            }
            let mut s = T::from(0u8);

            while i > 0 {
                s += self.array[i];
                i -= i & i.wrapping_neg();
            }
            s
        }
    }

    impl<T> Sum<(usize, usize), T> for BIT<T>
    where
        T: Add + Sub + Clone + Copy + From<u8> + AddAssign,
        T: std::ops::Sub<Output = T>,
    {
        fn sum(&self, i: (usize, usize)) -> T {
            let sum_l = <BIT<T> as Sum<usize, T>>::sum(self, i.0 - 1);
            let sum_r = <BIT<T> as Sum<usize, T>>::sum(self, i.1);
            sum_r - sum_l
        }
    }

    #[test]
    fn test_sum() {
        let mut a = BIT::new(100);

        for i in 1..101 {
            a.add(i, i);
        }

        assert_eq!((0..101).sum::<usize>(), a.sum(100));
        assert_eq!((2..101).sum::<usize>(), a.sum((2, 100)));
    }
}

use proconio::{fastout, input, marker::*};
use BIT::Sum;

#[fastout]
fn main() {
    input!(n: usize, q: usize, c: [usize; n], lr: [[Usize1; 2]; q]);

    let mut c_vv = vec![vec![0usize; 0]; n];
    let mut c_v = vec![-1i64; n + 1];
    for (i, v) in c.iter().enumerate() {
        let l = c_v[*v];
        if l != -1 {
            c_vv[l as usize].push(i);
        }
        c_v[*v] = i as i64;
    }

    let mut lr_vec = vec![vec![vec![0usize; 2]; 0]; n];
    for (i, v) in lr.iter().enumerate() {
        lr_vec[v[0]].push(vec![v[1], i]);
    }

    let mut ans = vec![0usize; q];
    let mut bi_tree = BIT::BIT::<usize>::new(n);
    for i in (0..n).rev() {
        for cv in &c_vv[i] {
            bi_tree.add(*cv + 1, 1);
        }

        for v in &lr_vec[i] {
            ans[v[1]] = (v[0] - i + 1) - bi_tree.sum(v[0] + 1);
        }
    }
    for v in &ans {
        println!("{}", *v);
    }
}


Measured memory_bytes: 125360
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s; cin >> s;
    char c = s[0];
    if(s.back() != c) s += c;

    int prev = 0, ans = 0;
    rep(i,1,s.length()) {
        if(s[i] == c) {
            // printf("i = %lld, prev = %lld\n", i, prev);
            ans += i - prev - 2;
            prev = i;
        }
    }
    cout << (ans % 2 ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 101
#define rep(i, n) for(ll i=0; i<n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, h[MAX_N];

signed main(){
    cin >> n;
    ll ret = 0;
    h[0] = 0;
    rep(i, n){
        cin >> h[i+1];
        ll d = h[i+1] - h[i];
        ret += (d>0) ? d: 0;
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
z=60,t;p(){printf("%02d:%02d:%02d\n", t/z/z,t/z%z,t%z);}main(h,m,s){for(;scanf("%d%d%d",&h,&m,&s),~h;p(t),t*=3,p(t))t=7200-h*z*z-m*z-s;exit(0);}

Measured memory_bytes: 612
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

struct Edge {
    int src, dst;
    int weight;
    Edge(int from, int to, int weight) :
    src(from), dst(to), weight(weight) { }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;


struct UndirectionalCompare {
    bool operator() (const Edge& e, const Edge& f) const {
        if (min(e.src,e.dst) != min(f.src,f.dst))
            return min(e.src,e.dst) < min(f.src,f.dst);
        return max(e.src,e.dst) < max(f.src,f.dst);
    }
};
typedef set<Edge, UndirectionalCompare> Edgeset;
void visit(const Graph &g, int v, int u,
           vector<int>& art, vector<Edgeset>& bcomp,
           stack<Edge>& S, vector<int>& num, vector<int>& low, int& time) {
    low[v] = num[v] = ++time;
    for(auto &e : g[v]){
        int w = e.dst;
        if (num[w] < num[v]) S.emplace(e);              // for bcomps
        if (num[w] == 0) {
            visit(g, w, v, art, bcomp, S, num, low, time);
            low[v] = min(low[v], low[w]);
            if ((num[v] == 1 && num[w] != 2) ||         // for arts
                (num[v] != 1 && low[w] >= num[v])) art.push_back(v);
            if (low[w] >= num[v]) {                     // for bcomps
                bcomp.push_back(Edgeset());
                while (1) {
                    Edge f = S.top(); S.pop();
                    bcomp.back().insert(f);
                    if (f.src == v && f.dst == w) break;
                }
            }
        } else low[v] = min(low[v], num[w]);
    }
}
void articulationPoint(const Graph& g,
                       vector<int>& art, vector<Edgeset>& bcomp) {
    const int n = g.size();
    vector<int> low(n), num(n);
    stack<Edge> S;
    for(int u = 0; u < n; u++){
        if (num[u] == 0) {
            int time = 0;
            visit(g, u, -1, art, bcomp, S, num, low, time);
        }
    }
}

int main(){
    int v,e;
    cin>>v>>e;
    Graph G(v);
    rep(i,e){
        int s,t;
        cin>>s>>t;
        G[s].pb(Edge{s,t,1});
        G[t].pb(Edge{t,s,1});
    }
    vector<int> art;
    vector<Edgeset> bcomp;
    articulationPoint(G, art, bcomp);
    set<int> ans;
    rep(i,art.size())ans.insert(art[i]);
    for(auto itr = ans.begin();itr!=ans.end();itr++){
        cout<<*itr<<endl;
    }
}

Measured memory_bytes: 9576
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

int main(void){
  int x1,x2,x3,x4,y1,y2,y3,y4;
  scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
  x3=x2+(y1-y2);
  y3=y2-(x1-x2);
  x4=x1+(y1-y2);
  y4=y1-(x1-x2);
  printf("%d %d %d %d\n",x3,y3,x4,y4);
  return 0;
}

Measured memory_bytes: 1708
#include<stdio.h>

int A[1000000],n;


int binarySearch(int key){
	int left=0;
	int right=n;
	int mid;
	while(left<right){
		mid=(left+right)/2;
		if(key==A[mid]) return 1;
		if(key>A[mid]) left=mid+1;
		else if(key<A[mid]) right=mid;
	}
	return 0;
}

int main(){
	int i,q,k,sum=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&k);
		if(binarySearch(k))sum++;
	}
	printf("%d\n",sum);
	return 0;
	
}

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

int main() {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if (M1 == M2) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,V,W,T;
    cin>>A>>V>>B>>W>>T;
    ll d = abs(B-A);
    if (d<=T*(V-W)){
        cout<<"YES\n";
    }else{
        cout<<"NO\n";
    }
    return 0;
}


Measured memory_bytes: 3652
import sys
input = sys.stdin.buffer.readline
import numpy as np

D = int(input())
c = np.array(input().split(), dtype=np.int32)
s = np.array([input().split() for _ in range(D)], dtype=np.int32)
last = np.zeros(26, dtype=np.int32)
# print(s)
# print(s.shape)

ans = []
point = 0
for i in range(D):
    down = (i+1-last)*c
    loss = down + s[i,:]
    idx = np.argmax(loss)
    ans.append(idx+1)
    point += s[i, idx] - down.sum()
    last[idx] = i+1
    # print(loss)

for i in range(D):
    print(ans[i])

Measured memory_bytes: 27568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
int main(){
	cout<<fixed<<setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m, a, sum1=0, sum=0;
    string s;
    cin>>n>>m;
	vector<int>A(100005, 0), B(100000, 0);
	rep(i,0,m){
		cin>>a>>s;
		if(!B[a]){
			if(s=="AC"){
				sum+=A[a];
				B[a]=1;
				sum1++;
			}else{
				A[a]++;
			}
		}
	}
	cout<<sum1<<" "<<sum<<"\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long long> x(N);
	vector<long long> y(N);
	vector<long long> h(N);

	for (auto i = 0; i < N; ++i)
	{
		cin >> x[i] >> y[i] >> h[i];
	}

	for (auto cx = 0; cx <= 100; ++cx)
	{
		for (auto cy = 0; cy <= 100; ++cy)
		{
			auto H = -1ll;
			for (auto i = 0; i < N; ++i)
			{
				if (h[i] <= 0)
				{
					continue;
				}

				auto tempH = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
				if (H < 0)
				{
					H = tempH;
				}
				else if (H != tempH)
				{
					H = 0;
					break;
				}
			}

			if (H == 0)
			{
				continue;
			}

			for (auto i = 0; i < N; ++i)
			{
				if (h[i] > 0)
				{
					continue;
				}

				if(H - abs(x[i] - cx) - abs(y[i] - cy) > 0)
				{
					H = 0;
					break;
				}
			}

			if (H > 0)
			{
				cout << cx << " " << cy << " " << H << endl;
				return 0;
			}
		}
	}

	return 0;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int N;
	cin >> N;

	VI A(N), B;
	REP(i, N) cin >> A[i];
	B = A;
	SORT(B);

	EACH(a, A)
	{
		if(a <= B[N / 2 - 1]){
			cout << B[N / 2] << endl;
		}
		else{
			cout << B[N / 2 - 1] << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 3840
n,*a=open(0).readlines();n=int(n);f,e=[sum(n==t.count(c)for t in zip(*a))for c in'#.'];r=range(n);print(-(e==n)or min(n*2-f-a[i].count('#')+all('#'<a[j][i]for j in r)for i in r))

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	double average=0.00,pos=0.00;
	cin>>n;
	int a[n+1];
	for (int i=1;i<=n;i++)  cin>>a[i];
	sort(a+1,a+n+1);
	for (int i=1;i<=n-1;i++)
	{
		if (i==1)
		{
			average=(a[i]+a[i+1])/2.0;
			pos=average;
		}
		else
		{
			average=(pos+a[i+1])/2.0;
			pos=average;
		}
	}
	cout<<average<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
const int Xp = 1e9 + 7;
int n,m,dp[1<<10][1<<10];
char w[1<<10];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    dp[1][0]=1;
    for(int i=1;i<=n;++i)
    {
        cin>>(w+1);
        for(int j=1;j<=m;++j)
            if(w[j]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%Xp;
    }
    cout<<dp[n][m];
    return 0;
}


Measured memory_bytes: 4352
import math

a,b,x=map(int,input().split())

if x>=a*a*b*0.5:
    div=(b-(x/(a**2)))/(a*0.5)
    degr = math.degrees(math.atan(div))
    print(degr)
else:
    teihen=(2*x)/(b*a)
    div=b/teihen
    degr = math.degrees(math.atan(div))
    print(degr)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

auto gcd(size_t l, size_t r) {
    if (r == 0)
        return l;
    return gcd(r, l % r);
}

auto gcd(size_t a, size_t b, size_t c) {
    return gcd(a, gcd(b, c));
}

int main() {
    size_t n = input();
    size_t m = input();
    vector<size_t> a = input(m);
    size_t c = 0;
    for (auto e : a)
        c += e;
    if (c <= n)
        cout << (n - c) << endl;
    else
        cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3708
n, m = map(int, input().split())
l_max = 0
r_min = 10**6
for i in range(m):
    l, r = map(int, input().split())
    l_max = max(l_max, l)
    r_min = min(r_min, r)

if l_max > r_min:
    print(0)
else:
    print(r_min-l_max+1)


Measured memory_bytes: 3060
a, b = map(int, input().split())
if a <= 0 <= b:
    print('Zero')
    exit()

if a > 0:
    print('Positive')
else:
    if (abs(a) - abs(b) + 1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')


Measured memory_bytes: 9040
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String result = "hon";
		while(N/10>0) {
			N=N%10;
		}
		if(N==3) {
			result ="bon";
		}else if(N==0||N==1||N==6||N==8){
			result ="pon";
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 35852
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	A,B = MI()
	if(A >= 10 or B>=10):
		print(-1)
	else:
		print(A*B)

main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  ll N,K;
  cin>>N>>K;
  ll a[N];
  rep(i,N){
    cin>>a[i];
  }
  ll l=1,r=1000000000;
  while(r-l>10){
    ll mid=(l+r)/2;
    ll k=0;
    rep(i,N){
      k+=(a[i]-1)/mid;
    }
    if(k>K){
      l=mid;
    }
    else{
      r=mid;
    }
  }
  ll ans=l;
  while(1){
    ll k=0;
    rep(i,N){
      k+=(a[i]-1)/ans;
    }
    if(k>K){
      ans++;
    }
    else{
      break;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 5160
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long a, b, c, d = 0, e = 0, f = 0;
	cin >> a;
	int test[101] = { 0 };
	int uiop[101] = { 0 };
	for (int h = 1; h <= a; h++) {
		cin >> b;
		test[h] = b;
	}
	for (int i = 1; i <= a; i++) {
		cin >> c;
		uiop[i] = c;
	}
	for (int j = 1; j <= a; j++) {
		for (int k = 1; k <= j; k++) {
			d += test[k];
		}
		for (int l = j; l <= a; l++) {
			f += uiop[l];
		}
		e = max(e, d + f);
		d = 0; f = 0;
	}
	cout << e << endl;
	cin >> e;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define REP(i,x,y) for(ll i = x;i <= y;++i)
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z))
        ;
    return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
void localTest() {
    #ifndef ONLINE_JUDGE
        freopen("inp", "r", stdin);
        freopen("out", "w", stdout);
    #endif      
}
int main() {

    localTest();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vector<ll> A(n);
    for(ll i = 0;i < n;++i) cin >> A[i];
    sort(all(A));
    ll sum = 0;
    for(ll i = 0;i < k;++i) sum += A[i];
    cout << sum << "\n";   
    
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

const ll mod = 998244353;

ll modpow(ll b, ll e) {
  ll ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}

ll inv(ll x) { return modpow(x, mod-2); }

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n, s;
  cin >> n >> s;
  vi a(n);
  rep(i,0,n) cin >> a[i];

  ll i2 = inv(2);
  vi dp(s+1, 0);
  dp[0] = 1;
  rep(i,0,n) {
    per(j,0,s) {
      if (j+a[i] <= s) {
        dp[j+a[i]] += dp[j]*i2 % mod;
        dp[j+a[i]] %= mod;

      }
    }
  }

  ll ans = modpow(2, n) * dp[s] % mod;
  ans %= mod; ans += mod; ans %= mod;

  cout << ans << '\n';

}

Measured memory_bytes: 3668
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        long a = s.nextLong(),b=s.nextLong(),x=s.nextLong();
        long start=a;
        if(start%x!=0)start = a+(x-(a%x));
        long end = b - (b%x);
        System.out.println((end-start)/x + 1);

    }


}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25348
import sys
N = int(input().rstrip('\n'))
S = [str(input().rstrip('\n')) for _ in range(N)]

plus_stock = []
minus_stock = []
for i, row in enumerate(S):
    lowest = 0
    now = 0
    for j,char in enumerate(row):
        if char == "(":
            now+=1
        elif char == ")":
            now-=1 
        if now < lowest:
            lowest = now
    if now >= 0:
        plus_stock.append([now, lowest])
    elif now < 0:
        minus_stock.append([-now, lowest - now])
plus_stock  = sorted(plus_stock, key = lambda x:x[1], reverse=True)
minus_stock = sorted(minus_stock, key = lambda x:x[1], reverse=True)

now = 0

for i in range(len(plus_stock)):
    if now + plus_stock[i][1] < 0:
        print("No")
        sys.exit()
    else:
        now = now+plus_stock[i][0]
last = now
now = 0
for i in range(len(minus_stock)):
    if now + minus_stock[i][1] < 0:
        print("No")
        sys.exit()
    else:
        now = now+minus_stock[i][0]
if last == now:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 269956
#include<iostream>
using namespace std;
typedef long long int ll;
int main()
{
    int t,c1=0,c2=0,c3=0,c4=0;
    string s;
    cin>>t;
    while(t--)
    {
      cin>>s;
      if(s=="AC") c1++;
        else if(s=="WA") c2++;
        else if(s=="TLE")c3++;
        else if(s=="RE") c4++;
    }
    cout<<"AC"<<" "<<"x"<<" "<<c1<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<c2<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<c3<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<c4<<endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//template<typename T>
#define o_set(T) tree<T, null_type,greater<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//use it like o_set(ll) x;  --> x.order.....
//-->for pair<ll,ll> : second element as index and for search use INT_MAX...
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set


#define fast ios::sync_with_stdio(false);cin.tie(0);cout<<setprecision(25)
#define pb push_back
#define I insert
#define F first
#define S second
#define digit(x) floor(log10(x))+1
const long long M1=1000000007;
const long long  M2=998244353;
#define L_MAX 1e18
using ll = long long;
using ld = long double;
using ii = pair<ll,ll>;
using matrix = vector<vector<ll>>;
using arr = vector<ll>;
using vs = vector<string>;
using pv = vector<ii>;
#define in1(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
template<typename T>
void showArr(T a){
    for(auto i : a) cout<<i<<" ";
    cout<<endl;
}
bool isValid(ll x,ll y,ll n,ll m){
    return (x>=0 and y>=0 and x<n and y<m);
}
ll power(ll a,ll n,ll m){
    ll ans=1;
    while(n>0){
        if(n&1){
            ans=(ans%m * a%m)%m;
        }
        n=n>>1;
        a=(a%m*a%m)%m;
    }
    return ans;
}
ll MMI(ll a,ll m){
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1){
        ll q=a/m,t=m;
        m=a%m,a=t,t=y,y=x-q*y,x=t;
    }
    if(x<0) x+=m0;
    return x;
}

ll dx[]={-1,1,0,0},dy[]={0,0,-1,1};
//ll dx[]={-1,1,-1,1,0,0,-1,1} , dy[]={-1,1,0,0,-1,1,1,-1};
int main(){
    fast;
    ll n;
    cin>>n;
    arr a;
    for(int i=0;i<2*n;i++){
        ll x;
        cin>>x;
        a.pb(x);
    }
    sort(all(a));
    ll ans=0;
    for(int i=0;i<(int)a.size();i+=2){
        ans+=min(a[i],a[i+1]);
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3636
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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;}

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

  int n,a,b;
  cin >>n>>a>>b;

  if((b-a)%2==0) cout << "Alice" << endl;
  else cout << "Borys" << endl;
  
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main(N,K,L):
    L = sorted(L,reverse=True)
    ans = 0
    for i in range(K):
        ans += L[i]
    print(ans)

if __name__ == '__main__':
    N,K = map(int, input().split())
    L = [int(l) for l in input().split()]
    main(N,K,L)

Measured memory_bytes: 3060