akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

string solve() {
    int p = 0;
    char e[20];
    int l = s.size();

    for (int i = 0; i < l; i++) {
        switch(s[i]) {
        case '0': e[p++] = '0'; break;
        case '1': e[p++] = '1'; break;
        case 'B': p = max(0, p-1); break;
        }
    }

    stringstream res;
    for (int i = 0; i < p; i++) res << e[i];

    return res.str();
}

void input() {
    cin >> s;
}

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

    input();
    cout << solve() << endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[N];
		
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		
		System.out.println(result(x,a));
		sc.close();
	}

	private static int result(int x, int[] a) {
		int count = 0;
		
		for(int t:a) {
			if(x > 0) {
				x -= t;
				count++;
			}
		}
		
		if(x < 0 || x > 0) {
			count--;
		}
		
		return count;
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL a,b;
    cin >> a >> b;

    cout << (abs(a-b) <= 1 ? "Brown" : "Alice") << endl;
    
    return 0;
}

Measured memory_bytes: 256
s = input()
"""
xabxa
"""
l = 0
r = len(s)-1
cnt = 0
while r - l >= 1:
    if s[r] == s[l]:
        l += 1
        r -= 1
    else:
        if s[l] == "x":
            l += 1
            cnt += 1
        elif s[r] == "x":
            r -= 1
            cnt += 1
        else:
            print(-1)
            exit()
print(cnt)        


Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        if(i%2==1 && a%2==1)
            cnt++;
    }
    cout<<cnt<<endl;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define rof_(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int N, K, x[100005];

void solve() {
	vector< int > L, R;
	
	L.push_back(0);
	R.push_back(0);
	
	for_(i,0,N) {
		if (x[i] < 0) L.push_back(-x[i]);
		else R.push_back(x[i]);
	}
	
	sort(allof(L));
	
	int n = L.size(), m = R.size();
	
	int ans = (int)1e9;
	for_(i,0,n) {
		if (i > K) break;
		if (m > K-i) {
			int dst = 2 * L[i] + R[K - i];
			ans = min(ans, dst);
		}
	}
	
	for_(i,0,m) {
		if (i > K) break;
		if (n > K-i) {
			int dst = 2 * R[i] + L[K - i];
			ans = min(ans, dst);
		}
	}
	
	cout << ans << endl;
}

int main() {
	cin >> N >> K;
	for_(i,0,N) cin >> x[i];
	solve();
}
//--------------8---------------->> coding space <<-----------------8-------------//


Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string s, t;
int dp[3003][3003];

string getLcs(int n) {
	string res = "";
	int i = 0; int j = 0;
	while (n > 0) {
		if (s[i] == t[j]) {
			res = res + s[i];
			n--;
			i++; j++;
		}
		else {
			if (dp[i + 1][j] > dp[i][j + 1])
				i++;
			else j++;
		}
	}
	return res;
}


int lcsLen(int i, int j) {
	if (i == s.length() or j == t.length())
		return 0;
	if (dp[i][j] != -1)
		return dp[i][j];
	if (s[i] == t[j])
		return dp[i][j] = 1 + lcsLen(i + 1 , j + 1);
	else
		return dp[i][j] =  max(lcsLen(i + 1, j), lcsLen(i, j + 1));
}


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

	cin >> s >> t;
	memset(dp, -1, sizeof(dp));
	int l = lcsLen(0, 0);
	cout << getLcs(l);

	return 0;
}

