akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n,u,v;
	cin >> n >> u >> v;
	u--,v--;

	vector<vector<int>> e(n);
	for(int i = 0;i < n-1;i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	vector<int> d1(n,INF);

	queue<int> que;
	d1[u] = 0;
	que.push(u);
	while(que.size()){
		int now = que.front();
		que.pop();

		for(int next:e[now]){
			if(d1[next] > d1[now] + 1){
				d1[next] = d1[now] + 1;
				que.push(next);
			}
		}
	}

	vector<int> d2(n,INF);
	d2[v] = 0;
	que.push(v);
	while(que.size()){
		int now = que.front();
		que.pop();

		for(int next:e[now]){
			if(d2[next] > d2[now] + 1){
				d2[next] = d2[now] + 1;
				que.push(next);
			}
		}
	}

	int d2_max = 0;
	for(int i = 0;i < n;i++){
		if(d1[i] <= d2[i] && d2[i] > d2_max){
			d2_max = d2[i];
		}
	}

	cout << d2_max-1 << endl;
}


Measured memory_bytes: 9500
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e18
#define MOD 10e9+7

typedef vector<int> vint;
typedef long long ll;



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

        vector<ll> n(4,0);

        rep(i,4){cin>>n[i];}

        ll max=-INF;

        for(int i=0;i<2;i++){
                for(int j=2;j<4;j++){
                        ll tmp=n[i]*n[j];
                        if(max<tmp){max=tmp;}
                }
        }
        cout<<max<<endl;



        return 0;
}


Measured memory_bytes: 3648
# frozen_string_literal: true

n = gets.to_i
w = gets.split.map(&:to_i)
left = w[0]
right = w.inject(:+) - w[0]
ans = (left - right).abs
(1..n - 2).each do |i|
  left += w[i]
  right -= w[i]
  tmp = (left - right).abs
  ans = tmp if ans > tmp
end
puts ans


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define int long long
#define re register
using namespace std;
#define gc getchar
string s[1002],t;
int n,sum[1002],ans;
bool add;
signed main(){
	cin>>n;
	for(re int i=1;i<=n;++i){
		cin>>s[i]>>sum[i];
	}
	cin>>t;
	for(re int i=1;i<=n;++i){
		ans+=sum[i]*add;
		if(s[i]==t)add=1;
	}
	cout<<ans;
	}



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

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; --i) // nから0までであることに注意!!
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

using ll = long long;

// ペアが両方とも長方形の外周上にあるやつだけ考える

struct T {
  int x, y, id;
  T () {}
  T (ll x, ll y, ll id) : x(x), y(y), id(id) {}
  bool operator < (const T &t) const {
    if (x == t.x) return y < t.y;
    return x < t.x;
  }
};

ll R, C, n, a, b, c, d;
// xz : y軸上の点, yz : x軸上の点, xr : x = R上の点, yc : y = C上の点
vector<T> xz, yz, xr, yc;
vector<T> v;

