akhauriyash/Code-Regression huggingface dataset:
// 2020-07-13 20:39:45
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

int mods[2], tots[2];
map<int, int> nums[2];
int rec(int n) {
  if(n == 0) return 0;
  else return 1 + rec(n % __builtin_popcount(n));
}
void answer() {
  int n; string x;
  cin >> n >> x;
  reverse(ALL(x));
  mods[0] = -1;
  mods[1] = 1;
  rep(i, n) if(x[i] == '1') rep(k, 2) mods[k]++;
  rep(k, 2) {
    int mod = mods[k];
    if(mod <= 0) continue;
    nums[k][0] = 1 % mod;
    REP(i, 1, n) {
      nums[k][i] = nums[k][i-1] * 2 % mod;
    }
    tots[k] = 0;
    rep(i, n) {
      if(x[i] == '1') {
        tots[k] += nums[k][i];
        tots[k] %= mod;
      }
    }
  }
  vector<int> res(n, 0);
  rep(i, n) {
    int k, mod, tot;
    if(x[i] == '0') {
      k = 1;
      tot = tots[k] + nums[k][i];
    } else {
      k = 0;
      tot = tots[k] - nums[k][i];
    }
    mod = mods[k];
    if(mod == 0) {
      res[i] = 0;
      continue;
    }
    tot += mod;
    tot %= mod;
    if(tot == 0) {
      res[i] = 1;
      continue;
    }
    res[i] = 1 + rec(tot);
  }
  reverse(ALL(res));
  for(const auto a : res) cout << a << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 22800
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    int dp[n];
    vector<int>ar(n);
    for(int i=0; i<n; i++)
        cin>>ar[i];

    dp[0]=0;
    dp[1]=abs(ar[1]-ar[0]);

    for(int i=0; i<=n-1; i++)
    {
        if(i-2>=0)
            dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 3996
#include<stdio.h>
 
#define N 100
 
void visit(int);
 
int color[N][N], d[N], f[N];
int n, t = 0;
 
int main() {
  int i, j, u, k, a;
 
  scanf("%d",&n);
  for(i = 0; i < n; i++) {
    scanf("%d%d", &u, &k);
    
    for(j = 0; j < k; j++) {
      scanf("%d",&a);
      color[u - 1][a - 1] = 1;
    }
  }
 
  for(i = 0; i < n; i++) {
    if(d[i] == 0) {
      visit(i);
    }
  }
 
    for(i = 0; i < n; i++) {
      printf("%d %d %d\n", i + 1, d[i], f[i]);
    }
 
    return 0;
}
 
void visit(int x) {
  int i;
  t++;
  d[x] = t;
 
  for(i = 0; i < n; i++) {
    if(color[x][i] != 0 && d[i] == 0) {
      visit(i);
    }
  }
 
  t++;
  f[x] = t;
}



Measured memory_bytes: 2104
import java.util.*;

public class Main {

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

        if (y % 2 != 0) {
            System.out.println("No");
            return;
        }

        if (x * 4 < y) {
            System.out.println("No");
            return;
        }
      
        if (y < x * 2) {
            System.out.println("No");
            return;
        }
      
        System.out.println("Yes");
    }
}


Measured memory_bytes: 35772
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    ll k = 2*n+m;
    PRINT(min(k/4,m/2));
}



Measured memory_bytes: 3648
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
 
int main(){    
  int N,D;
  cin >> N >> D;
  int count=0,people=0;

  while(count < N){
    count += 1;
    people++;
    count += D*2;
  }
  cout << people << endl;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll A,B,C;
    string S;
    cin >> A>>B>>C;

    cout << A * B / 2 << endl;

}


Measured memory_bytes: 3644
use proconio::input;

