akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
template<typename T> void __dump__(const T &first) { std::cerr << first << std::endl; }
template<typename First, typename... Rest>
void __dump__(const First& first, const Rest&... rest) { std::cerr << first << ", "; __dump__(rest...); }
#define dump(...) { std::cerr << __LINE__ << ":\t" #__VA_ARGS__ " = "; __dump__(__VA_ARGS__); }

int n;
string s;

int tf[100010];

string check(int a, int b) {
    tf[0] = a;
    tf[1] = b;
    for (int i = 2; i < n; ++i) {
        if (s[i - 1] == 'o') {
            if (tf[i - 1]) {
                tf[i] = !tf[i - 2];
            } else {
                tf[i] = tf[i - 2];
            }
        } else {
            if (tf[i - 1]) {
                tf[i] = tf[i - 2];
            } else {
                tf[i] = !tf[i - 2];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        int l = tf[(i - 1 + n) % n];
        int r = tf[(i + 1) % n];
        if (s[i] == 'o') {
            if (tf[i] ^ (l != r)) {
                return "";
            }
        } else {
            if (tf[i] ^ (l == r)) {
                return "";
            }
        }
    }
    string res;
    for (int i = 0; i < n; i++) {
        res += "SW"[tf[i]];
    }
    return res;
}

string solve() {
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            string res = check(i, j);
            if (res.size()) {
                return res;
            }
        }
    }
    return "-1";
}

