akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;


template<typename T, const T&(*f)(const T&, const T&) = std::min<T> >
struct rmq {
	vector<T> t;
	size_t d;
	
	rmq(size_t sz = 0, const T &val = T()): t(sz*2,val), d(sz) {}
	rmq(const vector<T> &vals){
		d = size(vals);
		t.resize(d*2);
		copy(begin(vals), end(vals), begin(t)+d);
		for(int i=d-1;i>0;--i) t[i] = f(t[i*2], t[i*2+1]);
	}
	
	void set_value(size_t i, const T& val){
		for(t[i+=d]=val; i>1; i>>=1) t[i>>1] = f(t[i], t[i^1]);
	}
	void update_value(size_t i, const T& val){
		set_value(i,f(t[i+d],val));
	}
	
	T operator()(size_t l, size_t r){
		T res = t[l+=d];
		for(++l,r+=d; l<r; l>>=1,r>>=1){
			if(l&1) res = f(res, t[l]), ++l;
			if(r&1) --r, res = f(res, t[r]);
		}
		return res;
	}
	
	T operator()(){ return t[1]; }
};


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	cin>>n;
	
	vector<ll> x(n), y(n);
	for(int i=0;i<n;++i) cin>>x[i]>>y[i];
	
	ll ans = -9e18;
	
	for(int it=0;it<4;++it){
		
		vector<int> p(n); iota(ALL(p),0);
		sort(ALL(p), [&](int i, int j){return pair(y[i],x[i]) < pair(y[j],x[j]);});
		
		vector<ll> xs;
		for(int i=0;i<n;++i) xs.push_back(x[i]);
		sort(ALL(xs));
		
		rmq<ll,min> q(n,9e18);
		
		for(int i : p){
			//cout<<"?"<<i<<": "<<x[i]<<' '<<y[i]<<endl;
			int k = lower_bound(ALL(xs), x[i]) - begin(xs);
			ll s = q(0,k+1);
			ans = max(ans, x[i]+y[i] - s);
			q.update_value(k,x[i]+y[i]);
		}
		
		
		for(int i=0;i<n;++i){
			ll tx = x[i], ty = y[i];
			
			x[i] = ty;
			y[i] = -tx;
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 14004
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a[100];
    a[0]=2;a[1]=1;
    for(int i=2;i<=86;i++){
        a[i]=a[i-1]+a[i-2];
    }
    long long n;
    cin>>n;
    cout<<a[n]<<endl;
    return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) 
		cout << "Yay!";
	else cout << ":(";
	
}



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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  char x,y;
  cin >> x >> y;
  if(x<y){
    cout << "<" << endl;
  }
  else if(x==y){
    cout << "=" << endl;
  }
  else{
    cout << ">" << endl;
  }
    
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

void koch(pair<double, double> p1, pair<double, double> p2, long n){
	if (n == 0) return;
	pair<double, double> s, u, t;
	s.first = (p1.first * 2 + p2.first) / 3;
	s.second = (p1.second * 2 + p2.second) / 3;
	t.first = (p1.first + p2.first * 2) / 3;
	t.second = (p1.second + p2.second * 2) / 3;
	u.first = 0.5 * t.first - 0.5 * sqrt(3) * t.second + 0.5 * s.first + 0.5 * sqrt(3) * s.second;
	u.second = 0.5 * sqrt(3) * t.first + 0.5 * t.second - 0.5 * sqrt(3) * s.first + 0.5 * s.second;
	koch(p1, s, n - 1);
	cout << s.first << " " << s.second << endl;
	koch(s, u, n - 1);
	cout << u.first << " " << u.second << endl;
	koch(u, t, n - 1);
	cout << t.first << " " << t.second << endl;
	koch(t, p2, n - 1);
}

int main(){
	long n;
	cin >> n;
	pair<double, double> p1, p2;
	p1.first = 0; p1.second = 0;
	p2.first = 100; p2.second = 0;
	cout << setprecision(10) << p1.first << " " << p1.second << endl;
	koch(p1, p2, n);
	cout << p2.first << " " << p2.second << endl;
	return 0;
}

