akhauriyash/Code-Regression huggingface dataset:
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){ //xのy乗
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

vector<int> di = {-1,0,1,0},dj = {0,-1,0,1};
vector<int> ndi = {2,2,2,2,2,1,1,1,1,1,0,0,0,0,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2},ndj = {-2,-1,0,1,2,-2,-1,0,1,2,-2,-1,1,2,-2,-1,0,1,2,-2,-1,0,1,2};

int main(){
  int H,W;
  cin >> H >> W;
  int Ch,Cw,Dh,Dw;
  cin >> Ch >> Cw >> Dh >> Dw;
  Ch--;
  Cw--;
  Dh--;
  Dw--;
  vector<string> S(H);
  rep(i,H)cin >> S.at(i);
  queue<pair<int,int>> q,nq;
  q.push(make_pair(Ch,Cw));
  vector<vector<int>> ans(H,vector<int>(W,-1));
  ans[Ch][Cw] = 0;
  while(!q.empty() || !nq.empty()){
    if(!q.empty()){
      int i = q.front().first,j = q.front().second;
      //cout << "i:" << i << " " << "j:" << j << endl;
        rep(d,4){
          int ni = i + di[d],nj = j + dj[d];
          if(0 <= ni && ni < H && 0 <= nj && nj < W){
            //cout << "ni:" << ni << " " << "nj:" << nj << endl;
            if(S.at(ni).at(nj) != '#' && ans[ni][nj] == -1){
              q.push(make_pair(ni,nj));
              ans[ni][nj] = ans[i][j];
            }else{
              nq.push(make_pair(i,j));
            }
          }else{
            continue;
          }
        }
        q.pop();
    }else{
      while(!nq.empty()){
        int ri = nq.front().first,rj = nq.front().second;
        rep(d,24){
          int nri = ri + ndi[d],nrj = rj + ndj[d];
          if(0 <= nri && nri < H && 0 <= nrj && nrj < W){
            if(S.at(nri).at(nrj) != '#' && ans[nri][nrj] == -1){
              ans[nri][nrj] = ans[ri][rj] + 1;
              q.push(make_pair(nri,nrj));
            }
          }else{
            continue;
          }
        }
        nq.pop();
      }
    }
  }
/*
  rep(i,H){
    rep(j,W){
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
*/
  cout << ans[Dh][Dw] << endl;


  return 0;
}


Measured memory_bytes: 9696
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int n;
        n = in.nextInt();
        int h[] = new int[n];

        for (int i=0; i<n; i++){
            h[i] = in.nextInt();
        }

        int moves;
        int maxMoves = 0;

        for (int i=0; i<n-1; i++){
           int j=i;
           moves = 0;
           while (h[j] >= h[j+1]){
               j++;
               moves++;
               if (j==n-1){
                   break;
               }
           }
           if (moves > maxMoves){
               maxMoves = moves;
           }

           if (maxMoves > ((n/2)+1)){
               break;
           }
        }

        out.println(maxMoves);
        out.close();




    }




    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 41188
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  ll h,w;
  cin >> h >> w;
  if(h%3==0||w%3==0){
    cout << 0 << endl;
    return 0;
  }
  ll ans = h*w;
  rep(_,2){
    rep(i,h-1){
      ll h1=i+1,h2=h-1-i;
      ll s1=h1*w, s2=w/2*h2, s3=(w+1)/2*h2;
      ans = min(ans,max(s1,s3)-min(s1,s2));
      if(h2>1){
        s2=h2/2*w, s3=(h2+1)/2*w;
        ans = min(ans,max(s1,s3)-min(s1,s2));
      }
    }
    swap(h,w);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<=111)
    cout<<111<<"\n";
     else if(n<=222)
    cout<<222<<"\n";
     else if(n<=333)
    cout<<333<<"\n";
     else if(n<=444)
    cout<<444<<"\n";
     else if(n<=555)
    cout<<555<<"\n";
     else if(n<=666)
    cout<<666<<"\n";
     else if(n<=777)
    cout<<777<<"\n";
     else if(n<=888)
    cout<<888<<"\n";
     else if(n<=999)
    cout<<999<<"\n";
    
    return 0;
    
}

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

