akhauriyash/Code-Regression huggingface dataset:
a = [[[0 for i in range(10)]for i in range(3)]for i in range(4)]
border = '#'*20
n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    a[b-1][f-1][r-1] += v
    
for i in range(4):
    for k in a[i]:
        for l in k:
                print(' {}'.format(l), end ='')
        print()
    if i != 3:
        print(border)


Measured memory_bytes: 5624
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int A, B;
    cin >>A>>B;
    if(A>=10 || B>=10) cout <<-1 <<endl;
    else cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, a, M = 1e9+7;
    map<int, int> mp;
    cin >> n;
    bool ok = true;
    fore(i,0,n) {
        cin >> a;
        mp[a]++;
        if (n&1) {
            if ((a&1) || a>(n/2)*2 || (a==0 && mp[a]>1)) ok = false;
        } else {
            if (!(a&1) || a>=n || a<1) ok = false;
        }
        if (mp[a]>2) ok = false;
    }
    if (ok) {
        n = n/2;
        int ans = 1;
        fore(_,0,n) {
            ans = (ans*2) % M;
        }
        cout << ans << endl;
    } else {
        cout << "0\n";
    }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s;
    int used[26];
    fill(used, used+26, 0);
    rep(i, 0, s.size()) used[s[i]-'a']++;
    if (s.size() < 26) {
        for (char c = 'a'; c <= 'z'; c++) {
            if (used[c-'a'] == 0) {
                cout << s;
              cout << c << endl;
              break;
            }
        }
    } else {
        eper(i, 24, 0) {
            used[s[i+1]-'a'] = 0;
            rep(j, 0, 26) {
                if ('a' + j > s[i] && used[j] == 0) {
                    cout << s.substr(0, i) << (char)('a' + j) << endl;
                    return 0;
                }
            }
        }
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#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>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e30
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N, M, Q, H, W, L, R, K, X, A, B, C, Z;
ll ans;
string S;
bool D[10];
ll x[100000000];
ll y[100000000];
ll nowcost = 1;
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll DP[1000001];
int main() {
	cin>>N>>K;
	rep(i,0,K){
		ll num;
		cin >>num;
		D[num]=true;
	}
	rep(i,N,1000000){
		ll count=0;
		ll num=i;
		while(num!=0){
			ll tmp=num%10;
			if(D[tmp])count++;
			num/=10;
		}
		if(count==0){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX= 2e3+100;

struct pp{
	ll v,ind;
	bool operator<(const pp &o){
		return v>o.v;
	} 	
};

pp c[MAX];
ll dp[MAX][MAX];
 	
int main(){
	fastio;
	ll n,k;
	cin>>n;
	f(i,1,n+1) cin>>k,c[i]={k,i};
	sort(c+1,c+n+1);
	f(i,1,n+1){
		f(j,1,i+1){
			dp[j][i-j]= max(dp[j][i-j],dp[j-1][i-j]+abs(c[i].ind - j)*c[i].v  );
			dp[i-j][j] =max(dp[i-j][j],dp[i-j][j-1]+abs(n-(j-1) - c[i].ind )*c[i].v  );
		}
	}
	ll ans=0;
	f(i,1,n+1) ans=max(ans,dp[i][n-i]);
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 26620
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

template<typename T> istream 
&operator>>(istream &a, vector<T> &v) { 
for (auto& x : v) a >> x; return a; }

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << min({a%2, b%2, c%2}) * min({a*b, a*c, b*c});
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int L,R,d;
    cin>>L>>R>>d;
    int ans=0;
    for (size_t i = L; i <= R; i++)
    {
        if(i%d==0)
        ans ++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

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

    int ans = 0;
    rep(k,1000) {
        vector<int> d(3);
        int tmp = k;
        rep(i,3) {
            d[i] = tmp % 10;
            tmp /= 10;
        }
        int now = 0;
        bool ok=false;
        for(int i=2; i>=0; --i) {
            ok = false;
            for (int j = now; j<n; ++j) {
                if (d[i] == int(s[j])-48) {
                    now = j+1;
                    ok = true;
                    break;
                }
            }
            if (!ok) break;
        }
        if (ok) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
using namespace __gnu_pbds;

tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderset;

const int N=2e5+5;
int n,a[N];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    int k;
    cin>>k>>s;
    n=s.size();
    if(n<=k) cout<<s;
    else
    {
        for(int i=0;i<k;i++) cout<<s[i];
        cout<<"...";
    }
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		char[][] field = new char[h][];
		for (int i = 0; i < h; i++) {
		    field[i] = sc.next().toCharArray();
		}
		int[][] ans = new int[h][w];
		int count = 0;
		for (int i = 0; i < h; i++) {
		    int cnt = 0;
		    for (int j = 0; j < w; j++) {
		        if (field[i][j] == '#') {
		            cnt++;
		            break;
		        }
		    }
		    if (cnt == 0) {
		        continue;
		    }
		    count++;
		    int idx = 0;
		    while (idx < w) {
		        boolean flag = false;
		        while (idx < w) {
		            ans[i][idx] = count;
		            if (field[i][idx] == '#') {
		                flag = true;
		            }
		            if (idx + 1 >= w) {
		                idx++;
		                break;
		            } 
		            if (flag && field[i][idx + 1] == '#') {
		                count++;
		                idx++;
		                break;
		            }
		            idx++;
		        }
		    }
		}
		for (int i = 0; i < h; i++) {
		    for (int j = 0; j < w; j++) {
		        if (ans[i][j] != 0) {
		            break;
		        }
		        int idx = 1;
		        while (i + idx < h && ans[i + idx][j] == 0) {
		            idx++;
		        }
		        if (i + idx < h) {
		            ans[i][j] = ans[i + idx][j];
		            continue;
		        }
		        idx = -1;
		        while (ans[i + idx][j] == 0) {
		            idx--;
		        }
	            ans[i][j] = ans[i + idx][j];
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < h; i++) {
		    for (int j = 0; j < w; j++) {
		        if (j != 0) {
		            sb.append(" ");
		        }
		        sb.append(ans[i][j]);
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
   }
}



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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#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 all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


ll MAXM = 3010;
vl fact(MAXM);
vl rfact(MAXM);

ll mod_pow(ll x, ll p, ll M) {
	ll a = 1;
	while (p) {
		if (p % 2)
			a = a*x%M;
		x = x*x%M;
		p /= 2;
	}
	return a;
}

ll mod_inverse(ll a, ll m) {
	return mod_pow(a, m - 2, m);
}

ll nCr(ll n, ll r) {
	ll ret = fact[n];
	ret = (ret*mod_inverse(fact[r], MOD)) % MOD;
	ret = (ret*mod_inverse(fact[n - r], MOD)) % MOD;
	return ret;
}


int main() {
	int n, m;
	cin >> n >> m;
	fact[0] = 1; rfact[0] = 1;
	rep1(i, n) {
		fact[i] = fact[i - 1] * i % MOD;
		rfact[i] = mod_inverse(fact[i], MOD);
	}
	string s;
	cin >> s;
	vi sum1(n + 1);
	rep(i, n) {
		if (s[i] == '1') {
			sum1[i + 1] = sum1[i] + 1;
		}
		else {
			sum1[i + 1] = sum1[i];
		}
	}
	vi l, r;
	rep(i, m) {
		int l0, r0;
		cin >> l0 >> r0;
		l0--;
		if (l.empty()) {
			l.push_back(l0);
			r.push_back(r0);
		}
		else {
			if (r.back() < r0) {
				if (l.back() == l0) {
					l.pop_back();
					r.pop_back();
				}
				l.push_back(l0);
				r.push_back(r0);
			}
		}
	}
	m = l.size();
	l.push_back(inf); r.push_back(inf);
	//DEBUG_VEC(sum1);
	//DEBUG_VEC(l); DEBUG_VEC(r);
	vll dp(m + 1, vl(n + 5));
	dp[0][sum1[l[0]]] = 1;
	int mi = sum1[l[0]], ma = sum1[l[0]];
	rep(i, m) {
		//DEBUG(i);
		//DEBUG(mi); DEBUG(ma);
		if (r[i] <= l[i + 1]) {
			for (int j = mi; j <= ma; j++) {
				if (i != m - 1) {
					dp[i + 1][sum1[l[i + 1]]] += dp[i][j] * nCr(r[i] - l[i], sum1[r[i]] - j) % MOD;
					dp[i + 1][sum1[l[i + 1]]] %= MOD;
				}
				else {
					dp[i + 1][n + 4] += dp[i][j] * nCr(r[i] - l[i], sum1[r[i]] - j) % MOD;
					dp[i + 1][n + 4] %= MOD;
				}
			}
			if (i != m - 1) {
				mi = ma = sum1[l[i + 1]];
			}
		}
		else {
			int mi0 = inf, ma0 = -1;
			for (int j = mi; j <= ma; j++) {
				int nokori = sum1[r[i]] - j;
				//DEBUG(nokori);
				for (int k = max(0, nokori - (r[i] - l[i + 1])); k <= min(nokori, l[i + 1] - l[i]); k++) {
					dp[i + 1][j + k] += dp[i][j] * nCr(l[i + 1] - l[i], k) % MOD;
					dp[i + 1][j + k] %= MOD;
					mi0 = min(mi0, j + k); ma0 = max(ma0, j + k);
				}
			}
			mi = mi0; ma = ma0;
		}
		//DEBUG(mi); DEBUG(ma);
	}
	cout << dp[m][n + 4] << endl;
}

Measured memory_bytes: 29952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    vector<ll> h(n);
    rep(i, 0, n) cin >> h[i];

    bool ok = true;
    rep(i, 0, n) {
        if(i == 0) {
            h[i]--;
            continue;
        }
        if (h[i] < h[i-1]) {
            ok = false;
            break;
        }
        if (h[i]-1 >= h[i-1]) h[i]--;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    char s[4];
    cin >> s;
    int ans = 0;
    for(int i=0;i<4;i++){
        if(s[i] == '+'){
            ans ++;
        }
        else{
            ans --;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  long long ans=0;
  for(int i=1;i<=n;i++)
  {
    if(i<=k)continue;
    ans+=(long long)(i-k)*(n/i)+max(((n%i)-k+1-(k==0)),0);
    //cout<<i<<" "<<count<<endl;
    
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>          
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)	make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

int a[100];
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	cout << a[0] * a[1] / 2 << '\n'; 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>

#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = 1ll << 60;

char map[3010][3010];
ll dp[3010][3010];
ll MOD = 1e9 + 7;


int main()
{

    int n;
    cin >> n;
    double p[n];

    REP(i, n)
    {
        cin >> p[i];
    }

    double dp[n + 1][n + 1];
    for (int i = 0; i < n + 1; ++i)
        for (int j = 0; j < n + 1; ++j)
            dp[i][j] = 0.0;

    dp[0][0] = 1.0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            if (j - 1 >= 0)
            {
                dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1.0 - p[i - 1]);
            }
            else
            {
                dp[i][j] = dp[i - 1][j] * (1.0 - p[i - 1]);
            }
        }
    }
    double ans = 0.0;
    for (int i = n / 2 + 1; i <= n; ++i)
    {
        ans += dp[n][i];
    }
    printf("%.10f\n", ans);
}

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

using namespace std;

using ll = long long;
using ld = long double;

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

    string s;
    cin >> s;

    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;

int main()
{
	int d;
	stack<int> q;
	while(~scanf("%d",&d)){
		if(d==0){
			printf("%d\n",q.top());
			q.pop();
		}
		else{
			q.push(d);
		}
	}		
}

Measured memory_bytes: 0
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<"  "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll fact[1001];
ll inv[10001];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll r;
	cin >> r;
	cout << 3*r*r;
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
x,y,z,k = map(int,readline().split())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]
c = [int(i) for i in readline().split()]
from heapq import heappush,heappop,heapify
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

chk = [(-(a[0]+b[0]+c[0]),0,0,0)]
heapify(chk)
C = set((0,0,0))
ans = []
for i in range(k):
  p,q,r,s = heappop(chk)
  ans.append(-p)
  if not (q+1,r,s) in C and q < x-1:
    C.add((q+1,r,s))
    heappush(chk,(-(a[q+1]+b[r]+c[s]),q+1,r,s))
  if not (q,r+1,s) in C and r < y-1:
    C.add((q,r+1,s))
    heappush(chk,(-(a[q]+b[r+1]+c[s]),q,r+1,s))
  if not (q,r,s+1) in C and s < z-1:
    C.add((q,r,s+1))
    heappush(chk,(-(a[q]+b[r]+c[s+1]),q,r,s+1))
    
for i in ans:
  print(i)

Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, h[N], dp[N];
int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++)
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    cout << dp[n - 1];
}

Measured memory_bytes: 4320
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
using namespace std;
int main() {
	int a, b, c, d, R, L;
	string ans;
	cin >> a >> b >> c >> d;
	R = a + b;
	L = c + d;
	if (R == L)
	{
		ans = "Balanced";
	}
	else if (R < L) {

		ans = "Right";
	}
	else
		ans = "Left";

	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }
  vector<vector<int> > g(N);
  vector<bool> checked(N, false);

  for (int i = 0; i < M; ++i) {
    int A, B;
    cin >> A >> B;
    --A; --B;
    g[A].push_back(B);
    g[B].push_back(A);
    if (H[A] == H[B]) {
      checked[A] = true;
      checked[B] = true;
    }
  }

  vector<pair<int, int> > vp;
  for (int i = 0; i < N; ++i) {
    vp.push_back(make_pair(H[i], i));
  }
  sort(vp.begin(), vp.end());
  reverse(vp.begin(), vp.end());
  
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int u = vp[i].second;
    if (not checked[u]) {
      ++ans;
      checked[u] = true;
    }
    for (auto v: g[u]) {
      checked[v] = true;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 9376
//おまじない
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int n;
  cin>>n;
  
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);}
  
  int c=0;
  
  for(int i=0; i<n-2; i++){
    if(((v.at(i)>v.at(i+1)) &&(v.at(i+1)>v.at(i+2)))||
       ((v.at(i)<v.at(i+1))&&(v.at(i+1)<v.at(i+2)))){
      c++;}}
    
    cout<<c<<endl;
  }
      
      
    

Measured memory_bytes: 256
use std::io::stdin;
// code...
fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let (n, m, k): (usize, usize, usize) = {
        let p: Vec<usize> = buf
            .trim()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();
        (p[0], p[1], p[2])
    };

    let mut ans = "No";
    for i in 0..n + 1 {
        for j in 0..m + 1 {
            if i * m + j * n - 2 * i * j == k {
                ans = "Yes";
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];
char field[200][200];

int main(){
  cin >> n;
  vi vec;
  rep(i,0,n){
    cin >> m;
    vec.pb(m);
  }
  sort(all(vec));
  l = vec[n-1];
  ll ans = 0;
  rep(i,0,n-1){
    if(abs(l-2*ans) > abs(l-2*vec[i]))ans = vec[i];
  }
  cout << l <<" " << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include <iostream>

long long x[100005];
int main(){
    long long n,a,b;
    std::cin >> n >> a >> b;
    for(int i = 1; i <= n; i ++){
        std::cin >> x[i];
    }
    long long res = 0;
    for(int i = 2; i <= n; i ++) res += (x[i] - x[i - 1] )* a > b ? b : a * (x[i] - x[i - 1]);
    std::cout << res;
}

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

using namespace std;

typedef long long ll;

int main() {
    int N,M,X;cin >> N >> M >> X;
    vector<int> A(N);
    for(int i=0;i<M;i++){
        cin >> A[i];
    }
    int cost_l=0;
    int cost_r=0;
    for(int i=0;i<M;i++){
        if(A[i]<X)cost_l++;
        if(A[i]>X)cost_r++;
    }
    int cost=min(cost_l,cost_r);
    cout << cost << endl;
    return 0;
}


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

int main(){
  
  int n;
  cin >> n;
  int k;
  cin >> k;
  
  int ans = 0;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    if(a>=k)ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    string s;
    cin>>s;
    // Sunny, Cloudy, or Rainy
    bool flag = true;
    for(long int i=0;i<s.size();i++)
    {
        if((i+1)%2==0)
        {
            if(s[i]=='R')
            {
                flag = false;
                break;
            }
        }
        else
        {
            if(s[i]=='L')
            {
                flag = false;
                break;
            }
        }
    }
    if(flag==true)
        cout<<"Yes\n";
    else
        cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;

lli binpow(lli a,lli b) 
{
    if (b == 0) return 1;
    lli res = binpow(a,b/2);
    res= (res*res);
    
    if(b%2) return (res*a);
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i,j,N=1000,cur;
    
    for(i=0;i<N;i++)
    {
        for(j=0;j<=i;j++)
        {
            cur=binpow(i,5)+binpow(j,5);
            if(cur==n)
            {
                if(j==0) cout<<i<<" "<<j;
                else     cout<<i<<" -"<<j;
                return 0;
            }
            
            cur=binpow(i,5)-binpow(j,5);
            if(cur==n)
            {
                cout<<i<<" "<<j;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3652
// Copyright 2020 yaito3014
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main() {
  int H, W, K;
  std::cin >> H >> W >> K;
  std::vector<std::string> c(H);
  for (auto& row : c) std::cin >> row;
  int sum = 0, ans = 0;
  for (auto& row : c) sum += std::count(cbegin(row), cend(row), '#');
  const int kH = 1 << H;
  const int kW = 1 << W;
  for (int mh = 0; mh < kH; ++mh) {
    for (int mw = 0; mw < kW; ++mw) {
      int s = 0;
      for (int h = 0; h < H; ++h)
        if (mh >> h & 1) s += std::count(cbegin(c[h]), cend(c[h]), '#');
      for (int w = 0; w < W; ++w)
        if (mw >> w & 1)
          for (const auto& row : c) s += row[w] == '#';
      for (int h = 0; h < H; ++h)
        for (int w = 0; w < W; ++w)
          if (mh >> h & 1 && mw >> w & 1 && c[h][w] == '#') --s;
      if (sum - s == K) ++ans;
    }
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int x;
  cin >> x;

  vector<bool> exp(x + 1, false);
  exp[1] = true;
  for (int i = 2; i * i <= x; i++) {
    int res = i * i;
    while (res <= x) {
      exp[res] = true;
      res *= i;
    }
  }

  repr(i, x) {
    if (exp[i]) {
      cout << i << endl;
      return 0;
    }
  }


  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

// cout << fixed << setprecision(12)

int main(){
  
  lint H,W,K; cin >> H >> W >> K;
  vvi grid(6, vi(6,0));
  for(lint i=0; i<H; i++){
    string str; cin >> str;
    for(lint j=0; j<W; j++){
      if(str[j]=='#') grid[i][j] = 1;
    }
  }
  
  lint Hmax = (1 << H);
  lint Wmax = (1 << W);
  
  lint ans = 0;
  
  for(lint i=0; i<Hmax; i++){
    for(lint j=0; j<Wmax; j++){
      
      vvi tmp = grid;
      
      bitset<6> h(i);
      bitset<6> w(j);
      
      for(lint ii=0; ii<6; ii++){
        if(h.test(ii)){
          for(lint jj=0; jj<6; jj++){
            tmp[ii][jj] = 0;
          }
        }
      }
      for(lint jj=0; jj<6; jj++){
        if(w.test(jj)){
          for(lint ii=0; ii<6; ii++){
            tmp[ii][jj] = 0;
          }
        }
      }
      
      lint cnt = 0;
      
      for(lint ii=0; ii<6; ii++){
        for(lint jj=0; jj<6; jj++){
          cnt += (tmp[ii][jj] == 1);
        }
      }
      
      //ans += (cnt == K);
      if(cnt == K){
        ans++;
        /*
        for(lint ii=0; ii<6; ii++){
          cout << endl;
          for(lint jj=0; jj<6; jj++){
            cout << tmp[ii][jj];
          }
        } 
        */
      }
        
    }
  }
  
  cout << ans << endl;
}
          

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int a[6];

int main() 
{
    for(int i = 1 ; i <= 5 ; i++)
        cin >> a[i];
    for(int i = 1 ; i <= 5 ; i++)
    {
        if(!a[i])
        {
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		
		if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
			System.out.println("Yes");
		else
			 System.out.println("No");
		
	}
}




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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  cout << 1 - N << "\n";
}

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

int main(){
  string s;
  int k;
  cin >> s >> k;
  int t;

  for(int i = 0; i < s.length() - 1; i++){
    if(s[i] == 'a')
      continue;

    t = 'z' + 1 - s[i];
    if(t <= k){
      s[i] = 'a';
      k -= t;
    }
  }

  k %= 26;
  while(k > 0){
    s[s.length()-1]++;
    if(s[s.length()-1] == 'z' + 1)
      s[s.length()-1] = 'a';
    k--;
  }
  cout << s << endl;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second

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

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

int n,m;

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

	cin>>n>>m;
	int ti=1;
	REP(i,m) ti*=2;
	cout<<(100*(n-m)+1900*m)*ti<<endl;

	return 0;
}


Measured memory_bytes: 256
import scala.util.control.Breaks

object Main extends App {
  val k =  scala.io.StdIn.readInt()
  val ab =  scala.io.StdIn.readLine()
  val abArray = ab.split(" ").map(_.toInt).toSeq
  val a = abArray(0)
  val b = abArray(1)
  var okFlg = false

  val break = new Breaks
  break.breakable {
    (a to b).foreach { i =>
      if (i % k == 0) {
        okFlg = true
        break.break()
      }
    }
  }
  if (okFlg) println("OK") else println("NG")
}

Measured memory_bytes: 54736
import sys
input = sys.stdin.readline
#####segfunc######
def segfunc(x,y):
    return x | y

def init(init_val):
    #set_val
    for i in range(len(init_val)):
        seg[i+num-1]=init_val[i]   
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
n = int(input())
s = list(input())[:-1]
ide_ele = 0
num =2**(n-1).bit_length()
seg=[ide_ele]*(2*num - 1)
s = [2 ** (ord(i) - ord('a')) for i in s]
init(s)
q = int(input())
for i in range(q):
    tmp = input()
    a,b,c = tmp[:-1].split()
    if a == "1":
        update(int(b)-1, 2 ** (ord(c) - ord('a')))
    else:
        if b == c:
            print(1)
        else:
            tmp = query(int(b)-1, int(c))
            tmp = format(tmp, 'b')
            print(tmp.count('1'))

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

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    cout << (b - 1 + a - 2) / (a - 1);

    return 0;
}

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

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define sz size()
#define pb push_back
#define mp make_pair
#define ALL(X) (X).begin(),(X).end()

using namespace std;

const double INF = 1000000000.0;
const double eps = 1e-8;

int root(vector<int> & ufa,int i)
{
	if(ufa[i] != i)
		ufa[i] = root(ufa,ufa[i]);
	return ufa[i];
}

void join(vector<int> & ufa,int i,int j)
{
	int ri = root(ufa,i);
	int rj = root(ufa,j);
	ufa[ri] = rj;
}

struct e
{
	int s;
	int t;
	double cst;
};

bool operator<(const e & lhs,const e & rhs)
{
	return lhs.cst < rhs.cst;
}

int main(void) {
	cout.precision(3);
	while(1)
	{
		int n;
		cin>>n;
		if(!n)break;
		vector<double> x(n);
		vector<double> y(n);
		vector<double> z(n);
		vector<double> r(n);
		vector<int> ufa(n);
		REP(i,n)ufa[i]=i;
		REP(i,n)cin>>x[i]>>y[i]>>z[i]>>r[i];
		vector<vector<double> > dist_big(n,vector<double>(n,INF));
		REP(i,n)REP(j,n)
		{
			if(i==j)continue;
			double d = (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]);
			dist_big[i][j]=dist_big[j][i]=sqrt(d)-(r[i]+r[j]);
			if(d <= (r[i]+r[j]+eps)*(r[i]+r[j]+eps))
			{
				join(ufa,i,j);
			}
		}
		set<int> sec;
		REP(i,n)
			sec.insert(root(ufa,i));
		int secn = sec.size();
		if(secn > 1)
		{
			vector<int> roots;
			FORIT(i,sec)
				roots.push_back(*i);
			vector<vector<double> > dist(secn,vector<double>(secn,INF));
			REP(i,n)REP(j,n)
			{
				if(ufa[i]==ufa[j])continue;
				int di,dj;
				REP(k,secn)
				{
					if(roots[k]==ufa[i])di=k;
					if(roots[k]==ufa[j])dj=k;
				}
				dist[di][dj]=min(dist[di][dj],dist_big[i][j]);
			}
			vector<e> edge;
			REP(i,secn)REP(j,i)
			{
				e p = {i,j,dist[i][j]};
				edge.push_back(p);
			}
			sort(ALL(edge));
			vector<int> ufa2(secn);
			REP(i,secn)ufa2[i]=i;
			double cost = 0.0;
			REP(i,edge.size())
			{
				e p = edge[i];
				if(root(ufa2,p.s) != root(ufa2,p.t))
				{
					join(ufa2,p.s,p.t);
					cost += p.cst;
					secn--;
					if(secn == 1)
						break;
				}
			}
			cout  << setiosflags(ios::fixed)<< cost << endl;
		}
		else
			cout << setiosflags(ios::fixed)<< 0.0 << endl;
	}
  return 0;
}

Measured memory_bytes: 1608
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

vector<pii> solve(int x, int y, int k){
    vector<pii> v;
    int n = max(2, (x+y-1)/k+1);
    if((n*k-x-y)%2){
        if(k%2 == 0) return v;
        ++n;
    }
    int d = (n*k-x-y) / 2;
    if(n == 3){
        int a = d / 2;
        int b = d - a;
        For(i, 1, n+1){
            if(i*k <= a) v.emplace_back(-i*k, 0);
            else if(i*k <= a+y+b) v.emplace_back(-a, i*k-a);
            else if(i*k <= a+y+b+a+x) v.emplace_back(i*k-a-y-b-a, y+b);
            else v.emplace_back(x, y+b-(i*k-a-y-b-a-x));
        }
        return v;
    }
    For(i, 1, n+1){
        if(i*k <= y+d) v.emplace_back(0, i*k);
        else if(i*k <= y+d+x) v.emplace_back(i*k-y-d, y+d);
        else v.emplace_back(x, y+d-(i*k-y-d-x));
    }
    return v;
}

int main(){
    int k, x, y;
    scanf("%d%d%d", &k, &x, &y);
    if(abs(x) + abs(y) == k){
        printf("%d\n%d %d\n", 1, x, y);
        return 0;
    }
    bool flag = false;
    if(abs(y) > abs(x)) swap(x, y), flag = true;
    pii sig = pii(1, 1);
    if(x < 0) x *= -1, sig.fi *= -1;
    if(y < 0) y *= -1, sig.se *= -1;
    auto ans = solve(x, y, k);
    if(ans.size() == 0){
        printf("-1\n");
        return 0;
    }
    printf("%d\n", (int)ans.size());
    for(pll p: ans){
        p.fi *= sig.fi;
        p.se *= sig.se;
        if(flag) swap(p.fi, p.se);
        printf("%lld %lld\n", p.fi, p.se);
    }
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fastin ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod=1e9+7;
ll a[200010],ans,n,sum[200010];
int main(){
	cin>>n;
	rep(i,1,n)	scanf("%lld",&a[i]);
	rep(i,1,n)	sum[i]=sum[i-1]+a[i],sum[i]%=mod;
	rep(i,1,n){
		ll sumj=sum[n]-sum[i];
		sumj=(sumj%mod+mod)%mod;
		ans=(ans+sumj*a[i]%mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
  int a,b ;//与えられる2つの整数
  double temp;//aとbの平均に1足した値
  int x;//aとbの平均(切り上げ)
  
  cin >> a >> b;
  temp = (a + b + 1) / 2;
  x = temp;
  cout << x << endl;
  
  return 0;
}

Measured memory_bytes: 256
import math
def gcd(a,b):
    if a==0: return b
    return gcd(b%a,a)
def div(n):
    cnt = 0
    temp = n
    for i in range(2,int(math.sqrt(n))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
            cnt += 1
    if temp!=1:
        cnt+=1
    return cnt+1

a,b = map(int,input().split())
print(div(gcd(a,b)))

Measured memory_bytes: 9132
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


Measured memory_bytes: 4064
n, d, a = map(int, input().split())
XH = []
for i in range(n):
    x, h = map(int, input().split())
    XH.append((x, h))
XH.sort()
X = [x for x, h in XH]
H = [h for x, h in XH]
# n, d, a = 9, 2, 2
# X = [1, 3, 4, 6, 9, 10, 12, 13, 16]
# H = [7, 6, 7, 5, 10, 3, 8, 9, 6]
X.append(10**10)
H.append(0)
j = 0
c = 0
S = [0]*(n+1)
for i in range(n):
    H[i] = max(0, H[i]-S[i])
    c += -(-H[i]//a)
    while X[j] <= X[i] + 2*d:
        j += 1
    S[i+1] += S[i] + -(-H[i]//a)*a
    S[j] -= -(-H[i]//a)*a
    # print(i)
    # print(H)
    # print(S)
# print(H)
# print(S)
print(c)


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

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while(a >= b && k)
	{
		b <<= 1;
		--k;
	}
	while(b >= c && k)
	{
		c <<= 1;
		--k;
	}
	if(a < b && b < c) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

signed main(){
  int r, g, b, n;cin>>r>>g>>b>>n;
  int ans = 0;
  rep(i,3001){
    rep(j,3001){
      if((n-(r*i+g*j)) % b == 0 && r*i+g*j <= n){
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rrep(i, 1, n + 1) {
    if (i % 3 == 0 && i % 5 == 0) continue;
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    ans += i;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;
string tab[MAXN];
int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
int d[MAXN];
vector <int> v[MAXN];

void addEdge(int i,int j,int x,int y,int n,int m){
	if(x<0 || x>=n || y<0 || y>=m) return;
	if(tab[i][j]!='.' || tab[x][y]!='.') return;
	v[i*m+j].push_back(x*m+y);
	v[x*m+y].push_back(i*m+j);
}

int bfs(int s,int n){
	fill(d,d+n,-1);
	queue <int> q;
	q.push(s);
	d[s]=0;
	while(!q.empty()){
		s=q.front();
		q.pop();
		for(auto to:v[s]){
			if(d[to]!=-1) continue;
			q.push(to);
			d[to]=d[s]+1;
		}
	}
	return d[n-1];
}

int main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int n,m,sum=0;
    cin >> n >> m;
    for(int i=0;i<n;i++){
		cin >> tab[i];
		sum+=count(tab[i].begin(),tab[i].end(),'.');
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			for(int k=0;k<4;k++)
				addEdge(i,j,i+dir[k][0],j+dir[k][1],n,m);
	int x=bfs(0,n*m);
	cout << (x==-1 ? x : (sum-1-x));
}


Measured memory_bytes: 33536