fn main() {
    input!(n: u64);
    let mut a = (0..=(n as f64).sqrt().floor() as u64)
        .rfind(|i| n % i == 0)
        .unwrap();
    let mut b = n / a;
    let mut ans_a = 0;
    let mut ans_b = 0;
    while 0 != a {
        ans_a += 1;
        a /= 10;
    }
    while 0 != b {
        ans_b += 1;
        b /= 10;
    }
    println!("{}", ans_a.max(ans_b));
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> a(N);
    copy_n(istream_iterator<unsigned long>(cin), N, a.begin());

    vector<vector<unsigned long>> factor(N + 1);
    for(unsigned long i = 1; i <= N; ++i)for(unsigned long j = 2 * i; j <= N; j += i)factor[j].push_back(i);

    for(unsigned long j = N; j > 0; --j)if(a[j - 1])for(const auto& i : factor[j])a[i - 1] ^= 1;

    cout << accumulate(a.begin(), a.end(), 0UL) << endl;
    for(unsigned long i = 0; i < N; ++i)if(a[i])cout << i + 1 << endl;
}

Measured memory_bytes: 35456
#include<stdio.h>
#define S 1000

int main(void){
  int i,num,j,k;
  int n[S];
  int curx,cury,map[S][10][10];
  int vectorflag;

  for(i=0;;i++){
    scanf("%d",&n[i]);
    if(n[i]==0)
      break;
    curx=0;
    cury=0;
    vectorflag=1;
    for(j=1;j<=n[i]*n[i];j++){
      map[i][cury][curx]=j;
      if(vectorflag==1){
        cury--;
        curx++;
        if(cury<0 && curx>=n[i]){
          curx--;
          cury++;
          cury++;
          vectorflag=2;
        }
        else if(cury<0){
          cury++;
          vectorflag=2;
        }
        else if(curx>=n[i]){
          curx--;
          cury++;
          cury++;
          vectorflag=2;
        }          
      }else if(vectorflag==2){
        cury++;
        curx--;
        if(curx<0 && cury>=n[i]){
          cury--;
          curx++;
          curx++;
          vectorflag=1;
        }
        else if(curx<0){
          curx++;
          vectorflag=1;
        }
        else if(cury>=n[i]){
          cury--;
          curx++;
          curx++;
          vectorflag=1;
        }
        
        if(curx<0){
          curx++;
          vectorflag=1;
        }
        if(cury>=n[i]){
          cury--;
          curx++;
          curx++;
          vectorflag=1;
        }          

      }
    }
  }
  num=i;
  for(i=0;i<num;i++){
    printf("Case %d:\n",i+1);
    for(j=0;j<n[i];j++){
      for(k=0;k<n[i];k++){
        printf("%3d",map[i][j][k]);
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
# 2019/07/17

from heapq import heappop,heappush

k,t=map(int,input().split())
a=list(map(int,input().split()))
que=[]
for i in range(t):
    hq=(-a[i],i)
    heappush(que,hq)

pre_v,pre_idx=heappop(que)
hq=(pre_v+1,pre_idx)
heappush(que,hq)

cnt=0

for i in range(k-1):
    v,idx=heappop(que)
    if idx==pre_idx :
        if que:
            hq=(v,idx)
            v,idx=heappop(que)
            heappush(que,hq)    
        else:
            cnt+=-v
            break
    v+=1
    hq=(v,idx)
    pre_v,pre_idx=hq
    if v==0:continue
    heappush(que,hq)

print(cnt)


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

bool dp[8010][20000];

int main(int argc, char **argv)
{
	string S; cin >> S;
	ll x, y; cin >> x >> y;
	ll N = S.size();

	vector<ll> ho, ve;
	ll right{0};
	ll cnt{0};

	for (ll i = 0; i < N;)
	{
		ll j = i + 1;
		if (S[i] == 'T')
		{
			++cnt;
		}
		else
		{
			while (j < N && S[j] == 'F') {++j;}
			if (cnt & 1)
				ve.push_back(j-i);
			else if (cnt == 0)
				right = j - i;
			else
				ho.push_back(j-i);
		}
		i = j;
	}

	// std::cout << "right : " << right << std::endl;
	bool ok{true};

	memset(dp, 0, sizeof dp);
	N = 1 + ho.size();
	dp[1][right+10000] = true;
	for (ll n = 1; n < N; ++n)
	{
		for (ll w = 0; w < 20000; ++w)
		{
			if (w-ho[n-1] >= 0)
				dp[n+1][w] |= dp[n][w-ho[n-1]];
			if (w+ho[n-1] < 20000)
				dp[n+1][w] |= dp[n][w+ho[n-1]];
		}
	}
	ok &= dp[N][10000+x];
	// std::cout << ok << std::endl;

	memset(dp, 0, sizeof dp);
	N = ve.size();
	dp[0][10000] = true;
	for (ll n = 0; n < N; ++n)
	{
		for (ll w = 0; w < 20000; ++w)
		{
			if (w-ve[n] >= 0)
				dp[n+1][w] |= dp[n][w-ve[n]];
			if (w+ve[n] < 20000)
				dp[n+1][w] |= dp[n][w+ve[n]];
		}
	}
	ok &= dp[N][10000+y];
	// std::cout << ok << std::endl;

	std::cout << (ok ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 156800
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define mp make_pair
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int N,M;
int g[705][705];
struct node {
    int to,next;
}E[1000005];
int sumE,head[705],tot,col[705],que[705],qr;
pii conn[705];
bool f[2][705];
void add(int u,int v) {
    E[++sumE].next = head[u];
    E[sumE].to = v;
    head[u] = sumE;
}
bool dfs(int u) {
    if(col[u] == -1) col[u] = 0;
    que[++qr] = u;
    for(int i = head[u] ; i ; i = E[i].next) {
    int v = E[i].to;
    if(col[v] == col[u]) return false;
    else if(col[v] == -1) {
        col[v] = col[u] ^ 1;
        if(!dfs(v)) return false;
    }
    }
    return true;
}
void Solve() {
    read(N);read(M);
    int u,v;
    for(int i = 1 ; i <= M ; ++i) {
    read(u);read(v);
    g[u][v] = g[v][u] = 1;
    }
    for(int i = 1 ; i <= N ; ++i) {
    for(int j = i + 1 ; j <= N ; ++j) {
        if(!g[i][j]) {add(i,j);add(j,i);}
    }
    }
    memset(col,-1,sizeof(col));
    for(int i = 1 ; i <= N ; ++i) {
    if(col[i] == -1) {
        qr = 0;
        if(!dfs(i)) {puts("-1");return;}
        int cnt[2] = {0,0};
        for(int j = 1 ; j <= qr ; ++j) cnt[col[que[j]]]++;
        conn[++tot] = mp(cnt[0],cnt[1]);
    }
    }
    int cur = 0;
    f[0][0] = 1;
    for(int i = 1 ; i <= tot ; ++i) {
    memset(f[cur ^ 1],0,sizeof(f[cur ^ 1]));
    for(int j = N ; j >= 0 ; --j) {
        if(j >= conn[i].fi) f[cur ^ 1][j] |= f[cur][j - conn[i].fi];
        if(j >= conn[i].se) f[cur ^ 1][j] |= f[cur][j - conn[i].se];
    }
    cur ^= 1;
    }
    int ans = N * N;
    for(int i = 0 ; i <= N ; ++i) {
    if(f[cur][i]) {
        ans = min(i * (i - 1) / 2 + (N - i) * (N - i - 1) / 2,ans);
    }
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}

Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#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 all(v) v.begin(),v.end()

int main() {
    int n;
    cin >> n;
    vector<int> s(n);
    int sum = 0;
    rep(i,n) {
        cin >> s[i];
        sum += s[i];
    }
    sort(all(s));
    if (sum % 10 == 0) {
        rep(i,n) {
            if (s[i] % 10 != 0) {
                sum -= s[i];
                break;
            }
        }
    }
    if (sum % 10 == 0) {
        cout << 0 << endl;
    } else {
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	double h,m;
	int cMA,cHA;
	int cMB,cHB;
	int cMC,cHC;
	int cMD,cHD;
	cMA=0;
	cHA=0;
	cMB=0;
	cHB=0;
	cMC=0;
	cHC=0;
	cMD=0;
	cHD=0;
		while(scanf("%lf %lf",&h,&m)!=EOF){
			if(h>=1.1){
				cHA++;
			}
			else if(0.6<=h){
				cHB++;
			}
			else if(0.2<=h){
				cHC++;
			}
			else{
				cHD++;
			}
			if(m>=1.1){
				cMA++;
			}
			else if(0.6<=m){
				cMB++;
			}
			else if(0.2<=m){
				cMC++;
			}
			else{
				cMD++;
			}
		}
	printf("%d %d\n%d %d\n%d %d\n%d %d\n",cHA,cMA,cHB,cMB,cHC,cMC,cHD,cMD);
	return 0;
}

Measured memory_bytes: 1056
_n, m = gets.chomp.split(' ').map(&:to_i)

list = []
hash = {}
m.times.each do
  pi, yi = gets.chomp.split(' ').map(&:to_i)
  if hash.key?(pi)
    hash[pi] << yi
  else
    hash[pi] = [yi]
  end
  list << [pi, yi]
end

sorted = {}

list.each do |pi, yi|
  unless sorted[pi]
    hash[pi] = hash[pi].sort.map.with_index(1) do |x, i|
      [x, i]
    end.to_h
    sorted[pi] = true
  end
  idx = hash[pi][yi]
  puts "#{format('%06d', pi)}#{format('%06d', idx)}"
end



Measured memory_bytes: 63356
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve(){
	int ans = 0;
	string s; cin >> s;
	rep(i, s.size())if (s[i] == '1')ans++;
		cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int a,b=0,c=0,i;
		for(i=0;i<3;i++) {
			a=stdIn.nextInt();
			if(a==5) b++;
			else if(a==7) c++;
		}
		System.out.print(b==2&&c==1?"YES":"NO");
	}
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    if(N==1 && M==1) cout << 1 << endl;
    else if(N==1) cout << M-2 << endl;
    else if(M==1) cout << N-2 << endl;
    else
    {
        cout << (M-2) * (N-2) << endl;
    }

    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q; cin >> n >> q;
    SegmentTree<int> seg(n,[](int a, int b){return min(a,b);}, INT32_MAX);
    REP(i,q){
        int c,x,y; cin >>c >>  x >> y;
        if(c == 0){
            seg.update(x,y);
        }
        else{
            cout << seg.query(x,y+1) << endl;
        }
    }

}


Measured memory_bytes: 3860
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;
 
public class Main {
 
	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;
 
	static void solve() {
		int S=in.nextInt();
		int h=S/3600;
		int m=(S%3600)/60;
		int s=S%60;
		out.println(h+":"+m+":"+s);
	}
 
	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();
 
		solve();
		out.flush();
 
		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}
 
	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 26116
dishes = [int(input()) for _ in range(5)]
ans = 0
a = 10

for x in dishes:
  if x % 10 == 0:
    ans += x
  else:
    ans += x - (x%10) + 10
    a = min(a, x%10)
    
if a == 10:
    a = 0
else:
    a -= 10
print(ans + a)

Measured memory_bytes: 3060
# 配列の宣言
A = []
B = []

# 文字列の取得と加工
LENGTH =int(input())
A = input().split()
B = A.copy()

def bubble (A, LENGTH):
    N = 0
    M = LENGTH - 1
    CHANGE = 0

    while N <= LENGTH -1:
        M = LENGTH - 1
        while M >= N + 1:
            if int(A[M][1:]) < int(A[M-1][1:]):
                tmp = A[M-1]
                A[M-1] = A[M]
                A[M] = tmp
                CHANGE += 1
            M -= 1
        N += 1

    print(" ".join(map(str,A)))
    print("Stable")

def selection (B, LENGTH):
    i = 0
    CHANGE_COUNT = 0

    while i <= LENGTH -1:
        j = i + 1
        mini = i
        while j <= LENGTH -1:
            if int(B[j][1:]) < int(B[mini][1:]):
                mini = j
            j += 1
        if mini != i:
            tmp = B[i]
            B[i] = B[mini]
            B[mini] = tmp
            CHANGE_COUNT += 1
        i += 1

    print(" ".join(map(str,B)))
    if A == B:
        print("Stable")
    else:
        print("Not stable")

bubble (A, LENGTH)
selection (B, LENGTH)


Measured memory_bytes: 5608
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
		int leftNum = 1;
		int rightNum = n;
    for(int i = 0; i < m; i++)
    {
      int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
			leftNum = Math.Max(leftNum, nums[0]);
			rightNum = Math.Min(rightNum, nums[1]);
    }

		Console.WriteLine(Math.Max(0, rightNum-leftNum+1));
	}
}

Measured memory_bytes: 17208
import math
N = int(input())

alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

def kyusu(n):
    return 26 * (26 ** n - 1) / 25

t = 1
while(N > kyusu(t)):
    t += 1

keta = []
for i in range(t - 1):
    base = 26 ** (t - i - 1)
    extra = kyusu(t - i - 1)
    tmp = math.ceil((N - extra) / base)
    keta.append(alphabet[tmp - 1].lower())
    N -= base * tmp

answer = ""
for i in range(len(keta)):
    answer += keta[i]

answer += alphabet[N - 1].lower()
print(answer)


Measured memory_bytes: 9180
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		
    		int x=Integer.parseInt(scan.next());
    		int t=Integer.parseInt(scan.next());
    		
    		if (x-t>=0) {
    			System.out.print(x-t);
    		}else {
    			System.out.print(0);
    		}
    		

    		
    	
  
    				
 
     
    }
    }

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/*---------------------------------------------------------------------------------------------------------------------*/

int arr[123456], vis[123456];

int main(){

    int n, m;
    cin >> n >> m;
    vector <vector<int> > vec(n+1);
    for(int i = 1; i <= n; i++) cin >> arr[i];

    for(int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(vec[i].size() == 0 && i == arr[i]){
                ans++;
                continue;
        }
        if(vis[i]) continue;
        set <int> se1, se2;
        queue <int> q;
        q.push(i);
        vis[i] = 1;
        se1.insert(i);
        se2.insert(arr[i]);
        while(!q.empty()){
              int n1 = q.front();
              q.pop();
              for(auto x:vec[n1]){
                  if(!vis[x]){
                     vis[x] = 1;
                     se1.insert(x);
                     se2.insert(arr[x]);
                     q.push(x);
                  }
              }
        }

        for(auto x:se1){
            if(se2.count(x)){
                    ans++;
            }
        }
       // cout << endl;
    }
    cout << ans;
}



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

int main(){
  string s; cin >> s;
  if (s.size() == 2) {
    if (s[0] == s[1]) {
      cout << 1 << " " << 2 << endl;
      return 0;
    }
  }
  for (int i = 2; i < s.size(); i++) {
    if (s[i-2] == s[i-1] || s[i-2] == s[i] || s[i-1] == s[i]) {
      cout << i-2 + 1 << " " << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 512
n = int(input())
route = [[] for i in range(n)] #どの木と隣接か
for i in range(n-1):
	a,b = (x-1 for x in map(int,input().split()))
	route[a]+=[b]
	route[b]+=[a]
c = list(map(int,input().split()))
c.sort(reverse=1)

check = [False]*n #check済みか否か
ans = [0]*n #cを入れてく
cnt = 0 #何個目を見てるか、cに使う
q = [0]
# print(route)
while q:
	cur = q[0] #今どこの木を見てるか
	q = q[1:]
	check[cur] = True
	ans[cur] = c[cnt]
	cnt += 1
	for r in route[cur]:
		if check[r]:
			continue
		q.append(r)
print(sum(ans[1:]))
print(*ans)

Measured memory_bytes: 6164
fun main(args: Array<String>) {
    edpa()
}

fun edpa() {
    val n = readLine()!!.toInt()
    val heights = readLine()!!.split(' ').map { it.toInt() }

    val inf =Long.MAX_VALUE/100
    val dp = LongArray(n) { inf }
    dp[0] = 0

    for (i in 0 until n - 1) {
        if (i + 1 <= heights.lastIndex) dp[i + 1] = Math.min(dp[i + 1], dp[i] + Math.abs(heights[i] - heights[i + 1]))
        if (i + 2 <= heights.lastIndex) dp[i + 2] = Math.min(dp[i + 2], dp[i] + Math.abs(heights[i] - heights[i + 2]))
    }

    val answer = dp[n - 1]

    println(answer)
}


Measured memory_bytes: 50504
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1e9+7
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for(ll i = x; i < n; i++)
#define rrep(i, x, n) for(ll i = x; i >= n; i--)
#define all(v) v.begin(),v.end()
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define e emplace
#define mp make_pair
double PI=3.14159265358979323846;
typedef long long int ll;
typedef long double ld;
typedef pair< ll, ll > pii;
typedef vector< ll > vi;
typedef vector< vi > vvi;

ll dp[100105];
ll h[100005];

int main()
{
	boost
	ll n, k;
	cin >> n >> k;
	rep(i, 0, n) cin >> h[i];
	rep(i, n, n + k + 1) h[i] = h[n - 1];
	rrep(i, n - 2, 0) {
		dp[i] = dp[i + 1] + abs(h[i] - h[i + 1]);
		rep(j, 2, k + 1) dp[i] = min(dp[i], dp[i + j] + abs(h[i + j] - h[i]));
	}
	cout << dp[0];
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var A = cin.scanint.Select(i => i - 1).ToArray();
        WriteLine(A[0] * A[1]);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13396
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        String[] in = new String[N];
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        for(int i=0;i<N;i++){
            in[i] = scan.next();
            if(in[i].equals("AC")){
                ac+=1;
            }else if(in[i].equals("WA")){
                wa+=1;
            }else if(in[i].equals("TLE")){
                tle+=1;
            }else if(in[i].equals("RE")){
                re+=1;
            }
        }

        System.out.println("AC x "+ac);
        System.out.println("WA x "+wa);
        System.out.println("TLE x "+tle);
        System.out.println("RE x "+re);

    }
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);


int n , m;

int st[N << 2];
int a[N];

vi adj[N];
int ans[N];

void update(int p , int l , int r , int dx , int val) {
    if(l == r) {
            st[p] = val;
            return;
    }

    int mid = l + (r - l) / 2;

    if(dx <= mid) update(p << 1 , l , mid , dx , val);
    else update(p << 1 | 1 , mid + 1 , r , dx , val);

    st[p] = max(st[p << 1] , st[p << 1 | 1]);
}

int query(int p , int l , int r , int S , int E) {
    if(l >= S && r <= E) return st[p];
    if(l > E || r < S) return 0;

    int mid = l + (r - l) / 2;

    return max(query(p << 1 , l , mid , S , E) , query(p << 1 | 1 , mid + 1 , r , S , E));
}

void dfs(int u , int p) {

    int orgVal = query(1 , 1 , N-1 , a[u] , a[u]);
    int newVal = max(orgVal , 1 + query(1 , 1 , N-1 , 1 , a[u] - 1));

    update(1 , 1 , N-1 , a[u] , newVal);

    ans[u] = st[1];

    for(int v : adj[u]) {
            if(v == p) continue;
            dfs(v , u);
    }

    update(1 , 1 , N-1 , a[u] , orgVal);
}


void solve(int testCase){

    scanf("%d" , &n);

    map < int , int > mp;
    for(int i = 1 ; i <= n ; i ++) {
            scanf("%d" , &a[i]);
            mp[a[i]];
    }

    for(int i = 1 ; i < n ; i ++) {
            int u , v; scanf("%d %d" , &u , &v);

            adj[u].push_back(v);
            adj[v].push_back(u);
    }

    int cnt = 0;
    for(auto &M : mp) M.second = ++ cnt;

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


    dfs(1 , 0);

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

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 35276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int n, m;
vector<string> a, b;

bool match(int r, int c){
    if (c + m - 1 >= n) return false;
    if (r + m - 1 >= n) return false;
    int cnt = 0;
    for(int i = r; i < r + m; i++){
        if (a[i].substr(c, m) != b[cnt]) return false;
        cnt++;
    }   
    return true;
}

int main(){
    cin >> n >> m;
    a.resize(n);
    b.resize(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    rep(row, n) rep(col,n){
        if (match(row, col)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;
using ll=long long;

int n;
ll a[10];

ll start[10],num[10];

int main(void){
	cin >> n;
	rep(i,n) cin >> a[i];
	sort(a,a+n);
	reverse(a,a+n);

	ll sum=0LL;
	rep(i,n) sum+=a[i];
	if(n<=3 || a[n-1]>=n-1){
		cout << sum-(n*(n-1)/2) << endl;
		return 0;
	}

	// (2,2,2,2) = 4
	// (2,2,2,2,2) = 4

	if(n==4){
		if(a[0]==2){
			cout << 4 << endl;
			return 0;
		}else if(a[1]==2){
			cout << a[0]+1 << endl;
			return 0;
		}else if(a[2]==2){
			cout << a[0]+a[1]-1 << endl;
			return 0;
		}else if(a[3]==2){
			cout << a[0]+a[1]+a[2]-3 << endl;
			return 0;
		}
	}

	// (2,2,2,2,2) = 4

	if(n==5){
		if(a[0]==2){
			cout << 4 << endl;
			return 0;
		}

		if(a[1]==2){
			if(a[0]==3)
				cout << 5 << endl;
			else
				cout << a[0]+1 << endl;
			return 0;
		}

		if(a[2]==2){
			cout << a[0]+a[1]-1 << endl;
			return 0;
		}

		if(a[3]==2){
			cout << a[0]+a[1]+a[2]-3 << endl;
			return 0;
		}

		if(a[4]==2){
			cout << a[0]+a[1]+a[2]+a[3]-6 << endl;
			return 0;
		}

		if(a[1]==3 && a[4]==3){
			cout << a[0]+a[1]+a[2]+a[3]+a[4]-8 << endl;
			return 0;
		}

		if(a[1]>=4 && a[4]==3){
			cout << a[0]+a[1]+a[2]+a[3]+a[4]-9 << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3132
n = int(input())
arr = list(map(int,input().split()))
arr.sort()
arr.reverse()

b = [0,0]

ind = 0
bef = -1
for a in arr:
    if a != bef:
        bef = a
    else:
        b[ind] = a
        ind += 1
        bef=-1
    if ind > 1:
        break

if ind > 1:
    print(b[0]*b[1])
else:
    print(0)



Measured memory_bytes: 15020
#include<cstdio>
int main()
{
    long long n,k,x,y;
    while(scanf("%lld%lld%lld%lld",&n,&k,&x,&y)!=EOF)
    {
        long long sum1=0;
        if(n<k)
          k=n;
        for(int i=0;i<k;i++)
            sum1+=x;
        for(int j=k;j<n;j++)
            sum1+=y;
        printf("%lld\n",sum1);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
#define trace1(x)				cerr<<#x<<": "<<x<<endl
#define trace2(x, y)			 cerr<<#x<<": "<<x<<"  "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		  cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	   cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll a[n],sum=0;
	rep(i,0,n) {
		cin >> a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	sum-=a[n-1];
	if(sum>a[n-1]) cout << "Yes";
	else cout << "No";
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i, n){
        if (i%2==0){
            if (s[i] == 'p') ans--;
        }
        else{
            if (s[i] == 'g') ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())
nsl = lambda: list(nsm())

n, k = nm()
if k == 1:
    print(0)
else:
    print(n - k)

Measured memory_bytes: 3316
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
const int MAXN=1e5+10;
int a[MAXN],b[MAXN],n,k,x,y,w,ans,p,q,tot;
int inline 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;
}
void inline init()
{
	tot=0;
	x=y=0;
    n=read();
    k=read();

    for(int i=1;i<=n;i++)
    {
        w=read();
        if(w<0) a[++x]=-w;
        else b[++y]=w;
    }
    ans=0x3f3f3f3f;
	
	p=min(x,k);
	q=min(y,k);
}
int main()
{
	
    init();
    sort(a+1,a+1+x);
	
    for(int i=0;i<=p;i++)if(k<=i+y)ans=min(a[i]*2+b[k-i],ans);
    for(int i=0;i<=q;i++)if(k<=i+x)ans=min(b[i]*2+a[k-i],ans);
	
	printf("%d",ans);
}

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

int n,m,sum,cnt;
int a[110];
vector<int> b;
int main() {
    cin >> n >> m;
    int odd = 0;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        if (a[i] & 1) {
            swap(a[i], a[cnt++]);
        }
    }
    if (m == 1 && n == 1) {
        cout << "1\n1\n1\n";
        return 0;
    }
    if (m == 1) {
        cout << a[0] << endl;
        cout << 2 << endl;
        cout << a[0]-1 << " " << 1 << endl;
        return 0;
    }
    if (cnt > 2) {
        cout << "Impossible" << endl;
        return 0;
    }
    swap(a[1],a[m-1]);
    for (int i = 0; i < m; i++) cout << a[i] << " \n"[i == m-1];
    a[0]--; a[m-1]++;
    cout << m - (a[0] == 0) << endl;
    for (int i = 0 + (a[0] == 0); i < m; i++) cout << a[i] << " \n"[i == m-1];
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main() {
	int n;
	long long list[87] = {[0] = 2, [1] = 1};
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) {
		list[i] = list[i - 1] + list[i - 2];
	}
	printf("%lld\n", list[n]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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



double N;

int main () {
  cin >> N;
  double cri = N / 1.08;
  int a = floor(cri);
  int b = ceil(cri);

  if (floor(a * 1.08) == N) {
    cout << a << "\n";
  } else if (floor(b * 1.08) == N) {
    cout << b << "\n";
  } else {
    cout << ":(" << "\n";
  }

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        if(s.equals("AAA")||s.equals("BBB")){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-10;
const int MOD = 1000000007;

#define X real()
#define Y imag()

typedef complex<double> P;
struct L{
	P p1, p2;
	L(P p1, P p2):p1(p1), p2(p2){}
	L(){}
};
istream& operator>>(istream &is, P &p) {
	double x, y;
	is >> x >> y;
	p = P(x, y);
	return is;
}
inline int sig(double x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }
inline double norm(const P &p){return p.X*p.X+p.Y*p.Y;}
inline double inp(const P& a, const P& b){return (conj(a)*b).X;}
inline double outp(const P& a, const P& b){return (conj(a)*b).Y;}


int T;

int main(){
	ios::sync_with_stdio(false);
	cin >> T;
	while(T--){
		P p1, p2, p3, p4;
		cin >> p1 >> p2 >> p3 >> p4;
		p2 -= p1; p4 -= p3;
		puts(!sig(inp(p2, p4*P(0, 1))) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
using namespace std;
int main()
{
    int a[10005]={0};
    int x=1,y=1,z=1,n;
    cin>>n;
   
   for(int x=1;x<=100;x++)
   for(int y=1;y<=100;y++)
   for(int z=1;z<=100;z++)
   {
       int s=x*x+y*y+z*z+x*z+x*y+z*y;
    if(s<=10000)
    a[s]++;
    }
    for(int i=1;i<=n;i++)
    cout<<a[i]<<endl;
    
    return 0;
}

Measured memory_bytes: 3092
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <istream>
#include <algorithm>

int main()
{
    int x, a, b;

    std::cin >> x;
    std::cin >> a;
    std::cin >> b;
    std::cout << (x - a) % b;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int n,a,b,count=0;
   cin>>n;
   for(int i=0;i<n;i++){
       cin>>a>>b;
       if(a==b){
           count++;
       }
       else{
           count=0;
       }
       if(count==3){
           break;
       }
   }
   if(count==3){
           cout<<"Yes"<<endl;
       }
     else{
         cout<<"No"<<endl;
     }
   return 0;
}

Measured memory_bytes: 3632