akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<bitset>


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
vector<ll> v;
ll cnt[60];
int main()
{
	int n;
	cin>>n;
	rep(i, 0, n)
	{
		ll x;
		cin>>x;
		rep(j ,0 ,60)
		{
			if(((1LL << j)&x) != 0) cnt[j]++;
		}
	}
	ll ans = 0;
	rep(j, 0, 60)
	{
		//cout<<cnt[j]<<endl;
		ll c = (cnt[j]* (n- cnt[j])) % M;
		ll z = ((1LL << j)) % M;
		ans = (ans + c*z) % M;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
string s;

int main() {
	cin >> s;
	int ans = 0;
	for(int i = 0; i < 4; i++) {
		if(s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//Om Sree Sai Ram
#include "bits/stdc++.h"
using namespace std;

const int mod = 1e9+7;

void add_self(int&a,int b)
{
  a+=b;
  if(a>=mod)
  {
    a-=mod;
  }
}


int main() 
{


string k;
int D;
cin>>k;
cin>>D;
int n = k.length();
vector<vector<int>>dp(D,vector<int>(2));
//dp[i][bool] i represents the current sum%D we are at. 
// we have two states, we may have already choosen smaller number or
// not choosen that is represented by bool flag

dp[0][0] = 1;
//dp[0][1] = 0; because we cannot get into the state with choosing any
//digit
//int sum =0;
for(int i=0;i<n;i++)
{
  vector<vector<int>> new_dp(D,vector<int>(2));
  for(int sum=0;sum<D;sum++)
  {
  //cout<<" i = "<<i<<endl;
  int curr = k[i]-'0';
  for(auto fl:{false,true})
      {
     for(int a=0;a<=9;a++)
        {
        if(!fl && a>(curr))
        {
          break;
        }
        else
        {
          add_self(new_dp[(sum+a)%D][fl||(a<curr)],dp[sum][fl]);
        }
      }
    }
  }
  dp = new_dp;
} 
add_self(dp[0][0],dp[0][1]);
int ans = dp[0][0];
//always 0 is trivial case. we need to discard it.
ans--;
if(ans==-1)
{
  ans = mod-1;
}
cout<<ans<<endl;
return 0;
}


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

struct Edge {
    int from,to;
    Edge(int f,int t) : from(f), to(t){}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

class LowLink {
    public:
        LowLink(int n) : mGraph(n), mOrd(n), mLow(n), mUsed(n,false) {}
        void add_edge(int u, int v){
            mGraph[u].emplace_back(u,v);
            mGraph[v].emplace_back(v,u);
        }
        // e(u,v)が橋　<=> ord[u] < low[v]
        // 頂点vが関節点 <=> ord[u] <= low[v]となるvの子uが存在
        int dfs(int v,int pv,int k){
            mUsed[v] = true;
            mOrd[v] = mLow[v] = k++; // 訪れた順
            bool is_articulation = false;
            int cnt = 0;
            for(Edge nv : mGraph[v]){
                if(!mUsed[nv.to]){ // まだ訪れてない
                    ++cnt;
                    k = dfs(nv.to,v,k);
                    mLow[v] = min(mLow[v], mLow[nv.to]);

                    is_articulation |= ~pv && mOrd[v] <= mLow[nv.to];
                    if(mOrd[v] < mLow[nv.to]) mBridges.emplace_back(minmax(v,nv.to));
                } else if(nv.to != pv){ // 後退辺だったら
                    mLow[v] = min(mLow[v], mOrd[nv.to]);
                }
            }
            is_articulation |= pv == -1 && cnt > 1;
            if(is_articulation) mArticulationPoints.push_back(v);

            return k;
        }

        void Init(){
            int k = 0;
            for(int i = 0; i < mGraph.size(); ++i){
                if(!mUsed[i]) k = dfs(i,-1,k);
            }
        }

        vector<pair<int,int> > GetBridges(){ return mBridges;}
        vector<int> GetArticulationPoints(){ return mArticulationPoints;}

    private:
        Graph mGraph;
        vector<int> mOrd;
        vector<int> mLow;
        vector<bool> mUsed;
        vector<pair<int,int> > mBridges;
        vector<int> mArticulationPoints;
};


int main(){
    int V,E,s,t;
    cin >> V >> E;
    LowLink lowlink(V);
    for(int i = 0; i < E; ++i){
        cin >> s >> t;
        --s;--t;
        lowlink.add_edge(s,t);
    }
    lowlink.Init();
    auto ans = lowlink.GetBridges();
    cout << ans.size() << '\n';
    return 0;
}


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

using namespace std;

int main(){
    int K;
    string S;
    cin>>K;
    cin>>S;
    if(S.length()<=K) cout<<S<<"\n";
    else {
        cout<<S.substr(0,K)+"..."<<"\n";
    }
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;

int main(){
    int A, B, C, D;

    cin >> A >> B >> C >> D;

    int diff;
    if(A<=C){
        if(B<=D){
            diff = B - C;
        }
        else{
            diff = D - C;
        }
    }
    else{
        if(B<= D){
            diff = B - A;
        }
        else{
            diff = D - A;
        }
    }

    if(diff < 0){
        diff = 0;
    }
    cout << diff << endl;


}

Measured memory_bytes: 256
msg = raw_input()
for i in range(len(msg)-4):
    if msg[i:i+5] == "apple":
        msg = msg[:i] + "peach" + msg[i+5:]
    elif msg[i:i+5] == "peach":
        msg = msg[:i] + "apple" + msg[i+5:]
print msg

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

using namespace std;


int main() {

	int N, M;
	int result = 0;
	cin >> N >> M;
	vector<int> foods(M, 0);

	for (int i = 0; i < N; i++) {
		int K, tempfood;
		cin >> K;

		for (int j = 0; j < K; j++) {
			cin >> tempfood;
			foods[tempfood - 1] += 1;
		}
	}

	for (auto i = 0; i < M; i++) {
		if (foods[i] == N)result += 1;

	}

	cout << result << endl;
	


	return 0;
}

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

bool findOperators(vector<int> &arr, stack<char> &operators, int idx, int val) {
  
  if (idx == 3) {
    if (val == 7) {
      return true;
    } else {
      return false;
    }
  }
  
  int num = arr.at(idx + 1);
  if (findOperators(arr, operators, idx + 1, val + num)) {
    operators.push('+');
    return true;
  }
  if (findOperators(arr, operators, idx + 1, val - num)) {
    operators.push('-');
    return true;
  }
  return false;
} 

int main() {
  string ABCD;
  cin >> ABCD;
  
  vector<int> arr(4);
  for (int i = 0; i < 4; i++) {
    arr.at(i) = ABCD.at(i) - '0';
  }
  
  stack<char> operators;
  findOperators(arr, operators, 0, arr.at(0));
  
  for (int i = 0; i < 3; i++) {
    cout << arr.at(i) << operators.top();
    operators.pop();
  }
  cout << arr.at(3) << "=7";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <math.h>
#include <array>
using namespace std;
typedef long long ll;
string sa,sb,sc;
int main(int argc,char const* argv[])
{
  cin >> sa >> sb >> sc;
  queue<char> a,b,c;
  for(int i=0;i<sa.size();i++)
    {
      a.push(sa[i]);
    }
  for(int i=0;i<sb.size();i++)
    {
      b.push(sb[i]);
    }
  for(int i=0;i<sc.size();i++)
    {
      c.push(sc[i]);
    }
  char now=a.front();a.pop();
  while(1)
    {
      if(now=='a')
	{
	  if(a.empty())
	    {
	      cout << 'A' << endl;
	      return 0;
	    }
	  now=a.front();a.pop();
	}
      else if(now=='b')
	{
	  if(b.empty())
	    {
	      cout << 'B' << endl;
	      return 0;
	    }
	  now=b.front();b.pop();
	}
      else if(now=='c')
	{
	  if(c.empty())
	    {
	      cout << 'C' << endl;
	      return 0;
	    }
	  now=c.front();c.pop();
	}
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int X=gi();
	    int Y=gi();
	    
	    


        //System.out.print(c);

        if (2*X<=Y&& Y<=4*X && Y%2==0) {
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35460
#include<bits/stdc++.h>
#define M 505
using namespace std;
int A[M],n,sum,m,W[M],tail;
int main(){
	int ans=1;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]),sum+=A[i];
	for(int i=1;i<=sqrt(sum);i++){
		if(sum%i!=0)continue;
		for(int j=1;j<=n;j++)W[j]=A[j]%i;
		sort(W+1,W+n+1);
		int R=n;
		long long tot=0;
		for(int j=1;j<=n;j++){
			while(R>=j&&i-W[R]<W[j])tot+=i-W[R],W[j]-=(i-W[R]),W[R]=0,R--;
			if(R>j)W[R]+=W[j],tot+=W[j],W[j]=0;
		}
		if(tot<=m)ans=max(ans,i);
		int now=sum/i;
		for(int j=1;j<=n;j++)W[j]=A[j]%now;
		sort(W+1,W+n+1);
		R=n;
		tot=0;
		for(int j=1;j<=n;j++){
			while(R>=j&&now-W[R]<W[j])tot+=now-W[R],W[j]-=(now-W[R]),W[R]=0,R--;
			if(R>j)W[R]+=W[j],tot+=W[j],W[j]=0;
		}
		if(tot<=m)ans=max(ans,now);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define pr pair<int, int>
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
const int INF = 1e9 + 7;
const int N = 122;
ll k, a[N];

int main(){
	read(k); int n = 50;
	rep(i, 0, n - 1) a[i] = k / n + i;
	k %= n; int pos = 0;
	while(k--){
		a[pos] += n;
		rep(i, 0, n - 1) if (i != pos) a[i]--;
		pos++;
	}
	printf("%d\n", n);
	rep(i, 0, n - 1) printf("%lld%c", a[i], " \n"[i == n - 1]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,x,y,i,j,k,p=0,q=0,h,w,r,t;
	string s;
	cin>>s;
	if(s=="SUN") cout<<7;
	else if(s=="MON") cout<<6;
	else if(s=="TUE") cout<<5;
	else if(s=="WED") cout<<4;
	else if(s=="THU") cout<<3;
	else if(s=="FRI") cout<<2;
	else if(s=="SAT") cout<<1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
bool e[300000];
int main()
{
  rep(i,300000) e[i]=false;
  for(int i=1;i<300000;i = ((i%7==1) ? i+5 : i+2)){
  	e[i]=true;
  }
  e[1]=false;
  for(int i=1;i<300000;i = ((i%7==1) ? i+5 : i+2)){
    if(e[i]){
      for(int j=i+i;j<300000;j+=i){
	e[j]=false;
      }
    }
  }
  
  //cout << "i";
  while(true){
    int a;
    cin >> a;
    if(a==1) break;
    set<int> c;
    for(int i=2;i<300000;i=((i%7==1) ? i+5 : i+2)){
      //   if(a%i==0) cout << i << " is yakusu." << endl;
      //if(e[i]) cout << i << " is sosu." << endl;
      if(a%i==0 && e[i]){
	c.insert(i);
      }
    }
    cout << a << ":";
    for(set<int>::iterator itr=c.begin();itr!=c.end();itr++){
      cout << " " << *itr;
    }
    cout << endl;
  }
  return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;
const double EPS=1e-12;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;cin>>S;
  bool isgood=true;
  for(ll i=0;i<3;i++){
    isgood &= S[i]!=S[i+1];
  }
  cout<<(isgood? "Good":"Bad")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
class activity
{
public:
  int a,b,c;
};
int maxhappiness(vector<activity> v, int n)
{
  int dp[n][3];
  dp[0][0] = v[0].a;
  dp[0][1] = v[0].b;
  dp[0][2] = v[0].c;
  for(int i=1;i<n;i++)
  {
    dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + v[i].a;
    dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + v[i].b;
    dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + v[i].c;
  }

  return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}
int main()
{
  int n;
  cin>>n;
  vector<activity> v;
  for(int i=0;i<n;i++)
  {
    activity A;
    cin>>A.a>>A.b>>A.c;
    v.push_back(A);
  }

  cout<<maxhappiness(v,n);


  
  return 0;
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int a, b;
  cin >> a >> b;
  cout << max(a+b, max(a*b, a-b));
  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define y0 y12345
#define y1 y54321
typedef unsigned long ul;
typedef long long ll;
//typedef pair<int, int> mpair;
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(a>b){a=b;return 1;}return 0;}
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n,m;cin>>n>>m;
	int dp[n+1];
	int f[n+1] = {0};
	rep(i, m){
		int a;
		cin>>a;
		f[a] = 1;
	}
	dp[n] = 1;
	dp[n-1] = 1-f[n-1];
	
	for(int i = n-2;i >= 0;i--){
		dp[i] = (dp[i+1] + dp[i+2])*(1-f[i])%1000000007;
	}
	cout << dp[0] << endl;
	return 0;
}


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

#define MOD 1000000007
#define ll long long int 
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template <typename T>
void printvec(vector<T>& vec)
{
    for(int i=0;i<vec.size();++i){
        cout<<vec[i]<<" ";
    }
    cout<<endl;

}

struct ListNode {
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};
 
int main()
{
    int n,k;cin>>n>>k;

    int height[n+1], dp[n+1];

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

    dp[1] = 0;
    dp[2] = abs(height[2]-height[1]);

    for (int i = 3; i <= n; ++i)
    {
      dp[i] = dp[i-1]+abs(height[i]-height[i-1]);
      for (int j = 2; j <= k && i-j>=1; ++j)
      {   
        dp[i] = min(dp[i], dp[i-j]+abs(height[i]-height[i-j]));
      }
    }

    cout<<dp[n];

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N;
    cin >> N;
    int v[N], temp;
    Fp(i, 0, N) cin >> v[i];
    Fp(i, 1, N - 1){
        Fp(j, 0, N - i){
            if(v[j] > v[j + 1]){
                temp = v[j];
                v[j] = v[j + 1];
                v[j + 1] = temp;
            }
        }
    }
    double ans = (double)v[0];
    Fp(i, 1, N){
        ans += (double)v[i];
        ans /= 2;
    }
    printf("%.10f", ans);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000


int main() {
	char a[N + 1];
	f(i, N + 1)a[i] = 0;
	long long n, k;
	long long x, y, z;
	long long s, ans, ans2;
	bool v = true;
	ans = 0;
	scanf("%s", a);
	n = strlen(a);
	scanf("%lld", &k);
	v = true;
		f(i, n) {
			if (a[i] != a[0])v = false;
	}
		if (v) {
			ans = n * k;
			ans = ans / 2;
			printf("%lld\n", ans);
			return 0;
		}
		ans2 = 0;
		x = 1;
		f(i, n-1) {
			if (a[i + 1] == a[i])x++;
			else {
				x = x / 2;
				ans += x;
				x = 1;
			}
		}
		x = x / 2;
		ans += x;
		x = 1;
		f(i, n)a[n + i] = a[i];
		n *= 2;
		f(i, n - 1) {
			if (a[i + 1] == a[i])x++;
			else {
				x = x / 2;
				ans2 += x;
				x = 1;
			}
		}
		x = x / 2;
		ans2 += x;
		x = 1;
		s = (ans2 - ans)*(k - 1);
		s += ans;

	printf("%lld\n", s);


	return 0;
}

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

using namespace std;

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

// chmax, chmin
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;
}

void solve(std::string S, std::string T) {
    int ans = 1e9;
    for (int i = 0; i + T.size() <= S.size(); i++) {
        int s = 0;
        for (int j = 0; j < T.size(); j++) {
            if (T[j] != S[i + j])s++;
        }
        ans = min (ans, s);
    }
    cout << ans << endl;
}

int main() {
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int N;
int a[110];
int ans = 0;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];
    
    sort(a, a + N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) Alice += a[i];
        else Bob += a[i];
    }
    ans = Alice - Bob;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.array;
import std.algorithm;
import std.conv;
import std.range;
import std.functional;
import std.bigint;

void main(string[] args) {
    auto input = readln.chomp.split.map!(to!BigInt);
    BigInt s = input[0];
    BigInt c = input[1];

    BigInt ans = min(s, c/2);
    ans += (c-ans*2)/4;
    ans.writeln;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#define LL long long  
#define LD long double

using namespace std;

const int M = 1000001;
int n,m,k,a[M];
map<pair<int,int>,int> mp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
	{
		LD k;
		cin>>k;
		k*=1e9;
		LL w=k+0.5;
		LL t=__gcd(w,(LL)1e9);
		w/=t; LL x=1e9; x/=t;
		int s2=0,s5=0;
		while(w%2==0) w/=2, s2++;
		while(w%5==0) w/=5, s5++;
		while(x%2==0) x/=2, s2--;
		while(x%5==0) x/=5, s5--;
		if(mp.find({s2,s5})==mp.end()) mp[{s2,s5}]=0;
		mp[{s2,s5}]++;
	}
	LL res=0;
	for(auto x:mp)
		for(auto y:mp)
		{
			int s2=x.first.first+y.first.first, s5=x.first.second+y.first.second;
			if(s2<0 || s5<0) continue;
			if(x==y)
			{
				res+=x.second*(y.second-1ll);
			}
			else res+=(LL)(x.second)*(y.second);
		}
		printf("%lld",res/2);
}

Measured memory_bytes: 3788
#include<stdio.h>

int main(void)
{
	int a,b,c;
	int tmp;
	
	scanf("%d%d%d", &a,&b,&c);
	
	if(a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	if(b > c){
		tmp = b;
		b = c;
		c = tmp;
	}		
	if(a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	
	return 0;
}


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

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

// const ll MOD = (ll)1e9+7;
const ll MAX = (ll)6e3+10;

int main(void) {
   ll X,Y;
   cin>>X>>Y;
   ll ans = 0;
   if (X==3) ans += 1e5;
   else if (X==2) ans += 2e5;
   else if (X==1) ans += 3e5;
   if (Y==3) ans += 1e5;
   else if (Y==2) ans += 2e5;
   else if (Y==1) ans += 3e5;

   if (X==1 && Y==1) ans += 4e5;
   cout<<ans<<endl;


   return 0;
}



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

using namespace std;

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

//===


const int INF = int(1e9 + 7);


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vector<Vi> to(N);
	for (int i = 0; i < M; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		to[u].push_back(v);
	}
	int S, T;
	cin >> S >> T;
	--S; --T;

	vector<vector<int>> dist(N,vector<int>(3,INF));

	queue<Pii> q;
	q.emplace(S,0);
	dist[S][0] = 0;
	while (!q.empty()) {
		int v = q.front().first;
		int l = q.front().second;
		q.pop();
		for (const auto& u : to[v]) {
			int nl = (l + 1) % 3;
			if (dist[u][nl] != INF) continue;
			dist[u][nl] = dist[v][l] + 1;
			q.emplace(u, nl);
		}
	}

	int ans = dist[T][0];
	if (ans == INF) ans = -1;
	else ans /= 3;
	cout << ans << endl;
}


Measured memory_bytes: 11264
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

H = input()
W = input()
N = input()
den = max(H, W)
print N / den + (N % den != 0)

Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    x-=z;
    int cnt=0;
    for(int i=x;i>=y+z;i-=y+z) cnt++;
    printf("%d\n",cnt);
    return 0;
}



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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int h, w;
  cin >> h >> w;
  vector<vint> a(h, vint(w));
  rep(i, h) rep(j, w) cin >> a[i][j];

  int ans = inf;
  rep(i, h) {
    rep(j, w) {
      int sum = 0;
      rep(k, h) {
	rep(l, w) {
	  sum += min(llabs(i-k)*a[k][l], llabs(j-l)*a[k][l]);
	}
      }
      chmin(ans, sum);
    }
  }
  cout << ans << endl;

  return 0;
}



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

int main()
{
	int n;
	cin >> n;
	map<int, int> m;
	for (int i = 2; i <= n; ++i) {
		int tmp;
		cin >> tmp;
		++m[tmp];
	}
	for (int i = 1; i <= n; ++i) {
		cout << m[i] << endl;
	}
}

Measured memory_bytes: 12540
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);

struct Step {
	int h, w;
	bool left;

	bool operator < (const Step& r)const {
		if (left != r.left)return left < r.left;
		else if (h != r.h)return h > r.h;
		else return w > r.w;
	}
};

struct Stage {
	int H, W;
	vector<vector<int>> s;
	vector<pair<int,int>> t;

	Stage()
	{
		cin >> W >> H;
		if (W == 0)return;
		s.resize(H, vector<int>(W, INF));
		dpL.resize(H, vector<int>(W, INF));
		dpR.resize(H, vector<int>(W, INF));
		REP(i, H){
			REP(j, W) {
				char c;
				cin >> c;
				switch (c) {
				case 'S':
					next.insert(Step({ i, j, true }));
					next.insert(Step({ i, j, false }));
					dpL[i][j] = 0;
					dpR[i][j] = 0;
					s[i][j] = 0;
					break;
				case 'T':
					t.push_back({ i,j });
					s[i][j] = 0;
					break;
				case 'X':
					break;
				default:
					s[i][j] = c - '0';
					break;
				}
			}
		}
	}

	void action()
	{
		//calculation
		while (!next.empty()) 
		{
			Step now = *next.begin();
			next.erase(next.begin());
			walk(now);
		}

		//output
		int res = INF;
		for (auto goal : t)
		{
			res = min(res, dpL[goal.first][goal.second]);
			res = min(res, dpR[goal.first][goal.second]);
		}
		cout << (res != INF ? res : -1) << endl;
	}

private:
	set<Step> next;
	vector<vector<int>> dpL, dpR;

	void walk(const Step& now)
	{
		//移動ベクトル定義
		int dh[] = { -2,-1,-1,0,0,0,1,1,2 };
		int dw[] = { 1,1,2,1,2,3,1,2,1 };
		if (now.left)
		{
			for (int& tmp : dw) {
				tmp *= -1;
			}
		}
		
		//移動
		REP(i, 9)
		{
			int h = now.h + dh[i];
			int w = now.w + dw[i];

			if (!is_in({ h,w }))continue;
			if (s[h][w] == INF)continue;

			if (now.left) {
				if (dpR[now.h][now.w] + s[h][w] >= dpL[h][w]) {
					continue;
				}
				else {
					dpL[h][w] = dpR[now.h][now.w] + s[h][w];
					next.insert({ h,w,!now.left });
				}
			}
			else{
				if (dpL[now.h][now.w] + s[h][w] >= dpR[h][w]) {
					continue;
				}
				else {
					dpR[h][w] = dpL[now.h][now.w] + s[h][w];
					next.insert({ h,w,!now.left });
				}
			}
		}
	}

	bool is_in(pair<int, int> p)const
	{
		if (p.first < 0)return false;
		if (p.second < 0)return false;
		if (H <= p.first)return false;
		if (W <= p.second)return false;
		return true;
	}
};


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	while (true)
	{
		Stage stage;
		if (!stage.W)break;
		stage.action();
	}
	//debug();
	
	return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef double db;
const int INF = 1e9 + 5;

set<string> s;
void solve()
{
	int n; 
	string a;
	int cnt=0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (s.find(a) == s.end())
		{
			cnt++;
			s.insert(a);
		}
	}
	cout << cnt;
}
int main()
{
//	int t;
//	cin >> t;
//	while (t-- > 0)
	solve();
}


Measured memory_bytes: 19180
from collections import deque


if __name__ == "__main__":
    que_num, query_num = map(lambda x: int(x), input().split())
    ques = [deque() for _ in range(que_num)]  # type: ignore

    for _ in range(query_num):
        op, *value = map(lambda x: int(x), input().split())
        if (0 == op):
            ques[value[0]].append(value[1])
        elif (1 == op):
            if ques[value[0]]:
                print(" ".join([str(elem) for elem in ques[value[0]]]))
            else:
                print("")
        elif (2 == op):
            if ques[value[1]]:
                if (len(ques[value[0]]) == 1):
                    ques[value[1]].append(ques[value[0]][0])
                elif (len(ques[value[1]]) == 1):
                    ques[value[0]].appendleft(ques[value[1]][0])
                    ques[value[1]] = ques[value[0]]
                else:
                    ques[value[1]] += ques[value[0]]
            else:
                ques[value[1]] = ques[value[0]]
            ques[value[0]] = deque()
        else:
            pass




Measured memory_bytes: 61668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7,mx=10005;
char s[mx];
int main()
{
  scanf("%s",s);
  int D;
  scanf("%d",&D);
  int len=strlen(s);
  vector<vector<int>>dp(D,vector<int>(2));
  dp[0][0]=1;
  for(int i=0;i<len;i++)
  {
  	   vector<vector<int>>new_dp(D,vector<int>(2));
	   for(int sum=0;sum<D;sum++)
	   {
		   	  for(int flag:{0,1})
		   	  {      int limit=flag?9:s[i]-'0' ;
				   	 for(int digit=0;digit<=limit;digit++)
				   	 {
				   	 int &ret= new_dp[(sum+digit)%D][flag||digit<limit];
				   	 ret+=dp[sum][flag];
				   	 if(ret>=mod)ret-=mod;
				   	 }
		   	  }  
	    }
	    dp=new_dp;
  }
  int answer=dp[0][0]+dp[0][1];
  cout<<(0LL+mod+answer-1)%mod;
  //cout<<answer;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
int main()
{
    ll a,b;
    cin>>a>>b;
    ll fl=(a*100)/8+((a*100)%8==0 ? 0 : 1),fr=((a+1)*100)/8+(((a+1)*100)%8==0 ? 0 : 1)-1,sl=b*10,sr=(b+1)*10-1;
    if (fr<sl || sr<fl)
        cout<<-1;
    else
        cout<<max(fl,sl);
    return 0;
}

Measured memory_bytes: 256
// {{{ by unolight
#pragma region
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
#pragma endregion
// }}}

void main() {
    int n,k;
    cin >> n >> k;
    if ( k==1 ) cout << 0 << '\n';
    else cout << (n-(k-1))-1 << '\n';
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#include<stack>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define D(n,retu) REP(i,n){cin>>retu[i];}

using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

//------------------変数-----------------------//
ll sx, sy, tx, ty, u = 0, dow = 0, lef = 0, righ = 0;
vector<vector<ll>>graph(19); bool graphb[19];
char ou[4] = { 'U','D','L','R' };
//-------------------関数----------------------//


int main() {
	cin >> sx >> sy >> tx >> ty;
	righ = abs(sx - tx);
	u = abs(sy - ty);
	if (u < dow) { swap(u, dow); swap(ou[0], ou[1]); }
	if (lef > righ) { swap(lef, righ); swap(ou[2], ou[3]); }
	REP(i, 2) {
		REP(i, dow) { cout << ou[1]; }
		REP(i, righ) { cout << ou[3]; }
		REP(i, u) {
			cout << ou[0];
		}
		REP(i, lef) { cout << ou[2]; }
		REP(i, dow) { cout << ou[0]; }
		REP(i, righ) { cout << ou[2]; }
		REP(i, u) {
			cout << ou[1];
		}
		REP(i, lef) { cout << ou[3]; }
		u++; dow++; lef++; righ++;
	}

	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, vector<int> > i_v;
typedef pair<int, int> i_i;
typedef pair<i_i, int> i_i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    i_v dp[100020];
    vector<int> To[100020];
    for(int i = 0; i <= 100005; i++){
        vector<int> in;
        dp[i] = {INF, in};
    }
    dp[0].first = 0;
    int n, m;
    cin >> n >> m;
    vector<i_i> pathes[100050];
    for(int i = 1; i <= m; i++){
        int p, q, c;
        cin >> p >> q >> c;
        pathes[p].push_back({q, c});
        pathes[q].push_back({p, c});
    }
    To[1].push_back(-1);
    deque<i_i_i> search;
    search.push_back({{1, -1}, 0});
    while(!search.empty()){
        i_i_i now = search.front();
        search.pop_front();
        int from = now.first.first;
        if(To[from].empty()){
            continue;
        }
        int company = now.first.second;
        int Cost = now.second;
        if(Cost >= dp[from].first + 1){
            continue;
        }
        if(from == n){
            cout << Cost << endl;
            return 0;
        }
        for(int i = 0; i < pathes[from].size(); i++){
            int to = pathes[from][i].first;
            int cost = Cost; 
            if(Cost == dp[from].first){
                if(count(To[from].begin(), To[from].end(), pathes[from][i].second) == 0){
                    cost++;
                }
            } else {
                if(company != pathes[from][i].second){
                    cost++;
                }
            }
            if(cost > dp[to].first){
                continue;
            }
            if(cost == dp[to].first){
                if(count(dp[to].second.begin(), dp[to].second.end(), pathes[from][i].second) >= 1){
                    continue;
                } else {
                    dp[to].second.push_back(pathes[from][i].second);
                    To[to].push_back(pathes[from][i].second);
                }
            } else {
                dp[to].first = cost;
                dp[to].second.clear();
                dp[to].second.push_back(pathes[from][i].second);
                To[to].clear();
                To[to].push_back(pathes[from][i].second);
            }
            //cout << "from " << from << " to " << to << " " << pathes[from][i].second << " " << cost << endl;
            if(cost == Cost){
                search.push_front({{to, pathes[from][i].second}, cost});
            } else {
                search.push_back({{to, pathes[from][i].second}, cost});
            }
        }
        To[from].clear();
    }
    cout << -1 << endl;
    return 0;
}


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

int main() {
int a;
while(cin>>a){
	long long A[100005]={};
	for(int i=0;i<a;i++){
		cin>>A[i];
	}
	long long l=0,r=1000000000000000;
	long long minr=1000000000000000;
	while(l<=r){
		long long m=(l+r)/2;
		long long tmp=m;
		int no=0;
		for(int i=0;i<a;i++){
			m-=m%A[i];
		}
		
		if(m==2){
			r=tmp-1;
			minr=min(minr,tmp);
		}
		
		else if(m>2){
			r=tmp-1;
		}
		else{
			l=tmp+1;
		}
	}
	long long maxr=0;
	l=0,r=1000000000000000;
		while(l<=r){
		long long m=(l+r)/2;
		long long tmp=m;
		int no=0;
		for(int i=0;i<a;i++){
			m-=m%A[i];
		}
		
		if(m==2){
			l=tmp+1;
			maxr=max(maxr,tmp);
		}
		
		else if(m>2){
			r=tmp-1;
		}
		else{
			l=tmp+1;
		}
	}
	if(maxr==0||minr==1000000000000000){
		cout<<-1<<endl;
	}
	else{
	cout<<minr<<" "<<maxr<<endl;
	}
	
	
	
}

	return 0;
}

Measured memory_bytes: 1152
import sys

def sub(a):
    return [a[i : j + 1] for i in range(len(a)) for j in range(i,len(a))]


s = input()
l = sub(s)
maks = 0

for i in l:
    sum = 0
    for x in i:
        if x == 'A' or x == 'C' or x == 'T' or x == 'G':
           sum += 1
    if sum == len(i):
        maks = max(maks, len(i)) 

print(maks)    

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    long long N;
    set<string> S;

    cin >> N;
    for (long long i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        S.insert(s);
    }

    cout << S.size() << endl;
}

Measured memory_bytes: 19200
n, k = list(map(int, input().split()))

dices = [i for i in range(1, n + 1)]
ans = 0
m = 0
while len(dices) > 0:
	ans += (0.5 ** m) * (len([x for x in dices if x >= k]) / n)
	dices = [2 * x for x in dices if x < k]
	m += 1
print(ans)



Measured memory_bytes: 7832
def main():
    N, Q = [int(s) for s in input().split()]
    adj = [[] for _ in range(N)]
    counters = [0] * N
    increments = [0] * N

    for _ in range(N - 1):
        a, b = [int(s) - 1 for s in input().split()]
        adj[a].append(b)
        adj[b].append(a)

    for _ in range(Q):
        p, x = [int(s) for s in input().split()]
        increments[p - 1] += x

    stack = [(0, 0, -1)]

    while stack:
        u, inc, parent = stack.pop()
        inc += increments[u]
        counters[u] += inc

        for v in adj[u]:
            if v != parent:
                stack.append((v, inc, u))

    print(' '.join(str(c) for c in counters))


if __name__ == '__main__':
    main()

Measured memory_bytes: 72224
//#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);
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> c(h);
    REP(i,h)cin >> c[i];
    int ans = 0;
    int hh = (1<<h);
    int ww = (1<<w);
    REP(i,hh){
        REP(j,ww){
            int th = i;
            int tw = j;
            int cnt = 0;
            REP(x,h){
                REP(y,w){
                    if(c[x][y]=='#'&&((th>>x)&1)==0&&((tw>>y)&1)==0){
                        cnt++;
                    }
                }
            }
            if(cnt==k){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define maxn 200001 * 2
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define pb push_back
#define mp make_pair

int n, m, x, y;
int a[maxn], head[maxn];
int cnt[maxn];
int cover;
void solve(){
	cin >> n >> m;
	for (int i = 1; i <= n; ++i){
		head[i] = n+i;
	}
	rep(_, n){
		cin >> x;
		if (cnt[--head[x]]++ == 0){
			cover++;
			if (head[x] < n) cover--;
		}
		a[_] = x;
	}
	rep(_, m){
		cin >> x >> y;
		x--;
		int z = a[x];
		// remove old a[x]
		if (--cnt[head[z]++] == 0){
			cover--;
			if (head[z]-1 < n) cover++;
		}
		// add new a[x]
		if (cnt[--head[y]]++ == 0){
			cover++;
			if (head[y] < n) cover--;
		}
		a[x] = y;
		cout << n - cover << endl;
		//for (int i = 1; i <= n; ++i) cout << i << '-' << head[i] - n << endl;
	}

}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);
    solve();
}

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

typedef long long ll;

int X;
ll ans = 2;

int main()
{
    scanf("%d",&X);
    for(int i = 0; i < X; i++)ans = 1LL + ans + ans + 1LL;
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
    string o,e; cin >> o >> e;
    int O = o.size(), E = e.size();
    rep(i,O+E){
        if(i%2 == 0){
            cout << o[i/2];
        }else{
            cout << e[i/2];
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  string S;
  cin >> N >> S;
  int count, ans = 0;
  string C;
  for(int i = 0; i < 1000; i++){
    C = to_string(i);
    if(C.size() == 1)C = "0" + C;
    if(C.size() == 2)C = "0" + C;
    count = 0;
    for(int j = 0; j < N; j++){
      if(C.at(count) == S.at(j))count++;
      if(count == 3){
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !

process.stdin.on('data', function (chunk) {
    var lines = chunk.toString().split(' ');


if (parseInt(lines[1]) >= parseInt(lines[2])){
	console.log('delicious');
}else if((parseInt(lines[1]) < parseInt(lines[2])) && ((parseInt(lines[2]) - parseInt(lines[1])) <= parseInt(lines[0]))){
	console.log('safe');
}else{
	console.log('dangerous');
}   


/*if (lines[1] >= lines[2]){
	console.log('delicious');
}else if((lines[1] < lines[2]) && ((lines[2] - lines[1]) <= lines[0])){
	console.log('safe');
}else{
	console.log('dangerous');
 }*/   


});



Measured memory_bytes: 21320
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


struct UnionFind{

    std::vector<int> data;
    // dataの各要素について
    // 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。
    // 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない

    //初期化 size:最大要素数
    UnionFind(int size): data(size, -1) {}
    
    // 集合を併合する
    // すでに同じ集合だった場合は、falseが返る
    bool unite(int x, int y){
        x=root(x);
        y=root(y);
        if( x != y ){
            // 要素数の大きな方へ合併するためのswap
            if( data[y] < data[x] ) std::swap(x, y);
            // 要素数を加算する
            data[x] += data[y];
            // yの属する集合のルートをxに変更
            data[y] = x;
        }
        return x!=y;
    }

    // 同じ集合かどうか判定
    bool find(int x, int y){
        return root(x) == root(y);
    }

    // 集合の識別番号を返す
    int root(int x){
        // 負の値を持つものがその集合のルート
        // 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く)
        return (data[x] < 0)? x : data[x]=root(data[x]);
    }

    // 集合の要素数を返す
    int size(int x){
        return -data[ root(x) ];
    }
};

ll calc(int m){
    return (ll)m*(ll)(m-1)/2;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<P> ab(m);
    rep(i, m){ 
        cin >> ab[i].first >> ab[i].second;
        ab[i].first--;
        ab[i].second--;
    }

    UnionFind uf(n);

    vector<ll> ans(m+1, 0);
    ll tmp = 0;
    for (int i = m-1; i >= 0; i--)
    {
        ll x = calc(uf.size(ab[i].first));
        ll y = calc(uf.size(ab[i].second));
        if (uf.root(ab[i].first) == uf.root(ab[i].second)) y=0;
        uf.unite(ab[i].first, ab[i].second);
        ll z = calc(uf.size(ab[i].first));
        ans[i] = ans[i+1] + z-x-y;
        //cout << ans[i] << endl;
    }
    
    for (int i = 0; i < m; i++)
    {
        cout << ans[0] - ans[i+1] << endl;
    }
    


}

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

void main() {
        char buf[128];
        int a, b;
        float t;
        fgets(buf, 128, stdin);
        sscanf(buf, "%d %d %f\n", &a, &b, &t);
        int num = 0;
        int i, j=(t+0.5)/a;
        for(i=0; i<j; i++) {
                num += b;
        }
        printf("%d\n", num);
        return ;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int min(int a,int b){
  if(a<b)return a;
  return b;
}
int main(){
  int n;
  cin>>n;
  int a[n-1],k,s=0;
  for(int i=0;i<n-1;i++)cin>>a[i];
  k=a[n-2];
  s+=(a[0]+a[n-2]);
  for(int i=0;i<=n-3;i++){//cout<<a[i]<< " - /";
	s+=min(a[i],a[i+1]);
  }
  cout<<s;
  return 0;
}

Measured memory_bytes: 256
//  Christopher_Yan Move on!!!
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <cmath>
#define int long long

using namespace std;

const int N = 1e5 + 10101;

int T, n, a, b, c, ec, f[N], ans = 0, siz[N], pot, nsiz, mind = 2147483647;

struct Edge
{
	int u, v, w, nxt;
}e[N << 2];

inline void Addedge(int a, int b, int c)
{
	++ec;
	e[ec].u = a;
	e[ec].v = b;
	e[ec].w = c;
	e[ec].nxt = f[a];
	f[a] = ec;
}

inline void read(int &x)
{
	int k = 1; x = 0;
	char c = getchar();
	while (!isdigit(c)) 
		if (c == '-') c = getchar(), k = -1;
		else c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ 48),
		c = getchar();
	x *= k;
}

void Get_siz(int u, int fa)
{
	siz[u] = 1;
	for (int i = f[u]; i != -1; i = e[i].nxt)
		if (e[i].v != fa)
			Get_siz(e[i].v, u),
			siz[u] += siz[e[i].v];
}

void Get_pot(int u, int fa)
{
	int msiz = -1;
	for (int i = f[u]; i != -1; i = e[i].nxt)
		if (fa != e[i].v)
			Get_pot(e[i].v, u),
			msiz = max(siz[e[i].v], msiz);
	if (max(siz[1] - siz[u], msiz) < nsiz) 
		pot = u, nsiz = max(msiz, siz[1] - siz[u]);
}

void DFS(int u, int fa, int dep)
{
	ans += dep;
	for (int i = f[u]; i != -1; i = e[i].nxt)
		if (fa != e[i].v)
			DFS(e[i].v, u, dep + e[i].w);
}

signed main()
{
	read(n); pot = 1;
	memset(f, -1, sizeof(f));
	for (int i = 1; i < n; ++i)
		read(a), read(b), read(c),
		Addedge(a, b, c), Addedge(b, a, c);
	Get_siz(1, 0);
	nsiz = siz[1];
	Get_pot(1, 0);
	DFS(pot, 0, 0);
	Get_siz(pot, 0);
	for (int i = f[pot]; i != -1; i = e[i].nxt)
		mind = min(e[i].w, mind);
	for (int i = 1; i <= n; ++i)
		if (i != pot && siz[i] >= (n + 1) >> 1)
			mind = i, f[0] = 99889;
	if (f[0] != -1)
	for (int i = f[pot]; i != -1; i = e[i].nxt)
		if (e[i].v == mind) 
			mind = e[i].w;
	printf("%lld\n", (ans << 1) - mind);
	return 0;
}

Measured memory_bytes: 15616