akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define print0(a)           cout<<a<<"\n"
#define print1(a)           cout<<a<<' '
#define print2(a,b)         cout<<a<<" "<<b<<" ";
#define print3(a,b,c)       cout<<a<<" "<<b<<" "<<c<<" ";
#define print4(a,b,c,d)     cout<<a<<" "<<b<<" "<<c<<" "<<d<<" ";
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 3e18;

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
signed main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n,k;
        cin>>n>>k;
        MAP mp;
        while(k--)
        {
            int d;
            cin>>d;
            while(d--)
            {
                int x;
                cin>>x;
                mp[x]++;
            }
        }
        int cnt=0;
        for(int i=1;i<=n;i++)
        {
            if(mp[i]==0)cnt++;
        }
        cout<<cnt<<"\n";
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||
*/



Measured memory_bytes: 3656
#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() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n+1) cin >> a[i];

  int l = a[n];
  ll r[n];
  r[n]=a[n];
  for(int i=n-1; i>=0; i--) {
    l = (l+1)/2;
    l += a[i];
    r[i] = r[i+1]+a[i];
  }
  if(l>1) {
    cout << -1 << endl;
    return 0;
  }

  ll cnt = 1;
  ll ans = 0;
  for(int i=0; i<=n; i++) {
    ans += cnt;
    cnt = min(r[i+1],(cnt-a[i])*2);
  }

  cout << ans << endl;
}


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

int main() {
    ll N,P;
    cin >> N >> P;
    int num[2] ={};
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        num[a%2]++;
    }
    if(P==1 && num[1] == 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans =1;
    for(int i=0;i<num[0];i++){
        ans *=2;
    }
    for(int i=0;i<(num[1]-1);i++){
        ans *= 2;
    }
    cout << ans << endl;


    return 0;
}

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

void add(std::vector<int>& vec, std::map<int, std::vector<int>>& links, std::vector<bool>& visited, int index) {
	auto link = links[index];
	for (int i = 0; i < link.size(); i++) {
		int dest = link[i];
		if (!visited[dest]) {
			vec[dest] += vec[index];
			visited[dest] = true;
			add(vec, links, visited, dest);
		}
	}
}


int main(void) {
	int n, q;
	std::cin >> n >> q;

	std::map<int, std::vector<int>> link;
	std::vector<int> vec(n);
	std::vector<bool> visited(n, false);
	visited[0] = true;
	for (int i = 1; i < n; i++) {
		int a, b;
		std::cin >> a;
		std::cin >> b;
		link[a - 1].push_back(b - 1);
		link[b - 1].push_back(a - 1);

	}
	for (int i = 0; i < q; i++) {
		int a, b;
		std::cin >> a >> b;
		vec[a - 1] += b;
	}
	add(vec, link, visited, 0);
	for (int i = 0; i < vec.size(); i++) {
		if (i > 0) std::cout << " ";
		std::cout << vec[i];
	}
	return 0;
}