int main() {
  init();
  cin >> R >> C >> n;
  rep(i,n) {
    cin >> a >> b >> c >> d;
    if ((a == 0 or a == R or b == 0 or b == C) and
        (c == 0 or c == R or d == 0 or d == C)) {
      if (a == 0) xz.push_back({a, b, i});
      else if (a == R) xr.push_back({a, b, i});
      else if (b == 0) yz.push_back({a, b, i});
      else yc.push_back({a, b, i});
      if (c == 0) xz.push_back({c, d, i});
      else if (c == R) xr.push_back({c, d, i});
      else if (d == 0) yz.push_back({c, d, i});
      else yc.push_back({c, d, i});
    }
  }

  int sxz, syz, sxr, syc;
  sxz = xz.size();
  syz = yz.size();
  sxr = xr.size();
  syc = yc.size();

  sort(all(xz));
  sort(all(yz));
  sort(all(xr));
  sort(all(yc));

  // 反時計回りにvへつっこむ
  rep(i,sxz) v.push_back({xz[i].x, xz[i].y, xz[i].id});
  rep(i,syc) v.push_back({yc[i].x, yc[i].y, yc[i].id});
  rrep(i,sxr-1) v.push_back({xr[i].x, xr[i].y, xr[i].id});
  rrep(i,syz-1) v.push_back({yz[i].x, yz[i].y, yz[i].id});
  
  stack<T> st;
  map<int, bool> mp;

  int si = v.size();
  
  rep(i,si) {
    if (!mp[v[i].id]) {
      st.push(v[i]);
      mp[v[i].id] = true;
    }
    else {
      T t = st.top();
      st.pop();
      if (t.id != v[i].id) {
        cout << "NO" << endl;
        return 0;
      }
      else {
        mp[v[i].id] = false;
      }
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 10260
#include <stdio.h>

int
main(void)
{
    int N, A[1000], result[1000], i, j, k, v;

    scanf("%d", &N);
    for(i = 0; i < N; ++i)
        scanf("%d", A + i);

    for(i = 0; i < N - 1; ++i)
        printf("%d ", A[i]);
    printf("%d\n", A[N-1]);

    for(i = 1; i < N; ++i) {
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            --j;
        }
        A[j+1] = v;
        for(k = 0; k < N - 1; ++k)
            printf("%d ", A[k]);
        printf("%d\n", A[N-1]);
    }
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main(){
int x,y;
cin>>x>>y;
bool a=false;
for(int i=0; i<=x; i++){
    if(i*2+(x-i)*4==y) a=true;
}
if(a) cout<<"Yes"<<endl;
else cout<<"No"<<endl;

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;



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

	ll N,ans=0,maxh=0;
	cin >> N;
	FOR(i,0,N){
		ll h;
		cin >> h;
		if(maxh<=h){
			maxh = h;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define lli long long int
#include <limits.h>
#include <fstream>
#define F first
#define S second
#define PI 3.141592653589793238
#define pb push_back

using namespace std;

//doesn't work for arrays
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli i,j,tt=1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;
        cout<<8-(n-400)/200;
    }
    return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int

int main(void) {

    int H , W;
    int a , b;

    scanf("%d %d",&H,&W);
    scanf("%d %d",&a,&b);

    int res = (H-a) * (W-b);
    printf("%d",res);

	return 0;
}



Measured memory_bytes: 128
import java.util.*;
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		// 食べた数の入力
    		int N = sc.nextInt();
		//払った金額
		int x=N*800;
		//もらった金額
		int y=(N/15)*200;
    		// 出力
    		System.out.println(x-y);
    	}
    }

Measured memory_bytes: 21716
#include <iostream>
#include<algorithm>
using namespace std;
int main() {
	int w1=0,w2=0,w3=0,k1=0,k2=0,k3=0,a[20];
	for(int i=0;i<20;i++){
		cin>>a[i];
	}
	for(int i=0;i<10;i++){
		if(w3<a[i]) swap(w3,a[i]);
		if(w2<w3) swap(w2,w3);
		if(w1<w2) swap(w1,w2);
	}
	for(int i=11;i<20;i++){
		if(k3<a[i]) swap(k3,a[i]);
		if(k2<k3) swap(k2,k3);
		if(k1<k2) swap(k1,k2);
	}	cout<<w1+w2+w3<<" "<<k1+k2+k3<<endl;
	return 0;
}

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

int main()
{
    double r;
    cin>>r;
    cout<<fixed<<setprecision(6)<<r*r*3.14159265359<<" "<<fixed<<setprecision(6)<<2*r*3.14159265359<<endl;
    return 0;
}

Measured memory_bytes: 3272
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }





void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> h(n);
    vector<int> c(n+10,1e9);
    
    rep(i,n) cin >> h[i];
    
    
    c[0] = 0;
    for (int i = 0; i < n; i++) {
        c[i+1] = min(c[i+1],c[i]+abs(h[i+1]-h[i]));
        c[i+2] = min(c[i+2],c[i]+abs(h[i+2]-h[i]));
    }
    cout << c[n-1] << endl;
}



signed main() {
    
    
    solve();
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define vs vector<string>
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define tr1(x)                cout<<#x<<": "<<x<<endl
#define tr2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define tr4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl
#define tr3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define db1(x) cerr << #x << ": " << x <<'\n'
#define db2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define db3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int, int> &a,const pair<int, int> &b)
{
    return (a.ss<b.ss);
}
int min(int a, int b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b, int c){
    return(max( max(a,b), c ));
}
int min(int a, int b, int c){
    return (min ( min(a,b) , c));
}
int poww(int a, int b)
{
    int res = 1;
    for(int i = 1; i<=b; ++i)
        res *= a;
 
    return res;
}
int findlcm(int arr[], int n)
{
    // Initialize result
    int ans = arr[0];
 
    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (__gcd(arr[i], ans)));
 
    return ans;
}
bool prime[100001];
void SieveOfEratosthenes(int n)
{
    memset(prime, true, sizeof(prime));
 
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
  }
}
 
