akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

class Main {

	public static void main(String[] args) throws IOException {

		List<Integer> tatelist = new LinkedList<>(Arrays.asList(1,2,6,5));

		List<Integer> yokolist = new LinkedList<>(Arrays.asList(1,3,6,4));

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] nums = br.readLine().split(" ");

		Dice cont = new Dice(nums);

		String oder = br.readLine();

		for(int i=0; i<oder.length(); i++){
			switch (oder.charAt(i)) {
			case 'N':
				tatelist.add(tatelist.get(0));
				tatelist.remove(0);
				yokolist.set(0, tatelist.get(0));
				yokolist.set(2, tatelist.get(2));
				break;
			case 'S':
				tatelist.add(0, tatelist.get(3));
				tatelist.remove(4);
				yokolist.set(0,tatelist.get(0));
				yokolist.set(2, tatelist.get(2));
				break;
			case 'E':
				yokolist.add(0,yokolist.get(3));
				yokolist.remove(4);
				tatelist.set(0,yokolist.get(0));
				tatelist.set(2,yokolist.get(2));
				break;
			case 'W':
				yokolist.add(yokolist.get(0));
				yokolist.remove(0);
				tatelist.set(0,yokolist.get(0));
				tatelist.set(2,yokolist.get(2));
				break;
			}
		}

		System.out.println(cont.getnum(yokolist.get(0)-1));
	}

}

class  Dice{
	int[] nums;

	Dice(String[] s){

		nums = new int[s.length];
		for(int i=0; i<s.length;i++){
			nums[i] = Integer.parseInt(s[i]);
		}
	}

	int getnum(int i){


		return nums[i];

	}


}

Measured memory_bytes: 24396
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  char c[3];
  cin>>c[0]>>c[1]>>c[2];
  sort(c,c+3);
  if(c[0]=='a'&&c[1]=='b'&&c[2]=='c')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

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

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

ll pow3[33];

ll calc(ll a, ll b, ll c, ll d, ll size = 30) {
	ll div = pow3[size-1];
	ll parta = a / div, partb = b / div;
	ll partc = c / div, partd = d / div;
	ll spath = abs(d-b) + abs(c-a);
	if (parta == partc && partb == partd) {
		return (calc(a - parta*div, b - partb*div, c - partc*div, d - partd*div, size-1));
	}
	
	//やばいやつら
	if (parta == partc || partb == partd) {
		if (partb == partd) { swap(a, b); swap(c, d); swap(parta, partb); swap(partc, partd); }
		if (parta == 1) {
			return (abs(d-b) + min(a-div+1+c-div+1, 2*div-a+2*div-c));
		}
		a -= parta*div, c -= partc*div;
		for (ll sz = size-2; sz >= 0; sz--) {
			ll dv = pow3[sz];
			ll pta = a/dv, ptc = c/dv;
			if (pta != ptc) return (spath);
			if (pta == ptc && pta == 1 && abs(d-b) / dv > 1) return (abs(d-b) + min(a-dv+1+c-dv+1, 2*dv-a+2*dv-c));
			a -= pta*dv, c -= ptc*dv;
		}
	}
	return (spath);
}

void solve() {
	ll a, b, c, d; cin >> a >> b >> c >> d; --a, --b, --c, --d;
	cout << calc(a, b, c, d) << endl;
}