Measured memory_bytes: 39160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

	int n;
	cin >> n;
	vi v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	for(int i = n - 1; i > 0; i--){
		if(v[i] < v[i - 1]) v[i - 1]--;
	}
	for(int i = 0; i < n - 1; i++){
		if(v[i] > v[i + 1]) return cout << "No", 0;
	}
	cout << "Yes";
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int a,i,n,s,x,y,h,w;
	1<=n && n<=1000000;
	scanf("%d",&n);
	while(n!=0) {
		s=0;
		for(i=1;i<=n;i++) {
			scanf("%d %d %d %d",&x,&y,&h,&w);
			1<=x && x<=200;
			1<=y && y<=200;
			1<=h && h<=200;
			1<=w && w<=200;
			a=x+y+h;
			if(a<=60 && w<=2) {
				s+=600;
			}
			else if(a<=80 && w<=5) {
				s+=800;
			}
			else if(a<=100 && w<=10) {
				s+=1000;
			}
			else if(a<=120 && w<=15) {
				s+=1200;
			}
			else if(a<=140 && w<=20) {
				s+=1400;
			}
			else if(a<=160 && w<=25) {
				s+=1600;
			}
			else {
				s+=0;
			}
		}
		printf("%d\n",s);
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 600
n,k=map(int,input().split())
a=list(map(int,input().split()))
g=0
for i in range(0,min(n,k)+1):
    for j in range(0,min(k-i,n-i)+1):
        s=sorted(a[:i]+a[n-j:])
        p=sum(s)
        t=i+j
        c=0
        while len(s)>=c+1 and t+1<=k:
            if s[c]<0:
                p-=s[c]
                c+=1
                t+=1
            else:
                break
        g=max(g,p)
print(g)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int mod = 1e9 + 7;
ll a[110][N],id[N],di[N];
map<int,int> m;
int main(){
    int n,k; cin>>n>>k;
    int cnt = 0;
    for(int l=1,r;l<=n;l=r+1){
        r = n / (n / l);
        id[++cnt] = r;
        m[n/l] = cnt;
    }
    for(int i=1;i<=cnt;i++) a[1][i] = id[i];
    for(int i=1;i<=cnt;i++) di[i] = m[n/(n/id[i])];
    for(int i=2;i<=k;i++){
        for(int j=1;j<=cnt;j++){
            a[i][j] = (a[i][j-1] + (id[j]-id[j-1]) * a[i-1][di[j]] % mod) % mod;
        }
    }
    cout<<a[k][cnt]<<endl;
}


Measured memory_bytes: 84096
import sys
from heapq import heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def dijkstra(start):
    INF = 10 ** 7
    dist = [INF] * (N+1)
    dist[start] = 0
    que = [(0,start)]
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for next in graph[prev]:
            d1 = d + 1
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
    return dist

# leafが2個以上：そこから2個終点として選ぶ
# leafが1個：１つの終点として、dfs
# leafなし：適当に頂点１を終点としてdfs
N, M = lr()
graph = [[] for _ in range(N+1)] # 1-indexed
for _ in range(M):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)

dig_1 = [i for i in range(1, N+1) if len(graph[i]) == 1]
if len(dig_1) >= 2:
    start = dig_1[0]
    goal = dig_1[1]
    dist_from_start = dijkstra(start)
    dist_from_goal = dijkstra(goal)
    d = dist_from_start[goal]
    answer = [None] * (d+1)
    answer[0] = start
    cur = start
    for i in range(1, d+1):
        for next in graph[cur]:
            if dist_from_goal[next] == d - i:
                answer[i] = next
                cur = next
                break
    print(d+1)
    print(*answer)
elif len(dig_1) == 1:
    start = dig_1[0]
    answer = [start]
    visited = set()
    cur = start
    while True:
        flag = True
        for next in graph[cur]:
            if next not in visited:
                flag = False
                visited.add(next)
                answer.append(next)
                cur = next
                break
        if flag:
            break
    print(len(answer))
    print(*answer)
else:
    # leaf数 0
    start = 1
    answer = [start]
    visited = set([1])
    cur = start
    while True:
        flag = True
        for next in graph[cur]:
            if next not in visited:
                flag = False
                visited.add(next)
                answer.append(next)
                cur = next
                break
        if flag:
            break
    # もう一回ゴールから
    answer = answer[::-1]
    cur = start
    while True:
        flag = True
        for next in graph[cur]:
            if next not in visited:
                flag = False
                visited.add(next)
                answer.append(next)
                cur = next
                break
        if flag:
            break
    print(len(answer))
    print(*answer)



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

int A[50];
int B[50];

vector<int> G[50];