Measured memory_bytes: 1252
x = int(input())
if x < 600: print(8)
elif x < 800: print(7)
elif x < 1000: print(6)
elif x < 1200: print(5)
elif x < 1400: print(4)
elif x < 1600: print(3)
elif x < 1800: print(2)
elif x < 2000: print(1)

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

int main() {
    int n; cin >> n;
    char s[51]; cin >> s;

    int ans = 0;
    for (int i = 0; i <= n - 3; ++i) {
        ans += s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C';
    }

    cout << ans << endl;
}



Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int main() {
	int a[3]; cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	cout << a[0] + a[1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long N, long long K){
    ll sum = 1;
    FOR(i, K, N + 1)
    {
        sum += (i * (N - i + 1) + 1) % MOD;
        sum %= MOD;
    }
    cout << sum << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 3264
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

int main() {

	float A, B, V, W, T;

	cin >> A >> V >> B >> W >> T;

	if (A > B)
	{
		V = -V;
		W = -W;
		if (V == W)
		{
			cout << "NO";

			return 0;
		}
		if (A + (V * T) <= B + (W * T))
		{
			cout << "YES";
		}
		else
		{
			cout << "NO";
		}

		return 0;
	}

	if (A + (V * T) >= B + (W * T))
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}

	return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> d(N);
    for(int i = 0 ; i < N; i++) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[N/2] - d[N/2 - 1] << endl;
}

Measured memory_bytes: 640
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let N = get!(i64);

    let ans = N / 3;

    // 出力
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int x,y;
    cin >> x >> y;
    bool ok = false;
    for(int i = 0;i < y/2+1;i++){
        if(i*2+(x-i)*4 == y)ok = true;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
def bubble_sort(a,n):
    m=0
    flag=True
    while(flag):
        flag=False
        for i in range(n-1,0,-1):
            if(a[i-1] > a[i]):
                tmp=a[i-1]
                a[i-1]=a[i]
                m+=1
                a[i]=tmp
                flag=True
                
    b=list(map(str,a))
    print(" ".join(b))
    print(m)

a=[]
n=int(input())
s=input()
a=list(map(int,s.split()))
bubble_sort(a,n)

Measured memory_bytes: 7684
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

int main(){
  ll n;
  cin >> n;
  
  ll res = n;
  for(ll a=1; a*a <= n; ++a){
    if(n%a==0) res = min(res, a + n/a - 2);
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int n, m;
vector<string> s;
int root[2001][2001], visit[2001][2001];
int ltor[2001][2001], rtol[2001][2001], ttob[2001][2001], btot[2001][2001];

int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};

void dfs(int i, int j){
    visit[i][j] = 1;
    REP(k,4){
        int ii = i + dx[k], jj = j + dy[k];
        if (ii < 0 || jj < 0 || ii >= n || jj >= m) continue;
        if (s[ii][jj] == '0' || visit[ii][jj]) continue;
        if (k == 0) btot[ii+1][jj+1] = 1;
        if (k == 1) ttob[ii+1][jj+1] = 1;
        if (k == 2) rtol[ii+1][jj+1] = 1;
        if (k == 3) ltor[ii+1][jj+1] = 1;
        dfs(ii, jj);
    }
}

void cumsum(int a[2001][2001]){
    REP(i,n) REP(j,m){
        a[i+1][j+1] += a[i+1][j];
    }
    REP(j,m) REP(i,n){
        a[i+1][j+1] += a[i][j+1];
    }
}

int main(){
    int q;
    cin >> n >> m >> q;
    s.resize(n);
    REP(i,n) cin >> s[i];

    REP(i,n) REP(j,m){
        if (s[i][j] == '0' || visit[i][j]) continue;
        root[i+1][j+1] = 1;
        dfs(i,j);
    }

    cumsum(root);

    FOR(j,1,m) REP(i,n){
        ltor[i+1][j] += ltor[i][j];
        rtol[i+1][j] += rtol[i][j];
    }

    FOR(i,1,n) REP(j,m){
        ttob[i][j+1] += ttob[i][j];
        btot[i][j+1] += btot[i][j];
    }


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

    while (q--){
        int x1, y1, x2, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        int ans = root[x2][y2] - root[x2][y1-1] - root[x1-1][y2] + root[x1-1][y1-1];
        ans += rtol[x2][y1] - rtol[x1-1][y1];
        ans += ltor[x2][y2] - ltor[x1-1][y2];
        ans += btot[x1][y2] - btot[x1][y1-1];
        ans += ttob[x2][y2] - ttob[x2][y1-1];
        printf("%d\n", ans);
    }


    return 0;
}

Measured memory_bytes: 100992
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define ios       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,a,n) for (ll i = a; i < (ll)(n); i++)
#define fon(i,n) for (ll i = (ll)n-1; i >=0; i--)
#define vi          vector<ll>
#define vii vector<pair<ll,ll>>
#define all(a)      (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ciin(v) forn(i,0,v.size()) cin>>v[i]
#define coutt(v) forn(i,0,v.size()) cout<<v[i]<<" "
using namespace std;
ll mod=1e9+7;
int main(){
    ios
    ll test;
    test=1;
    // cin>>test;
    while(test--){
        ll n,w;
        cin>>n>>w;
        vi wei(n),v(n);
        forn(i,0,n) cin>>wei[i]>>v[i];
        ll sum=0;
        forn(i,0,n) sum+=v[i];
        // cout<<sum;
        vi dp(sum+1,1e18);
        dp[0]=0;
        forn(i,0,n){
            for(int j=sum-v[i];j>=0;j--)
            {
                dp[j+v[i]]=min(dp[j+v[i]],dp[j]+wei[i]);
            }
        }
        // coutt(dp);
        ll fin=0;
        forn(i,0,sum+1){
            if(dp[i]<=w) fin=max(i,fin);
        }
        cout<<fin;
       


 
 }}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    int h, w;
    cin >> h >> w;

    vector<int> eh(h);
    vector<int> ew(w);
    string s[h];
    rep(i, h) {
        cin >> s[i];
    }

    rep(i, h) {
        bool ok = true;
        rep(j, w) {
            if (s[i][j] == '#') ok = false;
        }
        if (ok) eh[i] = 1;
    }

    rep(j, w) {
        bool ok = true;
        rep(i, h) {
            if (s[i][j] == '#') ok = false;
        }
        if (ok) ew[j] = 1;
    }

    rep(i, h) {
        if (eh[i] == 1) continue;
        rep(j, w) {
            if (ew[j] == 1) continue;
            cout << s[i][j];
        }
        cout << endl;
    }

    return 0;
}

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

#define ll long long 
using namespace std;

int m;
deque < pair < ll, int > > d[320];

ll get(int k, int i)
{
    if(k == 0)
        return 0;
    while(d[k].front().second < i - m)
        d[k].pop_front();
    return d[k].front().first;
}

void ins(ll val, int i, int k)
{
    while(!d[k].empty() && d[k].back().first <= val)
        d[k].pop_back();
    d[k].push_back(make_pair(val, i));
}

int k, n;
ll a[100020], answer = 0;

int main() {
    scanf("%d %d %d", &n, &m, &k);
    
    for(int i = 1; i <= n; ++ i)
      scanf("%lld", &a[i]);
    
    for(int i = 1; i < k; ++ i)
      d[i].push_back(make_pair(-1e15, 0));
    for(int i = 1; i <= n; ++ i)
    {
        for(int j = k; j >= 1;  -- j)
        {
            ll p = get(j - 1, i);
            p += j * a[i];
            if(j == k)
                answer = max(answer, p);
            else
                ins(p, i, j);
        }
    }
    
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 1280
S=input()
if len(S)%2==0:
    black="01"*(len(S)//2)
    white="10"*(len(S)//2)
    countb=0
    countw=0
else:
    black="01"*(len(S)//2)+"0"
    white="10"*(len(S)//2)+"1"
countb=0
countw=0
for i in range(len(S)):
    if S[i]!=black[i]:
        countb=countb+1
    elif S[i]!=white[i]:
        countw=countw+1
    else:
        pass
if countb>=countw:
    print(countw)
else:
    print(countb)

Measured memory_bytes: 9184
#include "bits/stdc++.h"

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int a,b,k;

void input(){
	cin>>a>>b>>k;
	return;
}

void solve(){
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			int sum=0;
			sum+=b*i;
			sum-=i*j;
			sum+=(a-i)*j;
			if(sum==k){
				cout<<"Yes"<<endl;
				return;
			}
		}
	}
	cout<<"No"<<endl;
	return;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

    int s;
    cin >> s;
    int l = s/100;
    int r = s%100;
    if((12>=l && l>=1)&&(12>=r && r>=1))cout <<"AMBIGUOUS"<<endl;
    else if((12>=l && l>=1)&&(12<r || r<1)) cout << "MMYY" <<endl;
    else if((12>=r && r>=1)&&(12<l || l<1)) cout << "YYMM" <<endl;
    else cout <<"NA" <<endl;  
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for i in range(n-1):
  ans+=b[a[i]-1]
  if a[i+1]==a[i]+1:
    ans+=c[a[i]-1]
ans+=b[a[n-1]-1]
print(ans)

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

int main()
{
    int ab, bc, ca;
    cin >> ab >> bc >> ca;
    cout << ab * bc / 2 << endl;
    return 0;
}

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

int main()
{
    int x;
    cin >> x;
    if (x < 1200)
        cout << "ABC";
    else
        cout << "ARC";
    return 0;
}

Measured memory_bytes: 256
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from fractions import gcd
def resolve():
    N,=pin()
    S=input()
    temp=0
    ans=0
    for s in S:
        if s=="I":
            temp+=1
        else:
            temp-=1
        ans=max(ans,temp)
    print(ans)
        
#%%submit!    
resolve()

Measured memory_bytes: 63980
#include<bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int n;
int dp[10005];
int damage[1005];
int cost[1005];
int f(int health){
	if(health<=0) return 0;
	int&ret = dp[health];
	if(~ret) return ret;
	ret = INF;
	for(int i=0; i<n; i++){
		ret = min(ret,f(health-damage[i])+cost[i]);
	}
	return ret;
}
int main(){
	memset(dp,-1,sizeof(dp));
	int h;
	cin>>h>>n;
	for(int i=0; i<n; i++) cin>>damage[i]>>cost[i];
	cout<<f(h);
}

Measured memory_bytes: 4276
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

int A, B;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	while (scanf("%d%d", &A, &B) == 2) {
		if (B % A == 0) cout << A+B << endl;
		else cout << B-A << endl;
	}

	return 0;
}
/*
    input:
    output:
    modeling:
    methods:
    complexity:
    summary:
*/

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  ll sum = 0;
  for (int i = 0; i < n; i++) sum ^= a.at(i);
  
  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << (sum ^ a.at(i));
  }
  cout << '\n';
}

Measured memory_bytes: 4780
import bisect

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
b.sort()
c.sort()

ans = 0

for i in range(n):
    bi = b[i]
    x = bisect.bisect_left(a, bi)
    y = bisect.bisect_right(c, bi)
    ans += x * (n - y)

print(ans)


Measured memory_bytes: 105572
#include <iostream>

using namespace std;

int main(){
  int h,w;
  cin >> h >> w;
  string str[h+1];
  for(int i=1;i<=h;i++){
    cin >> str[i];
  }
  for(int i=1;i<=2*h;i++){
    for(int j=0;j<w;j++){
      cout << str[(i+1)/2][j];
    }
    cout << endl;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <tuple>

using namespace std;

int main()
{
    int h,w,cnt=3000,sum=0;
    cin>>h>>w;
    char brd[55][55];
    bool done[55][55];
    memset(done, false, sizeof(done));
    for (int i=0; i<55; i++) for (int j=0; j<55; j++) brd[i][j]='#';
    for (int i=1; i<=h; i++) for (int j=1; j<=w; j++) cin>>brd[i][j];
    for (int i=1; i<=h; i++) for (int j=1; j<=w ;j++) done[i][j]=true;
    priority_queue<tuple<int, int, int>> que;
    que.push(make_tuple(-1,1,1));
    while (!que.empty())
    {
        int a=get<0>(que.top()), b=get<1>(que.top()), c=get<2>(que.top());
        que.pop();
        if (!done[b][c]) continue;
        done[b][c]=false;
        if (b==h && c==w) cnt=min(cnt, -a);
        if (brd[b-1][c]!='#' && done[b-1][c]) que.push(make_tuple(a-1, b-1, c));
        if (brd[b+1][c]!='#' && done[b+1][c]) que.push(make_tuple(a-1, b+1, c));
        if (brd[b][c-1]!='#' && done[b][c-1]) que.push(make_tuple(a-1, b, c-1));
        if (brd[b][c+1]!='#' && done[b][c+1]) que.push(make_tuple(a-1, b, c+1));
    }
    if (cnt!=3000)
    {
        for (int i=1; i<=h; i++) for (int j=1; j<=w; j++) if (brd[i][j]=='.') sum++;
        cout<<sum-cnt<<endl;
    }
    else cout<<-1<<endl;
    return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long 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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

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

    set<char> st;

    for(int i = 0; i < N; i++){
        char c; cin >> c;
        st.insert(c);    
    }
    
    if(st.size() == 3){
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }
    

    return 0;
}


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

double percent(double a,double b){
    double p;
    p = 100 * b / (a + b);
    return p;    
}

int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    int w_a = 100 * a;
    int w_b = 100 * b;
    int suger = 0, water = 0;
    int max_w = 0, max_s = 0;
    double max_p = 0;
    double p = 0;
    double i_p = percent(100, e);
    rep(i, 100) {
        rep(j, 100) {
            rep(k, 100) {
                rep(l, 100) {
                    if (i * 100 * a + j * 100 * b + c * k + d * l <= f) {
                        p = percent(w_a * i + w_b * j, c * k + d * l);
                        if (i_p < p) continue;
                        if (max_p <= p) {
                            max_p = p;
                            max_w = w_a * i + w_b * j;
                            max_s = c * k + d * l;
                        }

                    }
                }
            }
        }
    }
   
    cout << max_w + max_s << " " << max_s << endl;
}

Measured memory_bytes: 256
#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 F first
#define S second
#define EPS 1e-9
#define MOD 1000000007
#define int long long
using namespace __gnu_pbds;
using namespace std;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ost;
#define INF 10000000000


int32_t main(){
	int n, w;
	cin >> n >> w;
	int dp[w+1] = {0};
	for(int i = 0; i < n; i++){
		int wt, val;
		cin >> wt >> val;
		for(int i = w-wt; i >= 0; i--){
			dp[i+wt] = max(dp[i+wt], dp[i]+val);
		}
	}
	int ans = 0;
	for(int i = 0; i <= w; i++)
		ans = max(ans,dp[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> x(n);
    rep(i, n)
    {
        cin >> x[i];
    }

    vector<int> y(x);
    sort(y.begin(), y.end());

    rep(i, n)
    {
        int j = lower_bound(y.begin(), y.end(), x[i]) - y.begin();

        if (j < n / 2) {
            cout << y[n / 2] << endl;
        } else {
            cout << y[n / 2 - 1] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3712
import java.util.*;
import java.math.*;

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

        long sum = 0;
        for (int i = 1; i <= N; i++) {
            if (i % 3 == 0 || i % 5 == 0){
            } else {
                sum += i;
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 35812
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=sc.La2;
		var b=sc.La;
		long p=a.Sum();
		int ans=0;
		for(int i = s[0]+1,j=0;i>0;i--) {
			p-=a[i];
			while(j<s[1]&&p+b[j]<=s[2]){
				p+=b[j];
				j++;
			}
			if(p<=s[2]){
				ans=Max(ans,i-1+j);
			}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 74372
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	cin >> n;
	unordered_map<int, int> cnt;
	rep(i,n) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	vector<int> f;
	for (auto p : cnt)f.push_back(p.second);
	sort(all(f));

	long long sum = 0;
	for (int x : f)sum += x;

	int c = 0;
	int idx = f.size() - 1;

	vector<int> ans(n, 0);
	int a = n;
	for(int k=1;k<=n;k++){
		if (f.size() < k) {
			break;

		}

		while (a > 0 && k > sum / a) {
			a--;
			while (idx > 0 && f[idx] > a) {
				idx--;
				c++;
			}
			sum -= c;
		}
 		ans[k - 1] = a;
	}
	
	for (int x: ans) {
		cout << x << endl;
	}


	return 0;
}

Measured memory_bytes: 17140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    string s;cin>>s;
    rep(i,s.size())if(s[i]=='?')s[i]='D';
    out(s);
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int q = N - 1;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(q);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < q; i++) {
    cin >> C.at(i);
  }
  int s = 0;
  for (int i = 0; i < N; i++) {
    s += B.at(i);
  }
  int w = 0;
  int e = 0;
  int u = 0;
  for (int i = 0; i < q; i++) {
    w += i + 1;
    if(A.at(i) + 1 == A.at(w) && A.at(i) != N) {
      e += A.at(i) - 1;
      u += C.at(e);
      s += u;
      u -= C.at(e);
      e -= A.at(i) - 1;
    }
    w -= i + 1;
  }
  cout << s << endl;
}

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

using namespace std;

int main(void){
    unsigned long long n, a, b;

    cin >> n >> a >> b;

    unsigned long long ans = b-a;
    if(ans % 2 == 0){
        ans = ans/2;
    }else{
        ans = (2*min(a-1, n-b) + (b-a) + 1)/2;
    }
    cout << ans << endl;


    return 0;
}

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

using namespace std;

int h, w;
string str[25];

bool vis[25][25];
int d[25][25];

int xd[4] = {-1, 0, 0, 1};
int yd[4] = {0, -1, 1, 0};

bool chk(int a, int b) {
    return (a >= 0 && a < h && b >= 0 && b < w && !vis[a][b] && str[a][b] != '#');
}

int bfs(pair<int, int> s) {
    queue<pair<int, int> > q;
    memset(vis, false, sizeof(vis));
    memset(d, -1, sizeof(d));

    q.push(s);
    vis[s.first][s.second] = true;
    d[s.first][s.second] = 0;

    int ans = -1;
    while (!q.empty()) {
        pair<int, int> u = q.front();
        q.pop();
        for (int i = 0; i < 4; i++) {
            int a = u.first + xd[i], b = u.second + yd[i];
            if (chk(a, b)) {
                d[a][b] = d[u.first][u.second] + 1;
                ans = max(ans, d[a][b]);
                q.push({a, b});
                vis[a][b] = true;
            }
        }
    }

    return ans;
}

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> str[i];

    int ans = -1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (str[i][j] == '.') {
                ans = max(ans, bfs({i, j}));
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll M = (ll)1e9+7;

ll n, m, x, y, dp[100007];

int main () {
    fastIO;
    cin >> n >> m;
    for(li i = 0; i < m; i ++) { cin >> x; dp[x]=-1; }
    dp[0] = 1;
    for(li i = 0; i < n; i ++) {
        if(dp[i]==-1) continue;
        if(dp[i+1] != -1) dp[i+1] = (dp[i+1]+dp[i]) %M;
        if(dp[i+2] != -1) dp[i+2] = (dp[i+2]+dp[i]) %M;
    }
    cout << dp[n];
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll a,b; cin >> a >> b ;
  if(a < 0 && b< 0){
    if((b-a) %2 ==1) cout << "Positive" << endl;
    else cout << "Negative" << endl;
  }
  else if(a <= 0 && b >= 0){
    cout << "Zero" << endl;
  }
  else cout << "Positive" << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;

  return 0;
}


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


int main(){
	int n, c;
	scanf("%d %d", &n, &c);
	int d[c][c], grid[n][n], cc[3][c];
	memset(cc, 0, sizeof(cc));
	for(int i=0; i<c*c; i++) scanf("%d", &d[i/c][i%c]);
	for(int i=0; i<n; i++) for(int j=0; j<n; j++){
		scanf("%d", &grid[i][j]);
		grid[i][j]--;
		cc[(i+j)%3][grid[i][j]]++;
	}

	int ans = 1e11;	
	for(int i=0; i<c; i++){
		for(int j=0; j<c; j++) if(i!=j){
			for(int k=0; k<c; k++) if(i!=k && j!=k){
				int tmp = 0;
				for(int l=0; l<c; l++) tmp += cc[0][l] * d[l][i];
				for(int l=0; l<c; l++) tmp += cc[1][l] * d[l][j];
				for(int l=0; l<c; l++) tmp += cc[2][l] * d[l][k];
				ans = std::min(ans, tmp);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

int main () {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  cout << a.at(N-1) - a.at(0) << endl;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1144&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int W,H;
const int NONE=0, BLOCK=1, START=2, GOAL=3;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
int ans;
vector<vector<int>> field;

bool out_range(int x, int y){
	return x < 0 || y < 0 || x >= W || y >= H; 
}

void dfs(int x, int y, int depth)
{
	if(depth + 1 >= ans){ return; }
	
	REP( d, 0, 4 )
	{
		int nx = x + dx[d];
		int ny = y + dy[d];
		//次に移動する場所がBLOCKではなく、範囲内である。
		if(!out_range(nx,ny) && field[ny][nx] != BLOCK)
		{
			//エリア外に出るまで移動する
			while(!out_range(nx,ny))
			{
				//GOALならば、答えを更新する
				if(field[ny][nx] == GOAL)
				{
					ans = min(ans,depth+1);
					return;
				}

				//BLOCKならば、次の移動を行う
				if(field[ny][nx] == BLOCK)
				{
					field[ny][nx] = NONE;
					dfs(nx-dx[d], ny-dy[d], depth+1);
					field[ny][nx] = BLOCK;
					break;
				}

				nx = nx + dx[d];
				ny = ny + dy[d];
			}
		}
	}
	
	return;
}

int main()
{
	while(cin >> W >> H && W)
	{
		int sx,sy;
		field.assign(H,vector<int>(W));
		rep(y,H){
			rep(x,W){
				cin >> field[y][x];	
				if(field[y][x] == START){
					sx = x; 
					sy = y;
					field[y][x] = NONE;
				}
			}
		}
		ans = 11;
		dfs(sx,sy,0);	
		cout << ((ans <= 10) ? ans : -1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long int
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define N 300009
#define mod 1000000007
#define med 998244353
#define dbg cout<<"There There\n";
#define dbg1(x) cout<<"\nValue is "<<x<<endl
#define dbg2(x,y) cout<<"\nValue is "<<x<<" "<<y<<endl
#define dbg3(x,y,z) cout<<"\nValue is "<<x<<" "<<y<<" "<<z<<endl  
#define pq priority_queue<int>
#define mpq priority_queue<int,vector<int>,greater<int>>
#define pr pair<int,int>
#define mx INT_MAX
#define lmx LLONG_MAX
#define err return 0
#define cn continue 
#define bre break
   
string s;

int32_t main()
{
     IOS;
     cin>>s;
     sort(s.begin(),s.end());
     reverse(s.begin(),s.end());
     int see=0;
     for(int i=0;i<s.length();i++)
     {
          see+=(s[i]=='x');
     }
     if(see>7)
     {
          cout<<"NO\n";
          err;
     }
     cout<<"YES\n";
}


Measured memory_bytes: 256
using System;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			// 整数の入力
			long x = long.Parse(Console.ReadLine());
			long a = long.Parse(Console.ReadLine());
			long b = long.Parse(Console.ReadLine());

			long remain = x - a;
			while (remain >= b) {
				remain -= b;
			}

			Console.WriteLine(remain.ToString());

			Console.Out.Flush();

			Console.ReadLine();
		}
	}
}

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

void solve(std::string S, std::string T){
    ll ans =0;
    for(int i=0;i<S.size();i++){
        if(S[i] !=T[i]){
            ans++;
        }

    }
    cout << ans << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 4060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

string s, t;

int main() {
	cin >> s >> t;
	string u, v;
	rep(i, s.size()) {
		if (i % 2 == 0)u += s[i];
		else v += s[i];
	}
	int now = 0;
	int cnt = 0;
	rep(i, u.size()) {
		FOR(j, now, t.size()) {
			if (t[j] == u[i]) {
				cnt++;
				now = j + 1;
				break;
			}
		}
	}
	if (cnt == u.size()) {
		cout << "Yes" << endl;
		return 0;
	}
	now = 0;
	cnt = 0;
	rep(i, v.size()) {
		FOR(j, now, t.size()) {
			if (t[j] == v[i]) {
				cnt++;
				now = j + 1;
				break;
			}
		}
	}
	if (cnt == v.size()) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3204
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;

  // c[i][j] = count of number k <= N  where first digit is i and last digit is j
  // ans = sum_i sum_j c[i][j] * c[j][i]
  vector<vector<int>> c(10, vector<int>(10));
  for (int i = 1; i <= n; ++i) {
    int lastDigit = i % 10;
    int firstDigit = i;
    while (firstDigit / 10 > 0) { firstDigit /= 10; }
    ++c[firstDigit][lastDigit];
  }
  ll ans = 0;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      ans += c[i][j] * c[j][i];
    }
  }
  cout << ans << endl;
}


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

int main(void)
{
int N,j,k=0;
cin >> N;
char strA[100000],strB[100000];
while(1){
k++;
if(k==N+1){
break;
}
cin >> strA >> strB;
int ans[81]={0};
ans[0]=11111;
if(strlen(strA)>80||strlen(strB)>80){
cout << "overflow" << endl;
continue;
}
int a[81]={0},b[81]={0};
if(strA[strlen(strA)-1]=='0'&&strB[strlen(strB)-1]=='0'){
    cout << 0 << endl;
    continue;
}
j=strlen(strA)-1;
for(int i=80 ; j>=0 ; i--){
a[i]=(int)strA[j]-48;
j--;
}
j=strlen(strB)-1;
for(int i=80 ; j>=0 ; i--){
b[i]=(int)strB[j]-48;
j--;
}
for(int i=80 ; i!=0 ; i--){
ans[i]=ans[i]+a[i]+b[i];
if(ans[i]>=10){
ans[i]=ans[i]-10;
ans[i-1]++;
}
}
if(ans[0]!=11111){
cout << "overflow" << endl;
continue;
}
for(int i=1 ; i<81 ; i++){
if(ans[i]!=0){
j=i;
break;
}
}
char c[3];
for(int i=j ; i<81 ; i++){
printf("%c",ans[i]+48);
}
cout << '\n';
}
return 0;
}

Measured memory_bytes: 1180
import java.util. *;


class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int a = Integer.parseInt(input.next());
        int b = Integer.parseInt(input.next());
        
        if(a < b)
        {
            System.out.println("a < b");
        }
        else if(a > b)
        {
            System.out.println("a > b");
        }
        else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) a.begin(), a.end()
#define print(x) cout << x << "\n";

int main()
{
    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;
    for (int i = l; i <= r; i++) {
        if(i%d == 0) {
            ans++;
        }
    }

    print(ans);
}

Measured memory_bytes: 3612