void Main() {
	//init
	pow3[0] = 1;
	for (int i = 1; i <= 30; i++) pow3[i] = pow3[i-1] * 3;

	int Q; cin >> Q;
	while (Q--) solve();
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,lst=1,w[500005];char s[500005];ll ans;
vector<pii> r;
int main()
{
    scanf("%s",s+1);n=strlen(s+1);
    rep(i,2,n+1){
        if(s[i]!=s[i-1]){
            r.pb(mpr(lst,i-1));
            lst=i;
        }
    }
    rap(i,0,r.size()){
        int a=r[i].fi,b=r[i].se;
        rep(j,a,b+1){
            if(s[a]=='>') w[j]=max(w[j],b+1-j);
            else w[j]=max(w[j],j-a);
        }
    }
    rep(i,1,n+1) ans+=w[i];
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 4720
#include <iostream>
#include<vector>
#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 rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int N;
    cin>>N;
    vector<string>S(N);
    rep(i,N)cin>>S[i];
    vector<int>C(4);
    rep(i,N){
        if(S[i]=="AC")C[0]++;
        if(S[i]=="WA")C[1]++;
        if(S[i]=="TLE")C[2]++;
        if(S[i]=="RE")C[3]++;
    }
    cout<<"AC"<<" "<<"x"<<" "<<C[0]<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<C[1]<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<C[2]<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<C[3]<<endl;

    return 0;
}

Measured memory_bytes: 6428
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

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

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

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

ll N, M;

int main(int argc, const char * argv[]) {
    N = inputValue();
    M = inputValue();
    if (N < M) swap(N, M);
    
    ll ans = 0;
    if (N == 1 && M == 1) {
        ans = 1;
    }
    else if (M == 1) {
        ans = N - 2;
    } else {
        ans = (N - 2) * (M - 2);
    }

    output(ans);

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#define maxn 310
using namespace std;

char s[maxn];
int n,k,f[maxn][maxn][maxn];

template <typename T>
bool chkmax(T &a, T b){
	return a < b ? a = b, 1 : 0;
}

int main(){
    scanf("%s",s+1);
	n=strlen(s + 1);
	cin>>k;
    for(int len=1;len<=n;len++)
        for(int st=1;st<=n-len+1;st++) {
            int ed=st+len-1;
            for(int i=0;i<=k;i++) {
                if(st==ed) 
					f[st][ed][i]=1;
                else if(st+1==ed)
					f[st][ed][i]=i || s[st]==s[ed] ? 2 : 1;
                else{
                    f[st][ed][i]=max(f[st+1][ed][i],f[st][ed-1][i]);
                    if(s[st]==s[ed])
						chkmax(f[st][ed][i],f[st+1][ed-1][i]+2);
                    if(i) 
						chkmax(f[st][ed][i],f[st+1][ed-1][i-1]+2);
                }
            }
        }
    printf("%d\n", f[1][n][k]);
    return 0;
}


Measured memory_bytes: 114560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    ll cnt = 0;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

int main() 
{
    int n, count=0;
    cin >> n;
    
    int A[n];
    for(int i=0; i<n; i++) cin >> A[i];

    while(true){
        for(int i=0; i<n; ++i){
            if(A[i]%2){
                cout << count << endl;
                return 0;
            }
        }    
        for(int i=0; i<n; ++i){
            A[i] /= 2; 
        }
        ++count;
    }
}

Measured memory_bytes: 3632
s=input()
ans=0
i=0
while i!=len(s) and len(s)>=2:
  if s[i:i+2]=="01" or s[i:i+2]=="10":
      s=s[:i]+s[i+2:]
      ans+=2
      i=max(0,i-1)
  else:
    i+=1
print(ans)

Measured memory_bytes: 3424
#include <stdio.h>

int main(void)
{
	int N,i,min,max,A[101];

	scanf("%d",&N);

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

	min = max = A[0];

	for(i=1;i<N;i++){
		if(max<A[i]) max = A[i];
		else if(min>A[i]) min = A[i];
	}

	printf("%d\n",max-min);
	return 0;
}



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

const long long INF = 1LL << 60;

int main(){
    string S; 
    cin>>S;
    int cnt=0,ans=0;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S.at(i) != '0') cnt++;
        } else {
            if (S.at(i) != '1') cnt++;
        }
    }
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S.at(i) != '1') ans++;
        } else {
            if (S.at(i) != '0') ans++;
        }
    }
    ans = min(ans, cnt);
    cout << ans << endl;
}


Measured memory_bytes: 3688
#include <iostream>


using namespace std;

