akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <time.h>
using namespace std;

#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

void dfs(ll s,vector<vector<ll>> &v,vector<bool> &visited,vector<ll> &child,vector<ll> &level,vector<ll> &dp,vector<ll> &ans)
{
        ans.push_back(s);
        visited[s] = true;
        for(int i = 0;i < v[s].size();++i)
        {
            if(visited[v[s][i]] == false)
            {
                level[v[s][i]]=level[s]+1;
                dfs(v[s][i],v,visited,child,level,dp,ans);
                child[s]+=child[v[s][i]];
            }
            dp[s]=max(dp[s],1+dp[v[s][i]]);
        }
}

int main(){

    IOS;

    ll t,n,k,m;
    t=1;
    while(t--)
    {
        cin >> n >> m;
        vector<vector<ll>> v(n+1);
        vector<bool> visited(n+1,false);
        vector<ll> child(n+1,1);
        vector<ll> level(n+1,0);
        vector<ll> dp(n+1,0);
        vector<ll> ans;
        for(ll i=1;i<=m;i++)
        {
            ll a1,a2;
            cin >> a1 >> a2;
            v[a1].push_back(a2);
        }
        for(ll i=1;i<=n;i++)
        {
            if(visited[i]==false)
                dfs(i,v,visited,child,level,dp,ans);
        }
        ll ans1=0;
        for(ll i=1;i<=n;i++)
        {
            ans1 = max(ans1,dp[i]);
        }
        cout << ans1 << endl;
    }
    return 0;
}


Measured memory_bytes: 13812
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

//HEADER FILES AND NAMESPACES
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp>   
using namespace std;
using namespace __gnu_pbds;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);  

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r+", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w+", stdout);
#endif  
	
    int n;
    cin >> n;
    bool ok = false;
    int cnt = 0;
    for(int i=0;i<n;i++) {
    	int x,y;
    	cin >> x >> y;
    	if(x == y) {
    		cnt++;
    	}
    	else {
    		cnt = 0;
    	}
    	if(cnt == 3) {
    		ok = true;
    	}
    }
    cout << (ok ? "Yes" : "No") << '\n';
}
 
// read the question correctly (ll vs int)
// template by bqi343

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