//Define mx for maximum range and MOD for large numbers
#define mx 500005
#define mod 1000000007
 
// Declare all the variables and global functions here -
int t;
int32_t main(){
    IOS;
    int n;
    cin >> n;
    vi v;
    rep(i, 0, n){
        int c;
        cin >> c;
        v.pb(c);
    }

    sort(all(v));
    int x = n/2;

    int s = v[x-1];
    int e = v[x];

    cout << e-s << endl;

}  

Measured memory_bytes: 1400
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)

// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N;
	cin >> N;
	string W[N];
	for (int i = 0; i < N; ++i) cin >> W[i];
 
	// 解法
	bool ans = true;
	for (int i = 0; i < N; ++i){
		for (int j = 0; j < N; ++j){
			if (W[i]==W[j] && i!=j){
				ans = false;
				break;
			}
		}
	}
	
	string tail = W[0].substr(W[0].size()-1,1);
	for (int i = 1; i < N; ++i){
		// cout << tail << endl;
		if (W[i].substr(0,1)!=tail){
				ans = false;
				break;
		}
		tail = W[i].substr(W[i].size()-1,1);
	}
	
	if (ans) printf("Yes\n");
	else printf("No\n");
}
 


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> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    long long int k;
    cin>>n>>k;
    long long int a[n];
    for (int i=0;i<n;i++) cin>>a[i];
    long long int l=1;
    long long int r=1e9;
    while (l<r){
        long long int m=(l+r)/2;
        long long int cnt=0;
        for (int i=0;i<n;i++){
            if(a[i]>m){
                cnt+=(a[i]-1)/m;
            }
        }    
        if(cnt<=k) r=m;
        else l=m+1;
    }
    cout<<l<<"\n";
	return 0;
}

Measured memory_bytes: 5124
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let q = cin.getInt();
    for (let i = 0; i < q; i++) {
        let a = cin.getInt(), b = cin.getInt();
        if (a == b) {
            console.log(2 * a - 2);
        } else if (a + 1 == b || b + 1 == a) {
            console.log(2 * Math.min(a, b) - 2);
        } else {
            let ab = a * b;
            let d = Math.floor(Math.sqrt(ab));
            if (d * d == ab) d--;
            if (d * (d + 1) >= ab) {
                console.log(2 * d - 2);
            } else {
                console.log(2 * d - 1);
            }
        }
    }
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9804
n=int(input())
a=list(map(int,input().split()))

A=sum(a)
s=[0]*(n+1)
ans=float('inf')
for i in range(n-1):
    s[i+1]=s[i]+a[i]
    tem=abs(A-2*s[i+1])
    if tem>=0 and tem<ans:
        ans=tem
print(ans)

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

static const int INF = 1001001001;