int main() {
    while (cin >> n >> s) {
        cout << solve() << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
struct sat2{
    int N, n;
    vector<vector<int>> G, rG;
    vector<bool> used;
    vector<int> temp;
    vector<int> order;//分解後のトポロジカル順序
    vector<bool> judge;
    sat2(int V){
        G.resize(2 * V);
        rG.resize(2 * V);
        N = 2 * V;
        n = V;
        order.resize(2 * V);
        judge.resize(V);
    }
    void add_edge(int s, int t){
        G[s].push_back(t);
        rG[t].push_back(s);
    }
    void add(int s, bool f, int t, bool g){
        add_edge(s + (f ? n : 0), t + (g ? 0 : n));
        add_edge(t + (g ? n : 0), s + (f ? 0 : n));
    }
    void dfs(int s){
        used[s] = true;
        for(int j: G[s]){
            if(!used[j]) dfs(j);
        }
        temp.push_back(s);
    }
    void rdfs(int s, int k){
        used[s] = true;
        order[s] = k;
        for(int j: rG[s]){
            if(!used[j]) rdfs(j, k);
        }
    }
    bool solve(){//分解後の頂点数を返す
        used.resize(N, false);
        for(int i = 0; i < N; i++){
            if(!used[i]) dfs(i);
        }
        used.assign(N, false);  
        int k = 0;
        for(int i = (int)temp.size() - 1; i >= 0; i--){ //番号が大きい方から順にdfs
            if(!used[temp[i]]) {
                rdfs(temp[i], k);
                k++;
            }
        }
        bool flag = true;
        for(int i = 0; i < n; i++){
            if(order[i] > order[i + n]) judge[i] = true;
            else if(order[i] < order[i + n]) judge[i] = false;
            else flag = false;
        }
        return flag;
    }
};
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, D;
    cin >> N >> D;
    sat2 sat2(N);
    vector<int> X(N), Y(N);
    for(int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            if(abs(X[i] - X[j]) < D) sat2.add(i, false, j, false);
            if(abs(X[i] - Y[j]) < D) sat2.add(i, false, j, true);
            if(abs(Y[i] - X[j]) < D) sat2.add(i, true, j, false);
            if(abs(Y[i] - Y[j]) < D) sat2.add(i, true, j, true);
        }
    }
    bool flag = sat2.solve();
    if(!flag) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        for(int i = 0; i < N; i++){
            if(sat2.judge[i]) cout << X[i] << endl;
            else cout << Y[i] << endl;
        }
    }
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class S>void tf(bool b,S t,S f){cout<<(b?t:f)<<endl;}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}
template<class T>T chmax(T&a,T b){return a=a>b?a:b;}
template<class T>T chmin(T&a,T b){return a=a<b?a:b;}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;
	cin>>h>>w;
	vs a(h);
	rep(i,h)cin>>a[i];
	vvi is(h,vi(w,0));
	queue<pll> q;
	ll ans=0;
	rep(i,h)rep(j,w)if(!is[i][j]){
		q.emplace(i,j);
		ll d=0,e=0;
		while(!q.empty()){
			int y,x;
			tie(y,x)=q.front(); q.pop();
			if(is[y][x])continue;
			is[y][x]=1;
			if(a[y][x]=='.')d++;
			else e++;
			rep(v,4){
				int ny=y+dy[v];
				int nx=x+dx[v];
				if(ny<0 or ny>=h or nx<0 or nx>=w)continue;
				if(is[ny][nx])continue;
				if(a[y][x]==a[ny][nx])continue;
				q.emplace(ny,nx);
			}
		}
		ans+=d*e;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int inputInt() {
    int i;
    scanf("%d", &i);
    return i;
}

int N;
vector<int> A;
long long ret;

int main() {
    N = inputInt();
    A.resize(max((int)A.size(), N)); for(int i=0; i<N; ++i) A[i] = inputInt();
    sort(A.rbegin(), A.rend());
    ret = 0;
    for(int i=1; i<N; ++i) ret += A[i>>1];
    printf("%lld\n", ret);
    return 0;
}


Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;


public class Main {
    
         
    static FastReader in;
    static StringBuilder out;

    public  static void main(String[] args) {
        
        in = new FastReader();
        out=new StringBuilder();
        int n=in.nextInt();
        int bigCount=n/500, smCount=(n-bigCount*500)/5;
        long ans=(long)bigCount*1000 + (long)smCount*5;
        System.out.println(ans);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
     
    
}

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

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

  int max = 0;

  for (int i = 0; i < N; ++i){
    if(max<a[i]) max = a[i];
  }
  
  int count = 0;

  while(max>0){
    if(a[0]==max) ++count;
    for (int i = 1; i < N; ++i){
      if(a[i-1]!=max && a[i]==max) ++count;
    }
    for (int i = 0; i < N; ++i){
      if(a[i]==max) --a[i];
    }
    --max;
  }

  cout << count << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, d, A;
  int count = 0;
  vector<bool> sunuke;
    
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    sunuke.push_back(false);
  }  
  
  for (int i = 0; i < K; i++) {
    cin >> d;
    
    for(int j = 0; j < d; j++) {
      cin >> A;
      sunuke.at(A - 1) = true;
    }  
  }
  
  for (int i = 0; i < N; i++) {
    if (sunuke.at(i) == false) {
      count++;
    }  
  }  
  
  cout << count << endl;
}  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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; }

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

  int ans = 0;
  for (int b = 1; b*b <= x; ++b) {
    int tmp = b*b;
    while (tmp*b <= x) {
      if (b == 1) break;
      tmp *= b;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int W = s.nextInt();
    int H = s.nextInt();
    int x = s.nextInt();
    int y = s.nextInt();
    int ans = 0;

    System.out.printf("%.6f ",(double)W*H/2);
    if((double)x == (double)W / 2 && (double)y == (double)H / 2)
      System.out.println(1);
    else
      System.out.println(0);
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

#define PN 1000000
int isprime[PN + 5];
int prime_cnt[PN + 5];
vector<long long> prime;
void primechk() {
	for (int i = 1; i <= PN; i++) isprime[i] = i;
	for (long long i = 2; i <= PN; i++)
		if (isprime[i] == i) {
			prime.push_back(i);
			for (long long j = i * i; j <= PN; j += i)
				isprime[j] = i;
		}
}

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


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

	primechk();
	
	int N; cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];
	vector<int> v2 = v;

	bool pairwise = 1;
	for (int i = 0; i < N; i++) {
		set<int> st;
		while (v2[i] != 1) {
			st.insert(isprime[v2[i]]);
			v2[i] /= isprime[v2[i]];
		}
		for (int i : st) prime_cnt[i]++;
	}
	for (int i = 2; i <= 1000000; i++)
		if (prime_cnt[i] >= 2) {
			pairwise = 0;
			break;
		}
	if (pairwise) {
		cout << "pairwise coprime";
		return 0;
	}

	ll g = gcd(v[0], v[1]);
	for (int i = 2; i < N; i++) g = gcd(g, v[i]);
	if (g == 1) {
		cout << "setwise coprime";
		return 0;
	}
	cout << "not coprime";

	return 0;
}


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

using namespace std;

int N, M;

vector<int> labels;
vector<vector<int>> adlist;

int DFS(int node) {
	for (int next : adlist[node]) {
		if (labels[next] == -1) {
			labels[next] = labels[node];
			DFS(next);
		}
	}
}

