akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

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



signed main(){

    double T, X; cin >> T >> X;
    cout << setprecision(15) << T / X << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

set<int> st;

int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    int n;
    cin >> n;
    int res = 0;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        if (st.empty() || *st.begin() >= x){
            res++;
        }
        st.insert(x);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int main(){
    int w;
    int h;
    int x;
    int y;
    int r;
    cin >> w >> h >> x >> y >> r;
    if((x >= r) && (x <= w - r) && (y >= r) && (y <= h - r)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3120
#include<cstdio>
using namespace std;

int N,t[3],u[3];

int change(int a){
  if(11<=a&&a<=14)return 0;
  else if(18<=a&&a<=20)return 1;
  else if(21<=a||a<=1)return 2;
  return -1;
}
int main(){
  while(1){
    scanf("%d",&N);
    if(N==0)break;
    for(int i=0;i<3;i++)t[i]=u[i]=0;
    for(int i=0;i<N;i++){
      int a,b,c,x;
      scanf("%d%*c%d%d",&a,&b,&c);
      x=change(a);
      if(x==-1)continue;
      c=c-b;
      if(c<0)c+=60;
      if(c<=8)t[x]++;
      u[x]++;
    }

    if(u[0])
      printf("lunch %d\n",100*t[0]/u[0]);
    else 
      printf("lunch no guest\n");

    if(u[1])
      printf("dinner %d\n",100*t[1]/u[1]);
    else printf("dinner no guest\n");

    if(u[2])
      printf("midnight %d\n",100*t[2]/u[2]);
    else printf("midnight no guest\n");
  }
  return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define forx(i,j,n) for(int i=j;i<n;i++)
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false)
#define testcase int t; cin>>t
#define inputi(xx) scanf("%d",&xx)
#define inputll(xx) scanf("%lld",&xx)
#define printi(xx) printf("%d",xx)
#define printll(xx) printf("%d",xx)

ll fun(ll a,ll b,ll c){
    ll ans=0;
    ans+=b/c;
    ans-=a/c;
    if(a%c==0) ans++;
    return ans;
}

int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=fun(a,b,c)+fun(a,b,d)-fun(a,b,1LL*(c*d/__gcd(c,d)));
    cout<<b-a+1-ans;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
ans = 0.0
prob = [1.0 / 2 ** i for i in range(20)]
for s in range(1, n + 1):
	t = 0
	while s < k:
		t += 1
		s *= 2
	ans += prob[t]
print(ans / n)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException
	{
		int m,f,r,sum;

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

		for(int i=0; i<255; i++)
		{
			String[] mfr = br.readLine().split(" ");
			m = Integer.parseInt(mfr[0]);
			f = Integer.parseInt(mfr[1]);
			r = Integer.parseInt(mfr[2]);

			sum = m+f;

			if(sum+r == -3)  break;

			else if(m*f < 0 || sum < 30) System.out.println("F");

			else if(30 <= sum && sum < 50) System.out.println( (50 <= r) ? 'C' : 'D');

			else if(50 <= sum && sum < 65) System.out.println("C");

			else if(65 <= sum && sum < 80) System.out.println("B");

			else if(80 <= sum ) System.out.println("A");

		}
	}
}

Measured memory_bytes: 24228
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[102],b[1002],m,n;
  for(i=0;i<102;i++)
    a[i]=(int)pow(i,3);
  for(i=0;i<1002;i++)
    b[i]=(int)pow(i,2);
  while(cin>>n&&n){
    m=2000000000;
    for(i=0;a[i]<=n;i++)
      for(j=0;b[j]<=n-a[i];j++)
	m=min(m,n-a[i]-b[j]+i+j);
    cout<<m<<endl;
  }
  return 0;
}

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

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

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

    rep(i, 9) {
        rep(j, 9) {
            if (((i + 1) * (j + 1)) == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long double a,b,n,s,c;
  while(cin >> a >> b >> n){
    s = 0;
    c = a/b;
    a = a - b * (int)c;
    a *= 10;
    rep(i,n){
      c = a/b;
      a = a - b * (int)c;
      a *= 10;
      s += (int)c % 10;
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int main(void) {
  int N, L;
  cin >> N >> L;
  int apple[N + 1];
  int i, yotei = 0;
  for(i = 1; i < N + 1; i++) {
    apple[i] = i + L - 1;
    yotei += apple[i];
  }

  int eat = apple[1];
  for (i = 2; i < N + 1; i++) {
    if (abs(0 - apple[i]) < abs(0 - eat)) {
      eat = apple[i];
    }
  }

  int real = yotei - eat;

  cout << real << endl;
 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;
#include <iomanip>

void comb(vector<vector <long long int> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}
int main(int argc, char const *argv[]) {
  ll s=0, n, a, b;std::cin >> n >> a >> b;
  vll v(n), x;
  vector<vector<long long int> > V(51,vector<long long int>(51,0));
  comb(V);
  multiset<ll> z, y;
  re(i, n) {
    std::cin >> v[i];
    z.insert(v[i]);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());

  re(i, b){
    if(i<a) s+=v[i];
    if(i>=a&&v[i]<v[a-1]) break;
    x.push_back(v[i]);
    y.insert(v[i]);
  }
  std::cout << fixed << setprecision(10) << (ld)((ld)s/(ld)a) << '\n';
  ll ans = 0;
  if(y.count(*y.begin())==x.size()){
    for(int i=a;i<=min(b, (ll)z.count(*y.begin()));i++){
      ans+=V[z.count(*y.begin())][i];
    }
  }else{
    ans = V[z.count(*y.begin())][a-(x.size() - y.count(*y.begin()))];
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main(void){

  int i, a, b, c, n;

  n = 0;

  scanf("%d %d %d", &a, &b, &c);

  for(i=a;i<b+1;i++){
    if(c%i == 0){
      n++;
    }
  }

  printf("%d\n", n);

  return 0;

}



Measured memory_bytes: 2104
n=int(input())
info=[]
for i in range(n):
    info.append(list(map(int,input().split())))
    
info.sort(key=lambda x:x[1])

sum_task=0
for i in range(n):
    sum_task+=info[i][0]
    if sum_task>info[i][1]:
        print("No")
        break
    else:
        if i==n-1:
            print("Yes")

Measured memory_bytes: 53720
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  const int p = 37;
  const int k = p+1;
  const int n = k*(k-1)+1;

  VV a(n);
  a[0].push_back(1);
  rep(i, k) rep(j, k-1) {
    int x = i*(k-1) + j + 1;
    a[i].push_back(x+1);
    a[x].push_back(i+1);
  }

  VV b(k-1, V(k-1));
  rep(i, k-1) rep(j, k-1) b[i][j] = i*j%(k-1);

  rep(i, k-1) rep(j, k-1) rep(l, k-1) {
    int x = i*(k-1) + j + k;
    int y = (b[i][l] + j)%(k-1) + l*(k-1) + k;
    a[x].push_back(y+1);
  }

  cout << n << ' ' << k << '\n';
  rep(i, n) cout << a[i] << '\n';
  return 0;
}


Measured memory_bytes: 3728
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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



int main(){
    char c; cin >> c;
    cout << (char)(c+1) << endl;
    return 0;
}


Measured memory_bytes: 764
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if((a+b) % 2 == 0){
            System.out.println((a+b)/2);
        }else{
            System.out.println("IMPOSSIBLE");
        }
    }
}

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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]\n";}

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

	int n, l; cin >> n >> l;
	vector<ii> a(n);
	ll sum = 0;
	FOR (i, 0, n - 1) cin >> a[i].F, a[i].S = i, sum += a[i].F;
	vi ans;
	while (sz(a) > 2 and a[sz(a) - 1].F + a[sz(a) - 2].F < l) {
		if (sum >= l) {
			ans.push_back(a.back().S);
			sum -= a.back().F;
			a.pop_back();
		}
		else {
			cout << "Impossible\n";
			return 0;
		}
	}
	if (sz(a) > 1) {
		FOR (i, 0, sz(a) - 2) {
			if (sum >= l)
				ans.push_back(a[i].S + 1), sum -= a[i].F;
			else {
				cout << "Impossible\n";
				return 0;
			}
		}
	}
	cout << "Possible\n";
	for (int i: ans) cout << i << "\n";
	return 0;
}


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

vector<bool> used;
vector<int> perm;
vector<vector<int>> path;
int count = 0;

bool check(vector<int> vec, int point){
  for(auto v: vec){
    if(v == point) return true;
  }
  return false;
}

void permutation(int pos, int num){
  if(pos == num){
   	//ポイント同士がつながっているか調べる
    if(!check(path[0], perm[0]+1)) return;
    for(int i=0; i<perm.size(); i++){
      if(i == perm.size()-1){
        count++;
        return;
      }else if(!check(path[perm[i]+1], perm[i+1]+1)){
        return;
      }
    }
  }else{
    for(int i=0; i<num; i++){
      if(!used[i]){
        perm[pos] = i;
        used[i] = true;
        permutation(pos+1, num);
        used[i] = false;
      }
    }
  	return;
  }
}     

int main(){
  int n, m;
  cin >> n >> m;
  for(int i=0; i<n-1; i++){
    used.push_back(false);
    perm.push_back(0);
  }
  for(int i=0; i<n; i++){
    path.push_back(vector<int>());
  }
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    path[a-1].push_back(b-1);
    path[b-1].push_back(a-1);
  }
  permutation(0, n-1);
  cout << count << endl;
  return 0;
}
  

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

const long long int MAX = 1e18;

int main() {
  int n = 0;
  cin >> n;
  long long int a,ans = 1;
  bool over = false;
  

  for(int i = 0; i < n; i++){
    cin >> a;
    
    if(a == 0){
      ans = 0;
      break;
    }
    if (over) continue;
	if(a <= MAX/ans){
      ans *= a;
    }
    else {
      ans = -1;
      over = true;
    }
  }
        
    
    
  cout << ans << endl;
  return 0;
  
  
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n , a , b , ans , times , rem;
    cin >> n >> a >> b;
    if(a == 0){
        ans = 0;
        cout << ans;
        return 0;
    }
    if(b == 0){
        cout << n;
        return 0;
    }
    times = (n / (a + b));
    ans = times * a;
    rem = n % (a + b);
    if(rem <= a)
        ans += rem;
    else
        ans += a;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//組み合わせの数
//1 <= x の値を3つ使ってnを作成

//1,6,2
//1,5,3

int main(){
    //std::ifstream in("resource/input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int R,C;
    cin >> R >> C;

	int a[R][C];

	int rSum[R] = {};
	int cSum[C] = {};
	int iSum = 0;

	REP(i,R)
	{
		REP(j,C)
		{
			cin >> a[i][j];
			rSum[i] += a[i][j];
			cSum[j] += a[i][j];
			iSum += a[i][j];
		}
	}

	REP(i,R)
	{
		REP(j,C)
		{
			cout << a[i][j];
			cout << " ";
		}
		cout << rSum[i] << endl;
	}
	REP(j,C)
	{
		cout << cSum[j];
		cout << " ";
	}
	cout << iSum << endl;


    return 0;    
}




Measured memory_bytes: 3132
import java.util.*;
//System.out.println("")

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int cnt = 0;
        for(int i=0; i<n; i++){
            int a = sc.nextInt();
            int b =Math.min(a*2,(k-a)*2);
            if(b<0){
                cnt -= b;
            }else{
                cnt += b;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21844
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main()
{
  int n = readln.chomp.to!int;
  string s = readln.chomp;
  int leftW = 0;
  int rightE = 0;
  foreach (c; s) {
    if (c == 'E') {
      ++rightE;
    }
  }
  int ans = int.max;
  foreach (c; s) {
    if (c == 'E') {
      --rightE;
    }
    ans = min(ans, leftW + rightE);
    if (c == 'W') {
      ++leftW;
    }
  }
  ans.writeln;
}


Measured memory_bytes: 2812
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	var ab [100]bool
	for i := a; i < b; i++ {
		ab[i] = true
	}
	cnt := 0
	for i := c; i < d; i++ {
		if ab[i] {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5, Mod = 1e9 + 7;
int n;
char s[Maxn];
ll pw[Maxn], ans, p2 = 1;
int main()
{
	int cnt = 0;
	pw[0] = 1;
	for (int i = 1; i <= 100002; i++)
		pw[i] = pw[i - 1] * 3 % Mod;
	int a;
	cin >> s + 1;
	n = strlen(s + 1);
	for (int i = 1; i <= n; i++)
		if (s[i] != '0')
		{
			ans = (ans + p2 * pw[n - i] % Mod) % Mod;
			p2 = p2 * 2 % Mod;
		}
	cout << (ans + p2)%Mod << endl;
	return 0;
}


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

int main(){
	int N, ans = 1;
	string S;
	
	cin>>N>>S;
	
	for(int i = 1; i < N; i++)
		if(S[i] == S[i-1]&&S[i] == 'x')break;
		else ans++;
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3336
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define oprecision    \
  cout.precision(30); \
  cerr.precision(7);
#define ll long long
#define ld long double
#define ss string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define forn(n) for (int i = 1; i <= n; i++)
#define forlr(l, r) \
  for (int i = l; (l > r ? i >= r : i <= r); (l > r ? i-- : i++))
#define pb push_back
#define pc __builtin_popcount
#define pcll __builtin_popcountll
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
using namespace std;
ss s;
int main() {
  speed;
  oprecision;
  // code
  cin >> s;
  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes\n" : "No\n");
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,W=map(int,input().split())
    WV=[tuple(map(int,input().split())) for _ in range(n)]

    dp=[-INF]*(W+1)
    dp[0]=0
    for w,v in WV:
        for x in range(W,-1,-1):
            if(x+w<=W):
                dp[x+w]=max(dp[x+w],dp[x]+v)

    print(max(dp))
resolve()

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

using namespace std;

typedef long long llint;

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B), x(M), y(M), c(M);
  for (int i = 0; i < A; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < B; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> x[i] >> y[i] >> c[i];
  }
  int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
  for (int i = 0; i < M; i++) {
    int m = a[x[i] - 1] + b[y[i] - 1] - c[i];
    ans = min(ans, m);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2176
n = int(input())
sticks = list(map(int, input().split()))
cnt = 0
for i in range(0, n):
    for j in range(i+1, n):
        if sticks[i] == sticks[j]: continue

        for k in range(j + 1, n):
            if sticks[i] == sticks[k] or sticks[j] == sticks[k]: continue
            
            if sticks[i] + sticks[j] > sticks[k] and sticks[i] + sticks[k] > sticks[j] and sticks[j] + sticks[k] > sticks[i]:
                cnt+=1

print(cnt)

Measured memory_bytes: 9208
#include <iostream>
 
using namespace std;
 
    int TIME = 0;
    int d[101];
    int f[101];
    int num;
    int graph[101][101] = {0};
 
void dfs(int x){
    TIME++;
    d[x] = TIME;
 
    for(int i=1;i<=num;i++){
        if(graph[x][i] == 1 && d[i]==0){
            dfs(i);
        }
    }
    f[x] = ++TIME;
}
 
int main(){
    int hon;
    int eda;
    int ver;
 
    cin>>num;
    for(int i=0;i<num;i++){
        cin>>eda;
        cin>>hon;
        for(int j=0;j<hon;j++){
            cin>>ver;
            graph[eda][ver]++;
        }
    }
     
    for(int i=1;i<=num;i++){
        if(d[i]==0)
            dfs(i);
    }
 
    for(int i=1;i<=num;i++){
        cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
    }
 
    return 0;
}

Measured memory_bytes: 1200
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int n;
vector<vector<int>> a;
ll memo[100100][3];

ll dp(int i, int j){
    if(i == -1) return 0;
    if(memo[i][j] != 0) return memo[i][j];
    ll res = 0;
    for(int k = 0; k < 3; k++){
        if(k == j) continue;
        res = max(res, dp(i - 1, k) + a[i][k]);
    }

    return memo[i][j] = res;
}

int main(void){
    cin >> n;
    a.resize(n);

    for(int i = 0; i < n; i++){
        a[i].resize(3);
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
        }
    }

    cout << dp(n - 1, -1) << endl;
    
}

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

int main()
{
  string s, t, u;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  cin >> u;
  if (s == u)
  {
    a--;
  }
  if (t == u)
  {
    b--;
  }
  cout << a << " " << b << endl;
}
    

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

int l;
int compare_char(const void*a, const void* b) {
    return strncmp(*(char**)a, *(char**)b, l);
}

int main(void) {
    char **input;
    char *output;
    int n;
    char str[128];
    int i;
    char *p;
    
    output = fgets(str, 128, stdin);
    for(i=0;i<128;i++){
        if(str[i] == ' '){
            str[i] = '\0';
            n = atoi(str);
            l = atoi(&str[i+1]);
            break;
        }
    }

    input = malloc(n * sizeof(char*) + n * (l + 2));
    output = malloc(n * (l+2));
    for(i=0;i<n;i++){
        input[i] = (char*)input + (n * sizeof(char*)) + (i * (l+2));
        fgets(input[i], l + 2, stdin);
    }
    
    qsort(input, n, sizeof(char*), compare_char);
    p = output;
    for(i=0;i<n;i++){
        p += snprintf(p, l+1, "%s", input[i]);
        p--;
    }

    printf("%s\n", output);
    free(input);
    free(output);

    return 0;
}


Measured memory_bytes: 256
#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
using namespace std;

int main(){
    bool p=true;
    int x,y;
    string S;
    cin>>S;
    string T;
    cin>>T;
x=S.size(); y=T.size();
if(x==y-1){
for(int i=0;i<x;i++){
    if(S[i]!=T[i]){p=false;break;}
    else  p=true;
    }}
else p=false;

if(p)cout<<"Yes";
else cout<<"No";
return 0;
}

Measured memory_bytes: 2996
S = list(input())
T = list(input())
d = {}
e = {}
flag = 1

for i in range(len(S)):
    if S[i] not in d:
        d[S[i]] = T[i]
    else:
        if d[S[i]] != T[i]:
            flag = 0
            break

for i in range(len(S)):
    if T[i] not in e:
        e[T[i]] = S[i]
    else:
        if e[T[i]] != S[i]:
            flag = 0
            break



if flag == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 6704
import array
import textwrap
import math
mod = 10 ** 9 + 7
def prime(end, typecode="L"):
    assert end > 1
    # 整数iが素数であるかをis_prime[i]が示す
    # 最初はすべてTrueで初期化しておく
    # 最終的にprimesではなくこれを返してもよい
    is_prime = array.array("B", (True for i in range(end)))
    # 0, 1はいずれも素数ではない
    is_prime[0] = False
    is_prime[1] = False
    # 素数を格納する配列
    primes = array.array(typecode)
    # 篩う
    for i in range(2, end):
        if is_prime[i]:  # iが素数であるとき
            primes.append(i)  # 素数の配列に加える
            for j in range(2 * i, end, i):  # iを超えるiの倍数について
                is_prime[j] = False  # 素数ではないため除外する
    return primes.tolist()

n = int(input())
a = prime(n+1)
ans = 1
for i in a:
  b = 0
  c = i
  while c <= n:
    b += n // c
    c = c * i
  b += 1
  ans *= b
  ans %= mod
print(ans)

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, M;
    cin >> N >> M;
    unordered_map<ll, ll> mp;
    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        if (a == 1) {
            ++mp[b];
        }
        if (b == N) {
            ++mp[a];
        }
    }

    bool ok = false;
    for (const auto& p : mp) {
        if (p.second >= 2) {
            ok = true;
            break;
        }
    }

    cout << (ok ? "POSSIBLE\n" : "IMPOSSIBLE");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 8520
n=int(input())
m=1000

def calc(n):
    ans=0
    for i in range(len(n)):
        ans+=int(n[i])
    return ans

for i in range(1,n):
    a=i
    b=n-i
    m=min([calc(str(a))+calc(str(b)),m])

print(m)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N,K;
  cin >> N >> K;
  
  int num = 1;
  
  for (int i = 0; i < N; i++){
     if(num * 2 >= num + K){
     	num += K;
     }else{
     	num *= 2;
     }
  }
 
  cout << num << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

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

	int n = scan.nextInt();
	int[] a = new int[n];
	for(int i = 0; i < n; i++){
	    a[i] = scan.nextInt()-1;
	}

	int i = 0;
	int count = 1;
	while(true){
	    if(a[i] == 1){
		break;
	    }else if(a[i] == -1){
		break;
	    }else{
		int tmp = i;
		i = a[i];
		a[tmp] = -1;
		count++;
	    }
	}

	if(a[i] == -1){
	    System.out.println(-1);
	}else{
	    System.out.println(count);
	}
    }
}


Measured memory_bytes: 51788
n = int(input())
p = [int(i) for i in input().split()]

tmp = [0]*n

for i in range(len(p)):
    if i+1 == p[i]:
        tmp[i] = 0
    else:
        tmp[i] = 1

ans = sum(tmp)

if ans == 0 or ans == 2:
    print("YES")
else:
    print("NO")

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

int main(){
  bool d[20][30];
  string name[20];
  int n,p[20],m[20];

  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++){
      p[i] = 0;
      for(int j=0;j<30;j++)d[i][j] = false;
    }

    for(int i=0;i<n;i++){
      cin >> name[i] >> m[i];
      int tmp;
      for(int j=0;j<m[i];j++){
	cin >> tmp;
	d[i][tmp] = true;
      }
    }
    
    for(int i=0;i<30;i++){
      int sum = 0;
      for(int j=0;j<n;j++){
	if(d[j][i])sum++;
      }
      for(int j=0;j<n;j++){
	if(d[j][i])p[j] += n-sum+1;
      }
    }
    
    int num = 0;
    for(int i=1;i<n;i++){
      if(p[i] < p[num])num = i;
      else if(p[i] == p[num] && name[i] < name[num])num = i;
    }

    cout << p[num] << " " << name[num] << endl;
  }
}

Measured memory_bytes: 0
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long

using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	int x;

	scanf("%d",&x);
	int take = x/500;
	x-=(take*500);
	ll ans = (ll)(take) * 1000 + (x/5) * 5;
	printf("%lld\n",ans );
}


Measured memory_bytes: 256
INF = float("inf")
N = int(input())
H = list(map(int, input().split()))+[0]
DP = [0] + [INF] * (N + 1)
for i in range(N-1):
    DP[i+2] = min(DP[i+2], DP[i]+abs(H[i]-H[i+2]))
    DP[i+1] = min(DP[i+1], DP[i]+abs(H[i]-H[i+1]))
print(DP[N-1])

Measured memory_bytes: 13928
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    int r,g,b;
    cin>>r>>g>>b;
    int p=100*r+10*g+b;
    if(p%4==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
Q, H, S, D = map(int, input().split(' '))
N = int(input())

p3 = min([4 * Q, 2 * H, S])
p4 = min([2 * p3, D])


n4 = N // 2
n3 = N - n4 * 2

ans =  p3 * n3 + p4 * n4


print(int(ans))

Measured memory_bytes: 38256
from itertools import accumulate

N,M,Q=map(int,input().split())
table=[[0]*(N+1) for _ in range(N+1)]
for i in range(M):
    l,r=map(int,input().split())
    table[l][r]+=1
dp=[[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    dp[i+1]=list(accumulate(table[i+1]))
for i in range(Q):
    p,q=map(int,input().split())
    sum=0
    for k in range(p,q+1):
      sum+=dp[k][q]-dp[k][p-1]
    print(sum)

Measured memory_bytes: 57048
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main(){
  //入力
  int N,M;
  cin>>N>>M;
  //出力
  if(N==M){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;



int main(){

    int n;
    cin >> n;

    bool b = true;

    rep(i,n){
        int tmp;
        cin >> tmp;

        if(tmp % 2 == 0){
            if(tmp % 3 == 0 || tmp % 5 == 0){

            }else{
                b = false;
                break;
            }
        }
    }

    if(b){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int k = Console.ReadLine().Split().Select(int.Parse).ToArray()[1];
        int[] N = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(N.OrderByDescending(x => x).Take(k).Sum());
    }
}

Measured memory_bytes: 13396
#include<cstdio>
#include<cstring>
using namespace std;
int len;
char str1[100001],str2[100001];
int main()
{
	scanf("%s",str1);
	strcpy(str2,str1);
	len=strlen(str1);
	for(int i=0;i<len;i++)
		str2[len-i-1]=str1[i];
	if(strcmp(str1,str2)==0)
	{
		printf("Yes");
		return 0;
	}
	for(int i=0;i<len;i++)
		switch(str2[i])
		{
			case 'b':str2[i]='d';break;
			case 'd':str2[i]='b';break;
			case 'p':str2[i]='q';break;
			case 'q':str2[i]='p';break;
		}
	if(strcmp(str1,str2)==0)
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
int findmax(int n){
  vi sum(20000);
  rep(i,20000) sum[i]=i;
  rep(i,19999) sum[i+1]+=sum[i];
  rep(i,20000){
    if(sum[i]>=n) return i;
  }
}

signed main(){
  int n;
  cin>>n;
  vi ans;

  while(n>0){
    int k=findmax(n);
    ans.push_back(k);
    n-=k;    
  }
  rep(i,ans.size()) cout<<ans[i]<<endl;
  return 0;
}


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

int main(){
    ll n; cin>>n;
    ll ans=1e18;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ans=min(ans,i+(n/i)-2);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
class Main
{
public static void main(String args[])throws IOException
{
int N;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
N=Integer.parseInt(br.readLine());
if(N%1000==0)
System.out.println(N%1000);
else
System.out.println(1000-(N%1000));
}
}

Measured memory_bytes: 32308
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n, d;
    cin >> n >> d;

    if(n % (2 * d + 1) == 0){
        cout << n / (2 * d + 1);
    }
    else{
        
        cout << n / (2 * d + 1) + 1;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,k;
double t,a,minn=1e15,h[1005];
double abs(double f) {return f<0?-f:f;}
int main()
{
	scanf("%d%lf%lf",&n,&t,&a);
	for(int i=1;i<=n;++i) scanf("%lf",&h[i]);
	for(int i=1;i<=n;++i) {
		if(abs(t-h[i]*0.006-a)<minn) {minn=abs(t-h[i]*0.006-a);k=i;}
	}
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
       public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int turn;
    	int Taro_Point = 0;
    	int Hanako_Point = 0;
    	int compare;
    	
    	turn = scan.nextInt();
    	String[] Taro_Card= new String[turn];
    	String[] Hanako_Card= new String[turn];
    	
    	for(int i = 0; i < turn; i++){
    		Taro_Card[i] = scan.next();
    		Hanako_Card[i] = scan.next();
    		
    		compare = Taro_Card[i].compareTo(Hanako_Card[i]);
    		
    		if(compare > 0){
    			Taro_Point += 3;
    		}else if(compare == 0){
    			Taro_Point++;
    			Hanako_Point++;
    		}else{
    			Hanako_Point += 3;
    		}
    		
    	}
    	
    	System.out.println(Taro_Point + " " + Hanako_Point);
     }
}

Measured memory_bytes: 29484
#include <iostream>

int main()
{
	int a, b, c;

	std::cin >> a >> b >> c;

	if (a < 0 || a > 100 || b < 0 || b > 100 || c < 0 || c > 100)	return 0;

	if (a < b && b < c)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}

	return 0;
}


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

int main(){
  long N,x,ans=0;
  cin >> N >> x;
  vector<long> a(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  for(int i=0; i<N-1; i++){
    if(a[i]+a[i+1]>x){
      ans+=a[i]+a[i+1]-x;
      a[i+1]-=min(a[i+1],a[i]+a[i+1]-x);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n==7 || n==5 || n==3){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);


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

long long lcm(long long a, long long b) {
   long long tmp = max(a,b)/gcd(a,b);
   return min(a,b)*tmp;}

int main() {
   long long a, b;
   cin >> a >> b;

   cout << lcm(a, b) << endl;
   return 0;
}

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

int main() {
    int i, j, H, W;
    cin >> H >> W;
    while( H != 0 && W != 0 ){
        for ( i = 0; i < H; i++ ) {
            for ( j = 0; j < W; j++ ) {
                if((i + j) % 2 == 0) {
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <functional>
#include <iostream>
#include <limits.h>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <valarray>
#include <vector>

std::vector<std::string> GetInputValues();
std::valarray<long long> DeriveSumArr1();
std::valarray<long long> DeriveSumArr2();

std::string InputPattern = "InputX";

std::vector<std::string> GetInputValues()
{
    std::vector<std::string> InputValuesVect;

    if (InputPattern == "Input1") {
        InputValuesVect.push_back("2");
        InputValuesVect.push_back("3 1 4 1 5 9");
        //1
    }
    else if (InputPattern == "Input2") {
        InputValuesVect.push_back("1");
        InputValuesVect.push_back("1 2 3");
        //-1
    }
    else if (InputPattern == "Input3") {
        InputValuesVect.push_back("3");
        InputValuesVect.push_back("8 2 2 7 4 6 5 3 8");
        //5
    }
    else { //実際の入力
        while (true) {
            std::string wkStr;
            std::getline(std::cin,wkStr);
            if(std::cin.eof()) break;
            InputValuesVect.push_back(wkStr.c_str());
        }
    }

    return InputValuesVect;
}

int N;
int UB;
std::valarray<int> AArr;

int main()
{
    std::vector<std::string> InputVect = GetInputValues();
    N=atoi(InputVect.at(0).c_str());
    UB=3*N-1;
    AArr = std::valarray<int> (UB+1);
    int CurrInd=0;

    std::istringstream iss1(InputVect.at(1));
    while(iss1.eof() == false){
        int wkInt;
        iss1 >> wkInt;
        AArr[CurrInd++]=wkInt;
    }

    std::valarray<long long> SumArr1=DeriveSumArr1();
    //for(int I=0;I<=(int)SumArr1.size()-1;I++){
    //    printf("%d,",SumArr1[I]);
    //}
    //puts("");

    std::valarray<long long> SumArr2=DeriveSumArr2();
    //for(int I=0;I<=(int)SumArr2.size()-1;I++){
    //    printf("%d,",SumArr2[I]);
    //}
    //puts("");

    long long Answer=LLONG_MIN;
    for(int I=N;I<=2*N;I++){
        long long AnswerKouho=SumArr1[I-1]-SumArr2[I];
        if(Answer<AnswerKouho){
            Answer=AnswerKouho;
        }
    }
    printf("%lld\n",Answer);
}

//添字ごとのTopNの合計の配列を返す(前半部分)
std::valarray<long long> DeriveSumArr1()
{
    std::valarray<long long> SumArr1(UB+1);

    std::priority_queue<long long,std::vector<long long>, std::greater<long long> > Que;

    long long SumVal=0;
    for(int I=0;I<=UB;I++){
        Que.push(AArr[I]);
        SumVal+=AArr[I];

        if((int)Que.size()>N){
            SumVal-=Que.top();
            Que.pop();
        }
        SumArr1[I]=SumVal;
    }
    return SumArr1;
}

//添字ごとのTopNの合計の配列を返す(後半部分)
std::valarray<long long> DeriveSumArr2()
{
    std::valarray<long long> SumArr2(UB+1);

    std::priority_queue<long long> Que;

    long long SumVal=0;
    for(int I=UB;0<=I;I--){
        Que.push(AArr[I]);
        SumVal+=AArr[I];

        if((int)Que.size()>N){
            SumVal-=Que.top();
            Que.pop();
        }
        SumArr2[I]=SumVal;
    }
    return SumArr2;
}


Measured memory_bytes: 14412
def dictionary_order(Xs, n):
  ascend = [i+1 for i in range(n)]

  order = 1
  for i, x in enumerate(Xs):
    order += ascend.index(x) * factorial(n-1-i)
    ascend.remove(x)
  return order

def factorial(n):
  out = 1
  for i in range(2, n+1):
    out *= i
  return out

def main():
  N = int(input())
  Ps = list(map(int, input().split()))
  Qs = list(map(int, input().split()))
  if Ps == Qs:
    print(0)
  else:
    P_order = dictionary_order(Ps, N)
    Q_order = dictionary_order(Qs, N)
    print(abs(P_order-Q_order))
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064