akhauriyash/Code-Regression huggingface dataset:
// Aizu Vol-2 0280: The Outcome of Bonze
// 2017.8.7

#include <stdio.h>
#include <ctype.h>

char *gets(char *);
char buf[150], *p;

int getInt(void)
{
	int n = 0;
	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

int ba;
int f[12];

int main()
{
	int N;
	int i, j, k;

	while (1) {
		gets(p = buf); N = getInt();
		if (N == 0) break;
		gets(p = buf); while (isspace(*p)) p++;
		ba = 0; for (k = 0; k < N; k++) f[k] = 0;
		for (k = i = 0; i < 100; i++, p++) {
			if (*p == 'M') f[k]++;
			else if (*p == 'S') ba += f[k] + 1, f[k] = 0;
			else f[k] += ba + 1, ba = 0;      // *p == 'L'
			if (++k == N) k = 0;
		}
		for (i = 0; i < N; i++) {
			k = i;
			for (j = i + 1; j < N; j++) if (f[k] > f[j]) k = j;
			if (k != i) { int t = f[k]; f[k] = f[i], f[i] = t; }
		}
		printf("%d", f[0]);
		for (k = 1; k < N; k++) printf(" %d", f[k]);
		printf(" %d\n", ba);
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
int main() {
 vector<char> V(4);
 cin >> V.at(0) >> V.at(1)>> V.at(2)>>V.at(3);
 if (V.at(0) == V.at(1) && V.at(1) == V.at(2)) {
   cout << "Yes" << endl;
 }
  else if (V.at(3) == V.at(2) && V.at(1) == V.at(2)) {
   cout << "Yes" << endl;
 }
 else{
    cout << "No" << endl;
 }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())

# ちょっと自分でいじった版

dp = [0] * (N+1)

for n in range(1, N+1):
    dp[n] = float("inf")
    power = 1
    while power <= n:
        dp[n] = min(dp[n], dp[n-power] + 1)
        power *= 6
    power = 1
    while power <= n:
        dp[n] = min(dp[n], dp[n-power] + 1)
        power *= 9

print(dp[N])

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

int main() {
	int A, B;
	cin >> A;
	cin >> B;

	if (A + B == 3) {
		cout << 3 << endl;
	}
	else if (A + B == 4) {
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EXP 1000000007;
using namespace std;
int main(void){
	int h,w,k;
	int i,j;
	int bit[128][7];
	int dp[101][8];
	int mask[7];
	bool flg[128];
	cin>>h>>w>>k;
	mask[0]=1;
	for(i=1;i<w-1;i++){
		mask[i]=mask[i-1]*2;
	}	
	for(i=0;i<1<<(w-1);i++){
		for(j=0;j<w-1;j++){
			bit[i][j]=0;
		}
	}
	for(i=0;i<1<<(w-1);i++){
		flg[i]=true;
		for(j=0;j<w-1;j++){
			if((i&mask[j])!=0){
				bit[i][j]=1;
			}
		}
	}
	for(i=0;i<1<<(w-1);i++){
		for(j=0;j<w-1;j++){
			if(bit[i][j]==1&&bit[i][j-1]==1&&bit[i][j]==bit[i][j-1]&&j>0){
				flg[i]=false;
			}
		}
	}
	for(i=0;i<h+1;i++){
		for(j=0;j<w;j++){
			dp[i][j]=0;
		}
	}
	
	
	
	
	dp[0][0]=1;
	
	int l;
	int p,m;
	for(l=0;l<h;l++){
		for(i=0;i<1<<(w-1);i++){
			if(flg[i]){
				for(j=0;j<w;j++){
					if(j==0){
						if(bit[i][j]==1){
							dp[l+1][j+1]+=dp[l][j];
							dp[l+1][j+1]%=EXP;
						}
						if(bit[i][j]!=1){
							dp[l+1][j]+=dp[l][j];
							dp[l+1][j]%=EXP;
						}
					}
					else if(j==w-1){
						if(bit[i][j-1]==1){
							dp[l+1][j-1]+=dp[l][j];
							dp[l+1][j-1]%=EXP;
						}
						if(bit[i][j-1]!=1){
							dp[l+1][j]+=dp[l][j];
							dp[l+1][j]%=EXP;
						}
					}
					else{
						if(bit[i][j]==1){
							dp[l+1][j+1]+=dp[l][j];
							dp[l+1][j+1]%=EXP;
						}
						if(bit[i][j]!=1&&bit[i][j-1]!=1){
							dp[l+1][j]+=dp[l][j];
							dp[l+1][j]%=EXP;
						}
						if(bit[i][j-1]==1){
							dp[l+1][j-1]+=dp[l][j];
							dp[l+1][j-1]%=EXP;
						}
					}
				}
			}
		}
	}
	cout<<dp[h][k-1]<<endl;
	return 0;
}

	
	
		

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Range Set Counter (Hash)
//-------------------------------------------------
template<typename T>
class RangeSet
{
private:
    ::std::vector<T> v;
    ::std::unordered_map<T, ::std::vector<int> > data;
public:
    RangeSet(const ::std::vector<T> &v_):v(v_){
        int sz = v.size();
        for(int i=0;i<sz;i++){
            T t = v[i];
            data[t].push_back(i);
        }
    }
    //query for all elements
    int query(T x){
        if (!data.count(x)) return 0;
        return data[x].size();
    }
    //query for [a, b]
    int query(int a, int b, T x){
        if (a>b) return 0;
        if (!data.count(x)) return 0;
        auto right = ::std::upper_bound(data[x].begin(),data[x].end(),b);
        auto left  = ::std::lower_bound(data[x].begin(),data[x].end(),a);
        return right-left;
    }
    //search x for [k, tail]
    int find(int k, T x){
        if (!data.count(x)) return -1;
        auto itr = ::std::lower_bound(data[x].begin(),data[x].end(),k);
        if (itr!=data[x].end()){
            return *itr;
        }else{
            return -1;
        }
    }
    //update for one point
    void update(int k, T x){
        int ei = v[k];
        auto eitr = ::std::lower_bound(data[ei].begin(),data[ei].end(),k);
        data[ei].erase(eitr);
        v[k] = x;
        if (data.count(x)){
            auto itr = ::std::lower_bound(data[x].begin(),data[x].end(),k);
            data[x].insert(itr, k);
        }else{
            data[x].push_back(k);
        }
    }
};


//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    vector<char> v(n);
    rep(i,n) v[i]=s[i];
    RangeSet<char> rs(v);
    int q; cin>>q;
    while(q--){
        int t; cin>>t;
        if (t==1){
            int a; char b; cin>>a>>b; a--;
            rs.update(a,b);
        }else{
            int a,b; cin>>a>>b; a--; b--;
            int ans=0;
            rep(i,26)if(rs.query(a,b,char('a'+i)))
                ans++;
            cout<<ans<<"\n";
        }
    }
    return 0;
}


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

int main () {
    int n;
    string s;
    cin >> n >> s;
    
    if (s.substr(0, n/2) ==  s.substr(n/2, n)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}



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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

  char c;
  while (c = getchar(), c != EOF) {
    if ('a' <= c && c <= 'z') {
      c += 'A' - 'a';
    }
    cout << c;
  }

  return 0;
}

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

const long long INF = 1LL << 60;
 
 
bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
 
 
int main() {
  string S, T;

  cin >> S >> T;

  ll ans = INF;
  ll tmp = 0;

  for (ll i = 0; i < S.size()-T.size() + 1; i++) {
    
    tmp = 0;

    for (ll j = 0; j < T.size(); j++) {
      if (S.at(i+j) != T.at(j)) tmp++;
    }

    if (ans > tmp) ans = tmp;
    
  }

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

Measured memory_bytes: 3564
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

signed main()
{
  ll N, K;
  cin >> N >> K;

  ll x = N % K;

  ll a1 = x;
  ll a2 = abs(x - K);

  ll ans = min(a1, a2);
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
a,b,h,m=map(float,input().split(" "))

h=h%12
th_h=30*h+0.5*m
th_m=6*m
theita=abs(th_h-th_m)
if theita<180:
    print('%.20f'%math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(theita))))
elif theita>180:
    theita=360-theita
    print('%.20f'%math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(theita))))
else:
    print(a+b)


Measured memory_bytes: 9520
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  string s; cin >> s;
  int k; cin >> k;

  int n = s.size();
  int judge = true;
  for(int i = 0; i < n-1; i++){
    if(s[i] != s[i+1]) judge = false;
  }
  if(judge){
    cout << n * k / 2 << endl;
    return 0;
  }

  if(s[0] != s[n-1]){
    int cnt = 0;
    for(int i = 0; i < n-1; i++){
      if(s[i] == s[i+1]){
        s[i+1] = '-';
        cnt++;
      }
    }
    cout << cnt * k << endl;
  }else {
    int left,right,l = 0,r = 0;
    for(int i = 0; i < n; i++){
      if(s[i] != s[0]){
        left = i;
        break;
      }
      l++;
    }
    for(int i = n-1; i >= 0; i--){
      if(s[i] != s[0]){
        right = i;
        break;
      }
      r++;
    }
    int cnt = 0;
    for(int i = left; i < right; i++){
      if(s[i] == s[i+1]){
        s[i+1] = '-';
        cnt++;
      }
    }
    cout << cnt * k + (l + r) / 2 * (k - 1) + l / 2 + r / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin >> s;
  if(s[0]=='S'){
     cout << "Cloudy" << endl;

 }else if(s[0] == 'C'){
     cout << "Rainy" << endl;

 }else{
      cout << "Sunny" << endl;

 }

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n,temp;
  bool a=true;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>temp;
    if(temp%2==0){
      if(temp%3==0||temp%5==0){
      }else{
        a=false;
        break;
      }
    }
  }
  if(a){
    cout<<"APPROVED"<<endl;
  }else{
    cout<<"DENIED"<<endl;
  }
}        

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
int inf = 1e9;

int main() {
  int n, k; cin >> n >> k;
  vector<int> x(n);
  vector<int> y(n);
  vector<char> c(n);
  vector< vector<int> > dd(2*k+10, vector<int>(2*k+10, 0));
  for(int i=0; i<n; i++){
    cin >> x[i] >> y[i] >> c[i];
    if(c[i] == 'W') {
      y[i] += k;
      c[i] = 'B';
    }
    x[i] %= 2*k;
    y[i] %= 2*k;
    dd[x[i]+1][y[i]+1]++;
  }

  for(int i=1; i<=2*k; i++) {
    for(int j=1; j<=2*k; j++) {
      dd[i][j] += dd[i][j-1];
    }
  }
  for(int j=1; j<=2*k; j++) {
    for(int i=1; i<=2*k; i++) {
      dd[i][j] += dd[i-1][j];
    }
  }

  int mx = -1e9;
  for(int i=0; i<=k; i++) {
    for(int j=0; j<=k; j++) {
      int a = dd[i][j];
      int b = dd[i+k][j+k] - dd[i+k][j] - dd[i][j+k] + dd[i][j];
      int c = dd[2*k][j] - dd[i+k][j];
      int d = dd[i][2*k] - dd[i][j+k];
      int e = dd[2*k][2*k] - dd[2*k][j+k] - dd[i+k][2*k] + dd[i+k][j+k];
      int tmp = a + b + c + d + e;
      mx = max({mx, tmp, n - tmp});
    }
  }
  cout << mx << endl;

  return 0;
}


//EOF


Measured memory_bytes: 17024
use std::io;

fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

fn main() {
    let (a, b, c) = {
        let v = read::<usize>();
        (v[0], v[1], v[2])
    };

    if a + b >= c {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main(){
  string s, t; cin >> s >> t;
  int n = s.size(), m = t.size();
  vector<vector<int> > data(26);
  for(int i = 0; i < n; i++) data[s[i] - 'a'].push_back(i + 1);
  for(int i = 0; i < 26; i++) data[i].push_back(INF);
  for(int i = 0; i < m; i++){
    if(data[t[i] - 'a'].size() == 1){
      cout << -1 << endl;
      return 0;
    }
  }
  int id = 0, cnt = 0;
  for(int i = 0; i < m; i++){
    int num = t[i] - 'a';
    int next = *upper_bound(data[num].begin(), data[num].end(), id);
    if(next == INF){
      cnt++;
      id = data[num][0];
    }
    else{
      id = next;
    }
  }
  ll ans = ll(n) * ll(cnt) + ll(id);
  printf("%lld\n", ans);
}

Measured memory_bytes: 4232
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = myRead.readIntArray();
            var ans = s[0] <= s[1] * s[2] ? "Yes" : "No";
            WriteLine(ans);
        }
    }
    public static class myRead
    {
        public static int readInt() { return int.Parse(ReadLine()); }
        public static long readLong() { return long.Parse(ReadLine()); }
        public static string readStr() { return ReadLine(); }
        public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        public static string[] readStrArray() { return ReadLine().Split(' '); }
    }


    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); }
        public static long Combination(long n, long m)
        { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Lcm(long n, long m)
        { return n * m / Gcd(n, m); }
        public static long Pow(long n, long m)
        { return m == 0 ? 1L : m == 1 ? n : n * Pow(n, m - 1); }
    }


}