using namespace std;

int W, H;
int DpSum[101][101][4];

int solve() {
	int sum;

	for (int i = 2; i <= H; ++i) {
		for (int j = 2; j <= W; ++j) {
			DpSum[i][j][0] = DpSum[i][j - 1][0] + DpSum[i][j - 1][2];
			DpSum[i][j][1] = DpSum[i - 1][j][1] + DpSum[i - 1][j][3];
			DpSum[i][j][2] = DpSum[i][j - 1][1];
			DpSum[i][j][3] = DpSum[i - 1][j][0];
			for (int k = 0; k < 4; ++k) {
				DpSum[i][j][k] %= 100000;
			}
		}
	}

	sum = 0;
	for (int k = 0; k < 4; ++k) {
		sum += DpSum[H][W][k];
	}
	return sum % 100000;
}

int main() {

	while (cin >> W >> H, W) {
		memset(DpSum, 0, sizeof(DpSum));
		for (int i = 1; i <= W; ++i) {
			DpSum[1][i][0] = 1;
		}
		for (int i = 1; i <= H; ++i) {
			DpSum[i][1][1] = 1;
		}
		cout << solve() << endl;
	}

	return 0;
}


Measured memory_bytes: 3244
li = list(input())
li.sort()
while True:
    if len(li) == 0:
        print("Yes")
        break
    elif not len(li) % 2 == 0:
        print("No")
        break
    elif li[0] == li[1]:
        li.pop(0)
        li.pop(0)
    else:
        print("No")
        break

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	static int[][] d = new int[11][100001];
	static int[] max = new int[11];
	public static void main(String[] args) {
		for(int i = 0; i <= 10; i++) {
			max[i] = (i * (i + 1) * (2 * i + 1)) / 6;
		}
		boolean[] flag = new boolean[10];
		Arrays.fill(flag, true);
		dfs(0, 0, flag);
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			//if(n == 0) break;
			int s = sc.nextInt();
			System.out.println(d[n][s]);
		}
		sc.close();
	}
	static void dfs(int n, int t, boolean[] flag) {
		if(n == 11) return;
		for(int i = 0; i < 10; i++) {
			if(flag[i]) {
				int k = t + i * (n + 1);
				d[n + 1][k]++;
				flag[i] = false;
				dfs(n + 1, k, flag);
				flag[i] = true;
			}

		}
	}
}


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

int main(void){
  int N, K;
  cin >> N >> K;
  double sum = 0;
  double temp;
  for(int i = 1; i <= N; i++){
    temp = 1.0 / N;
    int x = i;
    while(x < K){
      x *= 2;
      temp /= 2;
    }
    sum += temp;
    //cout << sum << endl;
  }
  printf("%.12f\n", sum);
  //cout << sum;
  
  return 0;
}

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

int n, k;

int main(){
  cin >> n >> k;
  double res = 0;
  for(int i = 1; i <= n; i++){
    int cnt = 0;
    for(int j = i; j < k; j *= 2){
      cnt++;
    }
    res += pow(2, (-1)*cnt);
  }
  res /= n;
  cout << setprecision(10) << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;

signed main(){
	cin>>N;
	cout<<N*N<<endl;
	return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  val seq1 = for(i<-1 to 9) yield List(i,i,i)
  val seq2 = (1 to 9).iterator.sliding(3).toList

  def check(m:List[Int], count:Int,u:Int):Boolean =  {
    if(m.length != count) false
    else if(count==2) { if(m.head==m.last) true else false }
    else {
      if((u to 8).exists( i=> if(m.contains(i+1)) check(m diff seq1(i),count-3,i) else false)) true
      else (0 to 6).exists(i=> if(m.contains(i+1)) check(m diff seq2(i),count-3,u) else false)
    }
  }

  Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>
    val l = line.map(_.asDigit).toList
    val m = (1 to 9).filter { i=> if(l.count( _==i ) >= 4) false else check(i::l,14,0) }
    if(m.length>0) println(m.mkString(" ")) else println(0)
  }
}