int main() {
	//連結成分の個数を求める問題
	cin >> N >> M;

	labels.resize(N + 1, -1);
	adlist.resize(N + 1);

	for (int i = 0; i < M; i++)
	{
		int x, y, z;
		cin >> x >> y >> z;
		adlist[x].push_back(y);
		adlist[y].push_back(x);
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (labels[i] == -1) {
			labels[i] = ans;
			DFS(i);
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			String S = scan.next();
			char[] s = new char[N];
			s = S.toCharArray();
			RGB []map = new RGB[N];
			for(int i = 0;i<N;i++) {
				map[i] = new RGB(s[i]);
			}
			
			for(int i = 0;i<N;i++) {
				if(map[i].S=='R') {
					for(int j = i+1;j<N;j++) {
						if(map[j].S=='G')map[i].G++;
						if(map[j].S=='B')map[i].B++;
					}
				}
				if(map[i].S=='G') {
					for(int j = i+1;j<N;j++) {
						if(map[j].S=='R')map[i].R++;
						if(map[j].S=='B')map[i].B++;
					}
				}
				if(map[i].S=='B') {
					for(int j = i+1;j<N;j++) {
						if(map[j].S=='R')map[i].R++;
						if(map[j].S=='G')map[i].G++;
					}
				}	
			}
			
			long goukei=0;
			
			for(int i = 0;i<N-2;i++){
				if(map[i].S=='R') {
					for(int j = i+1;j<N-1;j++) {
						if(map[j].S=='B') {
							int k = j-i;
							if(j+k<N&&map[j+k].S=='G')goukei-=1;
							goukei+=map[j].G;	
						}
						if(map[j].S=='G') {
							int k = j-i;
							if(j+k<N&&map[j+k].S=='B')goukei-=1;
							goukei+=map[j].B;	
						}
					}
				}
				if(map[i].S=='G') {
					for(int j = i+1;j<N-1;j++) {
						if(map[j].S=='R') {
							int k = j-i;
							if(j+k<N&&map[j+k].S=='B')goukei-=1;
							goukei+=map[j].B;	
						}
						if(map[j].S=='B') {
							int k = j-i;
							if(j+k<N&&map[j+k].S=='R')goukei-=1;
							goukei+=map[j].R;	
						}
					}
				}
				if(map[i].S=='B') {
					for(int j = i+1;j<N-1;j++) {
						if(map[j].S=='R') {
							int k = j-i;
							if(j+k<N&&map[j+k].S=='G')goukei-=1;
							goukei+=map[j].G;	
						}
						if(map[j].S=='G') {
							int k = j-i;
							if(j+k<N&&map[j+k].S=='R')goukei-=1;
							goukei+=map[j].R;	
						}
					}
				}	
			}
			
			
			System.out.println(goukei);
			
			
			
			
			
			
			
			
			
		}
		
		
	}
		

}
class RGB{
	char S;
	int R;
	int G;
	int B;
	RGB(char k){
		S = k;
	}
}

Measured memory_bytes: 40388
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;



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

	ll h, w;
	vector<ll> v;
	for (ll i = 1; i < 150; i++) {
		for (ll j = i + 1; j <= 150;j++) {
			v.push_back((i * i + j * j)*1000+i);
		}
	}
	sort(v.begin(), v.end());
	cin >> h >> w;
	while (h!=0&&w!=0) {
		ll z = (h * h + w * w) * 1000 + h;
		auto ans = upper_bound(v.begin(), v.end(), z);
		ll H = *ans % 1000;
		ll S = *ans / 1000 - H * H;
		
		cout << H << " ";
		for (int i = 1; i <= 150; i++) {
			if (S == i * i)cout << i << endl;
		}
		cin >> h >> w;
	}
}


Measured memory_bytes: 3288
N=int(input())
dictionary={}
for i in range(N):
    a=input()
    if a not in dictionary:
        dictionary[a] =1
    else:
        dictionary[a] +=1
dict_sorted = sorted(dictionary.items(), key=lambda x:x[0])
dict_sorted = sorted(dict_sorted, key=lambda x:x[1],reverse=True)
max_count=dict_sorted[0][1]
for i,j in dict_sorted:
    if j==max_count:
        print(i)

Measured memory_bytes: 46684
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n,k);
    vector<ll> vec(n),dp(n,2000000000000000000);
    in(vec);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i+j>=n)break;
            dp[i+j]=min(dp[i+j],dp[i]+abs(vec[i+j]-vec[i]));
        }
    }
    out(dp[n-1]);
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

