akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int n, k;
int a[5005];
bool check(int c){
    vector<bool>dp(k+1,false);
    vector<bool>dp2(k+1,false);
    dp[0] = true;
    rep(i,n){
        rep(j,k+1)dp2[j] = dp[j];
        if(i==c)continue;
        rep(j,k+1){
            if(dp2[j] && j+a[i]<k+1){
                dp[j+a[i]]=true;
            }
        }
    }
    for(int i = max(k-a[c],0); i < k; i++){
        if(i<0)continue;
        if(dp[i]){
            return true;
        }
    }
    return false;
}
int main(){
    cin >> n >> k;
    //if(n>400||k>400)return 0;
    rep(i,n){
        cin >> a[i];
    }
    sort(a,a+n);
    int l = 0, r = n;
    int count = 0;
    while(count<16){
        int k = (l+r)/2;
        if(check(k)==true){
            r = k;
        }else{
            l = k;
        }
        count++;
    }
    cout << r << endl;
    /*rep(i,n){
        if(check(i)){show(i)}
    }*/
    //cout << n-count << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int a,b;
    int l = (int)s.size();
    REP(i,l){
        if(s[i]=='A'){
            a = i;
            break;
        }
    }
    REP(i,l){
        if(s[l-1-i]=='Z'){
            b=l-i-1;
            break;
        }
    }
    cout << b-a+1 << endl;

    return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    // double a,b,c;
    ll a,b,c;
    cin >> a >> b >> c;
    // c -= a;
    // c -= b;
    // a = sqrt(a);
    // b = sqrt(b);
    // if(2*sqrt(a)*sqrt(b) + a + b < c) cout << "Yes" << endl;
    // else cout << "No" << endl;

    // double ans = ((sqrt(a)+sqrt(b))*(sqrt(a)+sqrt(b)) - c )/(sqrt(a)+sqrt(b)+sqrt(c));
    // if(ans<0) cout << "Yes" << endl;
    // else cout << "No" << endl;

    // if(c - (a+b) > 0)
    // {
    //     if(2*a*b< (c-a-b)*(c-a-b)) cout << "Yes" << endl;
    //     else cout << "No" << endl;
    // }
    // else cout << "No" << endl;
    
    if(a>c || b>c) cout << "No" << endl;
    else
    {
        if(0 < (c-a-b)*(c-a-b)-4*a*b) cout << "Yes" << endl;
        else cout << "No" << endl;
    }    
    // cout << sqrt(a) << endl;
    // cout << sqrt(a*b) << endl;
    // cout << sqrt(a)*sqrt(b) << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c,x = 4.times.map { gets.to_i }

cnt = 0

(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      cnt += 1  if i*500 + j*100 + k*50 == x
    end
  end
end

puts cnt



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

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

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int n;
  cin >> n;
  Yes_No(n % 10 == 9 || (n / 10) % 10 == 9);
}
int main(void) { solve(); }


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    char a;
    cin >> a;
    if(a >= 'a' && a <= 'z') {
        cout << "a" << endl;
    } else {
        cout << "A" << endl;
    }
    return 0;
}




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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	int pre=-999;
	rep(i,n){
		if(pre<=a[i]-1){
			pre=a[i]-1;
		}
		else if(pre<=a[i]){
			pre=a[i];
		}
		else{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs           v.size()
#define sot(v)       sort(v.begin(),v.end())
#define rev(v)       reverse(v.begin(),v.end())
#define yes          cout<<"Yes"<<endl
#define no           cout<<"No"<<endl
#define ii           pair<int, int>
#define int          long long
#define ull          unsigned long long
#define pb           push_back
#define mpp          make_pair
#define Okay         0
#define pi           3.14159

const int inf = 1e6;
const int cont = 1e18;
const int mod = 1e9+7;
using namespace std;

void solve(){
    int n, m;
    cin>>n>>m;
    vector<string>a(n), b(m);
    for(string &it:a)cin>>it;
    for(string &it:b)cin>>it;
    bool ans = false;
    for(int i=0; i<=n-m; i++){
        for(int j=0; j<=n-m; j++){
            bool ok = true;
            for(int k=0; k<m; k++){
                if(b[k] != a[k+i].substr(j, m)){
                    ok = false;
                    break;
                }
            }
            if(ok)ans = true;
        }
    }
    if(ans)yes;
    else no;
}

int32_t main() {
    Fast;

    solve();
    return Okay;
}


Measured memory_bytes: 3600
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (LL i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (LL i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

LL const MaxSize = 100 + 5;
LL const MOD = 1e9 + 7;
LL const BASE = 256;

/*


 */

int N;
string s;

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/A_1.in", "r", stdin);
	cin >> N >> s;
	int rc = 0;
	LP(i, 0, N){
		if(s[i] == 'R')
			rc++;
	}
	if(rc * 2 > N){
		cout << "Yes";
	}else{
		cout << "No";
	}


	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 110000

ll n,m;
vector<vector<int>>edges(MAXN, vector<int>());

ll dp1[MAXN];
void dfs1(int now, int p=-1){
  dp1[now]=1;
  for(auto c:edges[now]){
    if(c==p)continue;
    dfs1(c, now);
    dp1[now] *= dp1[c];
    dp1[now] %= m;
  }
  dp1[now]++;
}

ll dp2[MAXN];
void dfs2(int now, int p=-1){
  if(p==-1)dp2[now]=1;
  ll ec = edges[now].size();

  vector<ll> lprod;
  ll pr = 1;
  rep(i, ec){
    int c = edges[now][i];
    if(c==p){
      lprod.push_back(pr);
      continue;
    }
    pr *= dp1[c];
    pr %= m;
    lprod.push_back(pr);
  }

  pr = 1;
  vector<ll> rprod;
  rrep(i, ec){
    int c = edges[now][i];
    if(c==p){
      rprod.push_back(pr);
      continue;
    }
    pr *= dp1[c];
    pr %= m;
    rprod.push_back(pr);
  }
  reverse(rprod.begin(), rprod.end());

  rep(i, ec){
    int c = edges[now][i];
    if(c==p)continue;
    dp2[c] = dp2[now];
    if(i)dp2[c] = dp2[c]*lprod[i-1]%m;
    if(i<ec-1)dp2[c] = dp2[c]*rprod[i+1]%m;
    dp2[c]++;
    dp2[c]%=m;
   dfs2(c, now);
  }
}

ll ans[MAXN];
void dfs3(int now, int p=-1){
  int ec = edges[now].size();
  ans[now] = dp2[now];
  for(auto c:edges[now]){
    if(c==p)continue;
    ans[now] *= dp1[c];
    ans[now] %= m;
    dfs3(c, now);
  }
}

int main(){
  cin>>n>>m;
  rep(i, n-1){
    int x,y;cin>>x>>y;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }

  dfs1(1);
  dfs2(1);
  dfs3(1);

  rep1(i, n){
    cout<<ans[i]<<endl;
  }

  return 0;

  rep1(i, n)cout<<dp1[i]<<' ';cout<<endl;
  rep1(i, n)cout<<dp2[i]<<' ';cout<<endl;
 
  return 0;
}


Measured memory_bytes: 28452
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 1e6 + 10;
 
struct IOsetup{
  IOsetup(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout.tie(nullptr);
    cout << fixed << setprecision(20);
  }
}IO;


int32_t main(){
 int a, b, k;
 cin >> a >> b >> k;
 int curr = min(a, k);
 k -= curr, a -= curr;
 int curr1 = min(k, b);
 k -= curr1, b -= curr1;
 cout << a << " " << b << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    Node rootNode;

    class Node {
        int value;
        Node p, l, r;

        public Node(int value) {
            this.value = value;
        }
    }

    void insert(Node n) {
        if (rootNode == null) {
            rootNode = n;
            return;
        }
        Node x = rootNode;
        Node y = x;
        while (x != null) {
            y = x;
            n.p = x;
            if (x.value < n.value) {
                x = x.r;
            } else {
                x = x.l;
            }
        }
        if (y.value < n.value) {
            y.r = n;
        } else {
            y.l = n;
        }
    }

    void find(int k) {
        Node x = rootNode;
        while (x != null) {
            if (x.value == k) {
                System.out.println("yes");
                return;
            } else if (x.value > k) {
                x = x.l;
            } else {
                x = x.r;
            }
        }
        System.out.println("no");
    }

    void print() {
        preorder(rootNode);
        System.out.println();
        inorder(rootNode);
        System.out.println();
    }

    void inorder(Node n) {
        if (n == null) return;
        System.out.print(" " + n.value);
        inorder(n.l);
        inorder(n.r);
    }

    void preorder(Node n) {
        if (n == null) return;
        preorder(n.l);
        System.out.print(" " + n.value);
        preorder(n.r);
    }

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (s.equals("insert")) {
                int k = sc.nextInt();
                insert(new Node(k));
            } else if (s.equals("print")) {
                print();
            } else if (s.equals("find")) {
                int k = sc.nextInt();
                find(k);
            }
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}



Measured memory_bytes: 208544
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

vector<int> topo_sort(vector< vector<int> > &g) {
    int64_t n = g.size();
    vector<int> in(n);
    for(int v=0; v<n; v++) {
        for(auto u: g[v]) {
            ++in[u];
        }
    }
    queue<int> q;
    for(int i=0; i<n; i++) {
        if(in[i] == 0) q.emplace(i);
    }

    vector<int> res;
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        res.emplace_back(v);
        for(auto u: g[v]) {
            if(--in[u] == 0) q.emplace(u);
        }
    }

    if(res.size() == n) {
        return res;
    } else {
        res.clear();
        return res;
    }
}

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

    vector< vector< int> > g(N*N);
    auto id = [N](int i, int j) {
        return i*N + j;
    };

    for(int i=0; i<N; i++) {
        vector<int> A(N-1);
        for(int j=0; j<N-1; j++) {
            cin >> A[j];
            --A[j];
        }
        for(int j=0; j<N-2; j++) {
            g[id(i, A[j])].emplace_back(id(i, A[j+1]));
            g[id(i, A[j])].emplace_back(id(A[j+1], i));
            g[id(A[j], i)].emplace_back(id(i, A[j+1]));
            g[id(A[j], i)].emplace_back(id(A[j+1], i));
        }
    }


    if(topo_sort(g).empty()) {
        cout << -1 << endl;
    } else {
        vector<int> dp(N*N, 1);
        for(auto v: topo_sort(g)) {
            for(auto u: g[v]) {
                dp[u] = max(dp[u], dp[v] + 1);
            }
        }
        cout << *max_element(dp.begin(), dp.end()) << endl;
    }
    return 0;
}


Measured memory_bytes: 70756
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  int a,b;
  cin >> a >> b;
  int res=1;
  for(int i=0;i<100;i++){
    if(res>=b){cout << i << endl;return;}
    res+=a-1;
  }
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
ll n;
struct germ{
	ll val,cost,diff;
};
germ a[25];
int main(){
	read(n);
	for(ll i=1;i<=n;i++){
		read(a[i].val);
	}
	for(ll i=1;i<=n;i++){
		read(a[i].cost);
		a[i].diff=a[i].val-a[i].cost;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		if(a[i].diff>=0){
			ans+=a[i].diff;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}


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

    vector<int> ans(100002);

    REP(i,n){
        int res;
        cin >> res;
        ans[res]++;
        ans[res+1]++;
        ans[res+2]++;
    }
    
    cout << *max_element(ans.begin(), ans.end()) << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#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=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int INF = 1e9;

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

    VI b(n), w(n);
    REP(i,2*n){
        char c;
        int x;
        cin >> c >> x;
        x--;
        if (c == 'B') b[x] = i;
        else w[x] = i;
    }

    VVI dp(n + 1, VI(n + 1, INF));
    VVI move_b(dp), move_w(dp);

    REP(i,n){
        int cnt = 0;
        FOR(j,i+1,n-1) if (b[j] < b[i]) cnt++;
        REP(j,n) if (w[j] < b[i]) cnt++;
        move_b[i][0] = cnt;
        REP(j,n){
            if (w[j] < b[i]) cnt--;
            move_b[i][j+1] = cnt;
        }

        cnt = 0;
        FOR(j,i+1,n-1) if (w[j] < w[i]) cnt++;
        REP(j,n) if (b[j] < w[i]) cnt++;
        move_w[i][0] = cnt;
        REP(j,n){
            if (b[j] < w[i]) cnt--;
            move_w[i][j+1] = cnt;
        }
    }

    // REP(i,n){
    //     REP(j,n+1) cout << move_w[i][j] << " ";
    //     cout << endl;
    // }

    dp[0][0] = 0;
    REP(i,n+1) REP(j,n+1){
        if (i < n){
            dp[i+1][j] = min(dp[i+1][j], dp[i][j] + move_b[i][j]);
        }
        if (j < n){
            dp[i][j+1] = min(dp[i][j+1], dp[i][j] + move_w[j][i]);
        }
    }
    cout << dp[n][n] << endl;

    // REP(i,n+1){
    //     REP(j,n+1) cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    return 0;
}


Measured memory_bytes: 47360
import math

A, B = map(int,input().split())

if A == 0 and B == 0:
    print(0)
    exit()

for i in range(1000):
    a = math.floor((i+1)*8/100)
    b = math.floor((i+1)/10)
    if A == a and B == b:
        print(i+1)
        exit()

print(-1)


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

int main(){
  ll n,y;
  cin >> n >> y;
  y /= 1000;
  if( 10*n < y ){
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
  }
  rep(i,n){
    rep(j,n){
      if( i+j > n ) break;
      if( 10*i + 5*j + (n-i-j) == y ){
        cout << i << " " << j << " " << n-i-j << endl;
        return 0;
      }  
    }
  }
  
  cout << -1 << " " << -1 << " " << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int N, M;
    int a, b;
    cin >> N >> M;
    vi ab;
    ab.resize(N + 1);
    REP(i, N + 1)
    ab[i] = INF;
    REP(i, M)
    {
        cin >> a >> b;
        if (ab[a] > b)
            ab[a] = b;
    }
    int ans = 0;
    int tmp = -1;
    REP(i, N + 1)
    {
        if (ab[i] == INF)
            continue;
        if (tmp <= i)
        {
            ans++;
            tmp = ab[i];
        }
        else
        {
            chmin(tmp, ab[i]);
        }
    }
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,S[100000],q,T[50000],c=0,i,i2,toread,cnt;
	cin>>n;
	for(i=0;i<n;i++)cin>>S[i];
	cin>>q;
	for(i=0;i<q;i++)cin>>T[i];
	/*for(i=0;i<n;i++){
		for(i2=0;i2<n;i2++){
			if(S[i]<S[i2]){
				toread=S[i];
				S[i]=S[i2];
				S[i2]=toread;
			}
		}
	}*/
	sort(S,S+n);
	for(i=0;i<q;i++){
		cnt=0;
		toread=n;
		while(toread>1){
			if(toread%2==0)toread/=2;
			else toread=(toread+1)/2;
			if(S[(toread-1)+cnt]<T[i])cnt+=toread;
			else if(S[(toread-1)+cnt]==T[i]){
				c++;
				break;
			}
		}
	}
	cout<<c<<endl;
}

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
#include <utility> 
#include <tuple>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;


int main() {
int n;
cin>>n;
for(int y=0;y<n;y++){
string s,t;
cin>>s>>t;
	int ls=s.size(),lt=t.size();
if(ls>80||lt>80) cout<<"overflow"<<endl;
else{
	if(ls>lt){
		int r=ls-lt;
		while(r>0){
			t="0"+t;
		r=r-1;
		}
	}
	if(lt>ls){
		int r=-ls+lt;
		while(r>0){
			s="0"+s;
		r=r-1;
		}
	}
	
	int l=s.size();
	int q=0;
	string ans="";
	for(int k=0;k<l;k++){
		int w=t[l-k-1]-'0'+s[l-k-1]-'0';
		w=w+q;
//		cout<<w<<endl;
		char z='0'+w%10;
		ans=z+ans;
		q=w/10;
	}
	if(q==1) ans='1'+ans;
	if(q>0 && l==80)cout<<"overflow"<<endl;
	else 	cout<<ans<<endl;
	

}
	
	


}
	return 0;
}

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

typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

int
gcd(int a, int b)
{
  if (a < b) { int tmp = a; a = b; b = tmp; }
  if (a % b) return gcd(b, a % b); else return b;
}

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

void
sort_unique(vector<int>& V)
{
  sort(V.begin(), V.end());
  V.erase(unique(V.begin(), V.end()), V.end());
}

int
main()
{
  int N, X; cin >> N >> X; 	// 1<= N <= 1e5, 1 <= X <= 1e9
  vector<int> V(N + 1);		// 1<= x <= 1e9
  REP(i, N) cin >> V[i];
  V[N] = X;

  SORT(V);

  vector<int> L(N);
  REP(i, N) {
    L[i] = V[i + 1] - V[i];
  }

  sort_unique(L);

  int ans = L[0];
  for (int i = 1; i < L.size(); ++i) {
    ans = gcd(ans, L[i]);
  }
  
  ANS(ans);

  return 0;
}

/*
4
1 2 2 1
 */


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;

public class Main {

    // static final int modnum = 1e9 + 7;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        // sc.next();
        String[] list = new String[N];

        for (int i = 0; i < N; i++) {
            String next = sc.next();
            // System.out.println(next);
            int nextInt = sc.nextInt();
            // System.out.println(next+"  "+nextInt);
            list[i] = next+" "+(200-nextInt)+" "+(i+1);
            // sc.next();
        }

        Arrays.sort(list, Comparator.naturalOrder());

        for (int i = 0; i < N; i++) {
            // System.out.println(list[i]);
            System.out.println(list[i].split(" ")[list[i].split(" ").length-1]);
        }
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const long long INFL = 1e18;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long N, K; cin >> N >> K; --K;
    vector<long long> h(N);
    rep (i, 0, N) cin >> h[i];

    sort(h.begin(), h.end(), greater<>());
    long long ans = INFL;
    for (long long i = 0; i < h.size()-K; i++) {
        ans = min(ans, h[i]-h[i+K]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
// aarsh01rsh@gmail.com
// Aarsh Sharma
#include<bits/stdc++.h>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}
string to_string(char ch) {
  string s(1, ch);
  return '\'' + s + '\'';
}
string to_string(const char *s) {
  return to_string((string)s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define f(i, x, n) for (int i = x; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int ll;
#define int ll
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;

const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 1e5 + 10;

int32_t main() {
  fast_io();

  int n; cin >> n;
  cout << (n*(n-1))/2;

  return 0;
}

Measured memory_bytes: 256
a = list(reversed(input().split()))
stack =[]
operator = ['+','*','-']
while a:
    box = a.pop()
    if not box in operator:
        stack.append(int(box))
    elif box == operator[0]: # +
        stack.append(stack.pop()+stack.pop())
    elif box == operator[1]: # *
        stack.append(stack.pop()*stack.pop())
    elif box == operator[2]:
        p = stack.pop()
        q = stack.pop()
        stack.append(q-p)
print(stack[0])


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B)
    {
        if (A != C)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else if (A == C)
    {
        if (A != B)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        if (B == C)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


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

int main(){
  int n,m,q;
  cin>>n>>m>>q;
  int d[555][555]={};
  for(int i=0;i<m;i++){
    int l,r;
    cin>>l>>r;
    l,r--;
    d[0][r]++;
    d[0][n]--;
    d[l][r]--;
    d[l][n]++;
  }
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      d[i][j+1]+=d[i][j];

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      d[j+1][i]+=d[j][i];

  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    l--,r--;
    cout<<d[l][r]<<endl;
  }
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	ll N, P;  cin >> N >> P;	
	
	ll ans = 1,  lim = P;
	for(ll i = 2 ; i * i <= lim ; i++){
			ll count = 0;
			while(P % i == 0){
					count++;
					P /= i;
			}
			if(count >= N)  ans *= pow(i, count / N);
	}

	if(N == 1)  ans *= P;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B=0,C;
  cin >> A;
  vector<int>S(A);
  for(int i=0;i<A;i++)cin >> S[i];
  sort(S.begin(),S.end());
    for(int i=0;i<A;i++){
    if(i==A-1)B+=S[i]/2;
    else B+=S[i];
  }
  cout << B << endl;
}


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

using namespace std;

int main(){
    string S;
    cin >> S;

    int l = S.length();
    int count=0;
    for(int i=0;i<l/2;++i){
        if (S[i] != S[l - 1 - i]) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll n;
vl a;

ll sum() {
  ll res = 0;
  rep(i, n) res += a[i] / n;
  return res;
}

int main() {
  cin >> n;
  a = vl(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  ll s = sum();
  while(s > 0) {
    ans += s;
    rep(i, n) a[i] += s - a[i] / n - a[i] / n * n;
    s = sum();
  }
  cout << ans << endl;
}

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

int main()
{
    int64_t x[5];

    std::cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

    for (size_t i = 0; i < 5; ++i)
    {
        if (x[i] == 0) {
            std::cout << i + 1 << std::endl;
        }
    }

    return 0;
}


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

ll gcd(ll m, ll n){
    ll tmp;
    while(m%n){
        tmp = n;
        n = m % n;
        m = tmp;
    }
    return n;
}

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

    ll n, k;
    cin >> n >> k;

    if(n <= k){
        cout << min(n, k-n) << endl;
        return 0;
    }

    // if(n == k*2) cout << 0 << endl;
    // if(n < k*2) cout << n-k << endl;
    // cout << gcd(n, k) << endl;

    cout << min(n%k, k-(n%k)) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b){
        if(b<c){
            printf("%d %d %d\n",a,b,c);
        }
        else if(c<a){
            printf("%d %d %d\n",c,a,b);
        }
        else{
            printf("%d %d %d\n",a,c,b);
        }
    }
    else if(b<a){
        if(a<c){
            printf("%d %d %d\n",b,a,c);
        }
        else if(c<b){
            printf("%d %d %d\n",c,b,a);
        }
        else{
            printf("%d %d %d\n",b,c,a);
        }
return 0;
}
    
 }   




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

int main(){
	string s;
	int joi, ioi;
	while(cin>>s){
		joi=ioi=0;
		for(int i=0; i<s.size()-2; i++){
			if(s[i]=='J'&&s[i+1]=='O'&&s[i+2]=='I')joi++;
			else if(s[i]=='I'&&s[i+1]=='O'&&s[i+2]=='I')ioi++;
		}
		printf("%d\n%d\n", joi, ioi);
	}
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
#define int ll
 
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
 
int read(){
    int i;
    scanf("%lld",&i);
    return i;
}
 
signed main(){
    while(true){
    int n=read();
    if(n==0) return 0;
    string s[n];
    int cnt[n];
    int cnt_max=0;
    FOR(i,0,n){
        int first,last;
        cin >> s[i];
        first = s[i].find_first_of('.');
        last = s[i].find_last_of('.');
        if(first == -1){
        	cnt[i] = -1;
        	continue;
        }
        else cnt[i] = last-first;
        s[i][last] = '+';
        cnt_max = max(cnt_max,cnt[i]);
    }
    FOR(j,0,cnt_max+1){
        int first=0,last=0;
        FOR(i,1,n){
            if(cnt[i] == j){
            	FOR(k,i+1,n){
	            	if (cnt[k] < j) {
	              		// ????????????????¨??????????????????´???
	              		break;
	        		 }
	                if(cnt[k] == j){
	                	int first = i;
	                	int last = k;
	                    FOR(l,first+1,last){
				            if(s[l][j] == '.') s[l][j] = '|';
		        		}
		        		break;
	                }
            	}
            }
        }
    }
     
    FOR(i,1,n){
        REP(j,cnt[i]){
            if(s[i][j] == '.') s[i][j] = ' ';
        }
    }
    REP(i,n) cout << s[i] << endl;
    }
}

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

int main()
{
    int N;

    cin >> N;

    if ((N == 3) || (N == 5) || (N ==7))
    {
        cout << "YES"  << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return(0);
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long l = 0;
		long r = (long)1e18;
		while(r-l>1){
			long c = (l+r)/2;
			if(isOK(c)){
				l = c;
			}else{
				r = c;
			}
		}
		Console.WriteLine(l);
	}
	
	bool isOK(long t){
		
		long s = t;
		long c = t*2;
		if(c > M){
			return false;
		}
		long restm = M - c;
		restm /= 2;
		return (restm + N) >= s;
		
	}
	
	long N,M;
	public Sol(){
		var d = rla();
		N = d[0]; M = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include <stdio.h>
int kiriage(int n){
    if(n%10 ==0){
        return n;
    }
    else{
    return n - (n%10) + 10;
    }
}
int main(){
    int A[5];
    scanf("%d %d %d %d %d", &A[0], &A[1], &A[2], &A[3], &A[4]);
    int cnt=10;
    for(int i=0;i<5;i++){
        if((A[i]%10<cnt)&&(A[i]%10!=0)){
            cnt = A[i]%10;
        }
    }
    int total = 0;
    for(int i=0;i<5;i++){
        total += kiriage(A[i]);
    }
    printf("%d", total + cnt-10);
    return 0;
}

Measured memory_bytes: 128
def main():
    n, x, *a = map(int, open(0).read().split())
    a = [0] + a
    ans = 0
    tmp = 0
    for i, j in zip(a, a[1:]):
        i -= tmp
        if i + j > x:
            c = (i + j) - x
            ans += c
            tmp = c
        else:
            tmp = 0

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14092
#include <stdio.h> 
 
 
 int main(){ 
     int x; 
     int i=0; 
     while(1){ 
         scanf("%d", &x); 
         if(x==0)break; 
         printf("Case %d: %d\n", ++i, x); 
     } 
     return 0; 
 } 



Measured memory_bytes: 2056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		StringBuffer sb = new StringBuffer(s);
		sb.reverse();
		final int MOD = 1000000007;
		final int N = 13;
		int[] count = new int[N];

		count[0] = 1;
		int order = 1;

		for (int i = 0; i < sb.length(); i++) {
			int[] next = new int[N];
			if (sb.charAt(i) == '?') {
//				System.out.print("★?★");
				for (int k = 0; k < 10; k++) {
					for (int j = 0; j < N; j++) {
						next[(k * order + j) % N] += count[j];
						next[(k * order + j) % N] %= MOD;
					}
				}
			} else {
				int i_ketame = sb.charAt(i) - '0';
//				System.out.print("★" + i_ketame + "★");

				for (int j = 0; j < N; j++) {
					next[(i_ketame * order + j) % N] += count[j];
					next[(i_ketame * order + j) % N] %= MOD;
				}
			}

			count = next;

			order *= 10;
			order %= N;
//			for (int m = 0; m < N; m++) {
//				System.out.print(count[m] + " ");
//			}
//			System.out.println();
		}

		System.out.println(count[5]);
		sc.close();
	}
}

Measured memory_bytes: 33788
package main

import (
	"fmt"
	//"sort"
)

func main() {
	var cnt int
	fmt.Scan(&cnt)

	nums := make([]int, cnt)
	for i := range nums {
		fmt.Scan(&nums[i])
	}
	mp := make(map[int]bool)

	for i := range nums {
		mp[nums[i]] = true
	}

	fmt.Print(len(mp))
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	for (int i=1; i<=100; i++){
		if(A%i==0 && B%i==0 && C%i!=0){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <numeric>
#include <cassert>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<PII > VPII;
typedef vector<VPII> VVPII;
typedef unordered_map<LL, LL> MLL;
typedef long double LD;

#define FOR(k,a,b) for(int k(a); k < (b); ++k)
#define REP(k,a) for(int k=0; k < (a); ++k)
#define ABS(a) ((a)>0?(a):-(a))

int main(int argc, char** argv) {
#ifdef HOME
	freopen("in.txt", "rb", stdin);
	freopen("out.txt", "wb", stdout);
#endif
	int N;
	scanf("%d", &N);
	vector<int> v(N);
	REP(i,N)
		scanf("%d", &v[i]);
	int actT = -1;
	int last = -1;
	int res = 0;
	REP(i, N)
	{
		if (actT == -1)
		{
			if (last != -1)
			{
				if (last < v[i])
					actT = 0;
				else if (last > v[i])
					actT = 1;
			}
		}
		else if (actT == 0)
		{
			if (last > v[i])
			{
				actT = -1;
				last = -1;
			}
		}
		else if (actT == 1)
		{
			if (last < v[i])
			{
				actT = -1;
				last = -1;
			}
		}
		if (last == -1)
			++res;
		last = v[i];
	}
	printf("%d\n", res);
	return 0;
}



Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = 10**20

def solve(N,A,B,C,D):
    memo = dict()
    def rec(n):
        if n in memo:
            return memo[n]
        elif n==0:
            return 0
        elif n==1:
            return D
        
        ret = D * n
        if n%2==0:
            ret = min(ret, rec(n//2)+A)
        else:
            ret = min(ret, rec(n//2)+A+D, rec(n//2+1)+A+D)
        
        if n%3==0:
            ret = min(ret, rec(n//3)+B)
        else:
            ret = min(ret, rec(n//3)+B+D*(n%3), rec(n//3+1)+B+D*(3-n%3))
        
        if n%5==0:
            ret = min(ret, rec(n//5)+C)
        else:
            ret = min(ret, rec(n//5)+C+D*(n%5), rec(n//5+1)+C+D*(5-n%5))
        
        memo[n] = ret
        return ret    
    return rec(N)

T = int(input())
answer = []
for t in range(T):
    N,A,B,C,D = map(int,input().split())
    
    ans = solve(N,A,B,C,D)
    answer.append(ans)

for a in answer:
    print(a)

Measured memory_bytes: 20184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		int k = sc.nextInt();
		
		char c = s.charAt(k-1);
		
		char[] ch = s.toCharArray();
		
		for(int i = 0; i < n; i++) {
			if(ch[i] != c) {
				ch[i] = '*';
			}
		}
		for(char chr : ch) {
			System.out.print(chr);
		}
		System.out.println();
	}
}


Measured memory_bytes: 23636
# coding: utf-8
# Your code here!

H,W,K=(int(x) for x in input().split())
c=[]
for i in range(H):
    c.append(input())
ans = 0
for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        for i in range(H):
            for j in range(W):
                if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and c[i][j] == '#':
                        black = black + 1
        if black == K:
            ans = ans + 1
print(ans)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
#define int long long
int f(int a, int b) //Assuming a > b
{
	if(a % b == 0) return b * (2 * (a / b) - 1);
	return a / b * 2 * b + f(b, a % b);
}

main()
{
	int n, x; cin >> n >> x;
	cout << n + f(x, n - x) << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    ll id = 1;
    ll t = 0;
    while (t < n)
    {
        while (t < n && a[t] != id)
        {
            t++;
            ans++;
        }

        if (id == a[t])
        {
            id++;
        }

        if (t == n)
        {
            if (id == 1)
            {
                cout << -1 << endl;
                exit(0);
            }
        }

        if (t == n - 1 && a[t] == id) // これちがう？
        {
            break;
        }

        t++;
        // id++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

const int MAXN = 15000;
const int MOD = 1000000007;
const int INF = 2000000000;
const double PI = 3.14159265358979;
const int dir_4r[] = { -1, 1, 0, 0 };
const int dir_4c[] = { 0, 0, -1, 1 };
const int dir_8r[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dir_8c[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int h, w, n;
int a[MAXN];
int mat[MAXN][MAXN];
int color;

int main()
{
	while (cin >> h >> w)
	{
		cin >> n;
		for (int i = 1; i <= n; ++i)
			cin >> a[i];

		color = 1;
		int r = 0;
		while (color <= n)
		{
			for (int i = 0; i < w; ++i)
			{
				mat[r][i] = color;
				a[color]--;
				if (a[color] == 0)
					color++;
			}
			if (color > n)
				break;
			r++;
			for (int i = w - 1; i >= 0; --i)
			{
				mat[r][i] = color;
				a[color]--;
				if (a[color] == 0)
					color++;
			}
			r++;
		}

		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
				printf("%d ", mat[i][j]);
			printf("\n");
		}
	}
	//system("pause");
	return 0;
}

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

int main(){
    int room=10, floor=3, build=4, n;
    int res[build+1][floor+1][room+1]={{{}}};
    
    cin >> n;
    for (int i=0; i<n; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        res[b][f][r] += v;
    }

    for (int i=1; i<=build; i++){
        for (int j=1; j<=floor; j++){
            for (int k=1; k<=room; k++){
                cout << ' ' << res[i][j][k];
            }
            cout << endl;
        }
        if (i!=build) cout << "####################" << endl;
    }

}


Measured memory_bytes: 3076
#include<iostream>
#include<string>
using namespace std;
int main()
{
  long int n,result=1;
  cin>>n;
  string color;
  cin>>color;
  for(long int i=1;i<color.length();i++)
  {
    if(color[i-1]!=color[i])
    {
      result+=1;
    }
  }
  cout<<result;
}

Measured memory_bytes: 3752