Measured memory_bytes: 47984
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/
bool solve(string a, string b)
{
    int n=a.length();
    for (int i=0;i<n;i++)
    {
        if (a[i]!=b[i])
        {
            return false;
        }
    }
    return true;
}
int main()
{
    start();

    string a, b;
    cin>>a>>b;
    int n=a.length();
    for (int i=0;i<n;i++)
    {
        if (solve(a, b))
        {
            cout<<"Yes";
            return 0;
        }
        string c=a;
        a=c[n-1];
        a+=c.substr(0, n-1);
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#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)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll N,n;
ll a[100001];
ll A[100001];
ll B[100001];
ll B2[100001];

ll bit[200003];

ll sum(ll i){
  i+=1LL;
  ll s = 0;
  while(i>0){
    s+=bit[i];
    i-= i&-i;
  }
  return s;
}

void add(ll i,ll x){
  i+=1LL;
  while(i<=2*n+1){
    bit[i]+=x;
    i += i&-i;
  }
}

void initbit(){
  rep(i,2*n+2){
    bit[i]=0LL;
  }
}

void Add(ll x,ll a){
  add(x+n,a);
}

ll Sum(ll x){
  return sum(x+n);
}

vector<ll> as;

bool ijomed(ll X){ //medがX以上である
  ll C=0LL;
  B[0]=B2[0]=0;
  rep1(i,n){
    if(A[i] < X) B[i] = -1;
    else B[i] = 1;
    B2[i]=B2[i-1]+B[i];
  }
  initbit();
  Add( 0,1 );
  rep1(i,n){
    C+= Sum( B2[i] );
    Add( B2[i],1 );
  }
  // cout<<X<<"a"<<endl;
  // rep1(i,n){
  //   cout<<B[i]<<" "<<B2[i]<<endl;
  // }
//
  return C >= (((n*(n+1)) /2) +1 )/2;
}

int main()
{
  cin>>n;
  a[0]=A[0]=0LL;

  rep1(i,n){
      cin>>a[i];
      as.pb(a[i]);
  }
  sort(as.begin(),as.end());
  as.erase(unique(as.begin(),as.end()),as.end());
  N=as.size();

  rep1(i,n){
    A[i] = lower_bound(as.begin(), as.end(), a[i]) - as.begin() + 1;
  }

  ll lb=1LL;
  ll ub=n+1;
  while(ub-lb>1LL){
    ll mid = (ub+lb)/2LL;
    if(ijomed(mid)) lb = mid;
    else ub = mid;
  }
//  cout<<lb<<" "<<ub<<endl<<A[0]<<" "<<A[1]<<endl<<a[0]<<" "<<a[1]<<endl;
  rep1(i,n){
    if(lb==A[i]){
      cout<<a[i]<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 5876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

vector<ll> divs(ll n) {
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.emplace_back(i);
            if (i < n / i) ret.emplace_back(n / i);
        }
    }
    return ret;
}

int n, k;
vector<int> A;
bool check(int d) {
    int res = 0, res2 = 0;
    vector<int> rem(n);
    rep(i, n) rem[i] = A[i] % d;
    sort(all(rem));
    int r = n - 1;
    rep(l, n) {
        res += rem[l];
        while(res > res2) res2 += d - rem[r], r--;
//        debug(res, res2);
        if (r <= l) break;
    }
    return res <= k;
}

void solve() {
    cin >> n >> k;
    int sum = 0;
    A.resize(n);
    for(auto &a : A) cin >> a, sum += a;
    auto div = divs(sum);
    sort(all(div), greater<>());
    for (int d : div) {
        if (check(d)) {
            cout << d << endl;
            return;
        }
    }
}

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


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

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) break;
		char code[1000][2];
		for (int i = 0; i < n; i++) {
			cin >> code[i][0] >> code[i][1];
			//cout << code[i][0] << code[i][1];
		}
		int m = 0;
		cin >> m;
		char str[100000];
		for (int j = 0; j < m; j++) {
			cin >> str[j];
			for (int k = 0; k < n; k++) {
				if (str[j] == code[k][0]) {
					str[j] = code[k][1];
					break;
				}
			}
		}
		for (int i = 0; i < m; i++) {
			cout << str[i];
		}
		cout << endl;
	}

}


Measured memory_bytes: 3108
#include<stdio.h>