template<typename T>
class SegTree {
public:
  int n;
  vector<T> data;
  SegTree(int m){
    n=1;
    while(n<m) n*=2;
    data.resize(2*n, 0);
  }
  T query(int l, int r){
    T ret = 0;
    for(l+=n, r+=n; l<r; l/=2, r/=2){
      if(l&1) ret = max(ret, data[l++]);
      if(r&1) ret = max(ret, data[--r]);
    }
    return ret;
  }
  void update(int k, T a){
    k+=n;
    data[k]=a;
    while(k>0){
      k = k/2;
      data[k] = max(data[k*2], data[k*2+1]);
    }
  }
  inline T operator[](int idx){ return data[idx+n]; }
};

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

  SegTree<long> st(n+5);
  rep(i,n){
    long pv = st.query(0,h[i]);
    st.update(h[i], pv + a[i]);
  }

  cout << st.query(0,n+5) << endl;

  return 0;
}


Measured memory_bytes: 6656
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            int ans = 0;
            char prev = 0;
            char current = 0;

            for (int i = 0; i < S.length(); i++) {
                current += S.charAt(i);
                if (current != prev) {
                    prev = current;
                    current = 0;
                    ans++;
                }
            }

            // 出力
            out.println(ans);

        }

    }
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	string s;
	cin>>s;
	int a=0, b=0;
	a=(s[0]-'0')*10+(s[1]-'0');
	b=(s[2]-'0')*10+(s[3]-'0');
	bool ok=false, ok2=false;
	if(a>0 && a<=12){
		ok=true;
	}
	if(b>0 && b<=12){
		ok2=true;
	}
	if(ok && ok2){
		cout<<"AMBIGUOUS"<<'\n';
		return 0;
	}
	if(ok){
		cout<<"MMYY"<<'\n';
		return 0;
	}
	if(ok2){
		cout<<"YYMM"<<'\n';
		return 0;
	}
	cout<<"NA"<<'\n';
	return 0;
}


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

using namespace std;

// dp[i][k][sum] := 先頭からi番目までの数字から k 枚選んだとき,
// 選んだ数字の総和を s にできる場合の数
long long dp[55][55][2550] = {0};

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

  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }

  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int k = 0; k <= i; k++) {
      for (int sum = 0; sum <= 2500; sum++) {
        dp[i + 1][k][sum] += dp[i][k][sum];
        dp[i + 1][k + 1][sum + x[i]] += dp[i][k][sum];
      }
    }
  }

  long long ans = 0;
  for (int k = 1; k <= n; k++) {
    ans += dp[n][k][k * a];
  }
  cout << ans << endl;

  return 0;
}


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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll num;
        cin >> num;
        A.push_back(num);
    }
    sort(A.begin(), A.end());
    ll lv = A.back();
    ll mv = A[0];
    for(int i=1;i<A.size()-1;i++) {
        if(A[i]>=0) {
            //cout << mv << " " << A[i] << endl;
            mv -= A[i];
        }
        else {
            //cout << lv << " " << A[i] << endl;
            lv -= A[i];
        }
    }
    //cout << lv << " " << mv << endl;
    cout << lv-mv << endl;
    lv = A.back();
    mv = A[0];
    for(int i=1;i<A.size()-1;i++) {
        if(A[i]>=0) {
            cout << mv << " " << A[i] << endl;
            mv -= A[i];
        }
        else {
            cout << lv << " " << A[i] << endl;
            lv -= A[i];
        }
    }
    cout << lv << " " << mv << endl;
    //cout << lv-mv << endl;
    return 0;
}