int main()
{
	int n, min, max;
	long long sum;
	cin >> n;
	cin >> min;
	sum = max = min;
	for(int i = 1; i < n; ++i)
	{
		int a;
		cin >> a;
		if(min > a)
		{
			min = a;
		}
		if(max < a)
		{
			max = a;
		}
		sum += a;
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>
int main()
{
	int a, out[100002], n,i;
	while(~scanf("%d", &n))
	{
		for(i=1; i<=n; i++)
		{
			scanf("%d", &a);
			out[a]=i;
		}
		for(i=1; i<=n; i++)
			printf("%d ", out[i]);
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);

    sort(a.begin(),a.end(),greater<int>());

    vector<int> b(0);
    for(int i = 1;i < n;i ++){
        if(a.at(i) == a.at(i-1)){
            b.push_back(a.at(i));
            i ++;
        }
    }

    if(b.size() < 2) cout << 0 << endl;
    else cout << b.at(0) * b.at(1) << endl;
}

Measured memory_bytes: 1660
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    ll all = a + b;
    ll ans = 0;
    if (1 <= n % all && n % all <= a) ans = a * (n / all) + (n % all);
    else ans = a * ((n + all - 1) / all);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i);
#define all(x) (x).begin(),(x).end();
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	ll x, y, cnt=0;
	cin >> x >> y;
	for (ll i = x; x <= y; x *= 2)cnt++;
	cout << cnt << endl;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll h, w;
  cin >> h >> w;

  vector<string> mp(h);
  rep(i, h) { cin >> mp[i]; }

  queue<T> que;
  rep(i, h) rep(j, w) {
    if (mp[i][j] == '#') que.emplace(i, j, 0);
  }

  ll ans = 0;
  while (!que.empty()) {
    ll y, x, n;
    tie(y, x, n) = que.front();
    que.pop();
    for (ll i = 0; i < 4; i++) {
      ll ny = y + dy[i], nx = x + dx[i], nn = n + 1;
      bool ok = 0 <= ny && ny < h && 0 <= nx && nx < w && mp[ny][nx] == '.';
      if(ok){
        mp[ny][nx] = '#';
        chmax(ans, nn);
        que.emplace(ny, nx, nn);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 29380
player_list = ['a', 'b', 'c']
s = {player_list[n]: list(raw_input()) for n in xrange(len(player_list))}

current_turn = player_list[0]

get_winner = lambda x, s: not s[x] and x.upper() or get_winner(s[x].pop(0), s)

print get_winner(current_turn, s)

Measured memory_bytes: 2820
N, Y = map(int, input().split())
ans = 0
for i in range(0, N + 1):
    for j in range(0, N - i + 1):
        if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
            print(i, j, N - i - j)
            exit()
print(-1, -1, -1)

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


signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    vector<int> v1(2);
    vector<int> v2(2);
    cin>>v1[0]>>v1[1]>>v2[0]>>v2[1];

    int ans = -1e18;

    for (int i=0; i<2; i++){
        for (int j=0; j<2; j++){
            ans = max(ans, v1[i]*v2[j]);
        }
    }

    cout<<ans<<endl;

    return 0;
}






Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	makei(x);
	YN(x == 7 || x == 5 || x == 3);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pf push_front
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define ll long long

using namespace std;

typedef pair<int, int> td;

int n;
ll w;
ll op[100010];

int main(){
    #ifdef ZERBRA
        freopen("code.inp", "r", stdin);
        //freopen("code.out", "w", stdout);
    #endif // ONLINE_JUDGE
    scanf("%d%I64d", &n, &w);
    for (int i = 1; i <= 1e5; ++i)
        op[i] = 1e18L;
    for (int i = 0; i < n; ++i){
        int weight, value;
        scanf("%d%d", &weight, &value);
        for (int j = 1e5; j >= value; --j)
            op[j] = min(op[j], op[j-value] + weight);
    }
    for (int i = 1e5; i >= 0; --i)
        if (op[i] <= w) {
            printf("%d", i);
            break;
        }
    return 0;
}


Measured memory_bytes: 1024
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;
const long long md = 1e9 + 7;

int n, h, d;
long long dp[1000005], dp2[1000005];

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
    //freopen("/Users/danya.smelskiy/Documents/Danya/Danya/output.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> h >> d;
    long long f = 1, ff = 0;
    for (int i = 1; i <= n; ++i) {
        f = (f * 1ll * i) % md;
        ff += f;
        if (ff >= md) ff -= md;
    }
    dp[0] = 1;
    dp2[0] = 1;
    int l, r;
    long long cur;
    for (int i = 1; i <= h; ++i) {
        l = i - d - 1;
        r = i - 1;
        cur = dp2[r];
        if (l >= 0) {
            cur -= dp2[l];
            if (cur < 0) cur += md;
        }
        if (i < h) {
            cur *= ff;
            cur %= md;
        } else {
            cur *= f;
            cur %= md;
        }
        dp[i] = cur;
        dp2[i] = dp2[i - 1] + cur;
        if (dp2[i] >= md) dp2[i] -= md;
    }
    cout << dp[h] << '\n';
}



Measured memory_bytes: 15872
function Main(args){
  input = args.split("\n");
  var N = input[0];
  var numbers = input[1].split(' ');
  
  var count = 0;
  
  while( isDividable(numbers) ){
    numbers = divideArray(numbers);
    count++;
  }
  
  console.log(count);
}

function isDividable(args){
  var numbers = args;

  for(var i=0; i<numbers.length; i++){
    if(numbers[i]%2 != 0){
      return false;
    }
  }
  
  return true;
}

function divideArray(args){
  var numbers = args;

  for(var i=0; i<numbers.length; i++){
    numbers[i] /= 2;
  }
  
  return numbers;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from math import sqrt 
from math import cos
from math import pi
def main():
    A, B, H, M = map(int, readline().split())
    h = (H/6)*pi+(((30/60)*M)/360)*2*pi
    m = (M/30)*pi
    theta = min(2*pi-abs(m-h), abs(m-h))
    print(sqrt(A**2+B**2-2*A*B*cos(theta)))
if __name__ == '__main__':
    main()

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

int main()
{
  int n;
  cin >> n;
  
  int a[n];
  rep(i,n) cin >> a[i];
  
  int max1 = 0, max2 = 0;
  rep(i,n)
  {
    if(a[i] > max1)
    {
      max1 = a[i];
    }else if(a[i] > max2 && a[i] <= max1){
      max2 = a[i];
    }
  }
  
  rep(i,n)
  {
    if(a[i] != max1)
    {
      cout << max1 << endl;
    }else{
      cout << max2 << endl;
    }
  }
      
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int dp[3010][3010],ma[3010],prv[3010][3010];
string ans;
string s,t;
void getans( int x, int y ){
	if( x==0 || y == 0) return ;
	if( prv[x][y] == 1){
		ans.pb(s[x-1]);
		getans( x-1, y-1 );
	}
	else if( prv[x][y] == 2 ){
		getans( x-1, y );
	}
	else{
		getans( x, y-1 );
	}
	return ;
}
signed main(){
	cin>>s>>t;
	for(int i=1;i<=s.size();i++){
		for(int j=1;j<=t.size();j++){
			if( s[i-1] == t[j-1] ){
				if( dp[i-1][j-1] + 1 > dp[i][j] ){
					dp[i][j] = dp[i-1][j-1] + 1;
					prv[i][j] = 1;
				}
			}
			if( dp[i-1][j] > dp[i][j] ){
				dp[i][j] = dp[i-1][j];
				prv[i][j] = 2;
			}
			if( dp[i][j-1] > dp[i][j] ){
				dp[i][j] = dp[i][j-1];
				prv[i][j] = 3;
			}
		}
	}
	for(int i=0;i<=s.size();i++){
		int tmp = 0;
		for(int j=0;j<=t.size();j++){
			if( dp[i][j] > tmp ) tmp = dp[i][j];
		}
		ma[i] = tmp;
	}
	getans( s.size(), t.size() );
	reverse( ans.begin(), ans.end() );
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 141568
import java.util.Scanner;
public class Main {
    static int n;
    static int s[];
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        s = new int[n];
        for(int i=0;i<n;i++){
            s[i] = sc.nextInt();
        }
        int q = sc.nextInt(); 
        int t[] = new int[q];
        for(int i=0;i<q;i++){
            t[i] = sc.nextInt();
        }
        int ans = 0;
        for(int i: t){
            if(bsearch(i, 0, n-1)){
                ans++;
            }
        }
        System.out.println(ans);
        sc.close();
    }
    
    public static boolean bsearch(int k, int i, int j){
        
        if(s[(i+j)/2]==k){
            return true;
        }else if(i>j){
            return false;
        }else if(s[(i+j)/2]<k){
            return bsearch(k, (i+j)/2+1, j);
        }else if(s[(i+j)/2]>k){
            return bsearch(k, i, (i+j)/2-1);
        }
        return false;
    }
}


Measured memory_bytes: 80032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

ll modnum = 1000000007;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main() {
    int n,m; cin >> n >> m;

    int ans = 0;
    if(n > 0) {
        ans += ((n*(n-1))/2);
    }
    if(m > 0) {
        ans += ((m*(m-1))/2);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	for i := 1; i <= 100; i++ {
		x := a * i
		if x%b == c {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type edge struct {
	a, b, c int
}

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)
	INF := int(math.Pow10(15))

	N, M := scanInt(), scanInt()
	E := make([]edge, M)
	for i := 0; i < M; i++ {
		E[i].a, E[i].b, E[i].c = scanInt()-1, scanInt()-1, scanInt()
	}

	dist := make([]int, N)
	for i := 1; i < N; i++ {
		dist[i] = -INF
	}

	for i := 0; i < N; i++ {
		for _, e := range E {
			if e.a != -INF {
				dist[e.b] = intMax(dist[e.b], dist[e.a]+e.c)
			}
		}
	}

	updated := make([]bool, N)
	for i := 0; i < N; i++ {
		for _, e := range E {
			if e.a == -INF {
				continue
			}
			if dist[e.b] < dist[e.a]+e.c {
				dist[e.b] = dist[e.a] + e.c
				updated[e.b] = true
			}

			if updated[e.a] {
				updated[e.b] = true
			}
		}
	}

	if updated[N-1] {
		fmt.Println("inf")
	} else {
		fmt.Println(dist[N-1])
	}
}


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

int main() {
    int N; cin>>N;
    vector<ll>x(N);
    rep(i,N)cin>>x[i];
    vector<ll>y=x;
    sort(y.begin(),y.end());
    rep(i,N){
        if(x[i]<y[N/2])cout<<y[N/2]<<endl;
        else cout<<y[N/2-1]<<endl;
    }
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define zero_pad(num) setfill('0') << std::right << setw(num)
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N,M;cin>>N>>M;
    vector<int>P(M),Y(M);
    vector<int>PY[N+1];
    REP(i,M){
        cin>>P[i]>>Y[i];
        PY[P[i]].pb(Y[i]);
    }
    map<int,int>memo;
    REPS(i,N){
        sort(PY[i].begin(),PY[i].end());
        REP(j,PY[i].size()){
            memo[PY[i][j]]=j+1;
        }
    }
    REP(i,M)cout<<zero_pad(6)<<P[i]<<zero_pad(6)<<memo[Y[i]]<<endl;
}

Measured memory_bytes: 14720
#include<stdio.h>
#include<string.h>
main()
{
	int i;
	char a[5], n;
	scanf("%s", a);
	for (i=0; i<strlen(a); i++)
	{
		n=a[i];
		if (n=='9')
		n='1';
		else if (n=='1')
		n='9';
		printf("%c", n);
	}
	return 0;
}

Measured memory_bytes: 128
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
from decimal import *

n = int(input())
d = 1000000007

if 2 < n:
    #ans = (10 ** n - 8 ** n) - (9 ** n - 8 ** n) * 2
    a = 10 ** n
    a %= d
    b = 9 ** n
    b %= d
    c = 8 ** n
    c %= d
    ans = a + c - b * 2
    ans %= d
elif n == 2:
    ans = 2
else:
    ans = 0
print(ans)


Measured memory_bytes: 11440
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}

int main(){
	int n;
	cin >> n;
	int x = 1,y=1;
	rep(i, 0, n) {
		int a;
		cin >> a;
		if (a % 2 == 0)x *= 2;
		y *= 3;
	}
	cout << y - x << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
cnt = 0

for i in range(n):
    for j in range(i + 1, n):
        for k in range(j +1, n):
            a = l[i]
            b = l[j]
            c = l[k]
            if a == b or b == c or c == a:
                continue
            if a + b > c and b + c > a and c + a > b:
                cnt += 1
print(cnt)


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

long long get_snuke(long long n){
	vector<pair<long long,long long>> P;
	string S = to_string(n);
	S = '0'+S;
	for(int i=S.size()-1;i>=0;i--){
		string T = S;
		for(int j=i+1;j<T.size();j++){
			T[j]='9';
		}
		for(int j=0;j<10;j++){
			if(T[i]>'9')break;
			
			long long s = 0;
			for(int k=0;k<T.size();k++){
				s += T[k]-'0';
			}
			P.emplace_back(stoll(T),s);
			
			T[i]++;
		}
	}
	sort(P.begin(),P.end(),[&](auto a,auto b){
		long long x = a.first*b.second;
		long long y = a.second*b.first;
		if(x==y){
			return a.first<b.first;
		}
		else{
			return x<y;
		}
	});
	return P[0].first;
}

int main(){
    
	long long K;
	cin>>K;
	long long now = 0;
	for(int i=0;i<K;i++){
		if(i==0){
			cout<<1<<endl;
			now=1;
		}
		else{
			now = get_snuke(now+1);
			cout<<now<<endl;
		}
	}
	
	
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
	public static void main(String[] args) {
 
	    Scanner sc = new Scanner(System.in);
	    int X = sc.nextInt();
	    int Y = sc.nextInt();
	    int Z = sc.nextInt();
	    
	    int A = Z;
	    int B = X;
	    int C = Y;
	    
	    System.out.println(A + " " + B + " " + C);
 
	  }
}

Measured memory_bytes: 21588
import sys
    
n = input()
num = list(n)
n100 = num[0]
n10 = num[1]
n1 = num[2]
if (num[0] == num[1]) and (num[0] == num[2]):
    print(n)
    sys.exit()

if int(n) < int(n100)*100 + int(n100)*10 + int(n100):
    print(int(n100)*100 + int(n100)*10 + int(n100))

if int(n) > int(n100)*100 + int(n100)*10 + int(n100):
    print((int(n100)+1)*100 + (int(n100)+1)*10 + (int(n100)+1))

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

using namespace std;
typedef vector<int> V;

template<typename T>
class svector:private std::vector<T>{
    using V=std::vector<T>;
    using SV=svector;
private:
    int sz;
public:
    using V::begin;
    using V::end;
    svector(int n,T ini):V(n*2+1,ini),sz(n){}
    svector(int n):SV(n,T()){}
    svector():V(),sz(0){}
    int size(){return sz;}
    T& operator[](int id){
	return V::operator[](id+sz);
    }
};
typedef svector<int> SV;
typedef svector<SV> SVV;
const int dx[7]={0,1,1,0,-1,-1,0};
const int dy[2][7]={{1,0,-1,-1,-1,0,0},{1,1,0,-1,0,1,0}};

bool inner(int lb,int x,int ub){
    return lb<=x&&x<=ub;
}
bool inner(int r,int c,int R,int C){
    return inner(-R,r,R)&&inner(-C,c,C);
}
    
int main(){
    int sx,sy,gx,gy,X,Y,n;
    cin>>sx>>sy>>gx>>gy>>n;
    vector<int> kx(n),ky(n);
    for(int i=0;i<n;i++)
	cin>>kx[i]>>ky[i];
    cin>>X>>Y;
    vector<SVV> dist(6,SVV(X,SV(Y,114514)));
    for(int i=0;i<n;i++)
	for(int t=0;t<6;t++)
	    dist[t][kx[i]][ky[i]]=-1;
    using node=tuple<int,int,int,int>;
    priority_queue<node> que;
    dist[0][sx][sy]=0;
    que.push(node(0,sx,sy,0));
    while(que.size()){
	auto v=que.top();que.pop();
	int cost,x,y,t;
	tie(cost,x,y,t)=v;cost*=-1;
	if(cost>dist[t][x][y])continue;
	
	//printf("(%d,%d,t=%d)=%d\n",x,y,t,cost);
	int sis=abs(t*x*y)%6;
	for(int d=0;d<7;d++){
	    int nx=x+dx[d];
	    int ny=y+dy[x&1][d];
	    int nt=(t+1)%6;
	    int ncost=cost;
	    if(sis!=d)ncost++;
	    if(inner(nx,ny,X,Y)&&dist[nt][nx][ny]>ncost){
		dist[nt][nx][ny]=ncost;
		que.push(node(-ncost,nx,ny,nt));
	    }
	}
    }
    int res=114514;
    for(int t=0;t<6;t++)
	if(dist[t][gx][gy]!=-1)
	    res=min(res,dist[t][gx][gy]);
    if(res==114514)cout<<-1<<endl;
    else cout<<res<<endl;
}

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

int main(){
    int M, D;
    cin >> M >> D;

    int ans = 0;
    for(int i = 1; i <= M; ++i){
        for(int j = 1; j <= D; ++j){
            int d1, d10;
            if(j < 10){
                d1 = j;
                d10 = 0;
            }else{
                d1 = j%10;
                d10 = j/10;
            }
            
            if(d1 >= 2 && d10 >= 2 && d1*d10 == i){
                ++ans;
            }
        }
    }

    cout << ans << endl;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	stack<int> st;
	string s;
	int a, b;
	while(cin >> s){
		if(s == "+") {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push(b + a);
		}
		else if(s == "-") {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push(b - a);
		}
		else if(s == "*") {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push(b * a);
		}
		else {
			st.push(strtol(s.c_str(), nullptr, 10));
		}
	}

	cout << st.top() << endl;
	return 0;
}


Measured memory_bytes: 3228
n, m = map(int, input().split())
switch = [list(map(int, input().split())) for _ in range(m)]
switch = [s[1:] for s in switch]
p = list(map(int, input().split()))

count = 0
for i in range(2 ** n):
    on_light = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m):
                if j + 1 in switch[k]:
                    on_light[k] += 1
    if all((on_light[i] % 2 == p[i]) for i in range(m)):
        count += 1

print(count)

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

bool nibu(vector<vector<int>> &G) {
    int N = G.size();
    vector<int> color(N, -1);
    function<bool(int)> dfs = [&](int cur) {
        bool res = true;
        for(auto &to : G[cur]) {
            if(color[to] != -1) {
                if(color[cur] == color[to]) return false;
            } else {
                color[to] = color[cur] ^ 1;
                res &= dfs(to);
            }
        }
        return res;
    };
    color[0] = 0;
    return dfs(0);
}

int solve() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    rep(i, 0, N) rep(j, 0, N) {
        char a; cin >> a;
        if(a == '1') G[i].push_back(j);
    }
    if(!nibu(G)) return -1;
    int ans = 0;
    rep(s, 0, N) {
        queue<int> Q; Q.push(s);
        vector<int> dist(N);
        while(!Q.empty()) {
            int cur = Q.front(); Q.pop();
            for(auto &to : G[cur]) {
                if(dist[to] || to == s) continue;
                Q.push(to);
                dist[to] = dist[cur] + 1;
                ans = max(ans, dist[to]);
            }
        }
    }
    return ans + 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << solve() << '\n';
    return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
s = str(input())
half_slen = int(len(s)/2)
half=s[0:half_slen]
ahalf=''.join(list(reversed(s[-half_slen:])))

cnt=0
for i in range(0,half_slen):
    if half[i] != ahalf[i]:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using  LL = long long;

LL yhaa(LL x, LL n, LL mod){
    if (n == 0){
        return 1;
    }
    if (n%2 == 0){
        LL t = (yhaa(x,n/2, mod)) % mod;//偶数の時は半分
        return (t*t) % mod;
    }
    return (x * yhaa(x, n-1, mod)) % mod;
}

LL nCk(LL n,LL k,LL m){
    int K;
    if (2+k > n){
        K  = n - k;
    }
    else{
        K = k;
    }
    LL X = 1;
    for(int i = 0; i < K;i++){
        X = (X*(n-i)) % m;
    }
    LL Y = 1;
    for(int i = 1; i < K+1; i++){
        Y = (Y*i) % m;
    }
    LL YY = yhaa(Y,1000000005,m);
    return (X*YY) % m;

}


int main(){
    int n, a, b;
    cin >> n >> a >> b;
    long long int m = 1000000007;
    if (n == 2){
        cout << 0 <<endl;
    }
    else{
        LL all = yhaa(2,n,m);
        LL C_a = nCk(n,a,m);
        LL C_b = nCk(n,b,m);
        if((all - C_a - C_b - 1 ) % m > 0){
            cout << (all - C_a - C_b - 1 ) % m << endl;
        }
        else{
            cout << m + (all - C_a - C_b - 1 ) % m << endl;
        }
    }
    
}

Measured memory_bytes: 3636
#include<stdio.h>
void main()
{
  int n,m,t,i,a,b,c;
  scanf("%d %d %d",&n,&m,&t);
  for(i=1;i>0;i++)
  {
    a=i*m;
    b=n-a;
    if(b<=0)
    {
     break;
    }
  }
 c=i*t;
  printf("%d",c);
}
  

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

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

  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  string s;
  
  for (int n = 0; n < N; n++){
    cin >> s;
    if (s == "AC"){
      AC++;
    }else if (s == "WA"){
      WA++;
    }else if (s == "TLE"){
      TLE++;
    }else if (s == "RE"){
      RE++;
    }
  }

  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
  
  return 0;
}


Measured memory_bytes: 3628
N = input()
res = [0] * N
for i in range(N - 1):
    C, S, F = map(int, raw_input().split())
    for j in range(i + 1):
        res[j] = max(S, res[j] if res[j] % F == 0 else res[j] - res[j] % F + F)
        res[j] += C
for t in res:
    print t


Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>
#include <set>
using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

struct LazySegmentTree
{
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v)
    {
        int sz = (int)v.size();
        n = 1;
        while (n < sz)
            n *= 2;
        node.resize(2 * n - 1);
        lazy.resize(2 * n - 1, 0);

        for (int i = 0; i < sz; i++)
            node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--)
            node[i] = node[i * 2 + 1] + node[i * 2 + 2];
    }

    void eval(int k, int l, int r)
    {
        if (lazy[k] != 0)
        {
            node[k] += lazy[k];
            if (r - l > 1)
            {
                lazy[2 * k + 1] += lazy[k] / 2;
                lazy[2 * k + 2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1)
    {
        if (r < 0)
            r = n;
        eval(k, l, r);
        if (b <= l || r <= a)
            return;
        if (a <= l && r <= b)
        {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else
        {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = node[2 * k + 1] + node[2 * k + 2];
        }
    }

    ll getsum(int a, int b, int k = 0, int l = 0, int r = -1)
    {
        if (r < 0)
            r = n;
        eval(k, l, r);
        if (b <= l || r <= a)
            return 0;
        if (a <= l && r <= b)
            return node[k];
        ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl + vr;
    }
};

int main()
{
    // 整数の入力
    ll N, D, A;
    cin >> N >> D >> A;
    vector<pair<ll, ll>> monsters;
    for (int i = 0; i < N; i++)
    {
        ll x, h;
        cin >> x >> h;
        monsters.push_back({x, h});
    }
    sort(monsters.begin(), monsters.end());
    vector<ll> initial_hp;
    for (int i = 0; i < N; i++)
    {
        initial_hp.push_back(monsters[i].second);
    }
    LazySegmentTree seg(initial_hp);
    ll index = 0;
    ll count = 0;
    while (index < N)
    {
        ll current = seg.getsum(index, index + 1);
        if (current <= 0)
        {
            index++;
            continue;
        }
        else
        {

            pair<ll, ll> to_monster = {monsters[index].first + 2 * D + 1, 0};
            ll to = lower_bound(monsters.begin(), monsters.end(), to_monster) - monsters.begin();
            // cout << "i:" << index << ",to:" << to << "current" << current << endl;
            ll attacks = (current + A - 1) / A;
            count += attacks;
            seg.add(index, to, -A * attacks);
            index++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 15852
#include "cstdio"
#include "vector"
#include "algorithm"
using namespace std;
int di[200001]={0};
vector<int> vec;
int main()
{
	int n,m,k;
	long long ans;
	int i,count=0,a;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		if(di[a]==0)
		{
			count++;
		}
		di[a]++;
	} 
	if(count<=k)
	{
		printf("0\n");
		return 0;
	} 
	for(i=1;i<200001;i++)
	{
		if(di[i]!=0)
		{
			vec.push_back(di[i]);
		}
	}
	sort(vec.begin(),vec.end());
	ans=0;
	m=count-k;
	for(i=0;i<m;i++)
	{
		ans+=vec[i];
	}
	printf("%lld\n",ans);
	return 0;
}

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

int bubbleSort(int A[], int N) {
    int Count = 0;
    bool IsContinue = true;
    
    for (int i = 0; IsContinue; i++) {
        IsContinue = false;
        for (int j = N - 1; j > i; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                IsContinue = true;
                Count++;
            }
        }
    }
    
    return Count;
}

int main(void) {
    int N, Count;
    cin >> N;
    int* A = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    Count = bubbleSort(A, N);
    
    for (int i = 0; i < N; i++) {
        if (i) {
            cout << " ";
        }
        cout << A[i];
    }
    
    cout << endl;
    cout << Count << endl;
    
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using PII = pair<int, int>;

class Solution {
public:
	int guessTheNumber(int n, const vector<PII>& conditions) {
		vector<int> digits(n, -1);
		for (const auto& condition : conditions) {
			const int s = condition.first, c = condition.second;
			if (digits[s - 1] != c) {
				if (digits[s - 1] == -1)
					digits[s - 1] = c;
				else
					return -1; /* conflict */
			}
		}

		int ans = 0;
		for (int i = 0; i < n; ++i) {
			const bool is_leading_digit = (n > 1) && (i == 0);
			int digit = digits[i];
			if (digit == -1)
				digit = is_leading_digit ? 1 : 0;

			if (is_leading_digit && digit == 0)
				return -1; /* leading zero */

			ans = ans * 10 + digit;
		}
		return ans;
	}
};

int main() {
	int n, m;
	cin >> n >> m;

	vector<PII> conditions(m);
	for (int i = 0; i < m; ++i)
		cin >> conditions[i].first >> conditions[i].second;

	Solution sol;
	const int ans = sol.guessTheNumber(n, conditions);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}
 
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e4 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
	else cout << "No";
}









Measured memory_bytes: 256