Measured memory_bytes: 80748
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (r <= x && x <= W-r && r <= y && y <= H-r)
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 3172
n,q=gets.chomp.split(" ").map{|i|i.to_i}
ary=Array.new
bry=Array.new
time=0

for i in 0..n-1
	bry=gets.chomp.split(" ")
	bry=bry.push(bry.pop.to_i)
	ary=ary.push(bry)
end

loop{
	if ary==[]
		break
	elsif ary[0][1] > q
		ary[0][1] -= q
		ary=ary.push(ary.shift)
		time += q
		next
	elsif ary[0][1] <= q
		time+=ary[0][1]
		ary[0][1]=0
		print("#{ary.shift[0]} #{time}\n")
	end
}

Measured memory_bytes: 14508
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

int main(){
    string s;cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3632
#include <cstdio>
int main(){
	int height, width, n;
	scanf("%d%d%d", &height, &width, &n);
	int col[height*width];
	int k = 0;
	for(int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		for(int j = k; j < k + a; j++){
			col[j] = i;
		}
		k += a;
	}
	int l[width];;
	for(int i = 0; i < height; i++){
		if(i % 2 == 0){
			for(int j = 0; j < width; j++){
				l[j] = col[i*width+j];
			}
		}else{
			for(int j = 0; j < width; j++){
				l[width - j - 1] = col[i*width+j];
			}
		}
		for(int j = 0; j < width; j++){
			printf("%d ", l[j]+1);
		}
		printf("\n");
	}
	return 0;
}

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N), OP(N);
    char op;
    OP[0] = 1;
    cin >> A[0];
    for ( int i = 1; i < N; i++ ) {
        cin >> op >> A[i];
        OP[i] = op == '+' ? 1 : -1;
    }
    ll s_all = 0, ss = 0, cn = 0;
    vector<ll> b(N);
    for ( int i = 0; i < N; i++ ) {
        s_all += A[i];
        if ( OP[i] < 0 ) cn++;
        ss += A[i] * OP[i];
    }
    if ( cn <= 1 ) {
        return ss;
    }
    ll s = 0;
    vector<ll> r(N); // 逆向き、-までの和
    for ( int i = N-1; i >= 0; i-- ) {
        s += A[i];
        if ( OP[i] < 0 ) {
            r[i] = s;
            s = 0;
        }
    }
    ll ans = - (1LL << 60), pn = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( OP[i] < 0 ) {
            ans = max(ans, s_all - pn * 2 - r[i] * 2);
            pn += A[i];
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, opt = -1, l, s[100005];

int main(){
	scanf("%d %d", &n, &l);
	FI(i, 1, n){
		scanf("%d", &s[i]);
		if(i > 1 && s[i] + s[i - 1] >= l){
			opt = i;
		}
	}
	if(opt == -1){
		printf("Impossible\n");
		return 0;
	}
	printf("Possible\n");
	FI(i, 1, opt - 2) printf("%d\n", i);
	FD(i, n - 1, opt) printf("%d\n", i);
	printf("%d\n", opt - 1);
	return 0;
}


Measured memory_bytes: 1152
n, m = map(int, input().split())
dic = {}
ok = True
for i in range(m):
    a, b = map(int, input().split())
    if a in dic:
        if b != dic[a]:
            ok = False
    else:
        dic[a] = b

if 1 in dic:
    if n != 1 and dic[1] == 0:
        ok = False

if ok:
    l = ['0'] * n
    for i in dic.keys():
        l[i-1] = str(dic[i])
    if n != 1 and l[0] == '0':
        l[0] = '1'
    print(''.join(l))
else:
    print(-1)

Measured memory_bytes: 3188
#include<iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  while(n != 0){
    int ans = 0;
    string s[150];


    for(int i=0;i<n;i++) cin >> s[i];

    for(int i=1;i<n;i++){
      if((s[i] == "lu" && s[i-1] == "ru") || (s[i] == "ru" && s[i-1] == "lu")){
        ans++;
      }
      if((s[i] == "ld" && s[i-1] == "rd") || (s[i] == "rd" && s[i-1] == "ld")){
        ans++;
      }
    }

    cout << ans << endl;
    cin >> n;
  }

  return 0;
}

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