Measured memory_bytes: 2804
(let* ((n (read))
       (a 0)
       (b 0)
       (c 0)
       (d 0))
  (loop :for k :from 1 :upto n
        :for j := (read-line)
        :do(cond ((string= "AC" j) (incf a))
                 ((string= "WA" j) (incf b))
                 ((string= "TLE" j) (incf c))
                 ((string= "RE" j) (incf d))))
  (mapcar (lambda (a b)
            (format t "~A x ~A~%" a b)) '("AC" "WA" "TLE" "RE") `(,a ,b ,c ,d)))

Measured memory_bytes: 58968
#include <cstdio>

int main()
{
int x1, y1, x2, y2;
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

int i;
for (i = 0; i < x2 - x1; i++){
printf("R");
}
for (int i = 0; i < y2 - y1; i++){
printf("U");
}

for (i = 0; i < x2 - x1; i++){
printf("L");
}
for (i = 0; i < y2 - y1; i++){
printf("D");
}

printf("D");
for (i = 0; i < x2 - x1 + 1; i++){
printf("R");
}
for (i = 0; i < y2 - y1 + 1; i++){
printf("U");
}
printf("L");

printf("U");
for (i = 0; i < x2 - x1 + 1; i++){
printf("L");
}
for (i = 0; i < y2 - y1 + 1; i++){
printf("D");
}
printf("R\n");

return 0;
}


Measured memory_bytes: 128
s = input()
n = len(s)
s1 = s[:(n-1)//2]
s2 = s1[::-1]

s3 = s[(n+3)//2-1:]
s4 = s3[::-1]

s0 = s[::-1]

if s1 == s2 and s3 == s4 and s == s0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
using System;
using System.Linq;
class Program
{
    public static void Main()
    {
        int[] nab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        bool f = (nab[2] - nab[1]) % 2 == 0;
        Console.WriteLine(f ? "Alice" : "Borys");
    }
}

Measured memory_bytes: 13268
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int mode;
    int fie[100001];
    for(int i=0;i<N;i++)cin>>fie[i];
    if(N<=2){
        puts("1");
        return 0;
    }
    if(fie[0]<fie[1])mode=1;
    else if(fie[0]>fie[1])mode=2;
    else mode=3;
    int ans=1;
    for(int i=2;i<N;i++){
        if(mode==1&&fie[i-1]<=fie[i])continue;
        if(mode==2&&fie[i-1]>=fie[i])continue;
        if(mode==3&&fie[i-1]==fie[i])continue;
        if(mode==1&&fie[i-1]>fie[i]){
            ans++;
            if(fie[i]<fie[i+1])mode=1;
            else if(fie[i]>fie[i+1])mode=2;
            else mode=3;
            continue;
        }
        if(mode==2&&fie[i-1]<fie[i]){
            ans++;
            if(fie[i]<fie[i+1])mode=1;
            else if(fie[i]>fie[i+1])mode=2;
            else mode=3;
            continue;
        }
        if(mode==3&&fie[i-1]>fie[i]){
            mode=2;
            continue;
        }
        if(mode==3&&fie[i-1]<fie[i]){
            mode=1;
            continue;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int w, h, n;
  cin >> w >> h >> n;
  int left = 0, right = w, top = h, down = down;
  rep(i, n){
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1){
      left = max(left, x);
    } else if(a == 2){
      right = min(right, x);
    } else if(a == 3){
      down = max(down, y);
    } else {
      top = min(top, y);
    }
  }

  cout << max((right - left), 0) * max((top - down), 0) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] line_split = line.split(" ",0);

        int a = Integer.parseInt(line_split[0]);
        int b = Integer.parseInt(line_split[1]);

        int area = a * b;
        int circumference = (a * 2) + (b * 2);
        System.out.println(area+" "+circumference);
    }
}


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

typedef long long ll;
using namespace std;
 
int main (){
  ll a,b,x;
  ll ans;
  cin >> a >> b >> x;
  ans = (b / x) - (a / x);
	if (a%x == 0){
    ans++;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(N: int, A: "List[int]"):
    sortA = sorted(A)
    ans = YES
    for n, e in enumerate(sortA):
        if n != len(sortA)-1 and e == sortA[n+1]:
            ans = NO
            break
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

const int M=1e9+7;
vector<int>num;
int d;
int dp[100007][110][2];
void add_self(int&a, int b){
     a=a+b;
     if(a>=M)a=a-M;
}
int call(int index, int mod, int flag){

     if(index==num.size()){
          if(mod==0) return 1;
          return 0;
     }
     int&ans=dp[index][mod][flag];
     if(ans!=-1) return ans;

     ans=0;
     int limit;
     if(flag==0){
          limit=num[index];
     }
     else{
          limit=9;
     }

     for(int i=0;i<=limit;i++){
          int nflag=flag;
          int nmod=(mod+i)%d;
          if(flag==0 and i<limit) nflag=1;
          add_self(ans,call(index+1, nmod, nflag));
     }
     return ans;
}


int main(){
     memset(dp, -1, sizeof(dp));
     string s;
     cin>>s;
     cin>>d;

     for(int i=0;i<s.size();i++)num.push_back(s[i]-'0');
     cout<<(call(0, 0, 0)-1+M)%M;
}


Measured memory_bytes: 87296
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
#define P(r) do{for(auto i:r){cout<<i<<' ';}cout<<'\n';}while(0)
int main()
{
    int N; cin >> N;
    vector<Int> A(3*N); REP(i, 3*N) cin >> A[i];
    vector<Int> B(N+1), C(N+1);
    priority_queue<Int, vector<Int>, greater<Int>> Q1(A.begin(), A.begin() + N);
    priority_queue<Int> Q2(A.begin() + 2*N, A.begin() + 3*N);
    B[0] = accumulate(A.begin(), A.begin() + N, (Int)0);
    FOR(i, 1, N+1) {
        Q1.push(A[N+i-1]);
        Int t = Q1.top();
        Q1.pop();
        B[i] = B[i-1] - t + A[N+i-1];
    }
    C[0] = accumulate(A.begin() + 2*N, A.begin() + 3*N, (Int)0);
    FOR(i, 1, N+1) {
        Q2.push(A[2*N-i]);
        Int t = Q2.top();
        Q2.pop();
        C[i] = C[i-1] - t + A[2*N-i];
    }
    FOR(i, 1, N+1) C[i] = min(C[i], C[i-1]);
    Int res = numeric_limits<Int>::min();
    REP(i, N+1) res = max(res, B[i] - C[N-i]);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    vector<LL> vc(n);
    
    for(int i=0; i<n; i++){
        cin >> vc[i];
    }
    
    LL res = INT_MIN;
    LL temp = vc[0];
    
    for(int i=1; i<n; i++){
        res = max(res,vc[i]-temp);
        temp = min(temp, vc[i]);
    }
    
    cout << res << endl;
    
    return 0;
    
}

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

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  int A;
  int ans=0;
  for (int i=0;i<M;i++){
    cin >> A;
    if (A<X){
      ans++;
    }
    else{
      break;
    }
  }
  ans=min(ans,M-ans);
  cout << ans << endl;
}


Measured memory_bytes: 256
def valid?(a, b, c)
  a <= b + c && b <= c + a + 1 && c <= a + b + 1
end
 
def calc(rear, front, west, east, north, south, best)
  path = []
  loop do
    a = rear + front
    b = west + east
    c = north + south
 
    return path if a + b + c == 0
 
    if east > 0 && valid?(b - 1, c, a)
      rear, front, west, east = east - 1, west, rear, front
      y = 69
    elsif north > 0 && valid?(c - 1, a, b)
      rear, front, north, south = north - 1, south, front, rear
      y = 78
    elsif south > 0 && valid?(c - 1, a, b)
      rear, front, north, south = south - 1, north, rear, front
      y = 83
    #elsif west > 0 && valid?(b - 1, c, a)
    else
      rear, front, west, east = west - 1, east, front, rear
      y = 87
    end
     
    if best
      x = best[path.size].ord
      return best if x < y
      best = nil if x > y
    end
    path << y  
  end
end
 
def find(target)
  best = nil
  target.permutation(6).to_a.uniq.each do |rear, front, west, east, north, south|
    a = rear + front
    b = west + east
    c = north + south
    if valid?(a, b, c)
      best = calc(rear, front, west, east, north, south, best)
    end
  end
  best
end
 
loop do
  target = gets.split.map!(&:to_i)
  break if target.all?(&:zero?)
  p, q = gets.split.map!(&:to_i)
  result = find(target)
  puts result ? result[p-1...q].pack('C*') : 'impossible'
end

Measured memory_bytes: 73564
#include<stdio.h>

int c1;
int array1[1000];

int exhaustive(int i, int a2){

  if(a2==0){return 1;}
  if(i>=c1){return 0;}

  

  int ans=( exhaustive (i+1,a2) || exhaustive(i+1,a2-array1[i]));
    
    return ans;
}



int main(void){
  
  
  scanf("%d",&c1);
  

  int i;



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


  
  int c2;
  scanf("%d",&c2);



  
  int array2;


  
  for(i=0;i<c2;i++){


    
    scanf("%d",&array2);

    if(exhaustive(0, array2)) {printf("yes\n");}
    else {printf("no\n");}


   }

 
  
  return 0;
}




Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 998244353, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 305;
int n, m, a[N][N], cnt[N], pw[N], equation[N][N], ans[N];
void add(int &x, int y) {
	x += y; if (x >= mod) x -= mod;
}
int rem(int x, int y) {
	x -= y;
	if (x < 0) x += mod;
	return x;
}
int mul(int x, int y) {
	return 1ll * x * y % mod;
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	pw[0] = 1;
	fw (i, 1, N) pw[i] = mul(pw[i - 1], 2);
	cin >> n >> m;
	fw (i, 0, n) {
		fw (j, 0, m) cin >> a[i][j];
	}
	//Fix subset of rows, if there is at least 1 odd column answer is 2 ^ (m - 1), else 0.
	//Count subset of rows that there are no odd columns. Use Gauss.
	fw (j, 0, m) ans[j] = 0;
	fw (j, 0, m) {
		fw (i, 0, n) equation[j][i] = a[i][j];
	}
	int cnt = 1, ptr = 0;
//	fw (lol, 0, m) {
//		cout << "Equation " << lol << ": ";
//		fw (lol2, 0, n) cout << equation[lol][lol2] << " ";
//		cout << "\n";
//	}
	fw (i, 0, n) {
//		cout << "Variable " << i << "\n";
		bool have1 = 0;
		fw (j, ptr, m) if (equation[j][i]) have1 = 1;
		if (have1) {
			fw (j, ptr, m) if (equation[j][i]) {
				fw (k, 0, n) swap(equation[j][k], equation[ptr][k]);
				swap(ans[j], ans[ptr]);
//				cout << "swap equation " << j << " with " << ptr << "\n";
				break;
			}
			fw (j, ptr + 1, m) if (equation[j][i]) {
				fw (k, 0, n) equation[j][k] ^= equation[ptr][k];
				ans[j] ^= ans[ptr];
			}
			ptr++;
		}
//		fw (lol, 0, m) {
//			cout << "Equation " << lol << ": ";
//			fw (lol2, 0, n) cout << equation[lol][lol2] << " ";
//			cout << "\n";
//		}
	}
	cnt = pw[n - ptr];
	cnt = rem(pw[n], cnt);
	cnt = mul(cnt, pw[m - 1]);
	cout << cnt;
	return 0;
}


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

int main(){
	int a,b,d,r;
	double f;

	cin>>a>>b;
	if(a==0||b==0){
		cout<<"0 0 0"<<endl;
		return 0;
	} 
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	cout<<d<<" "<<r<<" "<<fixed<<setprecision(5)<<f<<endl;
	return 0;
}

Measured memory_bytes: 3228
//abc129_c.cpp
//Sat Aug 10 20:37:35 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;


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

	int ok[n+1];
	fill(ok,ok+n+1,1);
	for (int i=0;i<m;i++){
		int temp;
		cin >> temp;
		ok[temp] = 0;
	}

	ll MOD = 1000000007;
	ll dp[n+1];
	fill(dp,dp+n+1,0);
	dp[0] = 1;dp[1] = 1;
	for (int i=2;i<=n;i++){
		if (ok[i]){
			if (ok[i-1]){
				dp[i] = (dp[i]+dp[i-1])%MOD;
			}
			if (ok[i-2]){
				dp[i] = (dp[i]+dp[i-2])%MOD;
			}
		}
	}

	cout << dp[n] << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define fast ios::base_sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;


signed main(){
    int n; cin >> n;
    int ans = 0 ;
    int mn = INT_MAX;
    for(int i=1; i<=n; i++){
        int x; cin >> x;
        if(mn >= x)
            mn = x;
        if(mn == x)
            ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰回数の上限を変更
N=int(input())

ans=""
for i in range(1,99):
    if N<=26**i:
        N-=1
        for j in range(i):
            ans+=chr(ord("a")+N%26)
            N //=26
        break
    else:
        N-=26**i

print(ans[::-1])


Measured memory_bytes: 9180
input_num = [int(s) for s in input().split()]
N = input_num[0]
Y = input_num[1]
flag = False
result = str(-1) + str(' ') + str(-1) + str(' ') + str(-1)

for x in range(N+1):
  for y in range(N+1-x):
    z = N-x-y
    if 10000*x + 5000*y + 1000*z == Y:
      result = str(x) + str(' ') + str(y) + str(' ') + str(z)
      flag = True
      
print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int inf=1e8;
int h,w,s[110][110],sx,sy,f[2][110][110][110];
char a[110][110];
void clear(int t)
{
	for (int u=0;u<sx;u++)
	{
		for (int r=0;r<=w-sy;r++)
		{
			for (int d=0;d<=h-sx;d++)
			{
				f[t][u][r][d]=-inf;
			}
		}
	}
}
int ask(int xa,int ya,int xb,int yb)
{
	if (xa>xb || ya>yb)
	{
		return 0;
	}
	return s[xb][yb]+s[xa-1][ya-1]-s[xb][ya-1]-s[xa-1][yb];
}
void upd(int &x,int v)
{
	x=max(x,v);
}
int main()
{
	scanf("%d%d",&h,&w);
	for (int i=1;i<=h;i++)
	{
		scanf("%s",a[i]+1);
	}
	for (int i=1;i<=h;i++)
	{
		for (int j=1;j<=w;j++)
		{
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
			if (a[i][j]=='o')
			{
				s[i][j]++;
			}
			if (a[i][j]=='E')
			{
				sx=i;
				sy=j;
			}
		}
	}
	int p=1;
	clear(p^1);
	f[p^1][0][0][0]=0;
	for (int l=0;l<sy;l++)
	{
		clear(p);
		p^=1;
		for (int u=0;u<sx;u++)
		{
			for (int r=0;r<=w-sy;r++)
			{
				for (int d=0;d<=h-sx;d++)
				{
					int v=f[p][u][r][d];
					if (v<0)
					{
						continue;
					}
					int tmp;
					if (l+r+1<sy)
					{
						tmp=ask(max(d+1,sx-u),sy-l-1,min(h-u,sx+d),sy-l-1);
					}
					else
					{
						tmp=0;
					}
					upd(f[p^1][u][r][d],v+tmp);
					if (u+d+1<sx)
					{
						tmp=ask(sx-u-1,max(r+1,sy-l),sx-u-1,min(w-l,sy+r));
					}
					else
					{
						tmp=0;
					}
					upd(f[p][u+1][r][d],v+tmp);
					if (l+r+sy<w)
					{
						tmp=ask(max(d+1,sx-u),sy+r+1,min(h-u,sx+d),sy+r+1);
					}
					else
					{
						tmp=0;
					}
					upd(f[p][u][r+1][d],v+tmp);
					if (u+d+sx<h)
					{
						tmp=ask(sx+d+1,max(r+1,sy-l),sx+d+1,min(w-l,sy+r));
					}
					else
					{
						tmp=0;
					}
					upd(f[p][u][r][d+1],v+tmp);
				}
			}
		}
	}
	cout<<f[p][sx-1][w-sy][h-sx]<<endl;
	return 0;
}
//南有乔木，不可休思。
//——《国风·周南·汉广》

Measured memory_bytes: 10496
#include <iostream>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int N;
int a[100005];

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> a[i];
	sort(a, a+N);
	
	int ans = -1;
	auto p = upper_bound(a, a+N, a[N-1]/2);
	if(p != a+N && *p != a[N-1]){
		ans = *p;
	}
	if(p != a){
		if(abs(ans - a[N-1]/2) > abs(*(p-1) - a[N-1]/2)) ans = *(p-1);
	}
	
	cout << a[N-1] << " " << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(ll i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    ll n,w;
    cin>>n>>w;
    ll wgt[n],val[n];
    rep(i,0,n)
    cin>>wgt[i]>>val[i];
    ll dp[n+1][w+1];
    repA(i,0,n)
    {
        repA(j,0,w)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(wgt[i-1]<=j)
            {
                dp[i][j]=max(val[i-1]+dp[i-1][j-wgt[i-1]],dp[i-1][j]);
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 79104
k, x = map(int, input().split())
a = max(-1000000, x-k+1)
b = min(1000000, x+k-1)
#print(a, b)

ans = []
for i in range(a, b+1):
    ans.append(str(i))

#print(ans)

ans = ' '.join(ans)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){

    int n; cin >> n;
    for(;;n++){
        string s = to_string(n);
        if(s[0] == s[1] && s[1] == s[2]){
            cout << n << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"import math\n"
"def f(x):return math.factorial(x)\n"
"def g(x):return f(x)//(f(x-2)*f(2))if x>1else 0\n"
"n,m=map(int,input().split())\n"
"b=0\n"
"c={}\n"
"for a in input().split():\n"
"  b+=int(a)\n"
"  c[b%m]=c.get(b%m,0)+1\n"
"print(sum(map(lambda x:g(x),c.values()))+c.get(0,0))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 16320
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  
  int main(){
     double a,b,h,m;
     cin>>a>>b>>h>>m;
     double x=h*30+m/2;
     double y=m*6;
     double z=abs(x-y);
     if(z>180)z=360-z;
     z*=acos(-1);
     z/=180;
     double ans=sqrt(a*a-2*a*b*cos(z)+b*b);
    printf("%.11f",ans);

  } 
      
      
    

  
          
  

Measured memory_bytes: 4224
# Aizu Problem ITP_1_6_A: Reversing Numbers
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

N = int(input())
A = [int(_) for _ in input().split()]
print(' '.join([str(a) for a in A[::-1]]))

Measured memory_bytes: 7712
#include <iostream>
#ifndef _LOCAL_DEBUG
#define endl '\n'
#endif
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	int a, b;
	a = t / 500;
	t -= a * 500;
	b = t / 5;
	cout << 1000 * a + b * 5 << endl;

	return 0;
}

Measured memory_bytes: 256