int main()
{
    int N;
    int sum = 0;
    std::cin >> N;
    std::vector<int> A(N + 2);
    A.at(0) = 0;
    for (unsigned i = 1; i < N + 1; ++i) {
        std::cin >> A.at(i);
    }
    A.at(N + 1) = 0;
    for (unsigned i = 0; i < N + 1; ++i) {
        sum += abs(A.at(i + 1) - A.at(i));
    }
    for (unsigned i = 0; i < N; ++i) {
        std::cout << sum - abs(A.at(i + 1) - A.at(i)) - abs(A.at(i + 2) - A.at(i + 1)) + abs(A.at(i + 2) - A.at(i)) << std::endl;
    }

    return 0;
}


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

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

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)(s1[0] + 'A' - 'a') << (char)(s2[0] + 'A' - 'a') << (char)(s3[0] + 'A' - 'a') << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define rep(p,a,b) for(ll p=a ; p<b ; p++)
#define F first
#define S second
using namespace std;


int main()
{
    ll t,i,j,k,ans,n,x;

    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>k>>x;
        if(500*k>=x)cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}



Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            string S = IO.ReadLineToString();
            long K = IO.ReadLineToLong();

            string ans = "1";
            for (var i = 0; i < Math.Min(99, K); i++)
            {
                if (S[i] != '1')
                {
                    ans = S[i].ToString();
                    break;
                }
            }

            //ここまで

            Console.WriteLine(ans);
            Console.ReadKey();
        }

    }

    static class Func
    {
        static long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(int n,int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public List<double> ReadLineToDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1e9+7
#define ALL(v) v.begin(), v.end()

int main()
{
    int c[3][3];

    REP(i, 3) REP(j, 3) {
         cin >> c[i][j];
    }

    bool ans = true;
    FOR(i, 1, 3) {
        FOR(j, 1, 3) {
            if (c[i][j] - c[i-1][j] != c[i][0] - c[i-1][0]) {
                ans = false;
            }
            if (c[i][j] - c[i][j-1] != c[0][j] - c[0][j-1]) {
                ans = false;
            }
        }
    }

    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import math
import sys

A, B, H, M = map(int, input().split(' '))

if H == 0 and M == 0:
    print(max(A, B) - min(A, B))
    sys.exit()

# 角速度(deg/h)
H_deg = 30
M_deg = 360

# 分針の角度(時間にする)
M_rad = math.radians(M_deg * M / 60)

# 時針の角度
H_rad = math.radians(H_deg * (H + M / 60))

# 二つの間の角度
if M_rad < H_rad:
    rad = (H_rad - M_rad)
else:
    rad = (M_rad - H_rad)

if rad >= math.pi:
    rad = math.radians(360) - rad

if rad == 0:
    print(A + B)
else:
    # 余弦定理
    C_2 = A**2 + B**2 - 2 * A * B * math.cos(rad)
    print(math.sqrt(C_2))


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

typedef long long int ll;
ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll n;
    cin >> n;
    vector<string> s(n);
    ll ans = 0;
    for(ll i = 0;i < n;i++){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());

    ll t = 0;
    for(ll i = 0;i < n - 1;i++){
        if(s[i] == s[i + 1]){
            t++;
        }
        else{
            for(ll j = 1;j <= t;j++){
                ans += j;
            }
            t = 0;
        }
    }

    for(ll i = 1;i <= t;i++){
        ans += i;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main(){
  int a,b,c;
  cin >> a >> b >> c;
  bool f = true;
  if((a == b && b == c) ||( a != b && b != c && a != c)) f = false;
  cans(f);

  
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll n;
  cin>>n;
  vector<ll> a(n+1);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  vector<ll> sup(n+1,0);
  for (int i = n-1; i > 0; --i)
  {
    sup[i]=sup[i+1]+a[i+1];
  }

  vector<ll> b(n+1);
  b[0]=1-a[0];
  if (b[0]<0) {
    cout<<-1<<endl;
    return 0;
  }
  for (int i = 1; i < b.size(); ++i)
  {
    b[i]=min(2*b[i-1]-a[i],sup[i]);
    if (b[i]<0||b[i-1]>a[i]+b[i]|| a[i]+b[i]>2*b[i-1]) {
      cout<<-1<<endl;
      return 0;
    }
  }
  // for(auto&& e: b) 
  // {
  //   cout<<e<<" ";
  // }
  // cout<<endl;

  cout<<accumulate(a.begin(), a.end(),0LL)+accumulate(b.begin(), b.end(),0LL)<<endl;
}

Measured memory_bytes: 5640
N = int(input())
S = [(input()) for i in range(N)]
A = {}
B = {}
for i in range(N):
    tmp = sorted(S[i])
    mojiretu = ' '
    
    for x in tmp:
        mojiretu += x
    if mojiretu in A:
        A[mojiretu] += B[mojiretu]
        B[mojiretu] += 1
    else:
        B[mojiretu] = 1
        A[mojiretu] = 0
answer = 0
for i in A:
    answer += A[i]
print(answer)

Measured memory_bytes: 84056
n,k,c=map(int,input().split())
s=input()
l=[]
r=[]
i=0
j=0
while len(l)<k and i<n:   
    if s[i]=='o':
      l.append(i+1)
      i+=c+1
    else: i+=1

while len(r)<k and j<n:   
    if s[-j-1]=='o':
      r.append(n-j)
      j+=c+1
    else: j+=1
for n in range(k):
  if l[n]==r[-n-1]:
    print(l[n])

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

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    rep(i,q) cin >> a[i];

    vector<int> ans(n);
    rep(i,q) ans[a[i]-1]++;
    rep(i,n) ans[i] += k - q;
    rep(i,n) puts(ans[i]<=0?"No":"Yes");

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include<iostream>
#include<queue>
using namespace std;
#define ll long long
#define PI 3.1415926535898
/*
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; ll n1[100005];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> n1[i];
	}
	ll ans = 0, tempmax = 0;
	for (int i = 0; i < n-1; i++)
	{
		if (n1[i] >= n1[i + 1])
			tempmax++;
		else
		{
			ans = max(tempmax, ans);
			tempmax = 0;
		}
	}
	ans = max(tempmax, ans);
	cout << ans << endl;
	return 0;
}*/

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b;
	while (cin >> a >> b)
	{
		int sum = 0;
		if (b == 1)
		{
			cout << 0 << endl;
			continue;
		}
		else
		{
			if (b <= a)
			{
				cout << 1 << endl;
				continue;
			}
			else
			{
				b -= a;
				sum++;
				while (b > 0)
				{
					sum++;
					b -= a - 1;
				}
				cout << sum << endl;
			}
		}
		
	
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  char s[101],p[101];
  int i,j,sn=0,pn=0,t;
 
  scanf("%s %s",s,p);
 
//文字数カウント
  while(s[sn] != '\0') sn++;
  while(p[pn] != '\0') pn++;
 
  for(i=0;i<sn;i++){
    t=1;
    for(j=0;j<pn;j++)
      if(s[(i+j)%sn] != p[j]) t=0;
    if(t) break;
  }
 
  if( t )
    printf("Yes\n");
  else
    printf("No\n");
 
  return 0;
}
   
  


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, x;
	cin >> n >> x;
	vector<int> m(n);
	for(int i = 0; i < n; ++i) {
		cin >> m[i];
		x -= m[i];
	}
	sort(m.begin(), m.end());
	int res = x/m[0] + n;
	cout << res << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define PI 3.141592653

int main(){
    int n;
    
    while(1){
        int sum[5002],ans=-200000000,a;
        scanf("%d",&n);
        
        if(n==0) break;
        
        sum[0]=0;
        sum[1]=0;
        
        for(int i=1;i<=n;i++){
            scanf("%d",&a);
            
            sum[i]+=a;
            sum[i+1]=sum[i];
            
            for(int j=0;j<i;j++){
                ans=max(ans,sum[i]-sum[j]);
            }
        }
        
        printf("%d\n",ans);
    }
    
    return 0;
}

Measured memory_bytes: 1208
n, y = map(int, input().split(' '))
a = False
for i in range(0, n+1):
    if a == True:
        break
    for i2 in range(0, n-i+1):
        c = n - i2 - i
        #print (i, i2, c)
        if i*10000 + i2 * 5000 + c * 1000 == y:
            print (i, i2, c)
            a = True
            break
if a == False:
    print ("-1 -1 -1") 


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Min(a, b) ((a < b)? a : b)
#define Max(a, b) ((a > b)? a : b)
#define Abs(x) ((x>=0)? x : -x)/*Return the absolute value of x.*/
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int a;
	scanf("%d", &a);
	printf("%d", 3*a*a);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    t = 1;
    for(int i=0;i<t;i++)
    {
        int x,n;
        cin>>x>>n;
        int arr[n];
        int dp[205]= {0};
        x = x+100;
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
            dp[arr[i]+100]++;
        }
        int mini = INT_MAX,l=0;
        for(int i=0;i<205;i++)
        {
            if(dp[i]==1)
            {
                continue;
            }
            if(mini>abs(i-x))
            {
                mini = abs(i-x);
                l = i;
            }
        }
        cout<<l-100;
    }
    return 0;
}

Measured memory_bytes: 3584
module deque_mod
    use,intrinsic :: iso_fortran_env
    implicit none
    type deque
        integer(int32),pointer:: v(:)
        integer(int32):: l,r
        integer(int32):: lmax, rmax
    end type
    private
    public:: deque
    public:: init_deque
    public:: append, appendleft
    public:: pop, popleft
    public:: right, left
    public:: remaining_elements
    public:: remain

contains
    subroutine init_deque(dq)
        ! 初期化
        type(deque):: dq
        dq%r=0; dq%rmax=1
        dq%l=1; dq%lmax=-1
        allocate(dq%v(dq%lmax:dq%rmax))
    end subroutine


    subroutine append(dq,num)
        ! 右端に挿入
        type(deque):: dq
        integer(int32):: num
        if (dq%r+1 > dq%rmax) call add_(dq)
        dq%r=dq%r+1
        dq%v(dq%r) = num
    end subroutine

    subroutine appendleft(dq,num)
        ! 左端に挿入
        type(deque):: dq
        integer(int32):: num
        if (dq%l-1 < dq%lmax) call add_(dq)
        dq%l=dq%l-1
        dq%v(dq%l) = num
    end subroutine

    subroutine add_(dq)
        ! arrayの延長
        type(deque):: dq
        integer(int32):: l
        integer(int32),pointer:: tmp(:)
        l = size(dq%v)
        allocate(tmp(l))
        tmp(:) = dq%v(:)
        deallocate(dq%v)
        allocate(dq%v(8*dq%lmax:8*dq%rmax))
        dq%v(dq%lmax:dq%rmax) = tmp(:)
        dq%lmax = 8*dq%lmax
        dq%rmax = 8*dq%rmax
    end subroutine


    function pop(dq) result(ret)
        ! 右端から取り出し
        type(deque):: dq
        integer(int32):: ret
        ret = dq%v(dq%r)
        dq%r=dq%r-1
    end function

    function popleft(dq) result(ret)
        ! 左端から取り出し
        type(deque):: dq
        integer(int32):: ret
        ret = dq%v(dq%l)
        dq%l=dq%l+1
    end function


    function right(dq) result(ret)
        ! 右端を確認
        type(deque):: dq
        integer(int32):: ret
        ret = dq%v(dq%r)
    end function

    function left(dq) result(ret)
        ! 左端を確認
        type(deque):: dq
        integer(int32):: ret
        ret = dq%v(dq%l)
    end function

    function remaining_elements(dq) result(ret)
        ! 残りの要素数
        type(deque):: dq
        integer(int32):: ret 
        ret = dq%r - dq%l + 1
    end function

    function remain(dq) result(ret)
        ! 要素が残っているかどうか
        type(deque):: dq
        logical:: ret
        ret = remaining_elements(dq) > 0
    end function
end module


program name
    use,intrinsic :: iso_fortran_env
    use deque_mod
    implicit none
    integer(int32):: n,i
    integer(int32), allocatable:: a(:), ans(:)
    type(deque):: b

    call init_deque(b)
    read*, n
    allocate(a(n),ans(n))
    read*, a(:)

    do i=1,n
        if (mod(i,2) == 1) then
            call append(b,a(i))
        else
            call appendleft(b,a(i))
        end if
    end do

    if (mod(n,2) /= 0) then
        do i=1,n
            ans(i) = pop(b)
        end do
    else
        do i=1,n
            ans(i) = popleft(b)
        end do
    end if

    print'(100000(i0,1x))', ans(:)




end program name

Measured memory_bytes: 6780
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}
template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}

