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

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*****************************************************START******************************************************************/


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1 ;
	 //cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		int n , ans = 0; cin >> n; 
		int arr[n];
		for(int i=0; i<n; i++){
			cin >> arr[i];
			if(i % 2 == 0 && arr[i] % 2 != 0)ans++;
		}
		cout << ans << endl;
				
	}
	return 0;
}


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

int main(){
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  ll diff1 = (a1 - b1) * t1;
  ll diff2 = (a2 - b2) * t2;

  if(0 < diff1) {
    diff1 = -diff1;
    diff2 = -diff2;
  }

  if(diff1 + diff2 < 0) {
    cout << 0 << endl;
    return 0;
  } else if(diff1 + diff2 == 0) {
    cout << "infinity" << endl;
    return 0;
  }

  ll answer = (-diff1/(diff1+diff2)) * 2 + (-diff1%(diff1+diff2) != 0);
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std; typedef long long ll; const int INF=1e9+7;
typedef pair<ll,ll> P;

int main() {
  int n; cin>>n; n*=2;
  int l[n]; for(int i=0;i<n;i++) cin>>l[i];
  sort(l,l+n);
  int an=0;
  for(int i=0;i<n;i+=2) {
    an+=min(l[i],l[i+1]);
  }
  cout<<an<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll l=LCM(c,d);
  ll ans=0;
  ans=((b/c)-((a-1)/c))+((b/d)-((a-1)/d))-((b/l)-((a-1)/l));
  cout << b-a+1-ans << endl;
  
}


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

int main(){
    
    long long int i, N, ans;
    cin >> N;
    ans = 0;
    
    vector< int > A(N, 0);
    
    for (i = 0; i < N; i++){
        cin >> A[i];
    }
    
    sort(A.begin(), A.end(), greater<int>());

    for (i = 1; i < N; i++){
        ans += A[i / 2];
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 3592
def checkback(B,i,j):
    samesum= (B[i][j]==B[i][j-1]) +(B[i][j]==B[i][j+1]) +(B[i][j]==B[i-1][j])
    if samesum==2:
        return not B[i][j]
    else:
        return B[i][j]

while(1):
    [N,K]=map(int,raw_input().split())
    if N==0:
        break
    if N%2 or K>2**(N/2):
        print "No\n"
    else:
        n=N/2
        A=[0 for i in range(N)]
        K-=1
        for i in range(1,n+1):
            A[2*(i-1)]= K/2**(n-i)
            A[2*(i-1)+1]= K/2**(n-i)
            K%=2**(n-i)
        B=[[-1 for i in range(N+2)] for j in range(N+2)]
        B[1][1:N+1]=A[:]
        for i in range(2,N+1):
            for j in range(1,N+1):
                B[i][j]=checkback(B,i-1,j)
        for i in range(1,N+1):
            ls=""
            for j in range(1,N+1):
                ls+=".E"[B[i][j]]
            print ls
        print"\n",

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

using namespace std;

const int INF = (int)1e8;

int main() {
    int n, m, d[102][102]; 
    int a[1003], b[1003], c[1003];

    cin >> n >> m;

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

    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    
    int ans = 0;

    for (int i = 0; i < m; i++) {
        bool is_valid = false;

        for (int start = 0; start < n; start++) {
            for (int goal = 0; goal < n; goal++) {
                if (start == goal) { continue; }
                if ( d[start][goal] == d[start][a[i]] + c[i] + d[b[i]][goal]
                    || d[start][goal] == d[start][b[i]] + c[i] + d[a[i]][goal] ) {
                    is_valid = true;
                }
            }
        }
        if (!is_valid) { ans++; }
    }
    cout << ans << endl;
    return 0;
}

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

//bool comp(pair<int,int> a, pair<int,int> b){return a.second < b.second;}

int main(void){
    
    long long X,Y;
    cin >> X >> Y;
    
    long long Z = X;
    int cont = 0;
    while(Z <= Y){

        Z *= 2;
        cont++;

    }
    cout << cont << endl;    
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    ll ans = 0;

    cin >> n;

    vector<ll> a(n);
    ll x = INF, xi = 0;
    ll res = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        res += abs(a[i]);

        x = min(x, abs(a[i]));
    }

    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] < 0)
        {
            a[i] *= -1;
            a[i + 1] *= -1;
        }
    }

    for (int i = 0; i < n; i++)
    {
        ans += a[i];
    }

    cout << max(ans, res - x * 2) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main () {
    int a,b=2,x=2,c=1,q;
    cin>>a;
    while(x<=a){
        q=x;
        for(int i=0;x<=a;i++){
            x=x*q;
            if(x<=a&&c<=x)c=x;
        }
        b=b+1;
        x=b;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stdio.h>
#include <functional>
#include <chrono>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init,ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T> &v) {
	T ans = -INF;
	rep(i,0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C& c, std::ostream& os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}
/*
ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}
*/
bool sortreverse(ll a, ll b) {
	return a > b;
}

bool kansu(pll a, pll b) {
	return a.first < b.first;
}

ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

ll n;

/* SegTree<X>(n,fx,ex): モノイド(集合X, 二項演算fx, 単位元ex)についてサイズnで構築
	set(int i, X x), build(): i番目の要素をxにセット。まとめてセグ木を構築する。O(n)
	update(i,x): i 番目の要素を x に更新。O(log(n))
	query(a,b): [a,b) 全てにfxを作用させた値を取得。O(log(n))
*/
template <typename X>
struct SegTree {
	using FX = function<X(X, X)>; // X•X -> X となる関数の型
	int n;
	FX fx;
	const X ex;
	vector<X> dat;
	SegTree(int n_, FX fx_, X ex_) : n(), fx(fx_), ex(ex_), dat(n_ * 4, ex_) {
		ll x = 1;
		while (n_ > x) {
			x *= 2;
		}
		n = x;
	}
	void set(ll i, X x) { dat[i + n - 1] = x; }
	void build() {
		for (ll k = n - 2; k >= 0; k--) dat[k] = fx(dat[2 * k + 1], dat[2 * k + 2]);
	}
	void update(ll i, X x) {
		i += n - 1;
		dat[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;  // parent
			dat[i] = fx(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}
	X query(ll a, ll b) { return query_sub(a, b, 0, 0, n); }
	X query_sub(ll a, ll b, ll k, ll l, ll r) {
		if (r <= a || b <= l) {
			return ex;
		}
		else if (a <= l && r <= b) {
			return dat[k];
		}
		else {
			X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
			X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
			return fx(vl, vr);
		}
	}
};

int main() {
	cin >> n;
	auto fx = [](ll x1, ll x2) -> ll { return max(x1, x2); };
	ll ex = 0;
	SegTree<ll> segki(n, fx, ex);

	vl h(n), a(n);
	rep(i, 0, n) {
		cin >> h[i];
	}
	rep(i, 0, n) {
		cin >> a[i];
	}

	rep(i, 0, n) {
		ll v = segki.query(0,h[i]);
		segki.update(h[i] - 1, v + a[i]);
	}
	printf("%lld\n", segki.query(0, n));
}

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

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

  for(int i = N; i <= 999; ++i){
    string str;
    str = to_string(i);
    if(str[0] == str[1] && str[1] == str[2]){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long lint;
int const N=1e5+10;
int n,a[N];
int dif[N];
int main()
{
	scanf("%d",&n);
	if(n==1) {printf("YES"); return 0;}
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	a[n+1]=a[1];
	lint s=(lint)n*(n+1)>>1,sum=0;
	for(int i=1;i<=n;i++) sum+=a[i],dif[i]=a[i+1]-a[i];
	if(sum%s!=0) {printf("NO"); return 0;}
	lint k=sum/s,sumX=0;
	for(int i=1;i<=n;i++)
	{
		lint x=(k-dif[i])/n;
		if(x<0 || x*n!=k-dif[i]) {printf("NO"); return 0;}
		sumX+=x;
	}
	if(sumX==k)	printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);

    ll b;
    while(cin>>b){
        if(b==0)
            break;
        set<ll, greater<ll>> fac;
        for (ll i = 1; i * i <= b; i++)
        {
            if(b%i==0)
                fac.insert(i), fac.insert(b / i), fac.insert(2*i), fac.insert(2*(b / i));
        }
        for (auto k:fac){
            //cerr << k << endl;
            //k is length
            ll n = b/k;

            ll m = k * 2;
            if(k%2==0 && (b/(k/2))%2==1 && (b/(k/2))/2-k/2+1>0){
                cout <<  (b/(k/2))/2 - k/2 + 1 << " " << k << endl;
                break;
            }
            if(b%k)
                continue;

            if(k%2==1 && n-k/2>0){
                cout << n - k / 2 << " " << k << endl;
                break;
            }
        }
    }
    
}


Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main() 
{
	double x1, x2, y1, y2, a;
	cin >> x1 >> x2 >> y1 >> y2 >> a;
	a = sqrt((y1 - x1) * (y1 - x1) + (y2 - x2) * (y2 - x2));
	cout << fixed << setprecision(8) << a << endl;
	return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, m; cin >> n >> m;
	std::vector<std::vector<std::pair<int, int>>> vec(n + 1);
	for(int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		
		vec[a].push_back({b, i});
	}
	
	std::vector<std::string> ans(m);
	for(int i = 0; i <= n; i++) {
		sort(begin(vec[i]), end(vec[i]));
		
		for(int j = 0; j < vec[i].size(); j++) {
			std::string t = std::to_string(i);
			while(t.size() < 6) t = "0" + t;
			
			std::string s = std::to_string(j + 1);
			while(s.size() < 6) s = "0" + s;
			
			ans[vec[i][j].second] = t + s;
		}
	}
		
	for(auto v : ans) cout << v << endl;
	return 0;
}


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

int main()
{
    int H, A;
    cin >> H >> A;
    int count = 0;
    while(H>0){
        H -= A;
        count += 1;
    }
    cout << count << endl;
}  

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  string s;
  cin >> s;
  if (s[s.size() - 1] != 's') {
    cout << s << "s" << endl;
  } else {
    cout << s << "es" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
import sys


def _s(): return sys.stdin.readline().strip()


def main():
    s = _s()
    t = _s()
    tn = len(t)
    mn = tn
    for i in range(0, len(s)-tn+1):
        tmp = 0
        for c1, c2 in zip(s[i:i+tn], t):
            if c1 != c2:
                tmp += 1
        mn = min(mn, tmp)
    return mn


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 67900
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    string s;
    cin >> s;
    ll q;
    cin >> q;

    deque<char> deq;
    
    rep(i,s.size()){
        deq.push_front(s.at(i));
    }
    

    ll flag = 1;
    rep(i,q){
        ll tmp;
        cin >> tmp;
        if(tmp == 1){
            flag++;
        }else if(tmp == 2){
            ll f;
            char c;
            cin >> f >> c;
            if((flag + f) % 2 == 1){
                deq.push_front(c);
            }else{
                deq.push_back(c);
            }
        }
    }

    if(flag % 2 == 0){
        while(!deq.empty()){
            cout << deq.front();
            deq.pop_front();
        }
    }else{
        while(!deq.empty()){
            cout << deq.back();
            deq.pop_back();
        }
    }
    cout << endl;

}

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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  
  int ans=0;
  for(int i=0 ; i<K ; i++){
    if(A>0){
      ans++;
      A--;
    }else if(B>0){
      B--;
    }else if(C>0){
      ans--;
      C--;
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 3624
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ

		Scanner vd= new Scanner(System.in);
		int n = vd. nextInt();
		int[] l = new int[n];
		for(int i=0; i<n;i++) l[i] = vd.nextInt();
		vd.close();

		int max=0;
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n;++i) {
			if(max<l[i]) max=l[i];
		}
		for(int i=0;i<n;++i) {
			if(min>l[i]) min=l[i];
		}
		System.out.println(max-min);
	}

}


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

int main()
{
    ll mod = 998244353;

    ll n;
    cin >> n;

    vector<ll> d(n);
    vector<ll> d_cnt(n, 0);

    rep(i, n)
    {
        cin >> d.at(i);
        d_cnt.at(d.at(i))++;
    }

    ll ans = (d_cnt.at(0) == 1);
    for (int i = 1; i < n; i++)
    {
        ll dist = d.at(i);
        if (dist == 0)
        {
            ans = 0;
        }
        else
        {
            ans *= d_cnt.at(dist - 1);
        }
        ans %= mod;
    }

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

Measured memory_bytes: 4816
ryoKinLst = [0] * 4
for i in range(4):
    ryoKinLst[i] = int(input())

minA = 0
minC = 0

minA = min(ryoKinLst[0], ryoKinLst[1])
minC = min(ryoKinLst[2], ryoKinLst[3])

print(minA + minC)


Measured memory_bytes: 2940
n = int(input())
a = list(map(int, input().split()))

def check(f):
        flag = f 
        t = 0 
        c = 0 
        for i in range(n):
                if t + a[i] <= 0 and flag == 1:
                        c += 1 - t - a[i]
                        t = 1 
                elif t + a[i] >= 0 and flag == -1: 
                        c += 1 + t + a[i]
                        t = -1
                else:
                        t += a[i] 
                flag *= -1
        return c 
    
total_p = check(1)
total_m = check(-1)
print(min(total_p, total_m))

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

int main(){
    int n;cin>>n;
    set<int> a;
    for(int i=0,p;i<n;i++){
        cin>>p;
        a.insert(p);
    }

    int p,q;
    set<int>::iterator itr;
    itr=a.end();
    itr--;
    p=*itr;

    a.erase(p);
    double x=p*0.5,dif=1000000000;

    itr=a.begin();
    while(itr!=a.end()){
        if(dif>abs(*itr-x)){
            dif=abs(*itr-x);
            q=*itr;
        }
        itr++;
    }

    cout<<p<<" "<<q<<endl;

    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <malloc.h>
#include <assert.h>
#include <ctype.h>
#include <memory.h>

typedef struct StkDat {
    int key;
    struct StkDat *next;
} StkDat;
typedef struct Stack {
    size_t len;
    StkDat *top;
} Stack;
#define stack_isempty(s) ((s)->top == NULL ? 1 : 0)
void stack_init(Stack *stk_hdr) {
    stk_hdr->len = 0;
    stk_hdr->top = NULL;
}
int stack_pop(Stack *stk_hdr) {
    assert(stk_hdr->len != 0);
    stk_hdr->len--;
    int key = stk_hdr->top->key;
    StkDat *old_head = stk_hdr->top;
    stk_hdr->top = stk_hdr->top->next;
    free(old_head);
    return key;
}

void stack_push(Stack *stk_hdr, const int key) {
    StkDat *new_dat = (StkDat *)malloc(sizeof(StkDat));
    new_dat->key = key;
    new_dat->next = stk_hdr->top;
    stk_hdr->top = new_dat;
    stk_hdr->len++;
}

#define TOKEN_INT   1
#define TOKEN_OP    2
#define TOKEN_OTHER 3
#define TOKEN_LAST  4

typedef struct Token {
    int kind;
    const char *start;
    const char *end;
    union {
        int val;
        const char *name;
    };
} Token;

Token token;
const char *stream;

void next_token() {
    token.start = stream;
    if(isdigit(*stream)) {
        int val = 0;
        while(isdigit(*stream)) {
            val *= 10;
            val += *stream++ - '0';
        }
        token.kind = TOKEN_INT;
        token.val = val;
    } else {
        token.kind = TOKEN_OTHER;
        switch(*stream) {
        case '+':
        case '-':
        case '*':
            token.kind = TOKEN_OP;
            token.name = stream;
            break;
        case '\0':
            token.kind = TOKEN_LAST;
            break;
        }
        stream++;
    }
    token.end = stream;
}

void lexing(const char *source) {
    stream = source;
    next_token();
    Stack stk;
    stack_push(&stk, token.val);
    while(token.kind != TOKEN_LAST) {
        next_token();
        if(token.kind == TOKEN_INT) stack_push(&stk, token.val);
        else if(token.kind == TOKEN_OP) {
            int x, y;
            switch(*token.name) {
            case '+':
                y = stack_pop(&stk);
                x = stack_pop(&stk);
                stack_push(&stk, x + y);
                break;
            case '-':
                y = stack_pop(&stk);
                x = stack_pop(&stk);
                stack_push(&stk, x - y);
                break;
            case '*':
                y = stack_pop(&stk);
                x = stack_pop(&stk);
                stack_push(&stk, x * y);
                break;
            default:
                break;
            }
        }
    }
    printf("%d\n", stack_pop(&stk));
}

int main() {
    char chr[512];
    scanf("%[^\n]", chr);
    lexing(chr);
    return 0;
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second
#define pr priority_queue
#define ump  unordered_map
#define prg priority_queue<ll, vec<ll> ,greater<ll> >
#define pb  push_back;
//parent finding
ll find(vector<ll> &v, ll n)
{
  if (v[n] == n)
    return n;
  return v[n] = find(v, v[n]);
}
bool is(ll x, ll y, ll n, ll m)
{
  if (x >= 0 && x < n && y >= 0 && y < m)
    return true;
  return false;
}
ll dx[4] = {1, -1, 0, 0};
ll dy[4] = {0, 0, 1, -1};
void bfs(vector<vector<char> > &vec, ll st1, ll st2, vector<vector<ll> > &dist)
{
  ll n = vec.size(), m = vec[0].size();
  pair<ll, ll> p;
  p.fi = st1; p.sec = st2;
  dist[st1][st2] = 0;
  deque<pair<ll, ll> > dq;
  dq.push_back(p);
  while (!dq.empty())
  {
    pair<ll, ll> p1;
    p1.fi = dq.front().fi; p1.sec = dq.front().sec;
    dq.pop_front();
    for (ll i = 0; i < 4; i++)
    {
      ll x = p1.fi + dx[i], y = p1.sec + dy[i];
      if (is(x, y, n, m) && vec[x][y] != '#')
      {
        if (dist[x][y] > dist[p1.fi][p1.sec])
        {
          dist[x][y] = dist[p1.fi][p1.sec];
          dq.push_front({x, y});
        }
      }
    }
    for (ll i = p1.fi - 2; i <= p1.fi + 2; i++)
    {
      for (ll j = p1.sec - 2; j <= p1.sec + 2; j++)
      {
        if (is(i, j, n, m) && vec[i][j] != '#')
        {
          if (dist[i][j] > dist[p1.fi][p1.sec] + 1)
          {
            dist[i][j] = dist[p1.fi][p1.sec] + 1;
            dq.push_back({i, j});
          }
        }
      }
    }
  }
  return ;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n, m; cin >> n >> m;
  ll st1, st2; cin >> st1 >> st2;
  ll dt1, dt2; cin >> dt1 >> dt2;
  st1--; st2--; dt1--; dt2--;
  vector<vector<char> > vec(n, vector<char> (m, 0));
  for (ll i = 0; i < n; i++)
    for (ll j = 0; j < m; j++)
      cin >> vec[i][j];
  vector<vector<ll> > dist(n, vector<ll> (m, LLONG_MAX));
  bfs(vec, st1, st2, dist);
  ll ans = dist[dt1][dt2];
  if (ans == LLONG_MAX)
    cout << "-1\n";
  else
    cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 12608
N = int(input())

if N < 105:
    print (0)
else:
    if N < 135:
        print (1)
    else:
        if N < 165:
            print (2)
        else:
            if N < 189:
                print (3)
            else:
                if N < 195:
                    print (4)
                else:
                    print (5)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String str = "";

        while(sc.hasNext()) {
        	str += sc.nextLine();
        }
        str = str.toLowerCase();

        char[] alphabet = new char[] {'a','b','c','d','e','f','g','h','i','j','k',
        							  'l','m','n','o','p','q','r','s','t','u','v',
        							  'w','x','y','z'};

        int[] ans = new int[alphabet.length];

        for(int i = 0; i < str.length(); ++i) {
        	for(int j = 0; j < alphabet.length; j++) {
        		if(str.charAt(i) == alphabet[j]) {
        			ans[j]++;
        		}
        	}
        }

        for(int i = 0; i < alphabet.length; i++) {
        	System.out.println(String.format("%s : %d", alphabet[i], ans[i]));
        }

    }
}


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

using namespace std;

const int N = 10000 + 5;
const int INF = 0x3f3f3f3f;
using LL = long long;
using P = pair<int, int>;
map<int, int> mp;
set<int> S;

int a[N];

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = INT_MAX;
    int tmp = max(x, y);
    ans = min(ans, tmp * 2 * c);
    
    ans = min(ans, x * a + y * b);

    if(x >= y){
        int sum = y * 2 * c + (x - y) * a;
        ans = min(ans, sum);
    }else{
        int sum = x * 2 * c + (y - x) * b;
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  string s;
  cin >> s;
  ll zero= 0, one = 0;
  ll ans = 0;
  rep(i,s.size()){
    if(s[i] == '0') zero++;
    if(s[i] == '1') one++;
    if(zero > 0 && one > 0){
      ans +=2;
      zero--, one--;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int gcd(int x,long int y)
{
    return y?gcd(y,x%y):x;
}

int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        int x=gcd(a,b);
        long long int y=(long long int)a*(long long int)b;
        cout<<y/x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int w;
int b;
char map[50][51];
int we;
int he;

int measure(int x,int y){
  int i,m=0,dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}},nx,ny;
  map[y][x]='F';
  for(m=1,i=0;i<4;i++){
    nx=x+dir[i][1];
    ny=y+dir[i][0];
    if(nx<we&&nx>-1&&ny<he&&ny>-1){
      if(map[ny][nx]=='.'){
	m+=measure(nx,ny);
      }else if(map[ny][nx]=='B'){
	b++;
      }else if(map[ny][nx]=='W'){
	w++;
      }
    }
  }
  return m;
}
int main(){
  int i,white,black,m,j;
  do{
    scanf("%d %d",&we,&he);
    if(we==0&&he==0) break;
    for(i=0;i<he;i++) scanf("%s",map[i]);
    for(i=white=black=0;i<he;i++){
      for(j=0;j<we;j++){
	if(map[i][j]=='.'){
	  m=measure(j,i);
	  if(w&&!b){
	    white+=m;
	  }else if(!w&&b){
	    black+=m;
	  }
	  w=b=0;
	}
      }
    }
    printf("%d %d\n",black,white);
  }while(1);
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795;

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

	for (char c : S){
		ll cnt = 0;
		for (char same : S){
			if (c == same)
			{
				cnt++;
			}
		}
		if (cnt % 2 == 1)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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


vector<int> adjList[100010];
set<int> incoming[100010];
vector<int> fin[100010];
int parent[100010];
void build_tree(int u, int p){
    parent[u] = p;
    for(auto v: adjList[u]){
        if(incoming[v].size() != 1) incoming[v].erase(u);
        else fin[u].push_back(v);
    }

    for(auto v: fin[u]) build_tree(v, u);
}

int main(){
    int N,M;cin>>N>>M;
    for(int i=0;i<N+M-1;i++){
        int u,v;cin>>u>>v;
        adjList[u].push_back(v);
        incoming[v].insert(u);
    }

    for(int i=1;i<=N;i++) if(incoming[i].size() == 0) build_tree(i, 0);
    for(int i=1;i<=N;i++) cout<<parent[i]<<endl;
}

Measured memory_bytes: 34048
s=list(input())	

ans1 = 0
for i in range(len(s)):
    if (i % 2 == 0 and s[i] == "0"):
        ans1 +=1
    elif i % 2 == 1 and s[i] == "1":
        ans1 += 1

print(min(ans1, len(s) - ans1))

Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <string>

using namespace std;
 
int main()
{
    int T;
    cin >> T;
    long long A, B, C, D;
    long long p, q, r;
    for(int i = 0; i<T;i++){
        cin >> A >> B >> C >> D;
        p = B;
        q = D;
        while(p%q !=0){
            r = p%q;
            p = q;
            q = r;
        }
        if(A>=B && B <=D && (B +(A%q)-q)<=C){
            cout << "Yes"<< endl;
        }else{
            cout << "No"<< endl;
        }

    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

struct UnionFind {
    UnionFind() {}
    UnionFind(int n) {
        resize(n);
    }
    
    void resize(int n) {
        par.resize(n, -1);
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
private:
    vector<int> par;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        uf.merge(a, b);
    }
    ll ans = 0;
    rep(i, n) {
        chmax(ans, (ll)uf.size(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3944
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	string s,t;
	cin>>s>>t;
	int n = s.size();
	int m = t.size();
	int mini = m;
	for(int i = 0;i<=n-m;i++)
	{
		int count = 0;
		for(int j = 0;j<m;j++)
		{
			if(t[j] != s[i+j]) count++;
		}
		
		mini = min(mini , count);
	}
	
	
	cout<<mini<<endl;
	
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int n;
	cin >> n;

	vector<int>p(n);

	REP(i, n) cin >> p[i];

	int minv = p[0];
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (minv >= p[i]) cnt++; //cout << i << endl;
		minv = min(minv, p[i]);
	}

	cout << cnt << endl;

	return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    string s;
    cin >> s;

    int st = -1, en = 0;

    rep(i, s.size()) {
        if (s[i] == 'A' && st == -1) st = i;
        if (s[i] == 'Z') en = i;
    }

    cout << en - st + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << (x) << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> P) { for(auto const &vv: P)os<<"("<<vv.first<<","<<vv.second<<")"; return os; }
template<class T> ostream& operator<<(ostream &os, set<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 1000001

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    sc(n);
    map<string,int> ss;
    FOR(i,0,n){
        string s;
        getstr(s);
        sort(all(s));
        ++ss[s];
    }
    ll res = 0;
    FORR(i,ss){
        res += (ll)i.e2*(i.e2-1)/2;
    }
    cout << res << '\n';
}



Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
int n,m,ans;
int i,j,k;
int main(){
    cin>>n>>m;
    for(i=0;i<=n;i++)
        for(j=0;j<=n;j++){
            k=m-i-j;
            if(k<=n&&k>=0)ans++;
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>

using namespace std;
typedef pair<int, int> pii;
struct SecondComparator {
	bool operator()(const pii &a, const pii &b){
		return pii(a.second, a.first) < pii(b.second, b.first);
	}
};

int main(){
	int N;
	cin >> N;
	vector<pii> problems(N);
	for(int i = 0; i < N; ++i){
		cin >> problems[i].first >> problems[i].second;
	}
	sort(problems.begin(), problems.end(), SecondComparator());
	int sum = 0;
	priority_queue<pii> pq;
	for(int i = 0; i < N; ++i){
		if(sum + problems[i].first <= problems[i].second){
			sum += problems[i].first;
			pq.push(problems[i]);
		}else if(!pq.empty() && pq.top().first > problems[i].first){
			sum += problems[i].first - pq.top().first;
			pq.pop();
			pq.push(problems[i]);
		}
	}
	cout << pq.size() << endl;
	return 0;
}

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

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  set<int> s;
  for(int i=0;i<M;i++){
    int A;
    cin >> A;
    s.insert(A);
  }
  int ans=0;
  int sum=0;
  for(int i=X;i>=0;i--){
    if(s.count(i)){
      sum++;
    }
  }
  ans=sum;
  sum=0;
  for(int i=X;i<=N;i++){
    if(s.count(i)){
      sum++;
    }
  }
  if(ans>sum){
    ans=sum;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll>
using namespace std;
int main() {
    string ss, tt, ans = "";
    cin >> ss;
    cin >> tt;
    int sz = ss.size(), tz = tt.size();
    vector<vector<int>> arr(sz + 1, vector<int>(tz + 1));
    for(int i = 1; i <= sz; ++i)
        for(int j = 1; j <= tz; ++j) {
            if(ss[i - 1] == tt[j - 1]){
                arr[i][j] = arr[i - 1][j - 1] + 1;
            }
            else
                arr[i][j] = max(arr[i - 1][j], arr[i][j - 1]);
        }
        int i = sz, j = tz;
        while(i >= 1 && j >= 1) {
            if(ss[i - 1] == tt[j - 1]) {
                ans += ss[i - 1];
                i -= 1;
                j -= 1;
            }
            else {
                if(arr[i][j] == arr[i - 1][j])
                    i = i - 1;
                else
                    j = j - 1;
            }
        }
        if(ans.size() > 0)
            reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 35584
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
using namespace std;

int main(){
  int N;
  cin>>N;
  
  string S[N];
  int num[N]={0};
  for(int i=0;i<N;++i){
    cin>>S[i];
  }
  sort(S,S+N);
  
  int mv=0;
  int toujou=0;
  string pname;
  
  set<string> s;
  //string ans="APPROVED";
  for(int i=0;i<N;++i){
    if(pname==S[i]){
      toujou++;
    }else{
      toujou=1;
    }
    if(toujou>=mv){
      mv=toujou;
    }
    
    pname=S[i];
  }
  //cout<<mv<<endl;
  
  toujou=0;
  for(int i=0;i<N;++i){
    if(pname==S[i]){
      toujou++;
    }else{
      toujou=1;
    }
    //cout<<toujou<<endl;
    if(toujou==mv){
      cout<<S[i]<<endl;
    }
    
    pname=S[i];
  }

  
  //cout<<ans<<endl;
}


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

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

int main() {
    string a = "yuiophjklnm";
    set<char> set;
    for (char c : a)
        set.insert(c);

    string s;
    while (cin >> s, s != "#") {
        int cur = set.count(s[0]);

        int ans = 0;
        for (char c : s) {
            if (cur != set.count(c)) {
                ans++;
                cur = set.count(c);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3176
// ------------------------------------
// Date:2018/ 3/17
// Problem:odd string_ _ d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

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

  SCIN(s);
  REP(i, s.size()) {
    if(i % 2 == 0) cout << s[i];
  }
  cout << endl;
  

  return 0;
}



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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, K, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    for(int i=K;i<N;i++) {
        if(A[i-K]<A[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

//int _; 

int n,m,a[100020],sum=0;
bool ans[100020];

int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> n >> m;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		ans[i]=true;
	}
	for(int i=0;i<m;i++)
	{
		int b,c;
		cin >> b >> c;
		b--;
		c--;
		if(a[b] >= a[c])
			ans[c]=false;
		if(a[c] >= a[b])
			ans[b]=false; 
	}
	for(int i=0;i<n;i++)
		if(ans[i])
			sum++;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4108
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		String s = sc.next();
		int n = s.length() / 2;
		int point = 0;
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) == 'g'){
				if(n > 0) point++;
			}else{
				if(n <= 0) point--;
			}
			n--;
		}
		System.out.println(point);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22740
N, M, C = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
A = N.times.map { gets.split.map(&:to_i) }

ans = 0

A.each do |a|
  s = a.zip(B).inject(0) { |res, (i, j)| res + (i * j) }

  ans += 1 if s + C > 0
end

puts ans


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

using namespace std;

int main(int argc, char* argv[]) {
  long long Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;

  // 0.25, 0.5, 1, 2

  long long cost = 0;

  if (D < 2 * S && D < 4 * H && D < 8 * Q) {
    cost += (N / 2) * D;
    N = N - floor(N / 2) * 2;
  }

  long long case1 = N * S;
  long long case2 = 2 * N * H;
  long long case3 = 4 * N * Q;

  cost += min(min(case1, case2), case3);

  cout << cost << endl;

  return 0;
}

Measured memory_bytes: 256