void answer1() {
  int N;
  cin >> N;
  vector<int> t(N);
  vector<int> x(N);
  vector<int> y(N);

  for (int i = 0; i < N; i++) {
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
}

void answer2() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  int pre_t = 0;
  int pre_x = 0;
  int pre_y = 0;
  bool is_ok = true;
  for (int i = 0; i < N; i++) {
    int t, x, y;
    cin >> t >> x >> y;

    int d_t = abs(t - pre_t);
    int d_x = abs(x - pre_x);
    int d_y = abs(y - pre_y);

    int remaining_t = d_t - d_x - d_y;
    if (remaining_t < 0 || remaining_t % 2 != 0) {
      is_ok = false;
    }

    pre_t = t;
    pre_x = x;
    pre_y = y;
  }
  if (is_ok) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

int main() {
  //answer1();
  answer2();
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <math.h>
#include <vector>
using namespace std;

int main() {
    unsigned long long int X = 0;
    int happy_500 = 0;
    int happy_5 = 0;
    cin >> X;

    while (X >= 5) {
        if (X >= 500) {
            X = X - 500;
            happy_500 += 1;
        }
        else if (X >= 5) {
            X = X - 5;
            happy_5 += 1;
        }
    }
    cout << 1000 * happy_500 + 5 * happy_5;
    return 0;
}

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

int main() {
	long long n;
	std::cin >> n;
	
	long long sum1 = 0, sum2 = 0;
	long long ans1 = 0, ans2 = 0;

	long long first;
	std::cin >> first;
	if (first == 0) {
		sum1 = 1;
		sum2 = -1;
		ans1 = ans2 = 1;
	}
	else if (first > 0) {
		sum1 = first;
		sum2 = -1;
		ans2 = std::abs(first + 1);
	}
	else {
		sum1 = 1;
		sum2 = first;
		ans1 = std::abs(1 - first);
	}

	for (int i = 1; i < n; ++i) {
		long long a;
		std::cin >> a;

		if (sum1 < 0) {
			ans1 += std::max(0ll, 1 - (sum1 + a));
			sum1 = (sum1 + a < 1 ? 1 : sum1 + a);
		}
		else {
			ans1 += std::max(0ll , sum1 + a + 1);
			sum1 = (sum1 + a > -1 ? -1 : sum1 + a);
		}

		if (sum2 < 0) {
			ans2 += std::max(0ll, 1 - (sum2 + a));
			sum2 = (sum2 + a < 1 ? 1 : sum2 + a);
		}
		else {
			ans2 += std::max(0ll, sum2 + a + 1);
			sum2 = (sum2 + a > -1 ? -1 : sum2 + a);
		}
	}

	std::cout << std::min(ans1, ans2) << std::endl;
}

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

int main(int argc, char **argv)
{
    long N, K;
    std::cin >> N >> K;

    if(N < std::abs(N-K)){
        std::cout << N << std::endl;
        return 0;
    }

    long n = N / K;
    long ans = std::min(std::abs(N-n*K), std::abs(N-(n+1)*K));
    ans = std::min(ans, std::abs(N-(n+2)*K));
    ans = std::min(ans, std::abs(N-(n-2)*K));
    ans = std::min(ans, std::abs(N-(n-1)*K));
    
    std::cout << ans << std::endl;
}


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

const int N=1e6+50, mod=1e9+7;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline int dec(int x,int y) {return (x-y<0) ? (x-y+mod) : (x-y);}
inline int mul(int x,int y) {return (long long)x*y%mod;}
inline int power(int a,int b,int rs=1) {for(;b;b>>=1,a=mul(a,a)) if(b&1) rs=mul(rs,a); return rs;}
inline int inv(int a) {return power(a,mod-2);}

struct combin {
	int fac[N],ifac[N];
	combin() {
		fac[0]=1;
		for(int i=1;i<N;i++) fac[i]=mul(fac[i-1],i);
		ifac[0]=ifac[1]=1;
		for(int i=2;i<N;i++) ifac[i]=mul(mod-mod/i,ifac[mod%i]);
		for(int i=2;i<N;i++) ifac[i]=mul(ifac[i-1],ifac[i]);
	}
	inline int C(int a,int b) {return mul(fac[a],mul(ifac[b],ifac[a-b]));}
} C;
#define x1 dqoaspjdioq
#define x2 dnasuihquih
#define y1 adsjiohejqu
#define y2 dnasuigqyuw
inline int path(int x1,int y1,int x2,int y2) {
	return C.C(x2-x1+y2-y1,x2-x1);
}
int n,m,a,b;
int main() {
	cin>>n>>m>>a>>b; 
	int ans=path(1,1,n,m);
	for(int i=1;i<=b;i++)
		ans=dec(ans,mul(path(1,1,n-a,i),path(n-a+1,i,n,m)));
	cout<<ans<<'\n';
}

Measured memory_bytes: 8064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

////////////////////////////////////////

int main(){
    ll n;cin>>n;
    ll x[n];rep(i,0,n-1)cin>>x[i];
    ll l,q;cin>>l>>q;
    ll dp[n][35];rep(i,0,34)dp[n-1][i]=n-1;
    for(ll i=n-2;i>=0;i--){
        dp[i][0]=upper_bound(x,x+n,x[i]+l)-x-1;
        if(dp[i][0]==n)dp[i][0]=n-1;
        rep(j,1,34){
            dp[i][j]=dp[dp[i][j-1]][j-1];
        }
    }
   /* rep(i,0,n-1){cout<<i<<":";
        rep(j,0,5){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    while(q--){
        ll a,b;cin>>a>>b;if(a>b)swap(a,b);a--;b--;
        ll ans=0;
        if(b==n-1){
            while(a<b){
                ll t=lower_bound(dp[a],dp[a]+35,b)-dp[a]-1;
                if(t==-1)t++;
                ans+=(ll)pow(2,t);
                a=dp[a][t];
            }
        }else{
            while(a<b){
                ll t=upper_bound(dp[a],dp[a]+35,b)-dp[a]-1;
                if(t==-1)t++;
                ans+=(ll)pow(2,t);
                a=dp[a][t];
            }
        }
        cout<<ans<<endl;
    }
    
    
    return 0;
}

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

int MAX = 10000;

void countingSort(int a[], int b[], int c[], int n)
{
  for (int i = 0; i <= MAX; i++)
    c[i] = 0;

  for (int i = 1; i <= n; i++)
    c[a[i]]++;

  for (int i = 1; i <= MAX; i++)
    c[i] += c[i - 1];

  for (int i = n; i > 0; i--)
  {
    b[c[a[i]]] = a[i];
    c[a[i]]--;
  }
}

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

  int a[n + 1], b[n + 1], c[MAX + 1];
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]);

  countingSort(a, b, c, n);

  for (int i = 1; i < n; i++)
    printf("%d ", b[i]);
  printf("%d\n", b[n]);
  return 0;
}

Measured memory_bytes: 18248
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    #include<string>
    #include<stdlib.h>
    using namespace std ;
    int main(){
      int A,B;
      cin>>A>>B;
      if((A%3==1&&B%3==1)||(A%3==2&&B%3==2))cout<<"Impossible"<<endl;
      else cout<<"Possible"<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	for (int i=0; i<3; i++)
		if (s[i]=='1') cout<<"9";
		else if (s[i]=='9')  cout<<"1";
		else cout<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main(){
		Scanner cin = new Scanner(System.in);
		while(true){
			int n = cin.nextInt();
			int m = cin.nextInt();
			if(n==0) break;
			boolean check[] =new boolean[1000];
			int i,j;
			int now = n-1;
			for(i=0;i<n-1;i++){
				int nokori = n-i;
				int need = m % nokori;
				if(need==0) need = nokori;
				for(j=0;j<need;j++){
					now = (now+1)%n;
					if(check[now])j--;
				}
				check[now] = true;
			}
			for(i=0;i<n;i++){ if(!check[i]) System.out.println(i + 1);}
		}
	}
}

Measured memory_bytes: 0
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var length = ToInt32(ReadLine());
        var str = ReadLine();
        var x = 0;
        var result = 0;
        for(var i = 0; i < length; i++)
        {
            switch (str.Substring(i, 1))
            {
                case "I":
                    x++;
                    break;
                case "D":
                    x--;
                    break;
            }
            if (result < x) result = x;
        }
        WriteLine(result);
    }
}



Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2])
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	int n,d;
	cin>>n>>d;
	int c=0;
	if(n%(2*d+1)!=0)c++;
	c+=n/(2*d+1);
	cout<<c;
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int cnt = sc.nextInt();
			int[] arr = new int[cnt];
			java.util.stream.IntStream.range(0, cnt).forEachOrdered(i -> arr[i] = sc.nextInt());

			StringBuilder sb = new StringBuilder();
			for (int j = cnt -1; j >=0; j-- ) {
				sb.append(arr[j] + " ");
			}
			System.out.println(sb.toString().trim());
		}
	}
}


Measured memory_bytes: 32396
#include<bits/stdc++.h>
const int N=505;
int H,W,h,w,i,j,a[N][N],s;
int main(){
	scanf("%d%d%d%d",&H,&W,&h,&w);
	for(i=0;i<H;++i)for(j=0;j<W;++j)s+=a[i][j]=i%h==h-1 && j%w==w-1?-h*w-(1<<20):
		(i%h==0 && j%w==0?h*w+(1<<20)-1:0);
	if(s<0){
		puts("No");
		return 0;
	}
	puts("Yes");
	for(i=0;i<H;++i)for(j=0;j<W;++j)printf("%d%c",a[i][j],"\n "[j<W-1]);
	return 0;
}

Measured memory_bytes: 3328
import numpy as np

x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
r = []
for i in range(x):
  for j in range(y):
    if (i + 1) * (j + 1) > k:
        break
    for l in range(z):
      if (i + 1) * (j + 1) * (l + 1) > k:
        break
      r.append(a[i] + b[j] + c[l])
r.sort()
for i in range(k):
  print(r[-(i+1)])


Measured memory_bytes: 17752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int main()
{
        ll a,b;
        cin>>a>>b;
        if(a%2!=0&&b%2!=0)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }

    return 0;
}


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

using namespace std;

int main(){
  char a;
  int vocales[123];
  memset(vocales,0,sizeof(vocales)); 
  while((a = getchar()) != EOF){
    vocales[int(tolower(a))] += 1;
  }
  for(int i=97;i<=122;i++){
      cout << char(i) << " : " << vocales[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3088
let rec q()=let a=Array.init 10(fun _->Scanf.scanf"%d,"(fun i->i*2000))in Scanf.scanf"%d,%d
"(fun v w->let rec($)i z=if Array.fold_left(+)0a/(v+w)*v<=z+a.(i)then q(Printf.printf"%d
"(i+1))else(i+1)$(z+a.(i))in 0$0);;try q()with _->()

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

const int MAX = 1000001; 


struct Qry 
{ 
	int l, r, idx; 
}; 

bool cmp(Qry x, Qry y) 
{ 
	return x.r < y.r; 
} 

void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answerAllQueries(int arr[], int n, Qry queries[], int q) 
{ 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

int main() 
{ 
	int n,q;
	int a[MAX];
	cin>>n>>q;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	Qry queries[MAX];
	int l1,r1;
	for(int i=0;i<q;i++)
	{
		cin>>l1>>r1;
		queries[i].l=l1-1;
		queries[i].r=r1-1;
		queries[i].idx=i;
	}
	sort(queries, queries+q, cmp); 
    answerAllQueries(a, n, queries, q); 
	return 0; 
} 


Measured memory_bytes: 19392
fn main() {
    input! {
        n: usize,
        s: [chars;n]
    }

    let mut cnt = 0;
    for i in 0..n {
        // i個右にずらす
        for j in 0..n {
            s[j].rotate_right(1);
        }
        // よい形になっているか確認する
        let mut is_good = true;
        for j in 0..n {
            for k in j..n {
                if s[j][k] != s[k][j] {
                    is_good = false;
                }
            }
        }
        if is_good {
            cnt += n
        }
    }

    println!("{}", cnt);
}

#[macro_export(local_inner_maccros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[macro_export(lcal_inner_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[macro_export(lcal_inner_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


Measured memory_bytes: 2576
//ABC121C
#include <iostream>
#include <vector> 
#include <algorithm> 
 
using namespace std;
 
struct Struct {
    unsigned long long num1;
    unsigned long long num2;
 
    Struct(unsigned long long n1, unsigned long long n2) {
        num1 = n1;
        num2 = n2;
    }
 
    bool operator<(const Struct& another) const {
        return num1 < another.num1;
    }
};

int main() {
    vector<Struct> vec;
    unsigned long long A[100001]; unsigned long long B[100001];
    int N,M; cin >> N >> M;
    for(int i = 0;i < N;i++){
        cin >> A[i] >> B[i];
        vec.push_back(Struct(A[i],B[i]));
    }

    sort(vec.begin(),vec.end());
    unsigned long long sum = 0; unsigned long long count = 0;
    int j= 0;
    for(j = 0;j < N;j++){
        sum += vec[j].num1 * vec[j].num2;
        count += vec[j].num2;
        if(count >= M){
            sum -= vec[j].num1 * vec[j].num2;
            count -= vec[j].num2;
            break;
        }
    }
    cout << sum + vec[j].num1 * (M - count) << endl;

    return 0;

}
    

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
 
vector <string> grid;
ll h,w;
ll ans = 0;
vector <vector<ll>> anss;

void func(ll x,ll y,ll d){
	if (anss[x][y] <= d) return;
	anss[x][y] = d;
	if (x > 0){
		if (grid[x-1][y] == '.') func(x-1,y,d+1);
	}
	if (y > 0){
		if (grid[x][y-1] == '.') func(x,y-1,d+1);
	}
	if (x < h-1){
		if (grid[x+1][y] == '.') func (x+1,y,d+1);
	}
	if (y < w-1){
		if (grid[x][y+1] == '.') func (x,y+1,d+1);
	}
} 

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> h >> w;
	grid.resize(h);
	for (int z=0;z<h;z++){
		cin >> grid[z];
	}
	for (int z=0;z<h;z++){
		for (int x=0;x<w;x++){
			if (grid[z][x] == '.'){
				anss.resize(0);
				anss.resize(h,vector<ll>(w,LLONG_MAX));
				func(z,x,0);
				for (int z=0;z<h;z++){
					for (int x=0;x<w;x++){
						if (anss[z][x] != LLONG_MAX) {
							ans = max(ans,anss[z][x]);
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> price(N);
    for(int i = 0; i < N; i++){
        cin >> price.at(i);
    }

    sort(price.begin(),price.end());
    
    int M = price.at(N-1) / 2;
    int total = 0;

    for(int i = 0; i < N - 1; i++){
        total += price.at(i);
    }

    cout << total + M << endl;

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
#define ss second
#define ff first
#define ld long double
const ll INF = 1e13;
const ll N = 301;
const ll mod= 1000000007;
bool prime(ll x)
{
	if(x<2) return false;
	for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
	return true;
}
vl fac(N);
void fact()
{
	fac[0]=1;
	loop(i,1,N) fac[i]=(fac[i-1]*i)%mod;
}
 ld dp[N][N][N];
void solve()
{
 ll h,w;
 cin>>h>>w;
 vector<string> a(h);
 vvl dp(h+1, vl(w+1,0));
 loop(i,0,h) cin>>a[i];
 dp[1][1] = 1;
 loop(i,1,h+1)
  loop(j,1,w+1)
  {
  	if(a[i-1][j-1]=='.') dp[i][j]=max(dp[i][j], dp[i-1][j]+dp[i][j-1])%mod;
  	else dp[i][j]=0;
  }
  cout<<dp[h][w];
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--) solve();
 return 0;
}

Measured memory_bytes: 9216
import sys
from collections import deque
input = sys.stdin.readline

N,M=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(N-1+M)]

#トポロジカルソートを使う方法
EDGEIN=[0]*(N+1)#その点に入るEDGEの個数
EDGEOUTLIST=[[] for i in range(N+1)]#EDGEの行き先
EDGEINLIST=[[] for i in range(N+1)]
ANSLIST=[-1]*(N+1)

for x,y in EDGE:
    EDGEIN[y]+=1
    EDGEOUTLIST[x].append(y)
    EDGEINLIST[y].append(x)

from collections import deque
QUE = deque()

for i in range(1,N+1):
    if EDGEIN[i]==0:
        QUE.append(i)#行き先のない点をQUEに入れる
        ANSLIST[i]=0
        
TOP_SORT=[]
while QUE:
    x=QUE.pop()
    TOP_SORT.append(x)#行き先がない点を答えに入れる
    for to in EDGEOUTLIST[x]:
        EDGEIN[to]-=1#行き先がない点を削除し,そこから一歩先の点のEDGEINを一つ減らす.
        if EDGEIN[to]==0:
            QUE.appendleft(to)

TOP_SORT_INV=[-1]*(N+1)
for i in range(N):
    TOP_SORT_INV[TOP_SORT[i]]=i

for i in range(1,N+1):
    if EDGEINLIST[i]==[]:
        continue
    
    ANSLIST[i]=TOP_SORT[max([TOP_SORT_INV[j] for j in EDGEINLIST[i]])]

for a in ANSLIST[1:]:
    print(a)


Measured memory_bytes: 54664
#include <stdio.h>

#define MAX 250

int main(){
  int n,i,a[MAX];

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

  for(i = 0 ; i < n ; i++){
    printf("node %d: key = %d, " ,i+1 ,a[i]);

    if(i){
      printf("parent key = %d, " ,a[(i+1)/2-1]);
    }

    if(2*i+1 < n){
      printf("left key = %d, " ,a[2*i+1]);
    }
    if(2*i+2 < n){
      printf("right key = %d, " ,a[2*i+2]);
    }
    printf("\n");
  }

  return 0;
}

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

bool flag[30];

int main() {
  string s;
  cin>>s;
  
  for (int i=0; i<s.size(); i++) {
    flag[s[i]-'a']=true;
  }
  for (int i=0; i<26; i++) {
    if (flag[i]==false) {
      s+=(char)('a'+i);
      cout<<s<<endl;
      return 0;
    }
  }
  for (int i=25; i>0; i--) {
    if (s[i]>s[i-1]) {
      int j;
      for (j=25; j>=i; j--) {
	if (s[i-1]<s[j]) break;
      }
      swap(s[j],s[i-1]);
      s.erase(s.begin()+i,s.end());
      cout<<s<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    cnt=[0]*(8*N)
    r=int(N**0.5)+1
    for x in range(1,r):
        for y in range(1,r):
            for z in range(1,r):
                cnt[x*x+y*y+z*z+x*y+y*z+z*x]+=1
                
    for i in range(1,N+1):
        print(cnt[i])
    
    
if __name__=="__main__":
    main()


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

int main(){
    int m,f,b;
    int a;
    cin >> m >> f >> b;
    if(m < b){
        a = b - m;
        if(a <=f){
            cout << a << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
    else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3100
out = 0
num = gets.chomp!.to_i
num.times do
  cnt = 0
  base1 = base2 = base3 = 0
  out = 0
  while out < 3
    act = gets.chomp!
    if act == "HIT"
      if base3 == 1
        cnt = cnt + 1
      end
      base3 = base2
      base2 = base1
      base1 = 1
    end
    if act == "OUT"
      out = out + 1
    end
    if act == "HOMERUN"
      cnt = cnt + base1 + base2 + base3 + 1
      base1 = base2 = base3 = 0
    end
  end
  printf("%d\n",cnt)
end

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
ll n,a,b,c,d;
string s;
bool check(ll start,ll end){
    for(ll i=start;i+1<=end;i++){
        if(s[i]=='#' and s[i+1]=='#'){
            return false;
        }
    }
    return true;
}
bool other_person(){
    for(ll i=b;i<=d;i++){
        if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.'){
            return true;
        }
    }
    return false;
}
int main() {
    int t;
    // cin>>t;
    t=1;
    while(t--){
        cin>>n>>a>>b>>c>>d;
        string temp;
        cin>>temp;
        // cin>>s;
        s='#'+temp+'#';
        if((!check(a,c))||(!check(b,d))){
            cout<<"No\n";
            continue;
        }
        if(c>d){
            if(!other_person()){
                cout<<"No\n";
                continue;
            }
        }
        cout<<"Yes\n";
    }
	return 0;
}

Measured memory_bytes: 772
#include <iostream>

#define ll long long
using namespace std;
ll a[200005];

int main()
{
    ios_base ::sync_with_stdio(false);

    int n;cin>>n;
    ll pr=-1,no=0;

    for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]-pr>1)
			no=1;

		pr=a[i];
	}

	if(no)
	{
		cout<<"-1\n";return 0;
	}

	ll op=0;
	for(int i=2;i<=n;i++)
	{
		if(a[i]==a[i-1]+1)
			op++;
		else
		   op+=a[i];
	}

	cout<<op<<"\n";
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#define N 10000

int main(){
  int n1,n2,i,j,c=0;
  int in[N],serch[N];

  scanf("%d",&n1);

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

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

  for(i=0;i<n2;i++){
    for(j=0;j<n1;j++){
      if( in[j]==serch[i]){
	c++;
	break;
      }
	}
  }

  printf("%d\n",c);
  return 0;
}



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

typedef long long int lli;

const lli maxn = lli(1e5)+5;

lli x[maxn], v[maxn], suff[maxn], pref[maxn];

int main(void)
{
	lli n, c;
	scanf("%lld%lld", &n, &c);
	for(lli i = 1;i <= n;i++) scanf("%lld%lld", &x[i], &v[i]);

	lli vsum = 0, res = 0;
	for(lli i = 1;i <= n;i++)
	{
		vsum += v[i];
		pref[i] = vsum-x[i];
		pref[i] = max(pref[i], pref[i-1]);
		res = max(res, pref[i]);
	}

	vsum = 0;
	for(lli i = n;i > 0;i--)
	{
		vsum += v[i];
		suff[i] = vsum-(c-x[i]);
		suff[i] = max(suff[i], suff[i+1]);
		res = max(res, suff[i]);
		res = max(res, suff[i]-(c-x[i])+pref[i-1]);
	}

	for(lli i = 1;i <= n;i++) res = max(res, pref[i]-x[i]+suff[i+1]);

	printf("%lld\n", res);
}

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

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

    int count=0;
    for(int i=0;i<s.size();){
        char now=s[i];
        while(s[i+1]==now) i++;
        count++;
        i++;
    }

    cout<<count<<endl;
}

Measured memory_bytes: 512
h,w=map(int,input().split())
a=[[0]*(w+2)]*(h+2)
a[0]="#"*(w+2)
a[h+1]="#"*(w+2)
for i in range(1,h+1):
  a[i]="#"+input()+"#"
  
for i in range(0,h+2):
  print(a[i])

Measured memory_bytes: 3060
def main():
    n = int(input())

    t = 1

    ans = ''
    while n > 0:
        p = ((n - 1) // t) % 26
        ans += chr(ord('a') + p)
        n -= t * (p+1)
        t *= 26

    ans = ans[::-1]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9092
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long W, std::vector<std::string> s){
    rep(i, W){
        rep(j, H){
            if(s[i][j] == '#'){
                bool badBlock = true;
                if(i-1>=0 && s[i-1][j] == '#') 
                    badBlock = false;
                if(i+1<W && s[i+1][j] == '#') 
                    badBlock = false;
                if(j-1>=0 && s[i][j-1] == '#') 
                    badBlock = false;
                if(j+1<H && s[i][j+1] == '#') 
                    badBlock = false;
                if(badBlock){
                    cout << NO << endl;
                    return;
                }
            }
        }
    }
    cout << YES << endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::string> s(W);
    for(int i = 0 ; i < W ; i++){
        std::cin >> s[i];
    }
    solve(H, W, std::move(s));
    return 0;
}


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

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N; cin >> N;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	ll ans = 0;
	bool fl = true;
	while (fl) {
		fl = false;
		ll s = 0;
		vector<ll> p(N);
		for (int i = 0; i < N; i++) {
			p[i] = a[i] / N;
			s += p[i];
		}

		for (int i = 0; i < N; i++) {
			a[i] = a[i] - p[i] * N + (s - p[i]);
			if (a[i] >= N)fl = true;
		}
		ans += s;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 100000 + 10;
int num[maxn];
int main()
{
    int n;  scanf("%d", &n);
    int res = 0;
    for (int i = 1; i <= n; i++)
    {
        int temp;   scanf("%d", &temp);
        res ^= temp;
    }
    if (res)    printf("No");
    else    printf("Yes");
    getchar();  getchar();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <bitset>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define FI first
#define SE second
using namespace std;
typedef long long LL;
const double pi=acos(-1.0);
int W,H;

inline bool in(double x,double y,double r)
{
    return x-r>=-1e-4&&x+r<=W+1e-4&&y-r>=-1e-4&&y+r<=H+1e-4;
}

inline double area(double r1, double r2,double s)
{
	if(r1 + r2 < s)
		return 0;
	else if(r2 - r1 > s)
		return pi * r1 * r1;
	else if(r1 - r2 > s)
		return pi * r2 * r2;
	double q1 = acos((r1 * r1 + s * s - r2 * r2) / (2 * r1 * s));
	double q2 = acos((r2 * r2 + s * s - r1 * r1) / (2 * r2 * s));
	return (r1 * r1 * q1 + r2 * r2 * q2 - r1 * s * sin(q1));
}

inline double sqr(double x) {return x*x;}
int main()
{
    int A,B,AB;
    while(scanf("%d%d%d%d%d",&W,&H,&A,&B,&AB)&&W)
    {
        int fg=0;
        if(A<B) swap(A,B),fg=1;
        double R=sqrt(A/pi);
        double r=sqrt(B/pi);
        double xa=R,ya=R;
        if(!in(xa,ya,R)) {puts("impossible");continue;}
        double d;
        if(!AB) d=R+r;
        else if(AB==B) d=0;
        else
        {
            double ll=R-r,rr=R+r,mid;
            for(int i=0;i<200;++i)
            {
                mid=(ll+rr)/2;
                if(area(R,r,mid)<=AB) rr=mid;
                else ll=mid;
            }
            d=rr;
        }
        double tx=W-r,ty=H-r;
        double dis=sqrt(sqr(tx-xa)+sqr(ty-ya));
        double xb=xa+(tx-xa)*d/dis;
        double yb=ya+(ty-ya)*d/dis;
        if(in(xb,yb,r))
        {
            if(fg)
            {
                swap(xa,xb);
                swap(ya,yb);
                swap(R,r);
            }
            printf("%.10f %.10f %.10f %.10f %.10f %.10f\n",xa,ya,R,xb,yb,r);
        }
        else puts("impossible");
    }
    return 0;
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 + 7 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
    int n ;
    cin >> n;
    vector < int > a(n) ;
    for( int i = 0 ; i < n ; i++) cin >> a[i] ;
    sort(a.rbegin(),a.rend());
    ll ans = a[0];
    priority_queue<pair<int,pair<int,int>>> q ;
    q.push({a[1],{a[0],a[1]}});
    q.push({a[1],{a[0],a[1]}});
    for( int i = 2 ; i < n ; i++){
        pair < int , pair < int , int > > cur = q.top();
        //cout << cur.ff << " " << cur.ss.ff << " " << cur.ss.ss << "\n";
        q.pop();
        ans += cur.ff ;
        q.push({a[i],{a[i],cur.ss.ff}});
        q.push({a[i],{a[i],cur.ss.ss}});
    }
    cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
    // cin >> t ;
    while(t--){
        solve( );
    }
}


Measured memory_bytes: 7164
#include <bits/stdc++.h>
using namespace std;
int64_t timesn(int64_t x, int64_t n) {
	int64_t output = 1;
	for (int64_t i = 0; i < n; ++i) {
		output *= x;
		if (output > 1000000007) {
			output %= 1000000007;
		}
	}
	return output;
}

int main() {
	//input
	int64_t N;
	cin >> N;

	//calculation
	int64_t output = 0;
	output = timesn(10, N) - timesn(9, N) - timesn(9, N) + timesn(8, N);
    output %= 1000000007;
  	output += 1000000007;
  	output %= 1000000007;

	//output
	cout << output << endl;


	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
  switch (c)
  {
  case '0':
    return 0;
  case '1':
    return 1;
  case '2':
    return 2;
  case '3':
    return 3;
  case '4':
    return 4;
  case '5':
    return 5;
  case '6':
    return 6;
  case '7':
    return 7;
  case '8':
    return 8;
  case '9':
    return 9;
  default:
    return 0;
  }
}
int main()
{
  ll A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  if (V * T >= abs(A - B) + W * T)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<char> t(q);
    vector<char> d(q);
    for(int i = 0; i < q; i++)
    {
        cin >> t[i] >> d[i];
    }
    int ub = n;
    int lb = -1;
    while(ub - lb > 1)
    {
        int mid = (lb + ub) / 2;

        char now = s[mid];
        int pos = mid;
        for(int j = 0; j < q; j++)
        {
            if(t[j] != now) continue;
            if(d[j] == 'L')
            {
                pos--;
                if(pos < 0) break;
            }
            else
            {
                pos++;
                if(pos >= n) break;
            }
            now = s[pos];
        }
        if(pos < 0)
        {
            lb = mid;
        }
        else
        {
            ub = mid;
        }
    }
    int left = lb;
    ub = n;
    lb = -1;
    while(ub - lb > 1)
    {
        int mid = (lb + ub) / 2;

        char now = s[mid];
        int pos = mid;
        for(int j = 0; j < q; j++)
        {
            if(t[j] != now) continue;
            if(d[j] == 'L')
            {
                pos--;
                if(pos < 0) break;
            }
            else
            {
                pos++;
                if(pos >= n) break;
            }
            now = s[pos];
        }
        if(pos >= n)
        {
            ub = mid;
        }
        else
        {
            lb = mid;
        }
    }
    int right = ub;
    cout << n-(left+1 + n-right) << endl;
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

string ss = "CODEFESTIVAL2016";

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int ans = 0;
	rep (i, s.size()) {
		if (s[i] != ss[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
macro_rules! input {
     (source = $s:expr, $($r:tt)*) => {
         let mut iter = $s.split_whitespace();
         input_inner!{iter, $($r)*}
     };
     ($($r:tt)*) => {
         let s = {
             use std::io::Read;
         let mut s = String::new();
         std::io::stdin().read_to_string(&mut s).unwrap();
         s
     };
     let mut iter = s.split_whitespace();
     input_inner!{iter, $($r)*}
     };
}
     
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]
use std::collections::HashSet;
fn main() {
    input!{
        s: String,
    }
    let mut set = HashSet::new();
    let (sub1, sub2): (HashSet<char>, HashSet<char>) = (['E', 'W'].iter().cloned().collect(), ['S', 'N'].iter().cloned().collect());
    for c in s.chars() { set.insert(c); }
    if set.len() % 2 == 0 {
        if set.len() == 2 {
            if set == sub1 || set ==  sub2 { println!("Yes"); }
            else { println!("No"); }
        } else { println!("Yes"); }
    } else { println!("No"); }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

int n, m;
priority_queue<int> a;
ll ans;
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> m;
    REP (i, n) {
        int d;
        cin >> d;
        a.emplace(d);
    }

    while (m--) {
        int cur = a.top();
        a.pop();
        a.emplace(cur / 2);
    }

    while (a.size()) {
        ans += a.top();
        a.pop();
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	while(n--)
	{
		int x;
		cin>>x;
		if(x%2==0&&x%3!=0&&x%5!=0)
		{
			cout<<"DENIED";
			return 0;
		}
	}
	cout<<"APPROVED";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    int n;
    cin >> n;
    int a,b,c,d;
    d = n%10;
    c = n/10 %10;
    b = n/100 %10;
    a = n/1000;
    
    if(a+b+c+d==7) cout << a << '+' << b << '+' << c << '+' << d << "=7" << ENT;
    else if(a+b+c-d==7) cout << a << '+' << b << '+' << c << '-' << d << "=7" << ENT;
    else if(a+b-c+d==7) cout << a << '+' << b << '-' << c << '+' << d << "=7" << ENT;
    else if(a+b-c-d==7) cout << a << '+' << b << '-' << c << '-' << d << "=7" << ENT;
    else if(a-b+c+d==7) cout << a << '-' << b << '+' << c << '+' << d << "=7" << ENT;
    else if(a-b+c-d==7) cout << a << '-' << b << '+' << c << '-' << d << "=7" << ENT;
    else if(a-b-c+d==7) cout << a << '-' << b << '-' << c << '+' << d << "=7" << ENT;
    else if(a-b-c-d==7) cout << a << '-' << b << '-' << c << '-' << d << "=7" << ENT;
    
    return 0;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, t, a, ans = 0;
    double tmp = INF;
    cin >> n >> t >> a;
    repi(i, n, 0)
    {
        int h;
        cin >> h;
        if (tmp > abs(a - t + h * 0.006))
        {
            tmp = abs(a - t + h * 0.006);
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  l1 <- getLine
  l2 <- getLine
  let a = read l1 :: Int
      b = read l2 :: Int
  print $ f a b

f 1 2 = 3
f 1 3 = 2
f 2 1 = 3
f 2 3 = 1
f 3 1 = 2
f 3 2 = 1

Measured memory_bytes: 508
#include<stdio.h>
int main()
{
	int x,y,z;
	int count=0;
	scanf("%d%d%d",&x,&y,&z);
	if(x<0||y<0||z<0||y+2*z>x||x>10.0E5||y>10.0E5||z>10.0E5)
	{
		printf("no answer\n");
	}
	else
	{
		x=x-z;
		while(x>=z+y)
		{  
			x=x-z;
			x=x-y;
		    count++;
			
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int min=1000001,max=-1000001;
  long sum=0;
  int n,x,i;

  scanf("%d", &n);
  for (i=0;i<n;i++){
    scanf("%d",&x);
    if(min>x){
      min = x;
    }
    if(max<x){
      max = x;
    }
    sum = sum + (long)x;
  }

  printf("%d %d %ld\n",min,max,sum);


  return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>=k;i--)
int main(void){
    long long a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
#define pb push_back
#define PI acos(-1.0)
#define EPS 1e-4
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fout(S,x)            cout<<fixed<<setprecision(x)<<(S)<<endl
#define present(c,x) ((c).find(x) != (c).end())
#define T() ll t;cin>>t;while(t--)
#define mem(input,b) memset(input,b,sizeof(input))
#define ff first
#define ss second
#define fread(input) freopen("input","r",stdin)
#define fwrite(b) freopen("b","w",stdout)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define FOREACH(i,c) for (__typeof ((c).begin()) i = (c).begin() ; i != (c).end() ; i++)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
const int maxn=1e5+5;
const int mod=1e9+7;
int hsh[100005];
int main(){
    fastio;
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        int x;
        cin>>x;
        hsh[x]++;
    }
    int ans = 0;
    for(int i=1;i<100004;++i){
        ans = max(ans, hsh[i-1]+hsh[i]+hsh[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}    


Measured memory_bytes: 640
S = input()
if len(S)==1:
  print('No')
  exit()

cntN = S.count('N')
cntW = S.count('W')
cntS = S.count('S')
cntE = S.count('E')

f1, f2 = False, False
if (cntN == 0 and cntS == 0) or (cntN > 0 and cntS > 0): f1 = True
if (cntW == 0 and cntE == 0) or (cntW > 0 and cntE > 0): f2 = True
print('Yes' if f1 is True and f2 is True else 'No' )

Measured memory_bytes: 39760