void solve(){
    string S;
    cin >> S;
    int countw(0), countb(0);
    ll ans = 0;
    REP(i, S.size()){
        if( S[i] == 'W'){
            countw++;
            ans += countb;
        }else{
            countb++;
        }
    }
    cout << ans << endl;


} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3780
import itertools
n = int(input())
xy = []

for i in range(n):
  x,y = map(int, input().split())
  xy.append([x,y])


a,b = [],[]
for v in itertools.combinations(xy,2):
  z = list(v)
  z.sort()
  x = z[1][0]-z[0][0]
  y = z[1][1]-z[0][1]
  a.append([x,y])
  if [x,y] in b:
    continue
  b.append([x,y])

c = 0
for i in b:
  c = max(c,a.count(i))
print (n-c)

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    //a=a%MOD;
    while(b>0){
        if(b&1)
		{res=(res*a);
		//res%=MOD;
		b--;}
        a=(a*a);
        //a%=MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	int a,b,c;
	cin>>a>>b>>c>>k;
	while(k and b<=a)
	b*=2,k--;
	while(k and c<=b)
	c*=2,k--;
	if(c>b and b>a)
	{
	    cout<<"Yes";
	    return;
	}
	cout<<"No";
}
int32_t main() {
    fast
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

Measured memory_bytes: 3636
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;

int main(){
  int a[10],b[10];
  for(int i=0;i<10;i++) cin >> a[i];
  for(int i=0;i<10;i++) cin >> b[i];
  sort(a,a+10,greater<int>()); sort(b,b+10,greater<int>());
  cout << a[0] + a[1] + a[2] << " " << b[0] + b[1] + b[2] << endl;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 3e5 + 5;
const int MOD = 998244353;
int fat[MAX];

inline int add(int a, int b) {
	a += b;
	if(a >= MOD) {
		a -= MOD;
	}
	return a;
}

inline int mult(int a, int b) {
	return (1LL * a * b) % MOD;
}

int f_exp(int x, int exp) {
	if(exp == 0) {
		return 1;
	}
	else if(exp & 1) {
		return mult(x, f_exp(x, exp - 1));
	}
	return f_exp(mult(x, x), exp / 2);
}

inline int inv(int x) {
	return f_exp(x, MOD - 2);
}

inline int comb(int n, int k) {
	return mult(fat[n], mult(inv(fat[k]), inv(fat[n - k])));
}

int main() {
	ios_base::sync_with_stdio(false);

	fat[0] = 1;
	fori(i, 1, MAX) {
		fat[i] = mult(fat[i - 1], i);
	}

	ll n, a, b, k;
	cin >> n >> a >> b >> k;

	int ans = 0;

	for(ll A = 0; A <= n; A++) {
		ll cur_k = k - A * a;

		if(cur_k >= 0 && cur_k % b == 0) {
			ll B = cur_k / b;

			if(A > n || B > n) {
				continue;
			}

			ans = add(ans, mult(comb(n, A), comb(n, B)));
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 1408
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
u=input().rstrip()
k=I()
for i in range(k):
    if u[i]=="1":
        continue
    else:
        print(u[i])
        sys.exit()
print("1")

Measured memory_bytes: 3316
using System;
using static System.Console;

namespace abc158
{
    class Program
    {
        static void Main()
        {
            var np = ReadLine().Split(' ');
            var n = int.Parse(np[0]);
            var p = int.Parse(np[1]);
            var s = ReadLine();

            var total = 0L;
            if (p == 2 || p == 5)
            {
                for (var i = 0; i < n; ++i)
                {
                    if ((s[i] - '0') % p == 0)
                    {
                        total += i + 1;
                    }
                }
            }
            else
            {
                var digit = 1;
                var current = 0L;
                var mods = new int[p];
                for (var i = n - 1; i >= 0; --i)
                {
                    current = (current + (s[i] - '0') * digit) % p;
                    total += mods[current] + (current == 0 ? 1 : 0);
                    ++mods[current];
                    digit = digit * 10 % p;
                }
            }
            WriteLine(total);
        }
    }
}


Measured memory_bytes: 28376
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pll pair<int ,int >
#define ppll pair < pll , pll >
#define mod 1000000007
unsigned int bp(int n) // built_in_pop_count // 
{ 
    unsigned int count = 0; 
    while (n) { 
        n &= (n - 1); 
        count++; 
    } 
    return count; 
} 
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
    }
    int sum = 0;
    for(int i = 0; i < n; ++i){
        sum ^= arr[i];
    }
    for(int i = 0; i < n; ++i){
        arr[i] ^= sum;
    }
    for(int i = 0; i < n; ++i){
        cout << arr[i] << " ";
    }
}

Measured memory_bytes: 5080
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

int fastpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

class Combination
{
public:

    vec fact, invfact;
    int MAX_N, mod;

    Combination(int MAX_N, int mod): MAX_N(MAX_N), mod(mod) {
        initialize();
    }

    void initialize(){
        fact = vec(MAX_N + 1);
        invfact = vec(MAX_N + 1);
        fact[0] = 1;
        FOR(i, 1, MAX_N + 1){
            fact[i] = (fact[i - 1] * i) % mod;
        }
        invfact[MAX_N] = fastpow(fact[MAX_N], mod - 2, mod);
        IREP(i, MAX_N){
            invfact[i] = (invfact[i + 1] * (i + 1)) % mod;
        }
    }

    int nCr(int n, int r){
        if(r > n || r < 0 || n < 0) return 0;
        if(n > MAX_N){
            MAX_N = n;
            initialize();
        }
        int a = fact[n];
        a = (a * invfact[r]) % mod;
        a = (a * invfact[n - r]) % mod;
        return a;
    }
};

signed main(){

    int N, M; cin >> N >> M;

    mat dp(N + 1, vec(N + 1, 0));
    REP(i, N + 1) dp[i][0] = 1;
    FOR(i, 1, N + 1){
        FOR(j, 1, i + 1){
            dp[i][j] = (dp[i - 1][j - 1] + (j + 1) * dp[i - 1][j]) % M;
        }
    }

    //2^i
    vec pow1(N * N + 1);
    pow1[0] = 1;
    FOR(i, 1, N * N + 1) pow1[i] = (pow1[i - 1] * 2) % M;

    //2^(2^i)
    vec pow2(N + 1);
    REP(i, N + 1) pow2[i] = fastpow(2, fastpow(2, i, M - 1), M);

    vec ways(N + 1, 0);
    REP(i, N + 1){
        REP(j, i + 1){
            int tmp = dp[i][j];
            tmp = (tmp * pow1[j * (N - i)]) % M;
            tmp = (tmp * pow2[N - i]) % M;
            ways[i] = (ways[i] + tmp) % M;
        }
    }

    Combination C(N, M);
    int ans = 0;
    REP(i, N + 1){
        if(i % 2 == 0) ans = (ans + C.nCr(N, i) * ways[i]) % M;
        else ans = (ans + C.nCr(N, i) * (M - ways[i])) % M;
    }
    cout << ans;
    
    return 0;
}

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

int main () {
  int N ;
  cin >> N ;
  vector<vector<int>> vec(N+1 , vector<int>(3)) ;
  vec[0][0] = 0 ;
  vec[0][1] = 0 ;
  vec[0][2] = 0 ;
  for (int i = 1 ; i<N+1 ; i++) {
    for (int j = 0 ; j<3 ; j++){
      cin >> vec[i][j] ;
    }
  }
  int count = 0 ;
  for (int i = 0; i<N ; i++) {
    int a = abs(vec[i+1][0]-vec[i][0]);
    int b = abs(vec[i+1][1]-vec[i][1]);
    int c = abs(vec[i+1][2]-vec[i][2]);
    if ((a%2==(b+c)%2) && (a >= b+c)){
      count++;
    }
  }
  if(count==N){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 5760