akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  int a;cin>>a;
  mint ans=1;
  rep(i,a){
    ans*=(i+1);
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
 
void testCase() {
    db r;
    cin >> r;
    db val = (M_PI)*2*r;
    cout << fixed << setprecision(10) << val << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> P(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> P[i];
	}

	auto ans = 1;
	auto m = P[0];
	for (auto i = 1; i < N; ++i)
	{
		if (m < P[i])
		{
			continue;
		}

		m = min(m, P[i]);
		++ans;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=805;
//i_am_noob
int n,a[20],maxx=-1,ans=0;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep(n) cin >> a[i];
	rep(n){
		if(a[i]>=maxx){
			maxx=a[i];
			ans++;
		}
	}
	print1(ans);
	return 0;
}


Measured memory_bytes: 256
A=1
B=1
C=0 #２つ前の項
D=0 #1
N=int(input())
if N==0 or N==1:
    print(1)
elif N==2:
    print(2)

else:   
    C=B  #１
    D=A+B #2
    for i in range (N-3):
        B=C
        C=D
        D=B+C
    print(C+D)


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

int main(){
  long long md = 1e9+7;
  int N; cin >> N;
  int bef = -1;
  vector<int> C;
  for (int i=0; i<N; i++){
    int c; cin >> c;
    if (c!=bef) C.push_back(c);
    bef = c;
  }
  int Clen = C.size();
  vector<long long> dp(Clen,0);
  dp[0]++;
  vector<int> check(2*100000+1,-1);
  for (int i=0; i<Clen; i++){
    if(i>0) dp[i] += dp[i-1];
    if (check[C[i]] >= 0){
      dp[i] += dp[check[C[i]]];
    }
    dp[i] %= md;
    check[C[i]] = i;
  }
  cout << dp[Clen-1] << endl;
}


Measured memory_bytes: 3444
/********************************************************************************
	
	Code by a weak man named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int MAXN = 1000010;

int n;
char S[MAXN];
char T[MAXN];

struct Node {
	int p, h;

	Node() {}
	Node(int p, int h):p(p), h(h) {}
};

queue<Node>q;

int main() {
#ifdef LOCAL
	FILE("");
#endif

	scanf("%d%s%s", &n, S + 1, T + 1);
	int pT = n, pS = n, res = 0, Add = 0, las = -1;
	while(pT) {
		while(pS && S[pS] != T[pT]) --pS;
		if(!pS) return puts("-1"), 0;
		while(!q.empty() && q.front().p - Add > pT) chkmax(res, q.front().h + Add), q.pop();
		if(las != pS && pS < pT) ++Add, q.push(Node(pS + Add, 1 - Add)), las = pS;
		--pT, pS -= pT < pS;
	} while(!q.empty()) chkmax(res, q.front().h + Add), q.pop();
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 10384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define ll long long

const int N = 1e6 + 9;
const int INF = 1e9 + 9;

void solve() {
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; ++ i) {
		cin >> a[i];
	}
	sort(all(a));
	if (a[n - 1] - a[0] >= 2) {
		cout << "No\n";
		return;
	}
	int cnt = 0, cnt1 = 0;
	for (int i = 0; i < n; ++ i) {
		if (a[i] == a[0])
			++cnt;
		else
			++cnt1;
	}
	if (cnt == n) {
		if (a[0] == n - 1 or a[0] <= n / 2)
			cout << "Yes\n";
		else
			cout << "No\n";
		return;
	}
	if (cnt1 <= 1) {
		cout << "No\n";
		return;
	}

	if (a[n - 1] >= cnt + 1 and a[n - 1] <= cnt + cnt1 / 2)
		cout << "Yes\n";
	else
		cout << "No\n";
}

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


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if (a < b){
    rep(i, b) cout << a;
    cout << endl;
  }
  else {
    rep(i, a) cout << b;
    cout << endl;
  }
  
  return 0;
}

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

int main()
{
    int n; cin>>n;
    vector<int> a(n); for(auto& e: a) cin>>e;
    vector<int> b(n); for(auto& e: b) cin>>e;
    vector<int> d(n);
    for(int i=0; i<n; ++i) d[i]=a[i]-b[i];
    sort(begin(d), end(d));
    auto c=d;

    int i=0, j=n-1;
    while (i<j && d[i]<0) {
        int x=min(d[j], -d[i]);
        d[j]-=x;
        d[i]+=x;
        if (d[j]==0) --j;
        if (d[i]==0) ++i;
    }
    int res=0;
    for(int i=0; i<n; ++i) {
        res+=c[i]!=d[i];
        if (d[i]<0) { cout<<-1<<endl; return 0; }
    }
    cout<<res<<endl;
}


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

using namespace std;
using ll = long long;

const ll MOD = 998244353;
ll x[301];
int N;

ll dp1[301][100001];
ll dp2[301][100001]; 


int main() {
    cin >> N;
    ll S = 0;
    ll ans = 1;
    for(int i = 0; i < N; i++) {
        cin >> x[i];
        S += x[i];
        ans *= 3;
        ans %= MOD;
    }

    dp1[0][0] = dp2[0][0] = 1;

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 100001; j++) {
            dp1[i+1][j+x[i]] += (dp1[i][j] * 2) % MOD; 
            dp1[i+1][j+x[i]] %= MOD;
            dp1[i+1][j] += dp1[i][j];
            dp1[i+1][j] %= MOD;

            dp2[i+1][j+x[i]] += dp2[i][j];
            dp2[i+1][j+x[i]] %= MOD;

            dp2[i+1][j] += dp2[i][j];
            dp2[i+1][j] %= MOD;
        }
    }

    for(int i = 0; i <= S/2; i++) {
        ans -= (dp1[N][i] * 3) % MOD; 
        ans %= MOD;
    }

    if(S%2 == 0) {
        ans += (dp2[N][S/2]*3 % MOD);
    }

    ans += MOD;
    ans %= MOD;
    cout << ans << endl;

}


Measured memory_bytes: 469760
#include <iostream>
#include<stdio.h>

using namespace std;
int n,h[100003],f[100003];

void DP()
{
    f[1]=0;
    f[2]=abs(h[1]-h[2]);
    for(int i=3;i<=n;++i)
    {
        f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%d",f[n]);
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&h[i]);
    }
    DP();
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  std::string s;
  int64_t count = 0;
  cin >> s;
  for (int i = 1; i < s.size(); i++) {
    if (s[i - 1] == s[i]) {
      if (s[i - 1] == '1') {
        s[i] = '0';
        count++;
      } else {
        s[i] = '1';
        count++;
      }
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define REPR(i, a, n) for (int i = (a); i >= (n); i--)
#define REPIT(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()
#define CO(x) cout << (x);
#define CON(x) cout << (x) << "\n"
#define COSP(x) cout << (x) << " "
#define mkp make_pair
#define mkt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/******* Variable ***********************************/
const int maxn = 1e6 * 50;
const double inf = 0x3f3f3f3f3f;
/******* Function ***********************************/
void out(auto &X) {
  REP(i, 0, X.size() - 1) CO(X[i]);
}
void outsp(const vector<int> X) {
  REP(i, 0, X.size() - 1) {
    cout << X[i] << (i != X.size() - 1 ? " " : "\n");
  }
}
/*****************************************************/
/******* Main ****************************************/
int main() {
  int ns, nt, ans = 0;
  cin >> ns;
  vector<int> S;
  REP(i, 0, ns - 1) {
    int s;
    cin >> s;
    S.pub(s);
  }
  cin >> nt;
  REP(i, 0, nt - 1) {
    int t;
    cin >> t;
    REP(i, 0, ns - 1) {
      if (S[i] == t) {
        ans++;
        break;
      }
    }
  }
  CON(ans);
  return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    string s;
    cin >> s;
    ll n = s.size();

    vector<vector<ll>> dp(n+1,vector<ll>(13,0));
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 13; j++){
            if(s[i-1]=='?'){
                for(int k = 0; k < 10; k++){
                    int x = k;
                    dp[i][(10*j+x)%13] += dp[i-1][j];
                    dp[i][(10*j+x)%13] %= MOD;
                }
            }else{
                int x = s[i-1] - '0';
                dp[i][(10*j+x)%13] += dp[i-1][j];
                dp[i][(10*j+x)%13] %= MOD;
            }
        }
    }

    cout << dp[n][5] << endl;
    return 0;

}