Measured memory_bytes: 28296
#include <bits/stdc++.h>
using namespace std;
 
int main()
{

	string s;
	
	int i;
	int mostLeftIndex;
	int mostRightIndex;

	cin >> s;
	
	i = 0;
	while(true) { 
		
		if ( s[i] == 'A' ) {
			mostLeftIndex = i;
			break;
		}		
		i++;
	}

	i = s.size() - 1;
	while (true) {

		if (s[i] == 'Z') {
			mostRightIndex = i;
			break;
		}
		i--;
	}
		
	cout << mostRightIndex - mostLeftIndex + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int N;
vector<LL> line;

bool check(int x){
	LL sum = line[x];
	REP(i, N){
		if(x==i)continue;
		if(sum*2 < line[i])return false;
		sum += line[i];
	}
	return true;
}

int main(){
	cin >> N;
	line.resize(N);
	foreach(i, line)cin>>i;
	sort(ALL(line));
	int lp = 0;
	int hp = N;
	while(lp<hp){
		int mid = (lp + hp) >> 1;
		if(check(mid)){
			hp = mid;
		}else{
			lp = mid + 1;
		}
	}
	cout << N - hp << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int n,m,x,y;
	int a,max=-100,min=100;
	scanf("%d %d %d %d",&n,&m,&x,&y);
	while(n){
		scanf("%d",&a);
		max=max<a?a:max;
		n--;
	}
	while(m){
		scanf("%d",&a);
		min=a<min?a:min;
		m--;
	}
	if(max<min){
		for(int i=max+1;i<=min;i++){
			if(x<i&&i<=y){n=1;}
		}
	}
	printf(n?"No War":"War");
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int count = 0, ans = 0;
    rep(i, s.length()) {
        if(s[i] == 'R') count++;
        else count = 0;
        ans = max(ans, count);
    }
    cout << ans << endl;
}


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

#define ll long long int
bool func(string s){
  string t(s.rbegin(), s.rend());
  if(s == t){
    return true;
  }
  return false;
}
 
int main(){
  string s;
  cin >> s;
  int n = s.size();
  string f = s.substr(0, ((n-1)/2));
  string e = s.substr(((n+3)/2)-1, n-1);
  if(func(s) && func(f) && func(e)){
    cout << "Yes";
  }else{
  	cout << "No";
  }
  
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        int n = int.Parse(ReadLine());

        foreach (int i in EnumerableCommon.Range(26))
        {
            if (i == 0) ;
            else if(n%4==0)
            {
                WriteLine("Yes");
                return;
            }
            else if(n%7==0)
            {
                WriteLine("Yes");
                return;
            }
            else if ((n - i * 4)>0&& (n - i * 4) % 7 == 0)
            {
                WriteLine("Yes");
                return;
            }
        }
        WriteLine("No");
    }
    public static partial class EnumerableCommon
    {
        public static IEnumerable<int> Range(int count)
        {
            return Enumerable.Range(0, count);
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	string t(s);
	reverse(begin(t),end(t));
	bool flag=true;
	rep(i,n){
		if(s[i]!=t[i]) flag=false;
	}
	string ns=s.substr(0,(n-1)/2);
	t=ns;
	reverse(begin(t),end(t));
	rep(i,ns.size()){
		if(ns[i]!=t[i]) flag=false;
	}
	ns=s.substr((n+3)/2-1);
	t=s;
	reverse(begin(t),end(t));
	rep(i,ns.size()){
		if(ns[i]!=t[i]) flag=false;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def main():
    n, m = map(int, input().split())
    s = [list(map(int, input().split()[1:])) for _ in range(m)]
    s_maps = [[0] * n for _ in range(m)]
    p = list(map(int, input().split()))
    for i in range(m):
        for j in s[i]:
            s_maps[i][j-1] = 1

    ans = 0
    for i in range(2**n):
        switch_str = format(i, '0{}b'.format(n))
        switch_state = list(map(int, list(switch_str)))
        flag = True
        for j, s_map in enumerate(s_maps):
            s_on = [i * j for i, j in zip(s_map, switch_state)]
            if sum(s_on) % 2 != p[j]:
                flag = False
                break
        if flag:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	const A = "AKIHABARA"
	// 'A'を挿入した時に"AKIHABARA"になる可能性のある文字列を全列挙する
	p := make(map[string]bool, 0)
	for bit := 0; bit < (1 << uint(len(A))); bit++ {
		t := ""
		for j := 0; j < len(A); j++ {
			// ビットjが立っていて、かつその文字が'A'の場合はスキップする
			if (bit&(1<<uint(j))) != 0 && A[j] == 'A' {
				continue
			} else { // それ以外は出力する
				t += string(A[j])
			}
		}
		p[t] = true
	}
	var S string
	fmt.Scan(&S)
	if p[S] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
     
    int main() 
    { 
         ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        ll n, a, b;
        ll s=0,q=0,p=0;
        cin>>n>>a>>b;
        
        cout<<n/(a+b)*a+min(n%(a+b),a);
    }

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

using namespace std;

int *a, *b, *c;
int *x, *y;
long long *dist;
vector<vector<pair<int, int> > > path;

void dfs(int n, int par, long long cost) {
  for (int i = 0; i < path[n].size(); i++) {
    int m = path[n][i].first;
    if (m == par) continue;
    dist[m] = cost + path[n][i].second;
    dfs(m, n, dist[m]);
  }
}

int main() {
  int N, Q, K;
  cin >> N;
  a = new int[N - 1];
  b = new int[N - 1];
  c = new int[N - 1];
  path.resize(N);

  for (int i = 0; i < N - 1; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    path[a[i]].push_back(make_pair(b[i], c[i]));
    path[b[i]].push_back(make_pair(a[i], c[i]));
  }

  cin >> Q >> K;
  K--;
  x = new int[Q];
  y = new int[Q];
  for (int i = 0; i < Q; i++) {
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
  }

  dist = new long long[N];
  dist[K] = 0;
  dfs(K, -1, 0);

  for (int i = 0; i < Q; i++) {
    cout << dist[x[i]] + dist[y[i]] << endl;
  }

  delete[] a;
  delete[] b;
  delete[] c;
  delete[] x;
  delete[] y;
  delete[] dist;

  return 0;
}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
vector <int> v;
vector <char> vc;
vector <string> vs;
map <string,int> sm;
map <int,int> mp;
map <char,int>cm;
//int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
//long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
//long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
//int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}

//int cnt =0;
//
//void SieveOfEratosthenes(int n)
//{
//   // v.push_back(1);
//
//    bool prime[n+1];
//    memset(prime, true, sizeof(prime));
//
//    for (int p=2; p*p<=n; p++)
//    {
//
//        if (prime[p] == true)
//        {
//
//            for (int i=p*p; i<=n; i += p)
//                prime[i] = false;
//        }
//    }
//
//
//    for (int p=2; p<=n; p++)
//       if (prime[p])
//          v.push_back(p);
//}
//
   

//int mod(string num, int a)
//{
//    // Initialize result
//    int res = 0;
//
//    // One by one process all digits of 'num'
//    for (int i = 0; i < num.length(); i++)
//         res = (res*10 + (int)num[i] - '0') %a;
//
//    return res;
//}

int main()
{
    int a,b,c=0,n,mn=0,mx=1000000000;
    string s,p;
    char ch;
    
    cin >> a >> b;
    
    
    n = b*2;
    
    if(n>=a)cout << 0 << endl;
    else cout << a-n << endl;
    
    
    
   
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <set> 
#include <iterator>
#include <bitset> 
#include <bits/stdc++.h> 
using namespace std;
typedef  long long int ll;
ll mod=1000000007;


int main() {
    int t=1;
    //cin>>t;
    while(t--)
    {   int n;
        cin>>n;
        ll a[n+1];
        for(int i=1;i<=n;i++)
            cin>>a[i];
        ll sum=0;
        for(int i=2;i<=n;i++)
        {   if(a[i-1]>a[i])
            {   sum=sum+a[i-1]-a[i];
                a[i]=a[i]+a[i-1]-a[i];
            }
        }
        cout<<sum;
            
            
    }
	return 0;
}


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

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

  int n, cnt=0;
  cin >> n;
  vi p(n);
  rep(i, n){
    cin >> p[i];
    if(p[i]!=i+1)cnt++;
  }

  printf(cnt==0||cnt==2 ? "YES\n" : "NO\n");

  return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int A, B, C, K;

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

    cin >> A >> B >> C >> K;

    int a1 = A*pow(2, K) + B + C;
    int a2 = B*pow(2, K) + A + C;
    int a3 = C*pow(2, K) + B + A;

    int ab = max(a1, a2);
    int abc = max(ab, a3);
    cout << abc << endl;
    return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,K;
	cin >> n >> K;
	vector<int> v(n+3),ret(n+3,INT_MAX);
	for (int i=0; i<n; ++i) cin >> v[i];
	ret[0]=0;
	for (int i=0; i<n; ++i){
		for (int k=1; k<=K; ++k) ret[i+k] = min(ret[i+k],abs(v[i]-v[i+k])+ret[i]);
	}
	cout << ret[n-1];
	return 0;
}

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

typedef pair<string, int> PAIR;

void fnInput(int& rnQtm, queue<PAIR>& rqPPrc)
{
  int nMaxProc;
  cin >> nMaxProc >> rnQtm;
  
  for (int i = 0; i < nMaxProc; i++)
  {
    string sPrcNam;
    int nPrcTim;
    cin >> sPrcNam >> nPrcTim;
    rqPPrc.push(PAIR(sPrcNam, nPrcTim));
  }
}

void fnSchedule(int nQtm, queue<PAIR>& rqPPrc)
{
  int nSumTim = 0;
  while (rqPPrc.size())
  {
    PAIR PProcess = rqPPrc.front(); rqPPrc.pop(); 
    if (PProcess.second > nQtm)
    {
      PProcess.second -= nQtm;
      rqPPrc.push(PProcess);
      nSumTim += nQtm;
    }
    else
    {
      nSumTim += PProcess.second;
      cout << PProcess.first << " " << nSumTim << endl;
    }
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int nQtm;
  queue<PAIR> qPPrc;
  
  fnInput(nQtm, qPPrc);
  fnSchedule(nQtm, qPPrc);

  return 0;
}



Measured memory_bytes: 6316
import sys

fin = sys.stdin.readline

N = int(fin())
sp = [fin().split() for i in range(N)]
sp = [(sp[i][0], int(sp[i][1]), i) for i in range(N)]

sp = sorted(sp, key=lambda x: x[1], reverse=True)
sp = sorted(sp, key=lambda x: x[0])

print(*[s[2]+1 for s in sp], sep="\n")

Measured memory_bytes: 38384
#include<stdio.h>
#include<string.h>

typedef struct Data{
  int area,pos;
} Data;

Data t[20000];

int u[20000];

int n,i;

char str[20001];

int T,U;

int ans,A;

Data B,X;

void D_push(Data data){
  t[T++]=data;
}

Data D_pop(){
  return t[--T];
}

void push(int x){
  u[U++]=x;
}

int pop(){
  return u[--U];
}


void init(){
  ans=T=U=0;
}

Data makeData(int x,int y){
  Data res;
  res.area=x;
  res.pos=y;
  return res;
}

int main(){
  init();
  scanf("%s",str);
  n=strlen(str);

  for(i=0;i<n;i++){

    if(str[i]=='/'){

      if(U==0)continue;
      A=pop();
      X=makeData(i-A,A);
      ans+=i-A;
      while(T>0){
  B=D_pop();
  if(B.pos<A){
    D_push(B);
    break;
  }
  X.area+=B.area;
  if(B.pos<X.pos)X.pos=B.pos;
      }
      D_push(X);
    }else if(str[i]=='\\'){
      push(i);
    }

  }

  printf("%d\n%d",ans,T);
  for(i=0;i<T;i++){
    printf(" %d",t[i].area);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<string.h>
#include<iostream>
using namespace std;
struct node {
	char s[101];
	int val,num;
}a[100];
bool cmp(node x, node y)
{
	if (strcmp(x.s, y.s) < 0 || (strcmp(x.s, y.s) == 0 && x.val > y.val))return 1;
	else return 0;
}
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%s", a[i].s,101);
		scanf("%d", &a[i].val);
		a[i].num = i;
	}
	sort(a+1, a+n + 1, cmp);
	for (int i = 1; i <= n; i++)
		printf("%d\n", a[i].num);
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#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;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<pii>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<string,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}

typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#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


int32_t main()
{
    fast;
    int n,m;cin>>n>>m;
    int ans=n*(n-1)/2+m*(m-1)/2;
    cout<<ans;
}

Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
    `(let ((it ,expr))
       ,then
       ,else))

(defun main (line)
  (if (= 3
         (length (remove-duplicates line)))
      "Three"
      "Four"))

(princ (main (read-times (read))))


Measured memory_bytes: 15928
import java.util.HashMap;
import java.util.Scanner;

class Main{

	static Scanner scanner = new Scanner(System.in);
	static HashMap<Integer, Integer> map;

	public static void main(String args[]){
		while(true){
			int n = scanner.nextInt();
			if(n == 0) break;
			map = new HashMap<Integer, Integer>();
			System.out.println(solve(n));
		}
	}

	static String solve(int n){
		int i = 0;
		Integer m;
		Integer num;
		String result = "NO COLOR";
		for(i = 0; i < n; i++){
			m = scanner.nextInt();
			num = map.get(m);
			if(num != null){
				num++;
				map.put(m, num);
				if(num > n/2) result = m + "";
			}else{
				map.put(m, 1);
				num = 1;
				if(num > n/2) result = m + "";
			}
			if(i % 300000 == 0) System.gc();
		}
		return result;
	}
}

Measured memory_bytes: 257340
import bisect
import heapq

N, M = map(int, input().split())
task = []
for i in range(N):
    a, b = map(int, input().split())
    task.append((a, b))

task.sort()

wa = []
ans = 0
j = 0
for i in range(M):
    while j < N and task[j][0] == i + 1:
        heapq.heappush(wa,-task[j][1])
        j += 1
    if wa:
        ans -= heapq.heappop(wa)

print(ans)


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

typedef long long LL;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e2 + 10;
double a[MAXN];

LL gcd(LL a, LL b)
{
	return b == 0 ? a : gcd(b, a % b);
}

LL qp(LL a, LL b)
{
	LL ans;
	for (ans = 1; b; b >>= 1, a = a * a % MOD)
		if (b & 1)
			ans = ans * a % MOD;
	return ans;
}

double avg(double a, double b)
{
	return (a + b) / 2;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	double ans = a[0];
	for (int i = 1; i < n; ++i)
	{
		//cout << ans << endl;
		ans = avg(ans, a[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int x,y,t;
int main()
{
    cin>>n;
    int px=0,py=0,pt=0;
    bool f=1;
    while(n--)
    {
        cin>>t>>x>>y;
        int d=abs(px-x)+abs(py-y);
        if(d>t-pt||d%2!=(t-pt)%2)
            f=0;
        px=x;
        py=y;
        pt=t;
    }
    cout<<(f?"Yes":"No")<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) cin >> P[i];
  
  int minimum = 1000000;
  int ans = 0;
  rep(i, N) {
    minimum = min(minimum, P[i]);
    if (minimum >= P[i]) ++ans;
  }
  
  cout << ans << endl;
  return 0;
}

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

int flags(int x){
    if(x<=1) return x;
    else if(x&1) return 1+flags(x/2);
    else return flags(x/2);
}

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<int>> choco(h+1,vector<int>(w+1));
    rp(i,h){
        rp(j,w){
            char ch;
            cin >> ch;
            choco.at(i+1).at(j+1)=ch-'0';
        }
    }
    int ans=1000000;
    rp(hcut,1<<(h-1)){
        vector<vector<int>> whitesum(12,vector<int>(1005,0));
        int ansctr=flags(hcut);
        rp(i,w){
            int hctr=0;
            rp(j,h){
                if(choco[j+1][i+1]==1)
                 whitesum[hctr][i+1]++;
                if(j<h-1){
                    if((hcut>>j)%2==1){
                        whitesum[hctr][i+1]+=whitesum[hctr][i];
                        hctr++;
                    }
                }
                if(j==h-1) whitesum[hctr][i+1]+=whitesum[hctr][i];
            }
        }
        int lastcut=0;
        bool out=false;
        for(int j=1; j<=w; j++){
            for(int i=0; i<=flags(hcut); i++){
                if(whitesum[i][j]-whitesum[i][lastcut]>k){
                    if(j-lastcut==1){
                        out=true; break;
                    }
                    lastcut=j-1; ansctr++; break;
                }
            }
            if(out) break;
        }
        if(!out) ans=min(ans,ansctr);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n; cin >> n;
  vector<int> p(n), q(n);
  rep(i, n) {
    cin >> p[i];
    q[p[i] - 1] = i;
  }

  int maxv = 1, t = 1;
  for (int i = 1; i < n; i ++) {
    if (q[i - 1] < q[i]) t ++;
    else {
      maxv = max(maxv, t);
      t = 1;
    }
  }
  maxv = max(maxv, t);

  cout << n - maxv << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;


ll myLcm(int a, int b){
    ll r = -1;
    while(r%a != 0 || r%b != 0){
        if(r < 0) r =0;        
        r += a;
        // printf("%lld %lld\n", r%a, r%b);
        // printf("TESTE\n");
    }    
    return r;
}

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

    int min = std::min(a,b);
    int max = std::max(a,b);

    cout <<  myLcm(min,max) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

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 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(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int INF = 1001001001;

vector< pair<ll, ll> > prime_factorize(ll N) {
    vector< pair<ll, ll> > res;

    for (ll a=2; a*a <= N; ++a) {
        if (N % a != 0) continue;

        ll e = 0;
        while (N % a == 0) {
            ++e;
            N /= a;
        }

        res.emplace_back(a, e);
    }

    if (N != 1) res.emplace_back(N, 1);

    return res;
}

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

    const auto pf = prime_factorize(N);
    ll ans = 0;
    for (auto p : pf) {
        ll e = p.second;
        ll cur = 1;
        while (e >= cur) {
            e -= cur++;
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    if(n == 1) {
        print(a == b);
    } else {
        print(max((b - a) * (n - 2) + 1, 0LL));
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def exist_or_not(list, value):
  for i in range(len(list)):
    if list[i] < value:
      continue
    elif list[i] == value:
      return i
    else:
      break
  return -1

n = int(input())
a = [0] * 100001
numbers = input().split(" ")
sum = 0
for x in numbers:
  int_x = int(x)
  a[int_x] += 1
  sum += int_x

q = int(input())

r = []
b = []
c = []



for i in range(q):
  numbers = input().split(" ")
  b.append(int(numbers[0]))
  c.append(int(numbers[1]))

for i in range(q):
  b_count = a[b[i]]
  a[c[i]] += b_count
  a[b[i]] = 0
  sum += (c[i] - b[i]) * b_count
  print(sum)


Measured memory_bytes: 18884
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;


public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        List<List<Integer>> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(new ArrayList<>());
            for (int j = 0; j < d; j++) {
                list.get(i).add(sc.nextInt());
            }
        }
        int count = 0;
        for (int i = 0; i < list.size() - 1; i++) {
            for (int j = i + 1; j < list.size(); j++) {
                int a = 0;
                for (int k = 0; k < list.get(i).size(); k++) {
                    a += Math.pow(list.get(i).get(k) - list.get(j).get(k), 2);
                }
                if (Math.sqrt(a) == (int) Math.sqrt(a)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }


    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

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

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }


        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 23252