int main(){
    ll n, m; cin >> n >> m;
    for(int i=0; i<m; i++){
        ll x;   cin >> x;
        n -= x;
    }
    if(n<0) n = -1;
    cout << n << endl;

}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define ll long long int

int main()
{
    fast_io;
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for(ll i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    vector<vector<ll>> dp(n, vector<ll>(n));
    for(ll k = 0; k < n; k++)
    {
        for(ll i = 0, j = k; j < n; j++, i++)
        {
            if(i == j)
                dp[i][j] = a[i];
            else
            {
                ll i1, j1, k1;
                i1 = (i + 2 > j) ? 0 : dp[i+2][j];
                j1 = (i+1 > j-1) ? 0 : dp[i+1][j-1];
                k1 = (i > j-2) ? 0 : dp[i][j-2];
                dp[i][j] = max(a[i] + min(i1, j1), a[j] + min(j1, k1));
            }
        }
    }
    cout << dp[0][n-1] - (sum - dp[0][n-1]);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#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=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

vi g[125252];
int dv[125252], du[125252];
constexpr int INF=1e9;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, u, v;
  cin>>n>>u>>v;
  --u;--v;
  REP(i, n-1){
    int a, b;
    cin>>a>>b;
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  REP(i, n){
    dv[i]=INF;
  }
  queue<int> q;
  q.push(v);
  dv[v]=0;
  while(q.size()){
    int s=q.front();q.pop();
    for(auto& x : g[s]){
      if(dv[x]!=INF){
        continue;
      }
      dv[x]=dv[s]+1;
      q.push(x);
    }
  }
  // REP(i, n){
  //   cout<<dv[i]<<" \n"[i==n-1];
  // }
  REP(i, n){
    du[i]=INF;
  }
  queue<int> q2;
  q2.push(u);
  du[u]=0;
  int ans=dv[u];
  while(q2.size()){
    int s=q2.front();q2.pop();
    for(auto& x : g[s]){
      // DEBUG(x);
      // DEBUG(du[x]);DEBUG(du[s]);DEBUG(dv[x]);
      if(du[x]!=INF || du[s]+1>=dv[x]){
        continue;
      }
      du[x]=du[s]+1;
      q2.push(x);
      CHMAX(ans, dv[x]);
    }
  }
  // REP(i, n){
  //   cout<<du[i]<<" \n"[i==n-1];
  // }
  --ans;
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 7296
#include<iostream>
using namespace std;
#define ll long long
int main()
{
    ll l,m,n;
    while(cin >>l)
    {
        if(l==0)break;
        int ans = 0;
        for(int i=1;i<13;i++)
        {
            cin >> m >> n;
            l -= (m-n);
            if(l<=0 && ans ==0)
            ans = i;
        }
        if(ans!=0)cout << ans << endl;
        else cout << "NA" <<endl;
    }
    return 0;
}

Measured memory_bytes: 0
//In the name of God
#include<bits/stdc++.h>

using namespace std;

const int N = 2e5 + 10;
int n, a[N], l[N], r[N];
stack<int> st1, st2;
long long res;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i=0; i < n; i++){
		l[i] = -1;
		while(st1.size() && a[st1.top()] > a[i])
			st1.pop();
		if(st1.size())
			l[i] = st1.top();
		st1.push(i);
	}
	for(int i=n-1; ~i; --i){
		r[i] = n;
		while(st2.size() && a[st2.top()] > a[i])
			st2.pop();
		if(st2.size())
			r[i] = st2.top();
		st2.push(i);
	}
	for(int i = 0; i < n; i++)
		res += 1LL * (i - l[i]) * (r[i] - i) * a[i];
	cout << res;
	return 0;
}

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

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
#define endl '\n'

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    vi b(n);
    b = a;
    sort(all(b));
    int max1 = b[n-1];
    int max2 = b[n-2];
    
    vi result(n);
    if(max1 == max2){
        rep(i,n){
            result[i] = max1;
        }
    }
    else{
        rep(i,n){
            if(a[i] == max1){
                result[i] = max2;
            }
            else{
                result[i] = max1;
            }
        }
    }
    rep(i,n){
        cout << result[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3968
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

use std::mem::swap;

#[derive(Debug, PartialEq, Clone)]
struct Node {
    parent: Option<usize>, 
    size: usize,
}

#[derive(Debug, PartialEq)]
pub struct UnionFind {
    tree: Vec<Node>,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind { tree: vec![Node { parent: None, size: 1 }; n] }
    }

    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let mut x = self.find(x);
        let mut y = self.find(y);

        if x == y {
            return false;
        }
        
        if self.tree[x].size < self.tree[y].size {
            swap(&mut x, &mut y);
        }

        self.tree[x].size += self.tree[y].size;
        self.tree[y].parent = Some(x);
        true
    }

    pub fn find(&mut self, x: usize) -> usize {
        match self.tree[x].parent {
            Some(p) => {
                let new_par = self.find(p);
                self.tree[x].parent = Some(new_par);
                new_par
            },
            None => x,
        }
    }

    pub fn same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }

    pub fn size(&mut self, x: usize) -> usize {
        let x = self.find(x);
        self.tree[x].size
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        edges: [(usize1, usize1); m],
    }

    let mut uf = UnionFind::new(n);

    let mut ans = n * (n - 1) / 2;
    let mut v = Vec::new();
    for &(a, b) in edges.iter().rev() {
        v.push(ans);
        if uf.same(a, b) {
            continue;
        }

        ans -= uf.size(a) * uf.size(b);
        uf.unite(a, b);
    }
    
    for val in v.iter().rev() {
        println!("{}", val);
    }
}