Measured memory_bytes: 13696
#include<stdio.h>
int main()
{
	int n,i,c=0;

	scanf("%d",&n);

	int p[n];

	for(i=0;i<n;i++)
		scanf("%d",&p[i]);
	for(i=1;i<n-1;i++){
		if((((p[i-1]<p[i])&&(p[i]<=p[i+1])))||(((p[i-1]>=p[i])&&(p[i]>p[i+1]))))
		c++;
	}
	printf("%d",c);
	return 0;
}

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

  
}

Measured memory_bytes: 4292
sa = raw_input()
sb = raw_input()
sc = raw_input()
st = [sa,sb,sc]
lns = [len(sa),len(sb),len(sc)]
ind = [0,0,0]
cur = 0
done = False
winner = "a"
dumb = ["A","B","C"]
while (not done):
    if (ind[cur] >= lns[cur]):
        winner = dumb[cur]
        done = True
        break
    else:
        x = st[cur][ind[cur]]
        ind[cur] += 1
        if (x=="a"):
            cur = 0
        elif (x=="b"):
            cur = 1
        elif (x=="c"):
            cur = 2

print str.upper(winner)

Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
bool a,b;
string s;
int main(){
	cin>>s;
	for(int i=0;i<3;i++){
		if(s[i]=='A')
			a=1;
		if(s[i]=='B')
			b=1;
	}
	if(a&&b)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
// AtCoder Regular Contest 088
// D - Wide Flip

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

string S;
int N;

int main() {
    int ans;

    cin >> S;
    N = S.length();

    ans = N;
    for (int i = 0; i < N - 1; i++) {
        if (S[i] != S[i + 1]) {
            ans = min(ans, max(i + 1, N - i - 1));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int main(void) {
  int input;
  fscanf(stdin, "%d", &input);

  int tmp;
  // 2の累乗に最も近い値を選択
  for (int i = input; i > 0; i--) {
    if (log2(i) == 0.0 // 1
        || log2(i) == 1.0 // 2
        || log2(i) == 2.0 // 4
        || log2(i) == 3.0 // 8
        || log2(i) == 4.0 // 16
        || log2(i) == 5.0 // 32
        || log2(i) == 6.0 // 64
        ) {
      tmp = i;
      break;
    }
  }

  // tmp以上input以下を走査
  int val = 0; // 割った回数
  int output = tmp; // 最終的な出力値
  for (int i = tmp; i <= input; i++) {
    int iternum = 0;
    int n = i;
    for(;;) {
      if (n % 2 == 0) {
        iternum++;
        n = n / 2;
      } else {
        break;
      }
    }

    if (val <= iternum) {
      val = iternum;
      output = i;
    }
  }

  printf("%d\n", output);
  return 0;
}

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

dif = [abs(a[i]-b[i]) for i in range(n)]
dif2 = [x**2 for x in dif]
dif3 = [x**3 for x in dif]

print(sum(dif))
print((sum(dif2))**(1/2))
print((sum(dif3))**(1/3))
print(max(dif))


Measured memory_bytes: 5644
/**********************************************************
* @Author: 			   Kirito
* @Date:   			   2020-04-12 20:24:35
* @Last Modified by:   Kirito
* @Last Modified time: 2020-04-12 20:35:12
* @Remark: 
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn=111111;
char str[maxn];

int main()
{
	FAST;
	int n;
	cin >> n >> str;
	ll r = 0, g = 0, b = 0;
	for(int i = 0; i < n; i++)
	{
		if(str[i] == 'R') r++;
		else if(str[i] == 'G') g++;
		else b++;
	}
	ll ans  = r * g * b;
	for(int d = 1; 2 * d < n; d++)
	{
		for(int i = 0; i + 2 * d < n; i++)
		{
			if(str[i] != str[i + d] && str[i + d] != str[i + 2 * d] && str[i] != str[i + 2 * d])
			{
				ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


////System.out.println();
public class Main implements Runnable { //クラス名はMain

    public static void main(String[] args) {
    	Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }

    //1≤N≤100
    //1≤W≤10^5
    //1≤wi≤W
    //1≤vi≤10^9
    //N W
    //w1 v1
    //w2 v2
    //wN  vN
    public void run() {
    	FastScanner3 sc = new FastScanner3(System.in);

        int N = sc.nextInt();
        int W = sc.nextInt();
        int w[] = new int[N];
        int v[] = new int[N];
        long dp[][] = new long[N+1][W+1];

        for(int i=0; i<N; i++) {
        	w[i] = sc.nextInt();
        	v[i] = sc.nextInt();
        }

        long ans = rec(0,W,dp,N,W,w,v);
        System.out.println(ans);

    }

    private static long rec(int i, int j,long dp[][],int N, int W,int w[],int v[]) {

    	try {
	    	//System.out.println("N : "+N + " " + i + " , " + j + " : " + Arrays.deepToString(dp));
    		if(dp[i][j] > 0) {
    			return dp[i][j];
    		}

	    	if(i == N) {
	    		return dp[i][j];
	    	}else if(j < w[i] ) {
	    		return dp[i][j] = rec(i+1,j,dp,N,W,w,v);
	    	}else {
	    		long left = rec(i+1,j,dp,N,W,w,v); // 入れない
	    		long right = rec(i+1, j - w[i],dp,N,W,w,v) + v[i]; //入れる
	    		if(left > right) {
	    			return dp[i][j] = left;
	    		}else {
	    			return dp[i][j] = right;
	    		}
	    	}
    	}catch(Exception e) {
    		e.printStackTrace();
    		return 0;
    	}
    }
}

//高速なScanner
class FastScanner3 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner3(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

#include <random>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")


int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);



    string s;
    cin >> s;
    if (s.size() % 2) {
        cout << "No";
        return 0;
    }


    for (int i = 0; i < s.size(); i++) {
        if (i % 2 && s[i] != 'i') {
            cout << "No";
            return 0;
        }

        if (i % 2 == 0 && s[i] != 'h') {
            cout << "No";
            return 0;
        }
    }
    
    cout << "Yes";

}

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

const int maxe = 2e5+5;

ll t=1, n, x, k;

void solve(){
	cin >> n >> x >> k;
	
	ll ans = k*(n/x);
	if(n%x != 0) ans += k;
	cout << ans;
	return;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	while(t--){
		solve();
	}
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
 ll a,b;cin>>a>>b;
 if(abs(a-b)%2==0) cout<<(a+b)/2<<endl;
 else cout<<"IMPOSSIBLE"<<endl;

}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


void _main() {
        int n; cin >> n;
        map<pair<int,int>, int> asa;
        for (int i = 1; i <= n; i++) {
                int front = i, back = i % 10;
                while (front / 10) front /= 10;
                asa[{front, back}]++;
        }


        ll ans = 0;
        for (int a = 0; a < 10; a++) {
                for (int b = 0; b < 10; b++) {
                        //a..b
                        //b..a
                        ans += asa[{a, b}] * asa[{b, a}];
                }
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

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

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vl v(n);
	for (ll i = 0; i < n; i++)
		cin >> v[i];
	ll prof = 0;
	ll buy = v[0];
	ll cash = 1000;
	ll sell = 0;
	int f = 0;
	for (ll i = 1; i < n; i++) {
		if (v[i] < v[i - 1]) {
			if (f == 1) {
				cash += (sell - buy) * (cash / buy);
				buy = v[i];
				f=0;
				continue;
			}
			buy = v[i];
		}
		else if (v[i] == v[i - 1]) {
			if (f == 1)
				sell = v[i];
			else
				buy = v[i];
		}
		else {
			if (buy == 0) {
				buy = v[i];
				continue;
			}
			sell = v[i];
			f = 1;
		}
	}
	if (f == 1)
		cash += (sell - buy) * (cash / buy);
	cout << cash << "\n";
}

Measured memory_bytes: 3568
import sys

def main():
    input = sys.stdin.readline
    N, x = map(int, input().split())
    A = list(map(int, input().split()))

    ans = 0
    a = 0
    for i in range(N):
        diff = (A[i] + a) - x
        diff = max(0, diff)
        ans += diff
        a = A[i] - diff

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 14080
n = int(input())
a = list(int(i) for i in input().split())
if n%2==0 and sum(a)==n*n//2 or n%2==1 and sum(a) == (n+1)*(n//2):
    print(2**(n//2)%(10**9+7))
else:
    print(0)

Measured memory_bytes: 14004
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();
        sc.close();

        /** だめだったその１**/
        //        long result = LongStream.rangeClosed(A, B)
        //                .filter(i-> i%C!=0)
        //                .filter(i-> i%D!=0)
        //                .count();
        //        
        //        System.out.println(result);

        /** だめだったその２**/
        //        long resultNoHantai = LongStream.rangeClosed(A, B)
        //                .filter(i -> i % C == 0 || i % D == 0)
        //                .count();
        //
        //        long result = B - A + 1L - resultNoHantai;
        //        System.out.println(result);

        long wareruC = B / C - A / C;
        if (A % C == 0L)
            wareruC++;

        long wareruD = B / D - A / D;
        if (A % D == 0L)
            wareruD++;

        long saisyoukoubaisuu = lcm(C, D);

        long wareruCD = B / saisyoukoubaisuu - A / saisyoukoubaisuu;
        if (A % saisyoukoubaisuu == 0L)
            wareruCD++;

        long result = (B - A + 1L) - wareruC - wareruD + wareruCD;

        System.out.println(result);

    }

    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (long)(c/b);
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#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 rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const { 
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


pair<ll, ll> rev(pair<ll, ll> a) {
	if (a.fi > 0) return make_pair(-a.se, a.fi);
	return make_pair(a.se, -a.fi);
}


int main() {
	int n;
	cin >> n;
	ll a[n], b[n];
	rep (i, n) cin >> a[i] >> b[i];

	int zero_zero = 0, zero_no = 0, no_zero = 0;
	map<pair<ll, ll>, int> cnt;
	rep (i, n) {
		if (a[i] == 0 && b[i] == 0) zero_zero++;
		else if (a[i] == 0) zero_no++;
		else if (b[i] == 0) no_zero++;
		else {
			ll g = gcd(a[i], b[i]);
			a[i] /= g;
			b[i] /= g;
			if (b[i] < 0) a[i] *= -1, b[i] *= -1;
			cnt[{a[i], b[i]}]++;
		}
	}


	mint ans = mint(2).pow(no_zero) + mint(2).pow(zero_no) - 1;
	set<pair<ll, ll>> used;
	for (auto x: cnt) {
		if (used.count(x.fi)) continue;
		int p = x.se;
		int pp = cnt[rev(x.fi)];
		if (pp) ans *= mint(2).pow(p) + mint(2).pow(pp) - 1;
		else ans *= mint(2).pow(p);
		used.insert(rev(x.fi));
	}

	ans += zero_zero;
	ans -= 1;

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

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

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

using namespace std;

typedef long long int lli;

int main () {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N, vector<int>(N, 0));
    REP (i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a][b] = 1;
        G[b][a] = 1;
    }
    vector<int> nlist(N);
    REP (i, 0, N) nlist[i] = i;
    int ans = 0;
    do {
        bool run = true;
        REP (i, 0, N - 1) {
            int first = nlist[i];
            int second = nlist[i + 1];
            if (G[first][second] == 0) run = false;
        }
        ans += run;
    } while(next_permutation(nlist.begin() + 1, nlist.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,dep[100009],ans,dp[100009];
vector<int>g[100009];
queue<int>q;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++) {
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		dep[y]++;
	}
	for(int i=1;i<=n;i++)
		if(dep[i]==0) q.push(i);
	while(!q.empty()) {
		int x=q.front();
		q.pop();
		ans=max(ans,dp[x]);
		for(int i=0;i<g[x].size();i++) {
			dep[g[x][i]]--;
			dp[g[x][i]]=max(dp[g[x][i]],dp[x]+1);
			if(dep[g[x][i]]==0) q.push(g[x][i]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    string s; cin >> s;
    bool yymm = false, mmyy = false;
    string fi = "";
    fi += s[2];
    fi += s[3];
    for (int i = 1; i <= 12; i++) {
        string ss = "";
        if (i < 10) {
            ss += "0";
        }
        ss += to_string(i);
        if (fi == ss) {
            yymm = true;
        }
    }
    fi = "";
    fi += s[0];
    fi += s[1];
    for (int i = 1; i <= 12; i++) {
        string ss = "";
        if (i < 10) {
            ss += "0";
        }
        ss += to_string(i);
        if (fi == ss) {
            mmyy = true;
        }
    }
    if (yymm && mmyy) {
        cout << "AMBIGUOUS\n";
        exit(0);
    }
    if (yymm) {
        cout << "YYMM\n";
        exit(0);
    }
    if (mmyy) {
        cout << "MMYY\n";
        exit(0);
    }
    cout << "NA\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int N, K;
    cin >> N >> K;
    vi A(N, 0);
    for(int i = 0; i < K; i++) {
        int d = 0;
        cin >> d;
        for(int j = 0; j < d; j++) {
            int b = 0;
            cin >> b;
            A[b - 1] = 1;
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(A[i] == 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>

int down(const void *a,const void *b){
  if(*(long long *)a > *(long long *)b) return -1;
  if(*(long long *)a < *(long long *)b) return 1;
  return 0;
}

int main(void){
  int n , a , b;
  scanf("%d %d %d",&n ,&a ,&b);

  long long v[n];
  for(int i = 0;i < n;i ++){
    scanf("%lld",&v[i]);
  }

  qsort(v,n,sizeof(long long),down);
  /*for(int i = 0;i < n;i ++){
	printf("%lld\n",v[i]);
  }*/

  
  long double ave = 0;
  for(int i = 0;i < a;i ++){
    ave += v[i];
    //printf("%llf\n",ave);
  } 
  ave /= a;
  printf("%llf\n",ave);

  int count = 0;
  for(int i = 0;i < n;i ++){
    if(v[i] == v[a-1]){
      count ++;
    }
  }

  long long binom[51][51];
  for(int i = 0;i <= 50;i ++){
    for(int j = 0;j <= 50;j ++){
      if(j == 0 || j == i){
        binom[i][j] = 1;
      }
      else{
        binom[i][j] = 0;
      }
    }
  }

  for(int i = 1;i <= 50;i ++){
    for(int j = 1;j <= i;j ++){
      binom[i][j] = binom[i-1][j-1] + binom[i-1][j];
    }
  }

  if(v[0] == v[a-1]){
    long long c = 0;
    for(int i = a;i <= b;i ++){
      c += binom[count][i];
    }
    printf("%lld\n",c);
  }

  else{
    int cut = 0;
    long long c;
    for(int i = 0;i < a;i ++){
      if(v[i] == v[a-1]){
        cut ++;
      }

      c = binom[count][cut];
    }
    printf("%lld\n",c);
  }

    
  
  return 0;
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	ll x;
	cin>>x;
	ll ans=0;
	ans+=(x/500)*1000;
	x=x%500;
	ans+=(x/5)*5;
	cout<<ans;
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define ALL(v) (v).begin(), (v).end()
ll MOD=1000000007;

int main(){
    ll N;    cin >> N;
    VL a(N); 
    ll sum = 0;
    rep(i,0,N){
        cin >> a[i];
        sum += a[i];
    }

    ll ans = 0;
    rep(i,0,N-1){
        sum = sum - a[i];
      	//cout << sum << endl;
        ans += (a[i]%MOD) * (sum%MOD);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4728
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

int digit_sum(int n){
  int sum = 0;
  while(n != 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

  int n;
  cin >> n;

  int ans = INF_INT;
  for(int a = 1; a < n; a++){
    int b = n - a;
    ans = min(ans, digit_sum(a) + digit_sum(b));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

int main() {
  int h, w, d, a;
  std::cin >> h >> w >> d;
  std::vector<std::pair<int, int>> xys(h * w + 1);
  for (int y = 0; y < h; ++y) {
    for (int x = 0; x < w; ++x) {
      std::cin >> a;
      xys[a] = {x, y};
    }
  }
  std::vector<int> total(h * w + 1);
  for (int di = 0; di < d; ++di) {
    total[di] = 0;
    for (int k = 1; di + k * d <= h * w; ++k) {
      int cur = di + k * d;
      int prev = cur - d;
      int power = std::abs(xys[cur].first - xys[prev].first) + std::abs(xys[cur].second - xys[prev].second);
      total[cur] = total[prev] + power;
    }
  }
  int q, l, r;
  std::cin >> q;
  for (int qi = 0; qi < q; ++qi) {
    std::cin >> l >> r;
    std::cout << total[r] - total[l] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nmax_def 110000
using namespace std;
typedef long long ll;

int main() {
	int i, j;
	int N, K;
	cin >> N >> K;
	bool ans;
	if (K > (N - 1) * (N - 2) / 2)
		ans = false;
	else
		ans = true;
	if (!ans)
		cout << "-1" << endl;
	else
	{
		int E = (N - 1)*(N - 2) / 2 - K;
		cout << (E + N - 1) << endl;
		for (i = 2; i <= N; i++)
			cout << "1 " << i << endl;
		int p = 2, q = 3;
		for (i = 1; i <= E; i++)
		{
			cout << p << " " << q << endl;
			q++;
			if (q > N)
			{
				p++;
				q = p + 1;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int inf = 1001001001;
int main(){
  int H,W,K,i,j;scanf("%d %d %d\n",&H,&W,&K);
  char c;bool w[H][W];
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      scanf("%c",&c);
      w[i][j] = c == '1';
    }
    scanf("\n");
  }
  int ans = inf,now,b = 0;
  while(b < (1<<(H-1))){
    bitset<9> B(b);
    now = B.count();
    int wc[1+B.count()] = {};
    int itr[H];itr[0] = 0;
    for(i=1;i<H;i++){
      itr[i] = itr[i-1]+B[i-1];
    }
    for(i=0;i<W;i++){
      for(j=0;j<H;j++){
        wc[itr[j]] += w[j][i];
      }
      if(*max_element(wc,wc+1+B.count()) > K){
        now++;memset(wc,0,sizeof(wc));
        for(j=0;j<H;j++) wc[itr[j]] += w[j][i];
        if(*max_element(wc,wc+1+B.count()) > K){
          now = inf;
        }
      }
    }
    ans = min(ans,now);
    b++;
  }
  printf("%d\n",ans);
}


Measured memory_bytes: 3832
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    T, A = map(int, input().split())
    H = list(map(int, input().split()))

    ans = -1
    diff = float("inf")
    for i in range(N):
        ave_t = T - H[i] * 0.006
        if abs(ave_t - A) < diff:
            diff = abs(ave_t - A)
            ans = i + 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <tuple>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long a[n], b[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    long long sum  = 0;
    for (int i = n - 1; i >= 0; --i) {
        sum += (b[i] - (sum + a[i]) % b[i]) % b[i];
//        cout << sum << endl;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  int i = 0;
  bool c = true;
  cin >> a;
  for(i = 0;i < 4;i++){
    if(a[i] == a[i + 1]){
     c = false;
    }
  }
  if(c){
    cout << "Good" << endl;
  }else{
    cout << "Bad" << endl;
}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector> 
#include <algorithm>
using namespace std;
int N;

int main(){
  scanf("%d", &N);
  vector<int> yesterday(3);
  vector<int> today(3);
  
  for(int i=0; i<N; i++){
    int a,b,c; scanf("%d %d %d", &a, &b, &c);
    if(i==0){
      today[0] = yesterday[0] = a;
      today[1] = yesterday[1] = b;
      today[2] = yesterday[2] = c;
      continue;
    }
    // a
    today[0] = max(yesterday[1]+a, yesterday[2]+a);
    // b
    today[1] = max(yesterday[2]+b, yesterday[0]+b);
    // c
    today[2] = max(yesterday[0]+c, yesterday[1]+c); 
    
    for(int j=0; j<3; j++) yesterday[j] = today[j];
  }
  int ans = *max_element(today.begin(), today.end());
  printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  std::vector<int64_t> a, b, c;
  for (int i = 0; i < x; i++) {
    int64_t m1;
    cin >> m1;
    a.push_back(m1);
  }
  for (int i = 0; i < y; i++) {
    int64_t m1;
    cin >> m1;
    b.push_back(m1);
  }
  for (int i = 0; i < z; i++) {
    int64_t m1;
    cin >> m1;
    c.push_back(m1);
  }

  std::vector<int64_t > a_b;
  for(auto tgt_a:a){
    for(auto tgt_b:b){
      a_b.push_back(tgt_a+tgt_b);
    }
  }
  std::sort(a_b.begin(),a_b.end(),std::greater< >());
  std::sort(c.begin(),c.end(),std::greater<>());
  std::vector<int64_t > d(3000);
  for(int i=0;i<std::min(3000,x*y);i++){
    d.push_back(a_b[i]);
  }
  std::vector<int64_t >result;
  for(auto tgt_d:d){
    for(auto tgt_c:c){
      result.push_back(tgt_c+tgt_d);
    }
  }
  std::sort(result.begin(),result.end(),std::greater<>());
  for(int i=0;i<k;i++){
    cout<<result[i]<<endl;
  }




  return 0;
}


Measured memory_bytes: 76284
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
            
print(ans)

Measured memory_bytes: 3060
h,w,a,b=map(int,input().split())

ans=[[0]*w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if i<b and j>=a:
            ans[i][j]=1
        elif i>=b and j<a:
            ans[i][j]=1
        else:
            continue

for i in range(h):
    print("".join(list(map(str,ans[i]))))


Measured memory_bytes: 51164
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
        int Y = fs.nextInt();

        for (int i = 0; i <= N; ++i) {
            for (int j = 0; j <= N-i; ++j) {
                int k = N - i - j;
                if (Y == 10000*i + 5000*j + 1000*k) {
                    System.out.println(i + " " + j + " " + k);
                    System.exit(0);
                }
            }
        }

        System.out.println(-1 + " " + -1 + " " + -1);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() { return Double.parseDouble(next());}
}




Measured memory_bytes: 36964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  double a,b,c,d,e,f;
  while(cin>>a>>b>>c>>d>>e>>f){
    double x = (c*e-b*f)/(a*e-d*b);
    double y = (c*d-a*f)/(b*d-e*a);
    if(abs(x)<0.0005){ x = abs(x);}
    if(abs(y)<0.0005){ y = abs(y);}
    printf("%.3f %.3f\n",x,y);
  }
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	vector<int> vec(4);
	for (int i = 0; i < 4; i++) cin >> vec[i];
	sort(vec.begin(), vec.end());
	if (vec[0] == vec[1] && vec[2] == vec[3]) cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#pragma gcc optimize("Ofast")
using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

map<string, vector<string>> G;
set<string> dp, vis;
void dfs(string s) {
	if (vis.find(s) != vis.end()) return;
	vis.insert(s);
	if (G[s].empty()) dp.insert(s);
	for (string c : G[s]) dfs(c);
}

int main() {
	for (;;) {
		int n; cin >> n;
		if (n == 0) break;
		G.clear(); dp.clear(); vis.clear();
		string ggn;
		rep(i, 0, n) {
			string line, buf; cin >> line;
			string gn;
			for (const char c : line) {
				if (c == ':') {
					gn = buf;
					if (i == 0) ggn = buf;
					buf = "";
				} else if (c == ',' || c == '.') {
					G[gn].push_back(buf);
					buf = "";
				} else {
					buf += c;
				}
			}
		}
		dfs(ggn);
		cout << dp.size() << endl;
	}
}



Measured memory_bytes: 3308
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);    
    int n = in.nextInt();
    int[] A = new int[n];
    for (int i = 0; n != 0; i++) {
      A[i] = in.nextInt();
      n--;
    }
    
    int q = in.nextInt();
    int[] M = new int[q];
    for (int i = 0; q != 0; i++) {
      M[i] = in.nextInt();
      q--;
    }
    
    for (int i = 0; i < M.length; i++) {
      System.out.println((dfs(0, A, 0, M[i])) ? "yes" : "no" );
    }
  }
  static boolean dfs(int p, int[] A, int t, int sum) {
    if (p == A.length) return t == sum;
    if (dfs(p + 1, A, t + A[p], sum)) return true;
    if (dfs(p + 1, A, t, sum))        return true;
    return false;
  }
}

Measured memory_bytes: 20652
//https://atcoder.jp/contests/abc128/tasks/abc128_a
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, P;
    cin >> A >> P;
    cout << ((A*3) + P) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256