int main(void){
	int n,t,i,f,res = 0,d[262144];
	scanf("%d%d",&n,&t);
	for(i = 1;i <= n;i++){
		scanf("%d",&d[i]);
		if(i == 1){f = d[i];}
		else{
			if(d[i] - d[i-1] > t){res+=(d[i-1]+t-f);f=d[i];}
		}
	}
	res+=(d[n]+t-f);
	printf("%d\n",res);
	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;

struct Node{
    //vector<set<int>> used;
    ll w;
    ll v;
    vector<int> rightEnds;
    int rightW;
    bool operator< (const Node &r) const{
        return v < r.v;
    }
};


int main(){
    int n;
    ll maxw;
    cin >> n >> maxw;
    vector<ll> w(n);
    vector<ll> v(n);
    rep(i, n){
        cin >> w[i] >> v[i];
    }

    vector<vector<ll>> list(4, vector<ll>());
    rep(i, n)   list[w[i]-w[0]].push_back(v[i]);
    rep(i, 4){
        sort(list[i].begin(), list[i].end(), greater<ll>());
    }

    priority_queue<Node> que;
    que.push({0, 0, vector<int>(4, -1), 0});

    ll maxv = 0;
    while(!que.empty()){
        Node node = que.top(); que.pop();
        maxv = max(node.v, maxv);

        ll border = 0;
        for(int wx = node.rightW; wx <= wx+1 && wx <= 3; wx++){
            int index = node.rightEnds[wx]+1;
            if(index == (int)list[wx].size()){
                if(wx+1 <= 3){
                    que.push({node.w, node.v, node.rightEnds, wx+1});
                }
                continue;
            }
            if(list[wx][index] <= border)   continue;

            border = list[wx][index];
            vector<int> r = node.rightEnds;
            r[wx]++;
            if(wx == node.rightW+1){
                que.push({node.w, node.v, r, wx});
            }
            
            if(node.w+wx+w[0] <= maxw){
                que.push({node.w+wx+w[0], node.v+list[wx][index], r, wx});
            }
        }


    }

    cout << maxv << endl;



    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static final long MOD = 1000000007;
	
	public static long mod_inv(long a, long m){
		return (a == 1 ? 1 : (1 - m*mod_inv(m%a, a)) / a + m);
	}
	
	public static long fact(long N){
		long ret = 1;
		for(int i = 1; i <= N; i++){
			ret *= i;
			ret %= MOD;
		}
		
		return ret;
	}
	
	public static void main(String[] args) throws IOException {
		try(Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			if(Math.max(N, M) - Math.min(N, M) >= 2){
				System.out.println(0);
			}else if(N == M){
				System.out.println((((fact(N) * fact(M)) % MOD) * 2) % MOD);
			}else{
				System.out.println(((fact(N) * fact(M)) % MOD));
			}
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23124
import kotlin.math.min

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun enumerateCombination(n: Int, k: Int): List<List<Int>> {
    if (k == 0) return listOf(listOf())

    val result = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        if (n - i - 1 < k - 1) continue
        enumerateCombination(n - i - 1, k - 1).forEach {
            result.add(listOf(i) + it.map { j -> j + i + 1 })
        }
    }

    return result
}

fun main() {
    val (n, m, x) = readIntList()
    val a = mutableListOf<List<Int>>()
    val c = mutableListOf<Int>()
    for (k in 0 until n) {
        val ca = readIntList()
        c.add(ca[0])
        a.add(ca.subList(1, ca.size))
    }

    var result = Int.MAX_VALUE
    (1..n).forEach { k ->
        enumerateCombination(n, k).forEach { comb ->
            val comprehension = Array(m) { 0 }
            var price = 0
            comb.forEach {
                a[it].forEachIndexed { index, value -> comprehension[index] += value }
                price += c[it]
            }
            if (comprehension.all { it >= x }) {
                result = min(result, price)
            }
        }
    }

    if (result == Int.MAX_VALUE) {
        println(-1)
    } else {
        println(result)
    }
}

Measured memory_bytes: 55184
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/

int n, a, b, x[100005], ans;
signed main() {
	cin >> n >> a >> b;
	rep(i, n)cin >> x[i];
	rep(i, n - 1) {
		ans += min(b, (x[i + 1] - x[i])*a);
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 1024
#include <bitset>
#include <iostream>

using namespace std;

int main()
{
    const auto primes = [] {
        bitset<1'300'000> b;
        auto t = b;
        t.set();
        t[0] = false;
        t[1] = false;
        int i = 0;
        while (true) {
            bool done = false;
            while (!t[i]) {
                ++i;
                if (i == t.size()) {
                    done = true;
                    break;
                }
            }
            if (done) {
                break;
            }

            b[i] = true;
            for (int j = i; j < t.size(); j += i) {
                t[j] = false;
            }
        }
        return b;
    }();

    while (true) {
        int q;
        cin >> q;
        if (q == 0) {
            return 0;
        }

        int start = 2;
        for (int i = 2; i < primes.size(); ++i) {
            if (primes[i]) {
                auto stop = i;
                if (i == q) {
                    cout << 0 << endl;
                    break;
                }
                else if (start < q && q < stop) {
                    cout << (stop - start) << endl;
                    break;
                }
                start = i;
            }
        }
    }
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C;
  int five,seven;
  cin >> A >> B >> C;
  
  if(A == 5) {
    five++;
  }
  if(B == 5) {
    five++;
  }
  if(C == 5) {
    five++;
  }
  if(A == 7 || B == 7 || C == 7) {
    seven=1;
  }
  
  if(five == 2 && seven == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
  
  


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

int card[255][14] ={{0}};

int main(void){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        char c;
        int num;
        cin >> c >> num;
        card[(int)c][num] = 1;
    }
    for(int i = 1; i <= 13; i++){
        if(card[(int)'S'][i] == 0){
            cout << "S " << i<< endl;
        }
    }
    for(int i = 1; i <= 13; i++){
        if(card[(int)'H'][i] == 0){
            cout << "H " << i<< endl;
        }
    }
    for(int i = 1; i <= 13; i++){
        if(card[(int)'C'][i] == 0){
            cout << "C " << i<< endl;
        }
    }
    for(int i = 1; i <= 13; i++){
        if(card[(int)'D'][i] == 0){
            cout << "D " << i<< endl;
        }
    }
}


Measured memory_bytes: 3080
from collections import defaultdict
from itertools import product

N = int(input())

f = defaultdict(int)
for x, y, z in product(range(1, 100), repeat=3):
    n = x * x + y * y + z * z + x * y + y * z + z * x
    f[n] += 1

for i in range(1, N + 1):
    print(f[i])


Measured memory_bytes: 11964
# -*- coding: utf-8 -*-
n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(n-2):
    if p[i]<=p[i+1]<p[i+2] or p[i]>p[i+1]>=p[i+2]:
        count=count+1
print(count)    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    string s;
    cin >> s;
    if(s[0]!=s[1] && s[1]!=s[2] && s[2]!=s[3]){
        cout << "Good" << endl;
    }
    else{
        cout << "Bad" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int a, b;
  cin >> a >> b;
  int ans =  a - 2*b;
  if (ans < 0) {
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	string s,t;
	cin >> s >> t;
	int n = s.size();
	for(int i = 0;i<n;i++)
	{
		bool isans = true;
		for(int j=i; j<i+n;j++)
		{
			
			if(s[j-i]!=t[j%n])
			{
				isans = false;
			}
			
		}
		if(isans)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;

int A,B,C;
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B;
    if(B != 1){
        cout << A-B << endl;
    }else
    {
        cout << 0 << endl;
    }
    

    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
const int MOD = (1e6+3);
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};

using namespace std;

void solve()
{
    int x, y;
    cin >> x >> y;
    if(y%2) {
        cout << "No";
        return;
    }
    if(2*x <= y && 4*x >= y){
        cout << "Yes";
        return;
    }
    cout << "No";
    return;

}
//new line is printed in the main

int main()
{
    int t = 1;
        // cin >> t; // comment out if no test case is required
    // int i = 1;
    while(t--){
        //cout << "Case " << i++ << ": ";
        solve();
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int n,c[11001],d[11001],val[11001];
vector<int> w[11001];
int main()
{
	cin>>n;
	for(int i=1,x,y;i<n;i++)cin>>x>>y,d[x]++,d[y]++,w[x].push_back(y),w[y].push_back(x);
	set<pair<int,int>> s;
	for(int i=1;i<=n;i++)cin>>c[i],s.insert({d[i],i});
	sort(c+1,c+1+n);
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		int u=s.begin()->second;
		val[u]=c[i];
		ans+=1ll*c[i]*d[u];
		s.erase(*s.begin());
		for(int v:w[u])
			if(s.count({d[v],v}))
			{
				s.erase({d[v],v});
				d[v]--;
				s.insert({d[v],v});
			}
	}
	cout<<ans<<'\n';
	for(int i=1;i<=n;i++)cout<<val[i]<<' ';
	cout<<'\n';
}


Measured memory_bytes: 1536
#include <stdio.h>
int main(){
  int x,y;

  for(;;){
    scanf("%d %d",&x,&y);

    if(x == 0 && y == 0)break;

    if(x < y){
      printf("%d %d\n",x,y);
    }
    else{
      printf("%d %d\n",y,x);
    }

  }
 
  return 0;
}

Measured memory_bytes: 600
import java.util.*;


public class Main {

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

        int N = sc.nextInt();
        int M = sc.nextInt();

        if(N == M){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}






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

void chmin(int& a, int b){
    a = min(a, b);
}

int main(){
    int N, M, L;
    cin >> N >> M >> L;
    int dist[300][300];
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) dist[i][j] = (i==j ? 0 : L+1);
    for(int i=0; i<M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        chmin(dist[a][b], c);
        chmin(dist[b][a], c);
    }
    for(int k=0; k<N; k++) for(int i=0; i<N; i++) for(int j=0; j<N; j++) chmin(dist[i][j], dist[i][k] + dist[k][j]);

    for(int i=0; i<N; i++) for(int j=0; j<N; j++) if(i != j){
        dist[i][j] = (dist[i][j] <= L ? 1 : 1e9);
    }
    for(int k=0; k<N; k++) for(int i=0; i<N; i++) for(int j=0; j<N; j++) chmin(dist[i][j], dist[i][k] + dist[k][j]);
    
    int Q;
    cin >> Q;
    while(Q--){
        int s, t;
        cin >> s >> t;
        s--; t--;
        int ans = (dist[s][t] == 1e9 ? -1 : dist[s][t]-1);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 896
/*
    Author  :   jignesh1604
    College :   SVNIT
*/

#include<bits/stdc++.h>
using namespace std;

void solve() {
    long long int n , w , i , j;
    cin >> n >> w;
    long long int wei[n+1] , val[n+1];
    for(i = 0 ; i < n ; i++) {
        cin >> wei[i] >> val[i];
    }
    vector<vector<long long int>> dp(n+1 , vector<long long int> (w+1 , 0));
    for(i = 1 ; i <= n ; i++) {
        for(j = 1 ; j <= w ; j++) {
            if(wei[i-1] <= j) {
                dp[i][j] = max(val[i-1] + dp[i-1][j-wei[i-1]] , dp[i-1][j]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[n][w] << "\n";
}

int main() {
    long long int tc = 1;
    // cin >> tc;
    while(tc-- > 0) {
        solve();
    }
}

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

int main() {
	int N;
	cin >> N;
	int count = 1;
	int count2 = 0;
	vector<int> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H.at(i);
	}
	int maxv = *max_element(H.begin(), H.end());
	for (int i = 1; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (i == j)
			{
				count2 = 0;
				break;
			}
			if (H.at(j) <= H.at(i))
			{
				count2++;
			}
			if (count2 == i && H.at(i - 1) <= H.at(i))
			{
				count++;
			}
		}
	}
	cout << count << endl;
}

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

// DFSで木を走査しながらLISをカウントする

const int MAX_N = 200005;
const int INF = 1001001001;

vector<int> a, ans;
vector<int> tree[MAX_N];
int dp[MAX_N];

void DFS(int v, int p = -1)
{
    int i = lower_bound(dp, dp + MAX_N, a[v]) - dp;
    int old = dp[i];
    dp[i] = a[v];
    ans[v] = i;
    if (p != -1)
        ans[v] = max(ans[v], ans[p]);
    for (int u : tree[v])
    {
        if (u == p)
            continue;
        DFS(u, v);
    }
    dp[i] = old;
}

int main()
{
    int N;
    cin >> N;
    a = ans = vector<int>(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < N - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    for (int i = 0; i < MAX_N; i++)
        dp[i] = INF;
    dp[0] = -INF;
    DFS(0);
    for (int i = 0; i < N; i++)
        cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 30868
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define dump(x)  cerr << #x << " => " << (x) << endl
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define EQ(a,b) (abs(a - b) < 1e-10)
using namespace std;
typedef long long LL;
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {1,0,-1,0};
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
// LONG_MAX,LLONG_MAX
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class Key,class Value> ostream& operator << (ostream &s, map<Key,Value> M)
{ for ( auto itr = begin(M); itr != end(M); ++itr) { s << itr->first << ":" << itr->second; } return s;}
typedef vector<LL> VL;
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L;
    cin >> L;
    VL A(L);
    REP(i, L) cin >> A[i];
    vector<VL> DP(L,VL(5,0));
    constexpr int Z = 0,D = 1,S = 2,G = 3,U = 4;
    DP[0][Z] = A[0];
    DP[0][D] = A[0] != 0 ? A[0] % 2 : 2;
    DP[0][S] = (A[0] % 2 == 0) ? 1 : 0;
    DP[0][G] = A[0] != 0 ? A[0] % 2 : 2;
    DP[0][U] = A[0];
    REP(i,L-1) {
        DP[i+1][Z] = DP[i][Z] + A[i+1];
        DP[i+1][D] = min(DP[i][Z],DP[i][D]) + ((A[i+1] != 0) ? A[i+1] % 2 : 2);
        DP[i+1][S] = min({DP[i][Z],DP[i][D],DP[i][S]}) + ((A[i+1] % 2 == 0) ? 1 : 0);
        DP[i+1][G] = min({DP[i][Z],DP[i][D],DP[i][S],DP[i][G]}) + ((A[i+1] != 0) ? A[i+1] % 2 : 2);
        DP[i+1][U] = min({DP[i][Z],DP[i][D],DP[i][S],DP[i][G],DP[i][U]}) + A[i+1];
    }

    cout << MIN(DP[L-1]) << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }


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

  ll n;
  cin >> n;
  vector<ll> a(n), sorted(n);
  rep(i, 0, n){
    cin >> a[i];
    sorted[i] = a[i];
  }
  sort(rall(sorted));
  ll maxi = sorted[0];
  ll nexti = sorted[1];

  rep(i, 0, n){
    //cout << a[i] << 'a' << endl;
    if(a[i] == maxi){
      if(maxi == nexti) cout << maxi << endl;
      else cout << nexti << endl;
    }else{
      cout << maxi << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-8;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=2e5+100;

void solve(){
	ll x;cin>>x;
	ll now=100;
	int ans=0;
	while(now<x){
		now+=(ll)(0.01*now);
		ans++;
	}
	ac;
}
int main(){
    //IOS;
    //freopen("in.txt","r",stdin);
    //freopen("D:\\data.txt","w",stdout);
    solve();
    
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for (int i = 0; i <= min(s, k); i++)
    {
        for (int j = 0; j <= min(s - i, k); j++)
        {
            int z = s - i - j;
            if (z >= 0 && z <= k)
            {
                ans++;                            
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 504
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int A,B,C;

int main(){
    cin>>A>>B>>C;
    out(((A+B)>=C?"Yes":"No"));
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int n;
    int ay[120];
    cin>>n;
    for(int i=0;i<n;++i)
        cin>>ay[i];
    int mi=2e9;
    int mx=0;
    for(int i=0;i<n;++i){
        mi=min(ay[i],mi);
        mx=max(mx,ay[i]);
    }
    cout<<mx-mi<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int x = 0;
  for(int i = 0; i < 3; i++)
  if(s[i] == s[i+1])
    x++;

    cout << (x != 0? "Bad" : "Good" )<< endl;

}

Measured memory_bytes: 256
from collections import deque
from collections import defaultdict

n = int(input())
graph = defaultdict(list)

for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append([b, i])
    graph[b].append([a, i])

ans = [0] * (n - 1)

q = deque([[1, 0, 0]])
while q:
    v, pcol, root = q.popleft()
    cnt = 1
    for node in graph[v]:
        if node[0] == root:
            continue
        if cnt == pcol:
            cnt += 1
        ans[node[1]] = cnt
        q.append([node[0], cnt, v])
        cnt += 1

print(max(ans))
print(*ans, sep="\n")

Measured memory_bytes: 52996
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<27;
const double PI=acos(-1);
int main(){
	int n,a,b,c;
	int ans=INF;
	cin >>n>>a>>b>>c;
	Vi l(n);
	Vi g(3);
	g[0]=a;
	g[1] = b;
	g[2] = c;
	rep(i,n){
		cin>>l[i];

	}
	Vi legth(3,0);
	Vi cost(3,0);
	int id;
	rep(bit,1<<(n*2)){
		rep(i,3){
			legth[i]=0;
			cost[i]=-10;
		}
		for(int i=0;i<n*2;i+=2){
			if(bit&(1<<i)){
				id=1;
			}else{
				id=0;
			}
			if (bit & (1 << (i+1)))
			{
				id += 2;
			}
			if(id!=3){
				legth[id]+=l[i/2];
				cost[id]+=10;
			}
		}
		rep(i,3){
			if(legth[i]==0){
				cost[i]=INF;
			}else{
				cost[i]+=abs(legth[i]-g[i]);
			}
		}
		chmin(ans,cost[1]+cost[2]+cost[0]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,k=MI()
    aa=set()
    for _ in range(k):
        II()
        for a in LI():aa.add(a)
    print(n-len(aa))

main()

Measured memory_bytes: 9144
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
using namespace std;

struct edge { int to, cost; edge(int _to, int _cost) {to = _to; cost=_cost;} };
typedef pair<int, int> pii;
int INF = 1012012012;

vector<edge> G[100];

int ds(int s, int g) {

	int field[100];
	priority_queue<pii, vector<pii>, greater<pii> > q;
	
	for(int i = 0; i < 100; i++)
		field[i] = INF;
	field[s] = 0;
	
	q.push(pii(0, s));
	
	while(!q.empty()) {
		pii p = q.top(); q.pop();
		int m = p.second;
		if(field[m] < p.first) continue;
		for(int i = 0; i < (int)G[m].size(); i++) {
			edge ee = G[m][i];
			if(field[ee.to] > field[m] + ee.cost) {
				field[ee.to] = field[m] + ee.cost;
				q.push(pii(field[ee.to], ee.to));
			}
		}
	}

	return (field[g] == INF) ? -1 : field[g];
	
}

int main() {

	int n, k;
	int a, b, c, d, e, f;
	
	while(cin >> n >> k, n + k != 0) {
	
		for(int i = 0; i < 100; i++)
			G[i].clear();
		
		while(k--, k != -1) {
			cin >> f;
			if(f == 0) {
				cin >> a >> b;
				cout << ds(a-1, b-1) << endl;
			} else {
				cin >> c >> d >> e;
				if(G[c-1].empty()) {
					G[c-1].push_back(edge(d-1, e));
				} else {
					bool add = true;
					for(int i = 0; i < (int)G[c-1].size(); i++) {
						if(G[c-1][i].to == d-1) {
							add = false;
							if(G[c-1][i].cost > e) {
								G[c-1][i].cost = e;
							}
							break;
						}
					}
					if(add) G[c-1].push_back(edge(d-1, e));
				}
				if(G[d-1].empty()) {
					G[d-1].push_back(edge(c-1, e));
				} else {
					bool add = true;
					for(int i = 0; i < (int)G[d-1].size(); i++) {
						if(G[d-1][i].to == c-1) {
							add = false;
							if(G[d-1][i].cost > e) {
								G[d-1][i].cost = e;
							}
							break;
						}
					}
					if(add) G[d-1].push_back(edge(c-1, e));
				}
			}
		}
		
		/*
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < (int)G[i].size(); j++) {
				cout << "[" << G[i][j].to << ", " << G[i][j].cost << "] ";
			}
			cout << endl;
		}
		*/
		
	}

	return 0;

}

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

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;
    for(int i = 0; i < n; ++i) {
        if(s[k-1] != s[i]) {
            s[i] = '*';
        }
    }
    cout << s << '\n';
}

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

struct edge{
    int to,cost;
    edge(int to,int cost):to(to),cost(cost){}
};

int N,M,X;
int H[100000];
vector<edge>G[100000];

const int INF=1001001001001001001ll;
int dist[100000];

signed main(){
    scanf("%lld%lld%lld",&N,&M,&X);
    rep(i,N)scanf("%lld",&H[i]);
    rep(i,M){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        a--;b--;
        G[a].pb(edge(b,c));
        G[b].pb(edge(a,c));
    }

    fill_n(dist,N,INF);
    dist[0]=0;
    priority_queue<pint,vector<pint>,greater<pint> >que;
    que.push(pint(0,0));

    while(que.size()){
        int v=que.top().se,c=que.top().fi;que.pop();
        if(dist[v]<c)continue;
        int h=max(0ll,X-c);
        rep(i,G[v].size()){
            edge &e=G[v][i];
            if(H[v]<e.cost)continue;
            int cc=e.cost;
            if(h-e.cost<0)cc+=e.cost-h;
            else if(h-e.cost>H[e.to])cc+=h-e.cost-H[e.to];
            if(dist[e.to]<=c+cc)continue;
            dist[e.to]=c+cc;
            que.push(pint(dist[e.to],e.to));
        }
    }

    //rep(i,N)cout<<i+1<<":"<<dist[i]<<endl;

    if(dist[N-1]==INF)puts("-1");
    else{
        int tmp=dist[N-1];
        tmp+=H[N-1]-max(0ll,X-tmp);
        printf("%lld\n",tmp);
    }
    return 0;
}

Measured memory_bytes: 21048
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        bool prime[1000000]={false};
        prime[1]=true;
        prime[2]=false;
        int cou=0;
        for(int i=2;i*i<=n;i++){
            if(!prime[i]){
                for(int j=2;i*j<=n;j++){
                    prime[i*j]=true;
                }
            }
        }
        for(int i=1;i<=n;i++){
            if(!prime[i])cou++;
        }
        cout<<cou<<endl;
    }
}

Measured memory_bytes: 2144
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e4 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
ll A[MAXN];
int maxa;
int p[MAXN*100];
map<int, int> mp;

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

ll fexp(ll b, ll e) {
	if (e == 0ll) return 1ll;
	if (e == 1ll) return b;
	ll temp = fexp(b, e / 2) % MOD;
	return ((temp * temp % MOD) * fexp(b, e % 2)) % MOD;
}

void sieve() {
	for (int i = 2; i <= maxa; ++i) {
		if (!p[i]) {
			for (int j = 1; i*j <= maxa; ++j) p[i*j] = i;
		}
	}
	return;
}


int main()
{
	int i, j;
	scanf("%d", &N);
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &A[i]);
		maxa = MAX(maxa, A[i]);
	}
	sieve();
	for (i = 1; i <= N; ++i) {
		ll temp = A[i];
		while (1) {
			if (temp == 1) break;
			int prime = p[temp];
			int cnt = 1;
			while (p[temp] == p[temp / prime]) {
				++cnt;
				temp /= prime;
			}
			temp /= prime;
			mp[prime] = MAX(mp[prime], cnt);
		}
	}

	ll lcm = 1ll;
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		for (i = 1; i <= it->second; ++i) {
			lcm = lcm * it->first % MOD;
		}
	}
	ll ans = 0;
	for (i = 1; i <= N; ++i) {
		ll temp = lcm * fexp(A[i], MOD - 2) % MOD;
		ans = (ans + temp) % MOD;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {

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

		while (true) {
			if (in.hasNext() == false) {
				break;
			}
			String text = in.next();
			char[] s = text.toCharArray();
			int joi = 0;
			int ioi = 0;
			for (int i = 0; i < text.length() - 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++;
				}
			}
			System.out.println(joi);
			System.out.println(ioi);
		}
	}
}

Measured memory_bytes: 19748
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

const int M = 80 * 160 + 10;
const int MM = 2*M;

int main() {
	int H, W; cin >> H >> W;
	VV A(H, V(W));
	VV B(H, V(W));
	rep(h, H) rep(w, W) cin >> A[h][w];
	rep(h, H) rep(w, W) cin >> B[h][w];

	vector<vector<bitset<MM>>> dp(H+1, vector<bitset<MM>>(W+1));
	dp[1][1].set(M + A[0][0] - B[0][0]);

	rep(h, H) rep(w, W) {
		int x = abs(A[h][w] - B[h][w]);
		dp[h+1][w+1] |= dp[h][w+1]<<x;
		dp[h+1][w+1] |= dp[h][w+1]>>x;
		dp[h+1][w+1] |= dp[h+1][w]<<x;
		dp[h+1][w+1] |= dp[h+1][w]>>x;
	}

	int ans = 1e6;
	rep(i, MM) {
		if (dp[H][W][i]) ans = min(ans, abs(i-M));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 21376
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = 1e18;
const int N = 18;




void solve(int t)
{
	ll n, x, p;
	cin >> n >> x >> p;
	cout << ((n / x) + (n % x != 0))*p << endl;


}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);




	int t = 1;
	//cin >> t;



	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 3656