Measured memory_bytes: 15612
from collections import deque

N,M=map(int,input().split())

tree=[[0] for _ in range(N)]

for _ in range(M):
    A,B=map(int,input().split())
    tree[A-1].append(B-1)
    tree[B-1].append(A-1)

dist = [-1]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in tree[v]:
        if dist[w] > -1:
            continue
        dist[w] = v
        que.append(w)

print("Yes")
for j in range(1,N):
    print(dist[j]+1)

Measured memory_bytes: 35928
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, L;
  cin >> N >> L;
  vector<int> aj(N);
  int sum = 0;
  REP(i, N) {
    aj[i] = L + (i + 1) - 1;
    sum += aj[i];
    // cout << aj[i] << endl;
  }
  int sub = 1e9;
  int ans = 0;
  REP(i, N) {
    int no = aj[i];
    int sum2 = sum - no;
    if (abs(sum - sum2) < sub) {
      sub = abs(sum - sum2);
      ans = sum2;
    }
  }
  cout << ans << 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;
using ll = long long;

int main(){
  int n,k; cin >>n >>k;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  cout << (n+k-3)/(k-1) << endl;
  return 0; 
}

Measured memory_bytes: 3680
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main()
{
    unsigned short *A,*B;
    int C[VMAX+1];
    int n,i,j;
    scanf("%d",&n);
    A=malloc(sizeof(short)*n+1);
    B=malloc(sizeof(short)*n+1);
    for(i=0;i<=VMAX;i++)
    {
        C[i]=0;
    }
    for(i=0;i<n;i++)
    {
        scanf("%hu",&A[i+1]);
        C[A[i+1]]++;
    }
    for(i=1;i<=VMAX;i++) C[i]=C[i]+C[i-1];
    for(j=n;j>=1;j--)
    {
        B[C[A[j]]]=A[j];
        C[A[j]]--;
    }
    for(i=1;i<=n;i++)
    {
        if(i>1) printf(" ");
        printf("%d",B[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  for (int a = M/N; a > 0; a--) {
    if ((M%a)%a == 0) {
      cout << a << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import math

def main():
    x = int(input())

    start_num = 100
    max_num = 3760+1000
    for i in range(max_num):
        if start_num >= x:
            print(i)
            exit()
        start_num = start_num + math.floor(start_num * 0.01)

if __name__ == '__main__':
    main()

Measured memory_bytes: 63540
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
 
public class Main {
    int N,T;
    int[] imos;
    public void solve() {
        N = nextInt();
        T = nextInt();
        imos = new int[T + 2];
 
        for(int i = 0;i < N;i++){
            int l = nextInt();
            int r = nextInt();
 
            imos[l]++;
            imos[r]--;
        }
 
        int ans = imos[0];
 
        for(int i = 0;i < T + 1;i++){
            imos[i + 1] += imos[i];
            ans = Math.max(ans,imos[i + 1]);
        }
 
        out.println(ans);
    }
 
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }
 
    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;
 
    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }
 
    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }
 
    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }
 
    public int nextInt() {
        return Integer.parseInt(next());
    }
 
    public long nextLong() {
        return Long.parseLong(next());
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 52624
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
using namespace std;
signed main() {
	int n, m, ans = 0; string s; cin >> n >> s;
	for (int h = 0; h < n; h++) {
		if (s[h] == 'R') {
			ans++;
		}
		else {
			ans--;
		}
	}
	if (ans > 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ll a , b;
    sf(a, b);
    ll t = __gcd(a, b);
    ll ans = a * b / t;
    out(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int m; cin >> m;
    vector<int> q(m);
    rep(i, m) cin >> q[i];

    vector<bool> ok(2000*20+10, false);
    rep(i, pow(2,n)) {
        int total = 0;
        rep(j, n) {
            if ((1<<j) & i) total += a[n-j-1];
        }
        ok[total] = true;
    }

    rep(i, m) {
        if (ok[q[i]]) puts("yes");
        else puts("no");
    }
}


Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int ans = 0;
  for(int i=1; i<=N;i++){
      string M = to_string(i);
      if(M.size()%2 !=0){
        ans ++;
      }
    }
  cout<<ans<<endl;
}



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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif

/*
Task: https://atcoder.jp/contests/code-festival-2016-qualb/tasks/codefestival_2016_qualB_c
C - Gr-idian MST
*/


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

void solve(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(n + m);
  for (int i = 0; i < n; i++) {
    cin >> a[i].ff;
    a[i].ss = 1;
  }
  for (int i = 0; i < m; i++) {
    cin >> a[n+i].ff;
    a[n+i].ss = 2;
  }

  sort(a.begin(), a.end());

  int cur = 0;
  ll ans = 0;
  n++, m++;
  while (cur < (int)a.size()){
    if (a[cur].ss == 1){
      ans += (ll)a[cur].ff * (ll)m;
      n--;
    } else {
      ans += (ll)a[cur].ff * (ll)n;
      m--;
    }
    cur++;
  }

  cout << ans << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 4780
n = int(input())
c = [list(map(int, input().split())) for i in range(2)]

total = sum(c[0]) + c[1][-1]
max_v = total
for i in range(n-2, -1, -1):
    total = total - c[0][i+1] + c[1][i]
    max_v = max(total, max_v)
print(max_v)

Measured memory_bytes: 3060
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;
typedef long long ll;

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
priority_queue <P,vector<P>,greater<P> > pqps2;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,ans;
ll a,b,c,d,e,g,h;
ll x[500005],y[500005],z[500005];
char s[500005];
vector<ll> pos[40];
ll kazu[40];
ll lside[40],rside[40];
ll dist;

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}

int main(){
    cin >> s;
	n = strlen(s);
	for(i=0;i<n;i++){
		pos[s[i] - 'a'].pb(i);
	}
	for(i=0;i<26;i++){
		a = pos[i].size();
		if(a%2 == 1)b++;
		lside[i] = 0;
		rside[i] = a - 1;
		kazu[i] = a;
	}
	if(b >= 2){
		p(-1);
		return 0;
	}
	c = n;
	while(c >= 3){
		//p("hoi");
		num = INF;
		ll chara = -1;
		//ll ld = -1,rd = -1;
		for(i=0;i<26;i++){			
			if(kazu[i] <= 1)continue;
			l = pos[i][lside[i]];
			r = pos[i][rside[i]];			
			l -= bitsum(l+1);
			r -= bitsum(r+1);			
			dist = l + (c - 1) - r;
			if(num > dist){				
				num = dist;
				chara = i;
			}
		}
		//pe(ld);p(rd);
		if(num == INF || chara == -1)break;		
		//p(chara);
		//p(num);
		//if(num == INF || chara == -1)break;
		//chara文字を消す
		l = pos[chara][lside[chara]];
		r = pos[chara][rside[chara]];
		ans += num;
		lside[chara]++;
		rside[chara]--;
		kazu[chara] -= 2;
		bitadd(l+1,1);
		bitadd(r+1,1);
		c -= 2;
	}
	//p("hoi");
	p(ans);
	
    return 0;
}

Measured memory_bytes: 31860
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define F first
#define S second
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N=1e5+10,LN=30,SQ=550;
const ll INF=1e16;
const int MOD=1000000007 /*998244353*/;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    ll ans=1;
    while (y != 0) {
        if (y & 1) ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
ll n,x,m,a[N],k[N],b,c,s,ans;
int main(){
    fast_io;
    cin >> n >> x >> m;
    a[1]=x;
    k[x]=1;
    for(ll i=2; i<N; i++){
        a[i]=a[i-1]*a[i-1]%m;
        if(k[a[i]]){
            b=k[a[i]];
            c=i-b;
            break;
        }
        k[a[i]]=i;
    }
    for(ll i=0; i<c; i++){
        s+=a[i+b];
    }
    for(ll i=1; i<b; i++) ans+=a[i];
    n-=b-1;
    ans+=(n/c)*s;
    n%=c;
    for(ll i=0; i<n; i++) ans+=a[b+i];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4712
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    cout<<(n+1)/2;
}

Measured memory_bytes: 3644
function Main(input) {
    var strArr = input.split("\n");
    var s = strArr[0];
    var t = strArr[1];
    var n = s.length;
    var m = t.length;
    var dp = [];
    for (var i = 0; i <= n; i++) {
        dp[i] = [];
        dp[i][0] = i;
    }
    for (var i = 0; i <= m; i++) {
        dp[0][i] = i;
    }
    for (var i = 1; i <= n; i++) {
        for (var j = 1; j <= m; j++) {
            dp[i][j] = Math.min(Math.min(dp[i - 1][j], dp[i][j - 1]) + 1,
                                dp[i - 1][j - 1] + (s[i - 1] == t[j - 1] ? 0 : 1));
        }
    }
    console.log(dp[n][m]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33508
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
GC040 A-2
"""

ali = list(input())

tmp = 0
b = [0]
for L in ali:
    if L == '<':
        tmp += 1
    else:
        tmp = 0
    b.append(tmp)

tmp = 0
c = [0]
ali.reverse()
for L in ali:
    if L == '>':
        tmp += 1
    else:
        tmp = 0
    c.append(tmp)
c.reverse()

numlist = [max(a, b) for (a, b) in zip(b, c)]
print(sum(numlist))


Measured memory_bytes: 35632
using System;
using System.Linq;

namespace AOJ {
    public class Problem {
        public static void Main() {
            var data = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(data[0] > data[1] ? "a > b" :
                              data[0] < data[1] ? "a < b" : "a == b");
        }
    }
}


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

int max_except(vector<int> a, int pos) {
  int max = 0;
  for (int i = 0; i < a.size(); i++) {
    if (i != pos && a[i] > max)
      max = a[i];
  }
  return max;
}

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

  vector<vector<int>> a(n, vector<int> (3));
  for (int i = 0; i < n; i++)
      cin >> a[i][0] >> a[i][1] >> a[i][2];

  vector<vector<int>> sums(n, vector<int> (3));
  sums[0] = a[0];

  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      sums[i][j] = a[i][j] + max_except(sums[i - 1], j);
    }
  }

  int max =  max_element(sums[n - 1].begin(), sums[n - 1].end()) - sums[n - 1].begin();
  cout << sums[n - 1][max] << "\n";
  return 0;
}

Measured memory_bytes: 11136
/*
 * @Author: hesorchen
 * @Date: 2020-07-03 17:05:01
 * @LastEditTime: 2020-09-04 19:10:39
 * @Description: https://hesorchen.github.io/
 */
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define endl '\n'
#define PI acos(-1)
#define PB push_back
#define ll long long
#define INF 0x3f3f3f3f
#define mod 1000000007
#define pll pair<ll, ll>
#define lowbit(abcd) (abcd & (-abcd))
#define max(a, b) ((a > b) ? (a) : (b))
#define min(a, b) ((a < b) ? (a) : (b))

#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define FRE                              \
    {                                    \
        freopen("in.txt", "r", stdin);   \
        freopen("out.txt", "w", stdout); \
    }

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * f;
}
//head==============================================================================

char mp[110][110];
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%s", mp[i] + 1);
    while (1)
    {
        int heng, zong;
        heng = zong = 0;
        for (int i = 1; i <= n; i++)
        {
            int f2 = 0;
            for (int j = 1; j <= m; j++)
            {

                if (mp[i][j] == '#')
                    f2 = 1;
            }
            if (!f2)
            {
                heng = i;
                break;
            }
        }
        if (heng)
        {
            for (int i = heng; i < n; i++)
            {
                for (int j = 1; j <= m; j++)
                {
                    mp[i][j] = mp[i + 1][j];
                }
            }
            n--;
            continue;
        }

        for (int j = 1; j <= m; j++)
        {
            int f2 = 0;
            for (int i = 1; i <= n; i++)
            {
                // if (mp[i][j] == '.')
                //     f1 = 1;
                if (mp[i][j] == '#')
                    f2 = 1;
            }
            if (!f2)
            {
                zong = j;
                break;
            }
        }
        if (zong)
        {
            for (int i = 1; i <= n; i++)
            {
                for (int j = zong; j < m; j++)
                {
                    mp[i][j] = mp[i][j + 1];
                }
            }
            m--;
            continue;
        }
        break;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
            printf("%c", mp[i][j]);
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 3160
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if n % 2 == 1:
    print(B[(n - 1) // 2] - A[(n - 1) // 2] + 1)
else:
    print((B[(n - 1) // 2] + B[n // 2]) - (A[(n - 1) // 2] + A[n // 2]) + 1)

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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  
  string ans;
  ans.push_back(s[0]);
  for(int i = 1; i < s.size(); ++i)
  {
    if(s[i] != ans.back()) ans.push_back(s[i]);
  }
  
  cout << ans.size() << endl;
}

Measured memory_bytes: 640
n, a, b = map(int, input().split())
dab = a - b
H = []
for _ in range(n):
    H.append(int(input()))
maxh = max(H)

l = 0
r = -(-maxh//b)
def ht(mid):
    cnt = 0
    for h in H:
        rem = h - b*mid
        if rem > 0:
            cnt += -(-rem//dab)
    return cnt <= mid

while (r-l) > 1:
    mid = (l + r) // 2
    if ht(mid):
        r = mid
    else:
        l = mid
print(r)


Measured memory_bytes: 12968
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    
    vc<pair<int, int>> ai(n);
    For(i, n){
        ai[i].first = a[i];
        ai[i].second = i;
    }
    DeSort(ai);

    vc<vc<ll>> dp(n+1, vc<ll>(n+1, 0));
    int d = n;
    for(const auto &[a, i] : ai){
        for(int l = 0; l+d <= n; l ++){
            int r = l+d;
            Maxi(dp[l+1][r], dp[l][r] + (ll)a*abs(i-l));
            Maxi(dp[l][r-1], dp[l][r] + (ll)a*abs(i-r+1));
        }
        d --;
    }
    
    ll ans = 0;
    For(i, n+1) Maxi(ans, dp[i][i]);
    Cout(ans);
}


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

int main()
{
    string s;
    cin>>s;
    int temp = 0;
    for(int i=0;i<s.size();i++)
    {
       if(i%2!=0 && s[i]=='R')
       {
           temp = 1;
           break;
       }
       else if(i%2==0 && s[i]=='L')
            {
                temp = 1;
                 break;
            }
    }
    if(temp == 1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256