int vis[50];
int num;
void dfs(int v, int p){
	vis[v] = 1;
	num++;
	for(auto c : G[v]){
		if(c != p && !vis[c]) dfs(c, v);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, M;
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		cin >> A[i] >> B[i];
		A[i]--, B[i]--;
	}

	int ans = 0;
	for(int i = 0; i < M; i++){
		for(int j = 0; j < N; j++){
			G[j].clear();
		}

		for(int j = 0; j < M; j++){
			if(i != j){
				G[A[j]].push_back(B[j]);
				G[B[j]].push_back(A[j]);
			}
		}

		memset(vis, 0, sizeof vis);
		num = 0;
		dfs(0, -1);
		if(num != N){
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int s = sc.nextInt();
			int d = sc.nextInt();
			if (s == 0 && d == 0) break;
			int[][] lensd = new int[s][d];
			int[] min = new int[d];
			Arrays.fill(min, Integer.MAX_VALUE);
			for (int i = 0; i < s; ++i) {
				for (int j = 0; j < d; ++j) {
					lensd[i][j] = sc.nextInt();
					if (lensd[i][j] != 0) min[j] = Math.min(min[j], lensd[i][j]);
				}
			}
			int[][] lendd = new int[d][d];
			for (int i = 0; i < d; ++i) {
				for (int j = 0; j < d - i - 1; ++j) {
					lendd[i][i + j + 1] = lendd[i + j + 1][i] = sc.nextInt();
				}
			}
			boolean[] visited = new boolean[d];
			int ans = 0;
			for (int i = 0; i < d; ++i) {
				int minLen = Integer.MAX_VALUE;
				int minI = -1;
				for (int j = 0; j < d; ++j) {
					if (visited[j]) continue;
					if (min[j] < minLen) {
						minLen = min[j];
						minI = j;
					}
				}
				ans += minLen;
				visited[minI] = true;
				for (int j = 0; j < d; ++j) {
					if (visited[j] || lendd[minI][j] == 0) continue;
					min[j] = Math.min(min[j], lendd[minI][j]);
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let a:i64 = read();
    let b:i64 = read();
    let c:i64 = read();
    
    println!("{}", if a+b>=c {"Yes"} else {"No"});

}


Measured memory_bytes: 4352
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	ll x, k, d; cin >> x >> k >> d;
	x = abs(x);
	if(d > x / k ){
		ll sho = (x - x % d) / d;
		if((k - sho)% 2 == 0) ans = x % d;
		else ans = abs(x % d - d);
	}
	else ans = x - d * k;
	cout << ans << endl;
}

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

int main() {
  int s;
  cin >> s;
  map<int, int> mp;
  mp[s]++;
  
  int cnt = 0;
  while (1) {
    cnt++;
    if (s % 2 == 0) {
      s /= 2;
    } else {
      s = 3 * s +1;
    }
    mp[s]++;
    if (mp[s] > 1) {
      cout << cnt + 1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)


int main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt	
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	 #endif

    FAST
	//PRECISE

ll n;
cin>>n;
ve <ll> c(n),a(n);
FOR(i,0,n)
cin>>c[i];
FOR(i,0,n)
cin>>a[i];
reverse(a.begin(),a.end());
ll ind1=-1,ind2=-1;
ll val=-1;
FOR(i,0,n)
if(a[i]==c[i]){
	ind1=i;val=a[i];break;}

FORR(i,n,0)
if(a[i]==c[i]){
	ind2=i;break;}

ll ind3=M,ind4=-1;
FOR(i,0,n)if(c[i]==val||a[i]==val){ind3=min(ind3,i);}
FORR(i,n,0)if(c[i]==val||a[i]==val){ind4=max(ind4,i);}

if(ind1!=-1&&(ind3+n-1-ind4)<ind2-ind1+1)
	cout<<"No";
else{
	cout<<"Yes\n";
	if(ind1!=-1){
		ll j=ind1;
		ll i=0;
		while(i<ind3&&j<=ind2)
			swap(a[i],a[j]),i++,j++;
		i=ind4+1;
		while(i<n&&j<=ind2)
			swap(a[i],a[j]),i++,j++;
	}
	FOR(i,0,n)
	cout<<a[i]<<" ";
}



return 0;
 }



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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int k;
    cin >> k;
    int ans = 0;
    for (int i = 1;i < k+1;++i) for (int j = 1;j < k+1;++j) for (int l = 1;l < k+1;++l) ans += gcd(i,gcd(j,l));
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;

int H,W,A,B;
int c[1005][1005];
void input(){
	cin>>H>>W>>A>>B;
	rep(i,H)rep(j,W){
		if(i>=B&& j<A)c[i][j]=1;
		if(i<B&& j>=A)c[i][j]=1;
	}
	rep(i,H){
		rep(j,W)cout<<c[i][j];
		cout<<endl;
	}
}

void solve(){

}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 5120
N,K=map(int,input().split())

mod=10**9+7

ans=0
L=[[0,0]]
for i in range(1,N+1):
    if i*i==N:
        L.append([i,i])
        break
    elif i*i>N:
        break
    else:
        L.append([N//i,i])
R=[]
for i in range(len(L)):
    if L[-1-i][0]==L[-1-i][1]:
        continue
    else:
        R.append([L[-1-i][1],L[-1-i][0]])
Arr=L+R
#print(Arr)

for i in range(1,len(Arr)):
    ans+=pow(Arr[i][0],K-1,mod)*(Arr[i][1]-Arr[i-1][1])
#print(ans%mod)
DP=[[1 for i in range(len(Arr)-1)]for j in range(K)]
for j in range(len(Arr)-1):
    DP[0][j]=(Arr[j+1][1]-Arr[j][1])
#print(DP)
for i in range(1,K):
    Rui=[DP[i-1][0]]
    for j in range(1,len(Arr)-1):
        Rui.append(Rui[-1]+DP[i-1][j])
    #print(Rui)
    for j in range(len(Rui)):
        DP[i][j]=(Rui[-1-j]*(Arr[j+1][1]-Arr[j][1]))%mod
print(sum(DP[-1])%mod)

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

int main() {
	vector<long long> num(3,0);
	for(int i=0;i<3;i++)
	{
		cin >> num.at(i);
	}
	sort(num.begin(),num.end());
	long long a=num.at(0),b=num.at(1),c=num.at(2);
	long long k=0;
	if(c%2>0)
	{
		k = a * b;
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)

const int MOD = 1e9+7;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	ll n;
	scanf("%ld", &n);
	COMinit();
	ll ans = 0;
	for(ll i=1; ; i++){
		ll x = n - 3*i;
		if(x<0) break;
		ans += COM(x+1+i-1-1, i-1);
		ans %= MOD;
	}
	printf("%ld\n", ans);
	return 0;
}



Measured memory_bytes: 15740
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
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
//------------------------------------------
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;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

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

const int N = 200005;
LL x[N], y[N];

int main() {
	int n;
	scanf("%d", &n);
	REP(i, n)scanf("%lld%lld", &x[i], &y[i]);
	REP(i, n)if (x[i] > y[i])swap(x[i], y[i]);
	LL xmin = 1e9, xmax = 0, ymin = 1e9, ymax = 0;
	REP(i, n) {
		xmin = min(xmin, x[i]);
		xmax = max(xmax, x[i]);
		ymin = min(ymin, y[i]);
		ymax = max(ymax, y[i]);
	}
	LL ans = (xmax - xmin) * (ymax - ymin);
	vector<pair<LL, LL>> xy;
	multiset<LL> sb;
	LL d = ymax - xmin;
	REP(i, n) {
		if (x[i] == xmin) {
			sb.insert(y[i]);
		}
		else if (y[i] == ymax) {
			sb.insert(x[i]);
		}
		else {
			sb.insert(x[i]);
			xy.push_back(MP(x[i], y[i]));
		}
	}
	SORT(xy);
	int k = xy.size();
	REP(i, k + 1) {
		ans = min(ans, ((*(--sb.end())) - (*sb.begin())) * d);
		if (i == k)break;
		sb.erase(sb.find(xy[i].first));
		sb.insert(xy[i].second);
	}
	cout << ans << endl;
	return 0;
}

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

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

	int i;
	int ans = 0;
	int x=0;

	for(i=0;i<n;i++)
	{
		if(s[i]=='I') x++;
		else x--;

		ans = max(ans,x);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long x, y, mod=1000000007, a, b, q, ans[1000005];
void build(){
	ans[0]=1;
	for (long long i=1; i<1000003; i++){
		ans[i]=ans[i-1]*i; 
		ans[i]%=mod;
	}
}
long long div(long long a){
	long long b=mod-2, sol=1;
	while (b){
		if (b&1) sol*=a; a*=a; b>>=1; sol%=mod; a%=mod;
	}
	return sol;
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> x >> y; 
if ((x+y)%3) {cout << 0; return 0;}
if (x>2*y or y>2*x){cout << 0; return 0;}
	a=(x+y)/3; b=(x+y)/3*2 - max(x, y); build();
	cout << ((((ans[a]*div(ans[b]))%mod)*div(ans[a-b]))%mod);
return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define ill long long
#define rep(i, a, b) for(ill i = (ill)(a); i < (ill)(b); i++)
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a+b)%24 << "\n";
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,l[150],s,p,ans=1e9;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>l[i],s+=l[i];
    for(int i=1;i<=n;i++)p+=l[i],ans=min(ans,abs(p-(s-p)));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int n = input[0];
            int m = input[1];
            Console.WriteLine((n - 1) * (m - 1));
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int n = scanner.nextInt();
		    int k = scanner.nextInt();
		    int x = scanner.nextInt();
		    int y = scanner.nextInt();
		    
		    if( n > k )
		    {
		    System.out.println(k * x + (n-k) * y);
		    }
		    else 
		    {
		    	System.out.println(n * x);
		    }
		    scanner.close(); }
		  }

Measured memory_bytes: 23764
# -*- coding: utf-8 -*-
from collections import deque


def list_n():
    return [int(e) for e in input().split()]


def main(o, e):
    answer = ''
    o = deque(o)
    e = deque(e)
    for i in range(len(o) + len(e)):
        if i % 2 == 0:
            answer += o.popleft()
        else:
            answer += e.popleft()
    return answer

# print(main(
#     'xyz',
#     'abc'
# ))
if __name__ == '__main__':
    o = input()
    e = input()
    print(main(o, e))


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

int main() {
  string a, b; cin >> a >> b;
  
  bool isEqual = false;
  bool isAGreater = true;
  
  if (a.size() > b.size()) {
    ;
  } else if (a.size() < b.size()) {
    isAGreater = false;
  } else {
    isEqual = true;
    for (int i = 0; i < a.size(); i++) {
      if (a[i] > b[i]) {
        isEqual = false;
        break;
      } else if (a[i] < b[i]) {
        isEqual = false;
        isAGreater = false;
        break;
      }
    }
  }
  
  if (isEqual) cout << "EQUAL" << endl;
  else if (isAGreater) cout << "GREATER" << endl;
  else cout << "LESS" << endl;
}

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

void solve(){
    int n;
    cin >> n;
	if(n%10 == 3){
    	cout << "bon" << "\n";
    }
  	else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8){
    	cout << "pon" << "\n";
    }
  	else{
    	cout << "hon" << "\n";
    }
}


int main(){
    ll t;
    // cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll x,y,u,v;
lli m = 35;
lli mod;
vll d;
lli dist;

void error(){
  cout << -1 << endl;
  exit(0);
}

void solve(lli u, lli v){
  vll ans_u = vll(m);
  vll ans_v = vll(m);
  lli x = (u+dist)/2;
  lli y = (v+dist)/2;
  for(lli i = 0;i < m;i++){
    ans_u[i] = (x&d[i]) ? 1 : -1;
    ans_v[i] = (y&d[i]) ? 1 : -1;
  }
  for(lli i = 0;i < m;i++){
    if(ans_u[i] == 1 && ans_v[i] == 1) cout << 'R';
    if(ans_u[i] == 1 && ans_v[i] == -1) cout << 'U';
    if(ans_u[i] == -1 && ans_v[i] == 1) cout << 'D';
    if(ans_u[i] == -1 && ans_v[i] == -1) cout << 'L';
  }
  if(mod==0) cout << 'R';
  cout << endl;
}

int main(){
  cin >> n;
  x = vll(n);
  y = vll(n);
  u = vll(n);
  v = vll(n);
  for(lli i = 0;i < n;i++) cin >> x[i] >> y[i];
  for(lli i = 0;i < n;i++) u[i] = x[i]+y[i], v[i] = x[i]-y[i];
  mod = abs(u[0])%2;
  if(find_if(u.begin(),u.end(),[mod](lli x){return abs(x)%2 != mod;}) != u.end()) error();
  if(find_if(v.begin(),v.end(),[mod](lli x){return abs(x)%2 != mod;}) != v.end()) error();
  for(lli i = 1, j = 0;j < m;j++,i <<= 1) d.push_back(i);
  dist = accumulate(d.begin(),d.end(),0ll);
  if(mod == 0) d.push_back(1ll);
  if(mod == 0) cout << m+1 << endl;
  else cout << m << endl;
  for(lli i = 0;i < d.size()-1;i++) cout << d[i] << " ";
  cout << d[d.size()-1] << endl;
  for(lli i = 0;i < n;i++){
    solve(u[i],v[i]);
  }
  return 0;

}


Measured memory_bytes: 256
package main

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

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func main() {
	n, _ := strconv.Atoi(nextLine())
	for i := n; ; i++ {
		if i%10 == i/10%10 && i%10 == i/100%10 {
			fmt.Println(i)
			return
		}
	}
}


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

int main(){
    int n,k; string s;
    cin>>n>>k>>s;
    int ans=0;
    rep(i,n-1){
        if(s[i]==s[i+1])ans++;
    }
    cout<<min(ans+2*k,n-1)<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int A[]={1, 3, 5, 7, 8, 10, 12}, B[4]={4, 6, 9, 11}, C=2;
  int i, x, y, cntA=0, cntB=0;
  unused = scanf("%d %d", &x, &y);

  for(i=0; i<7; i++){
    if(A[i]==x || A[i]==y) cntA++;
    if(i<4 && (B[i]==x || B[i]==y)) cntB++;
  }
  if(cntA==2 || cntB==2) printf("Yes");
  else printf("No");

  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a,b;
	cin>>a>>b;
	string ans="Positive";
	if((a<0&&b>0)||a==0||b==0)ans="Zero";
	else if(a>0)ans=ans;
	else if(b<0&&(b-a)%2==0)ans="Negative";
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
K = int(input())
md = 0
if K % 2 == 0:
    print(-1)
    exit()
for i in range(10 ** 6):
    a, b = divmod(md + 7 * (pow(10, i, K)), K)
    if b == 0:
        print(i + 1)
        exit()
    else:
        md = b
print(-1)


Measured memory_bytes: 63680
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int g = 0;
		int p = 0;
		int res = 0;
		String str = sc.next();
		for (int i = 0; i < str.length(); i++) {
			if (g > p) {
				p++;
				if (str.charAt(i) == 'g') res++;
			} else {
				g++;
				if (str.charAt(i) == 'p') res--;
			}
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 12904
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <functional>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vec;
typedef pair<int, int> P;
#define rep(n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define out(a) cout << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 100000000

int w, h;
int f[55][55] = { 0 };

void dfs(int y, int x) {
	for (int i = -1; i <= 1; i++) {
		for (int j = -1; j <= 1; j++) {
			int ny = y + i;
			int nx = x + j;
			if (0 <= ny&&ny < h && 0 <= nx&&nx < w&&f[ny][nx] == 1) {
				f[ny][nx] = 0;
				dfs(ny, nx);
			}
		}
	}
	return;
}

int main() {
	while (true) {
		cin >> w >> h;
		if (w == 0 && h == 0) return 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> f[i][j];
			}
		}
		int res = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (f[i][j] == 1) {
					f[i][j] = 0;
					res++;
					dfs(i, j);
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;

int a[maxn];

bool visited[maxn];

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

	int n , x;
	cin >> n >> x;

	if(x == 1 || x == 2 * n - 1)
		return cout << "No" << endl , 0;
	if(n == 2)
		return cout << "Yes\n1 2 3" << endl , 0;

	cout << "Yes" << endl;
	a[n] = x;
	a[n + 1] = x + 1;
	a[n - 1] = x - 1;

	visited[x] = visited[x + 1] = visited[x - 1] = 1;

	if(x + 2 <= 2 * n - 1)
		a[n - 2] = x + 2 , visited[x + 2] = 1;
	else
		a[n + 2] = x - 2 , visited[x - 2] = 1;

	int pt = 1;
	for(int i = 1; i <= 2 * n - 1; i++)
		if(!a[i])
		{
			while(visited[pt])
				pt++;
			a[i] = pt++;
		}

	for(int i = 1; i <= 2 * n - 1; i++)
		cout << a[i] << " ";
	cout << endl;
}


















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

using namespace std;
typedef long long ll;

const ll oo = 1e18;
const int N = 200005;

int n;
int v[N];

// 0, even, odd, even, 0
// 0, 1,     2,   3,  4

ll dp[N][5];
ll f(int i, int j){
    if(i == n) return 0;
    ll &ans = dp[i][j];
    if(~ans) return ans;
    ans = 1e18;
    if(j == 0) ans = f(i + 1, j) + v[i];
    if(j == 1) ans = f(i + 1, j) + (v[i] == 0 ? 2 : v[i] % 2);
    if(j == 2) ans = f(i + 1, j) + !(v[i] % 2);
    if(j == 3) ans = f(i + 1, j) + (v[i] == 0 ? 2 : v[i] % 2);
    if(j == 4) ans = f(i + 1, j) + v[i];
    if(j < 4) ans = min(ans, f(i, j + 1));
    return ans;
}

int main(){
    memset(dp, -1, sizeof dp);

    scanf("%d", &n);

    for(int i = 0; i < n; i++)
        scanf("%d", v + i);

    printf("%lld\n", f(0, 0));
}


Measured memory_bytes: 18176
#include <stdio.h>
int main(void)
{
  int A, B, ans;
  scanf("%d %d", &A, &B);
  if(A>9 || B>9){
    ans = -1;
  }
  else{
    ans = A * B;
  }
  printf("%d",ans);
  
  return 0;
}

Measured memory_bytes: 128
import itertools

N = int(input())
l = [i+1 for i in range(N)]
l = tuple(itertools.permutations(l, N))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

pn = l.index(P)
qn = l.index(Q)
print(abs(pn-qn))

Measured memory_bytes: 41072
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,a,b;
	cin>>n>>a>>b;
	if((b-a) %2 ==0)
		cout<<"Alice\n";
	else
		cout<<"Borys\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int N,a,b,s[100010],vistied[100010] = {},g;
ll c,dist[100010] = {};
vector<vector<pair<int,ll>>> v(100010);
vector<int> gs;

bool dfs1(int n){
	vistied[n] = 1;
	s[n] = 1;
	bool judge = true;
	for(auto x:v[n]){
		if(vistied[x.first]==0){
			dfs1(x.first);
			s[n] += s[x.first];
			if(s[x.first]>N/2) judge = false;
		}
	}
	if(N-s[n]>N/2) judge = false;
	if(judge) gs.push_back(n);
}

void dfs2(int n){
	for(auto x:v[n]){
		if(dist[x.first]==-1){
			dist[x.first] = dist[n] + x.second;
			dfs2(x.first);
		}
	}
}

int main(){
	cin >> N;
	for(int i=1;i<N;i++){
		cin >> a >> b >> c;
		v[a].push_back({b,c});
		v[b].push_back({a,c});
		dist[i] = -1;
	}
	dist[N] = -1;
	dfs1(1);
	g = gs[0];
	dist[g] = 0;
	dfs2(g);
	sort(dist+1,dist+N+1);
	ll ans = 0;
	for(int i=1;i<=N;i++){
		ans += 2*dist[i];
	}
	if(gs.size()==1) ans -= dist[2];
	else{
		for(auto x:v[gs[0]]){
			if(x.first==gs[1]) ans -= x.second;
		}
	}
	cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<pair<double, double>> xy(n);
    rep(i, n) {
        double x, y;
        cin >> x >> y;
        xy[i] = {x, y};
    }
    sort(xy.begin(), xy.end());
    double ans = 0;
    double cnt = 0;
    do {
        double sum = 0;
        rep(i, n-1) {
            double x_diff = xy[i].first - xy[i+1].first;
            double y_diff = xy[i].second - xy[i+1].second;
            sum += sqrt(x_diff * x_diff + y_diff * y_diff);
        }
        ans += sum;
        ++cnt;
    } while ( next_permutation(xy.begin(), xy.end()));
    printf("%.7lf\n", ans / cnt);
    return 0;
}


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

// edit by  (xcode)

using namespace std;

#define int         long long
#define ll          long long
#define double      long double
#define pb          push_back
#define in          insert
#define mp          make_pair
#define f           first
#define s           second
//#define x           first
//#define y           second
#define all(el)     el.begin(), el.end()
#define allr(el)    el.rbegin(), el.rend()
#define sz(el)      (int)el.size()
#define endl        "\n"

inline int chkmax(int &x, int y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

inline int chkmin(int &x, int y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

signed main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int res = 0;
    vector<vector<int>> dp(n + 1, vector<int> (s + 1));
    for (int i = 1; i <= n; i++) {
        if (a[i - 1] <= s) {
            dp[i][a[i - 1]] += i;
            dp[i][a[i - 1]] %= 998244353;
        }
        for (int j = 0; j <= s; j++) {
            dp[i][j] += dp[i - 1][j];
            dp[i][j] %= 998244353;
        }
        for (int j = 0; j <= (s - a[i - 1]); j++) {
            dp[i][j + a[i - 1]] += dp[i - 1][j];
            dp[i][j + a[i - 1]] %= 998244353;
        }
        res += dp[i][s];
        res %= 998244353;
    }
    cout << res;
    return 0;
}



Measured memory_bytes: 70784
%:pragma GCC optimize("Ofast")
%:pragma GCC target("sse3","sse2","sse")
%:pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
%:pragma GCC target("f16c")
%:pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
%:pragma GCC diagnostic error "-fwhole-program"
%:pragma GCC diagnostic error "-fcse-skip-blocks"
%:pragma GCC diagnostic error "-funsafe-loop-optimizations"
%:pragma GCC diagnostic error "-std=c++14"

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<x<<endl
#define Divhe() cout<<">>>>>>>>>>>>>>>"<<endl
#define Divshe() cout<<"<<<<<<<<<<<<<<<"<<endl
#define Oops() cout<<"!!!!!!!!!!!!!!!"<<endl

/*
-<Unlimited Blade Works>-
*/

const int N=5200;
const int MOD=1e9+7;

int Mul(int a,int b)
{
	unsigned long long x=(long long)a*b;
	unsigned xh=(unsigned)(x>>32),xl=(unsigned)x,d,m;
	asm
		(
		 "divl %4;\n\t"
		 :"=a"(d),"=d"(m)
		 :"d"(xh),"a"(xl),"r"(MOD)
		);
	return m;
}

int U(int x,int y)
{
	return ((x+=y)>=MOD)?(x-MOD):x;
}

void SU(int& x,int y)
{
	((x+=y)>=MOD)?(x-=MOD):0;
}

int D(int x,int y)
{
	return ((x-=y)<0)?(x+MOD):x;
}

void SD(int& x,int y)
{
	((x-=y)<0)?(x+=MOD):0;
}

int n;
vector<int> G[N];

int sz[N],dp[N][N],cm[N];

void Dfs(int u,int fa=0)
{
	sz[u]=dp[u][1]=1;
	for(int v:G[u])if(v!=fa)
	{
		Dfs(v,u);
		int sm=0;
		for(int i=2;i<=sz[v];i+=2)
			SD(sm,Mul(dp[v][i],cm[i]));
		int rec=sz[u];
		for(int i=(sz[u]+=sz[v]);i>=1;--i)
		{
			int& t=dp[u][i];
			t=Mul(t,sm);
			for(int j=max(1,i-sz[v]),k=min(i,rec);j<=k;++j)
				SU(t,Mul(dp[u][j],dp[v][i-j]));
		}
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1,u,v;i<n;++i)
	{
		scanf("%d%d",&u,&v);
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}

	cm[0]=1;
	for(int i=2;i<=n;i+=2)
		cm[i]=Mul(cm[i-2],i-1);

	Dfs(1);

	int ans=0;
	for(int i=2;i<=n;i+=2)
		SU(ans,Mul(dp[1][i],cm[i]));
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 102528
#define _CRT_SECURE_NO_WARNINGS
/*                   وتزودوا فإن خير الزاد التقوى                    */
/*       وما تدري نفس ماذا تکسب غدا وما تدري نفس باي ارض تموت      */
#include <bits/stdc++.h>
#include<unordered_map>
#include<iomanip>
#include<fstream>
using namespace std;
#include<iostream>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define dll double
#define PI acos(-1)
#define watch(x) cout<<#x<<" = { "<<x<<" }\n"
#define sz(n) n.size()
#define M_Sayed fast() 
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define RT(v) return cout<<v,0
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
const double EPS = (1e-7);
ll Ceil(ll x, ll y) { return (x + y - 1) / y; }
void run() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }
ll power(ll x, ll y, ll mod) {
	if (y == 0) return 1;
	if (y == 1) return x % mod;
	ll r = power(x, y >> 1, mod);
	return (((r * r) % mod) * power(x, y & 1, mod)) % mod;
}
void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
ll n, m, t = 1, k;
int main()
{
	run();
	M_Sayed;
	//cin >> t;
	ll a, b, c, d;
	t = 1e4;
	//bool b=1
	while (t--) {
		cin >> a >> b >> c >> d;
		c -= b;
		if (c <= 0)RT("Yes");
		a -= d;
		if (a <= 0)RT("No");
	}
	RT("No");

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define fast cin.tie(0);cout.tie(0);
#define order ios::sync_with_stdio(0);
using namespace std;
vector<ll>v[20][10];
int c=0,w;
ll m=1,t=10;
int main()
{
    cin>>w;
    for(ll i=0;i<t;i++)
    {
        v[0][i].push_back(i);
        if(i)c++;
        if(c==w)
        {
            cout<<v[0][i].back();
            return 0;
        }
    }
    for(int j=1;j<12;j++)
    {
        m*=10;
        for(ll i=0;i<10;i++)
        {
            for(int k=-1;k<=1;k++)
            {
                if(i+k<0||i+k>9)continue;
                //cout<<i<<" "<<k<<":\n";
                for(int l=0;l<v[j-1][i+k].size();l++)
                {
                    v[j][i].push_back(v[j-1][i+k][l]+m*i);
                    if(i!=0)c++;
                 //   cout<<v[j][i].back()<<" ";
                    if(c==w)
                    {
                        cout<<v[j][i].back();
                        return 0;
                    }
                }
               // cout<<"\n";
            }
        }
     //   cout<<c<<"\n";
    }
   // cout<<c;
}


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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)

void solve(){
    ll x,k,d;
    cin>>x>>k>>d;
    if(x<0){
        ll tp=abs(x);
        ll req=tp/d;
        if(req>=k){
            x+=d*k;
            cout<<abs(x)<<endl;
            return ;
        }
        x+=req*d;
        k-=req;
    } else {
        ll tp=x;
        ll req=tp/d;
        if(req>=k){
            x-=d*k;
            cout<<x<<endl;
            return ;
        }
        x-=req*d;
        k-=req;
    }
    if(k%2==1){
        if(x>=0){
            cout<<abs(x-d)<<endl;
        } else {
            cout<<abs(x+d)<<endl;
        }
        return ;
    }
    else {
      ll ans=abs(x);
      cout<<ans<<endl;
      return ;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    // cin >> t;
    for(long int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3620
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<int>
#define pint        	pair<int, int>
#define umint        	unordered_map<int, int>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define fj(x)			for(int j=0; j<x; j++)
#define fn(n, x)			for(int i=n; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {

    om_shree_ganeshaya_namah();

    in(n);
    vector<double> arr(n);
    f(n) cin>>arr[i];

    vector<vector<double>> dp(n+1, vector<double>(n+1));

    dp[0][0] = 1;

    for(int i=1; i<=n; i++){
    	for(int j=0; j<=i; j++){
    		if(j==0)
    			dp[i][j] = (dp[i-1][j]*(1-arr[i-1]));
    		else
    			dp[i][j] = (dp[i-1][j]*(1-arr[i-1]))+(dp[i-1][j-1]*arr[i-1]);
    	}
    }

    /*for(int i=1; i<=n; i++){
    	for(int j=0; j<=n; j++){
    		cout<<dp[i][j]<<" ";
    	}
    	cout<<endl;
    }*/

    double ans =0;
    for(int i=(n/2)+1; i<=n; i++)
    	ans+=dp[n][i];
    cout<<sp(ans, 10);

}

Measured memory_bytes: 73744
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N, M, A;
  cin >> N >> M;
  for (int i=0; i<M; i++) {
    cin >> A;
    N -= A;
  }
  cout << max(-1, N) << endl;
}

Measured memory_bytes: 3656