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

using namespace std;

int main()
{
	string S;
	cin>> S;
	bool s[3]={false};
	string ret="Yes";
	for(int i=0;i<3;i++)
	{
		if(s[S[i]-'a'])
		{
			ret="No";
			break;
		}
		else s[S[i]-'a']=true;
	}
	cout<< ret<< endl;

	return 0;
}


Measured memory_bytes: 764
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int N = 104, W = (int)1e5 + 10;
ll dp[W], val[N], w[N]; // dp[w] := max value possible of knapsack with weight atmost w till some iteration
int n, cap;

void solve() {
   dp[0] = 0;

   for (int i = 1; i <= n; ++i) {
      for (int j = cap; j >= 1; --j) {
         if (j >= w[i]) dp[j] = max(dp[j], dp[j-w[i]] + val[i]);
      }
   }

   cout << dp[cap] << "\n";
}

signed main() {
   IOS; PREC;
   cin >> n >> cap;
   for (int i = 1; i <= n; ++i) cin >> w[i] >> val[i];
   solve();

   return EXIT_SUCCESS;
}


Measured memory_bytes: 1024
N,M=map(int, input().split())
PY=[tuple(map(int, input().split()))for _ in range(M)]
ans=[None]*M
I=sorted(range(M),key=lambda i: PY[i][1])
C=[0]*(N+1)
for i in I:
    p=PY[i][0]
    C[p]+=1
    ans[i]=(p,C[p])
def f(x):
    s=str(x)
    return "0"*(6-len(s))+s
for p,c in ans:
    print(f(p)+f(c))

Measured memory_bytes: 32892
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <bitset>
#define SIZE 200000

typedef long long ll;
using namespace std;

int main(){
    ll A,B,V,W,T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    if(B < A){
        if( B - W*T >= A - V*T){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }else if(A < B){
        if(A+ V*T >= B + W*T){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] D = new int[N+1];
        int X = sc.nextInt();

        D[0] = 0;

        for (int i = 0; i < N; i++) {
            int Li = sc.nextInt();
            D[i + 1] = D[i] + Li;
        }

        int cnt = 0;

        for (int d : D) {
            if (d <= X)
                cnt++;
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	/** 一行で最大拾うアイテム数+1 */
	private static final int MAX = 4;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int r = scanner.nextInt(), c = scanner.nextInt(), k = scanner.nextInt();
			long[][] v = new long[r][c];
			IntStream.range(0, r).forEach(i -> Arrays.fill(v[i], 0L));
			IntStream.range(0, k).forEach(i -> v[scanner.nextInt() - 1][scanner.nextInt() - 1] = scanner.nextLong());
			long[][][] dp = new long[MAX][r][c];
			dp[0][0][0] = 0L;
			dp[1][0][0] = v[0][0];
			IntStream.range(0, r).forEach(i -> IntStream.range(0, c).forEach(j -> {
				if (i > 0) {
					dp[0][i][j] = max(dp[0][i][j],
							IntStream.range(0, MAX).mapToLong(l -> dp[l][i - 1][j]).max().getAsLong());
					if (v[i][j] > 0) {
						dp[1][i][j] = max(dp[1][i][j],
								IntStream.range(0, MAX).mapToLong(l -> dp[l][i - 1][j]).max().getAsLong() + v[i][j]);
					}
				}
				if (j > 0) {
					if (v[i][j] > 0) {
						IntStream.range(1, MAX).forEach(
								l -> dp[l][i][j] = max(dp[l][i][j], dp[l - 1][i][j - 1] + v[i][j], dp[l][i][j - 1]));
					} else {
						IntStream.range(0, MAX).forEach(l -> dp[l][i][j] = max(dp[l][i][j], dp[l][i][j - 1]));
					}
				}
			}));
			System.out.println(IntStream.range(0, MAX).mapToLong(l -> dp[l][r - 1][c - 1]).max().getAsLong());
		}
	}

	/**
	 * 複数のlongのmaxを取得する
	 * 
	 * @param a 一つ目のlong
	 * @param b 二つ目以降のlong
	 * @return 複数のlongのmax
	 */
	private static long max(long a, long... b) {
		long result = a;
		for (long l : b) {
			result = Math.max(result, l);
		}
		return result;
	}
}


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

int main(){

	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if (x < 0 || y < 0 || x + r > W || y + r > H || x - r < 0 || y - r < 0){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
	
}


Measured memory_bytes: 3120
#include<string.h>
#include<stdio.h>
int a[200005],b[200005];
int main(){
	int n,i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if(n%2==0){
		int head=1,e=0,mid=(n+1)/2;
		while(mid-e>0&&mid+1+e<=n){
			b[mid+1+e]=a[head];
			b[mid-e]=a[head+1];
			e++;head+=2;
		}
	}
	else{
		int mid=(n+1)/2,head=1,e=0;
		while(mid-e>0&&mid+1+e<=n){
			b[mid-e]=a[head];
			b[mid+1+e]=a[head+1];
			head+=2;e++;
		}
		b[1]=a[n];
	}
	printf("%d",b[1]);
	for(i=2;i<=n;i++)
		printf(" %d",b[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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;}


int main() {
    ll X, Y;
    cin >> X >> Y;
    if (abs(X-Y) <= 1) {
        cout << "Brown\n";
    } else {
        cout << "Alice\n";
    }






}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){
  int N, M; cin >> N >> M;
  string S; cin >> S;

  int cnt = 0; bool flag = true;
  for (int i = 0; i < S.length(); i++){
    if (S[i] == '0'){
      if (cnt >= M){
        flag = false;
      }
      cnt = 0;
    }else{
      cnt++;
    }
  }
  if (cnt >= M) flag = false;

  if (flag == true){
    vector <int> ans;
    for (int i = S.length() - 1; i >= 0; i--){
      
      for (int j = M; j >= 1; j--){
        if (i - j >= 0){
          if (S[i - j] == '0'){
            ans.push_back(j);
            i = i - j + 1;
            break;
          }
        }
      }
    }
    
    for (int i = ans.size() - 1; i >= 0; i--){
      cout << ans[i];
      if (i != 0) cout << " ";
    }
    cout << endl;
    
  }else{
    cout << -1 << endl;
  }
  

  return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP)
 { return firstP.first < secondP.first; }//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

ll n,a,b;
vi v;

string s;

bool ck(char c){
	if(c=='A')return true;
	if(c=='C')return true;
	if(c=='G')return true;
	if(c=='T')return true;
	else return false;
}

int main(){
	cin>>s;
	ll ans =0;
	ll tmp = 0;
	rep(i,s.size()){
		if(ck(s[i])){
			tmp = 0;
			for(int j = i;j<s.size();j++){
				if(ck(s[j]))tmp++;
				else break;
			}
			chmax(ans,tmp);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
//
// Created on 2020/01/13.
//

//
// Created on 2020/01/12.
//

#include <istream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;

const int MAX = 510000;//nCkのn,kの取りうるMAX
const int MOD = 1000000007;

long long fac[MAX],finv[MAX],inv[MAX];

//階乗のテーブルを作る
void COM_initialize(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2 ; i < MAX ; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD -inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

//二項係数計算,nCkのn,kを引数として渡す
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD)% MOD;
}
int main() {

    int n;
    int k;
    cin>>n>>k;
    vector<ll>A_array(n);
    for (int i = 0; i < n; ++i) {
        cin>>A_array[i];
    }
    sort(all(A_array));

    COM_initialize();
    ll sum_max = 0;
    for (int j = 0; j < n; ++j) {
        sum_max += COM(j,k-1)*A_array[j]%MOD;
    }

    ll sum_min = 0;
    reverse(all(A_array));
    for (int j = 0; j < n; ++j) {
        sum_min += COM(j,k-1)*A_array[j]%MOD;
    }

    ll ans;
    ans = sum_max  - sum_min;
    cout<<ans%MOD<<endl;
}


Measured memory_bytes: 12928
//Krzysztof Boryczka
#pragma GCC optimize "O3"
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e) for(int i=b; i<=e; i++)
#define FORD(i, b, e) for(int i=b; i>=e; i--)
#define SIZE(x) ((int)x.size())
#define pb push_back
#define st first
#define nd second
#define sp ' '
#define ent '\n'

const int mod=1e9+7;
const int M=61;

int ile[M+1][2];
int n, ans;
ll a;

void dodaj(ll v){
	FOR(i, 0, M){
		ile[i][v&1]++;
		v>>=1;
	}
}

void oblicz(ll v){
	FOR(i, 0, M){
		ans=(ans+(ll)ile[i][(v&1)^1]*((1ll<<i)%mod))%mod;
		v>>=1;
	}
}

void solve(){
	cin>>n;
	FOR(i, 1, n){
		cin>>a;
		oblicz(a);
		dodaj(a);
	}
	cout<<ans<<ent;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// int tt; cin>>tt;
	// FOR(te, 1, tt)
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    string n;
    cin >> n;
    if(n == "RRS"||n == "SRR")cout << 2 << endl;
    else if(n == "RRR")cout << 3 << endl;
    else if(n == "SSS")cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3636
import std.stdio;
import std.algorithm;
void main(){
	int[] n;
	n.length = 10;
	for(int i;i<10;i++)
		readf("%d\n", &n[i]);
	foreach(int i;sort!((int a, int b){return a > b;})(n)[0..3])
		writeln(i);
}

Measured memory_bytes: 992
N,M,C = map(int,input().split())
list_1 = list(map(int,input().split()))
list_2 = [list(map(int,input().split())) for i in range(N)]
cnt =0

for i in range(N):
    siki = sum([ list_1[m]*list_2[i][m] for m in range(M)])+C
    if siki >0:
        cnt +=1
print(cnt)

Measured memory_bytes: 3064
import itertools
s = input()

# 1, 2, 3, 4, 5, 6, 7, 8, 9, 9
#   0  1  0  0  0  1  0  0  0
# len(s) - 1
ans = 0
for p in itertools.product([0, 1], repeat=len(s) - 1):
    div = int(s[0])
    for idx, flg in enumerate(p, 1):
        if flg == 0:
            div *= 10
            div += int(s[idx])
        else:
            ans += div
            div = 0
            div += int(s[idx])
    ans += div
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);

    if(a==b && b==c && a%2==0) {
        printf("-1\n"); return 0;
    }

    int i;
    for(i=0; i<10000; i++) {
        if(a%2 || b%2 || c%2) {
            printf("%d\n", i); return 0;
        }
        int a2=b/2+c/2;
        int b2=a/2+c/2;
        int c2=a/2+b/2;
        a=a2, b=b2, c=c2;
    }
    printf("-1\n"); 

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cout<<read<int>()*read<int>()<<endl; 
    return 0;
}


Measured memory_bytes: 3652
function Main(input) {
  var array = input.split('\n');
  var limit = array[5];
  var max = array[4];
  var min = array[0];
  var maxDistance = max - min;
  if(maxDistance > limit) {
    console.log(':(');
  } else {
    console.log('Yay!');
  }
}

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

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

int main(){
    int n;
    cin >> n;
    vector<bool> a(INF,false);

    int b;

    rep(i,n){
        cin >> b;
        b--;
        if(a[b]){
            cout << "NO" << endl;
            return 0;
        }
        a[b] = true;
    }
    cout << "YES" << endl;

}

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

int n, a[110] , i, j, k;

void insertsort() {
	for (i = 1; i<n; i++) {
		int key = a[i];
		j = i - 1;
		while (j>=0 && a[j]>key) {
			a[j+1]=a[j];
			j--;
			}
		a[++j]=key;

		for (k = 0; k < n; k++) {
			if (k == n - 1) { cout << a[k] << endl;
			}
		else cout << a[k] << " ";
		}
	}
}

int main(){
	cin >> n;
	for (i = 0; i < n; i++)	cin >> a[i];
	for (k=0; k<n; k++) {
		if (k == n - 1) { cout << a[k] << endl; }
		else cout << a[k] << " ";
	}
	insertsort();

return 0;
}

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

int mtoi(const string& str)
{
	int res = 0,temp = 1;
	for (int j = 0; j < str.length(); j++) {
		if(str[j] >= '0' && str[j] <= '9')
			temp = (int)(str[j] - '0');
		else if (str[j] == 'i') {
			res += temp;
			temp = 1;
		}
		else if (str[j] == 'x') {
			res += temp * 10;
			temp = 1;
		}
		else if (str[j] == 'c') {
			res += temp * 100;
			temp = 1;
		}
		else if (str[j] == 'm') {
			res += temp * 1000;
			temp = 1;
		}
	}
	return res;
}

int main()
{
	int n,res;
	string a,b;
	char ch;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		res = mtoi(a) + mtoi(b);
		if (res / 1000) {
			if (res / 1000 != 1) {
				cout << res / 1000;
			}
			cout << 'm';
			res -= res / 1000 * 1000;
		}
		if (res / 100) {
			if (res / 100 != 1) {
				cout << res / 100;
			}
			cout << 'c';
			res -= res / 100 * 100;
		}
		if (res / 10) {
			if (res / 10 != 1) {
				cout << res / 10;
			}
			cout << 'x';
			res -= res / 10 * 10;
		}
		if (res) {
			if (res != 1) {
				cout << res;
			}
			cout << 'i';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#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 F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, m, a[101][101], b[101][101];
bool d1[81][81][30001];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> m;
   for (int i = 1; i <= n; i ++)
      for (int j = 1; j <= m; j ++)
         cin >> a[i][j], d1[i][j][0] = mod;
   for (int i = 1; i <= n; i ++)
      for (int j = 1; j <= m; j ++)
         cin >> b[i][j], d1[i][j][1] = mod;
   int S = abs (a[1][1] - b[1][1]);
   d1[1][1][15000 + S] = d1[1][1][15000 - S] = 1;
   for (int x = 1; x <= n; x ++) {
      for (int y = 1; y <= m; y ++) {
         for (int has = 0; has <= 30000; has ++) {
            if (!d1[x][y][has]) continue;
            for (int i = 1; i <= 2; i ++) {
               int new_x = x + dx[i], new_y = y + dy[i];
               if (new_x < 1 || new_y < 1 || new_x > n || new_y > m) continue;
               int S = a[new_x][new_y] - b[new_x][new_y];
               d1[new_x][new_y][has + S] = d1[new_x][new_y][has - S] = 1;
            }
         }
      }
   }
   int ans = mod;
   for (int i = 0; i <= 30000; i ++)
      if (d1[n][m][i])
         ans = min (ans, abs (15000 - i));
   cout << ans;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 190464
s = input()
x = [s[j] for j in range(0,len(s))]
x.insert(0,'2')
count = 0
for j in range(1,len(x)):
    if x[j] == '0' and x[j] == x[j-1]:
        x[j] = '1'
        count = count + 1
    elif x[j] == '1' and x[j] == x[j-1]:
        x[j] = '0' 
        count = count + 1
print(count)


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

int bubbleSort(int A[], int N) {
	int j, flag, counter;
	counter = 0;
	flag = 1;
	while (flag > 0) {
		flag = 0;
		for ( j = N - 1; j > 0; j--) {
			if (A[j] < A[j-1]) {
				int tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
				flag = 1;
				counter++;
			}	
		}
	}

	return counter;
}

int main() {
	int N,  d, A[100];
	
	cin >> N;
	for ( int i = 0; i < N; i++) scanf("%d", &A[i]);
	
	d = bubbleSort(A, N);
		
	for ( int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	
	cout << endl;
	cout << d << endl;
	
	return 0;
}


Measured memory_bytes: 3240
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
long long sum=0;
int n=0;
string S,s;
int djs(int x,long long y,long long all)
{
    if(x==n)
    {
        sum+=(all+y);
        return 0;
    }
    else
    {
        djs(x+1,(S[x]-'0'),all+y);
        djs(x+1,y*10+(S[x]-'0'),all);
    }
}
int main()
{
    while(cin>>S)
    {
        sum=0;
        n=0;
        while(S[n++]);
        n--;
        djs(0,0,0);
        cout<<sum/2;
    }
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._
  val Array(n, l) = readLine.trim.split(' ').map(_.toInt)
  val pawns = Array.fill(n){
    readLine.trim.split(' ').map(_.toInt) match {
      case Array(pos, 0) ⇒ Left(pos)
      case Array(pos, 1) ⇒ Right(pos)
    }
  }.sortBy(_.position)
  var currentScore = 0L
  val forward = Array.fill(n){0L}
  for (i ← pawns.indices) {
    pawns(i) match {
      case Left(pos) ⇒
        currentScore += pos - i - 1
      case Right(pos) ⇒
        currentScore += i - pos + 1
    }
    forward(i) = currentScore
  }
  currentScore = 0L
  val backward = Array.fill(n){0L}
  for (i ← pawns.indices.reverse) {
    pawns(i) match {
      case Left(pos) ⇒
        currentScore += pos - (l - (n - i - 1))
      case Right(pos) ⇒
        currentScore += (l - (n - i - 1)) - pos
    }
    backward(i) = currentScore
  }
  var min = math.max(forward.last, backward.head)
  for (i ← pawns.indices.tail) {
    min = math.max(min, forward(i - 1) + backward(i))
  }
  println(min)
  sealed class Pawn(val position: Int)
  case class Left(override val position: Int) extends Pawn(position)
  case class Right(override val position: Int) extends Pawn(position)
}



Measured memory_bytes: 173924
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            for(int i=1;i<=h;i++){
                for(int j=1;j<=w;j++){
                    System.out.printf("#");
                }
            System.out.printf("\n");
            }
        System.out.println();
        }
    }
}


Measured memory_bytes: 58720
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string s;
  cin>>s;
  char a=s[5];
  char b = s[6];
  DUMP(a,b);
  if(b<='4' && a=='0'){
    cout<<"Heisei";
    return 0;
  }
  cout<<"TBD";

  return 0;
}


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

int main(){
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0 ; i<n ; i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    
    for(int i=1 ; i<n ; i++){
        a[i][0]+=max(a[i-1][1],a[i-1][2]);
        a[i][1]+=max(a[i-1][2],a[i-1][0]);
        a[i][2]+=max(a[i-1][1],a[i-1][0]);
    }
    cout<<max(a[n-1][0],max(a[n-1][1],a[n-1][2]))<<endl;
    return 0;
}

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


#define ll long long
#define pb push_back

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

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

const int mod = 1e9+7;
const ll inf = 2e18+5;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    ll h,n;
    ll value,cost;
    cin>>h>>n;
    vl dp(h+1,inf);
    // dp[x] = minimum cost to get value x
    dp[0] = 0;
    
    while(n--){
        cin >> value >> cost;
        loop(i,0,h+1){
            //dp[i] --> dp[i+value]
            ll j = min(h,i+value);
            dp[j] = min(dp[j],dp[i]+cost);
        }
    }
    cout<<dp[h]<<endl;

    return 0;
}   

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int SIZE = 1e5+9;

int n;
ll a[SIZE];
ll m[SIZE];
ll sum;

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    sum /= 2;

    m[0] = sum;
    for(int i = 1; i < n; i += 2) {
        m[0] -= a[i];
    }

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

    for(int i = 0; i < n; i++) {
        cout << 2 * m[i];
        cout << (i == n-1 ? "\n" : " ");
    }


}

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

int main() {
  int n,k;
  cin>>n>>k;
  ll ans=1;
  ans=k*pow(k-1,n-1);
  cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt(), x = sc.nextInt() - 1, y = sc.nextInt() - 1;
        int ans[] = new int[n-1];
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++) {
                int dist = j - i;
                dist = Math.min(dist, Math.abs(i - x) + Math.abs(j - y) + 1);
                dist = Math.min(dist, Math.abs(j - x) + Math.abs(i - y) + 1);
                ans[dist-1] ++;
            }
        for (int cnt : ans)
            out.println(cnt);
        out.flush();
        out.close();
    }


    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        boolean ready() throws IOException {
            return br.ready();
        }

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

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

        int nextChar() throws IOException {
            return next().charAt(0);
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

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

    }
}


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

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

    string buffer;
    vector<int> output;
    int i = 0;
    while (1) {
        while (S[i] != 'L' && i != S.length()) {
            buffer += S[i];
            i++;
        }
        while (S[i] != 'R' && i != S.length()) {
            buffer += S[i];
            i++;
        }
        int count = 0;
        for (int i = 0; i < buffer.length(); i++) {
            if (buffer[i] == 'R') {
                count++;
            }
        }
        int right = 0;
        int left = 0;
        right += count / 2;
        right += (buffer.length() - count + 1) / 2;
        left = buffer.length() - right;
        for (int i = 0; i < count - 1; i++) {
            output.push_back(0);
        }
        output.push_back(left);
        output.push_back(right);
        for (int i = 0; i < buffer.length() - count - 1; i++) {
            output.push_back(0);
        }
        /**/
        buffer = "";
        if (i == S.length()) {
            break;
        }
    }

    for (int i = 0; i < output.size(); i++) {
        printf("%d ", output[i]);
    }
    printf("\n");

    return 0;
}


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

int main()
{
    int H, W;
    
    for (int i = 0; ; i++) {
        scanf("%d %d", &H, &W);
        if (H == 0 and W == 0) break;
        
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((i + j)%2 == 0) putchar('#');
                else putchar('.');
            }
            putchar('\n');
        }
        putchar('\n');
    }
}



Measured memory_bytes: 3176
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
typedef long long ll;
const ll MOD = 1e9+7;
int main(int argc,char **argv){
    (void)argc;
    (void)argv;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k;
    cin >> k;
    rep(i,0,k){
        cout<<"ACL";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3536
import sys

def solve():
    S = input()
    ans = 0
    OK = set(["A", "G", "C", "T"])
    for i in range(len(S)):
        for j in range(i + 1, len(S) + 1):
            temp = 0
            for k in range(i, j):
                if S[k] in OK: temp += 1
                else: break
            else:
                ans = max(ans, temp)
    print(ans)
            
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
a, b, c = map(int, input().split())
count=0
while a%2==0 and b%2==0 and c%2==0:
  ah=a//2
  bh=b//2
  ch=c//2
  a=bh+ch
  b=ch+ah
  c=ah+bh
  if a==b and a==c and a%2==0:
    count=-1
    break
  else:
    count+=1
print(count)

Measured memory_bytes: 3064
using namespace std;
#include <bits/stdc++.h>
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-b)<=d){
        if(abs(b-c)<=d){
            std::cout << "Yes" << std::endl;
        }
        else{
            std::cout << "No" << std::endl;
        }
    }
    else if(abs(a-c)<=d){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<set<int> > graph(N);
	for (int i = 0; i < M; ++i)
	{
		int A, B;
		cin >> A >> B;
		--A, --B;
		graph[A].insert(B);
		graph[B].insert(A);
	}

	vi group(N,-1);
	map<int, int> population;
	int iGroup = 0;
	for (int i = 0; i < N; ++i)
	{
		if (group[i] > -1)
			continue;
		int ct = 0;
		queue<int> qu;
		group[i] = iGroup;
		qu.push(i);
		++ct;
		while (!qu.empty())
		{
			int base = qu.front();
			qu.pop();
			for (auto& x : graph[base])
			{
				if (group[x] > -1)
					continue;
				group[x] = iGroup;
				qu.push(x);
				++ct;
			}

		}
		population.insert({ iGroup, ct });
		++iGroup;
	}
	int maxCt = 0;
	for (auto& x : population)
		maxCt = max(maxCt, x.second);
	cout << maxCt << endl;
	return 0;
}

Measured memory_bytes: 32476
#include<iostream>
#include<vector>

using namespace std;

int main(void)
{
  int n; cin>>n;
  vector<int> a(n);
  int c=0;
  
  for(int i=0;i<n;i++){
    cin>>a[i];
    if((i%2==0)&&((a[i]+1)%2==0)){c++;}
  }
  
  cout<<c<<endl;
  
  return 0;
}

Measured memory_bytes: 3520
n,k=map(int,input().split())
d=[]
a=[]
b=0
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))




import itertools



c=list(itertools.chain.from_iterable(a))
for i in range(1,n+1):
    if c.count(i)==0:
        b+=1
print(b)




Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

const int limit = 50;
vint a[limit],b[limit];
bool graph[limit][limit];
bool visited[limit];

int main(){
  int n,k;
  cin >> n >> k;
  map<int,int> count;
  rep(i,n){
    int a;
    cin >> a;
    count[a]++;
  }
  vint ans(0);
  for(auto p:count){
    auto key = p.first;
    auto value = p.second;

    ans.push_back(value);
  }
  sort(ans.begin(),ans.end());
  int ANS = 0;
  if(ans.size()>=k){
    rep(i,ans.size()-k){
      ANS += ans[i];
    }
  }
  cout << ANS << endl;
}

Measured memory_bytes: 10748
#include <iostream>
#include <string>
#include <cstdint>

using namespace std;

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

	int n = num.size(), m = n - 1;
	int64_t chr[10];
	for (int i=0 ; i<n ; i++)
	{
		chr[i] = num[i]-'0';
	}

	int64_t sum = 0;
	for (int i=1<<m ; i>0 ; )
	{
		i--;

		int64_t acc = chr[0];
		for (int j=0 ; j<m ; j++)
		{
			if ((i>>j)&1)
			{
				sum += acc;
				acc = chr[j+1];
			}
			else
			{
				acc *= 10;
				acc += chr[j+1];
			}
		}
		sum += acc;
	}

	cout << sum << "\n";
}


Measured memory_bytes: 256
//    ABC073A.C

#include<stdio.h>


int main(void){
    
    int n, i, f = 0;

    scanf("%d", &n);
    while( 1 ) {
        if ( n == 0) break;
        if (n % 10 == 9) {
            f = 1;
            break;
        }
        n /= 10;
    }
    if (f == 1) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <iomanip>
#include <vector>

using namespace std;



int two;
int five;

void two_five(int i)
{
	//cout << "i = " << i << endl;
	if (i % 2 == 0 && i > 0)
	{
		two++;
		two_five(i / 2);
	} else if (i % 5 == 0 && i > 0) {
		five++;
		two_five(i / 5);
	}
}

int main()
{
	int n;
	
	while (cin >> n)
	{
		if (n == 0) break;
		two = five = 0;
		for (int i=n; i>=1; i--)
		{
			two_five(i);
		}
		cout << min(two, five) << endl;
	}
	
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    map<long, int> mp;
    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for (auto x : mp) {
        if (x.second % 2 != 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6528
<?php
// Your code here!
fscanf(STDIN,"%d %d %d",$a,$b,$k);

if($a + $b <= $k){
    echo "0 0";
    exit();
}

if($a - $k < 0){
    echo '0',' ',$b - ($k - $a);
}else{
    echo $a - $k, ' ',$b;
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin>>N;
  va.resize(N);
  rep(i,0,N-1){
    cin>>va[i];
  }
  ;
}
void solve() {
  // GCD?
  int ans = va[0];
  for(auto x : va){
    ans = __gcd(ans,x);
  }
  ;
  cout<<ans<<endl;
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

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

const int MOD = 1e9 + 7;

template < typename T >
void printVector (const vector < T > & vec) {
	for (const T x : vec) {
		cout << x << " ";
	}
	cout << endl;
}

template < typename T >
void printMatrix (const vector < vector < T > > & mat) {
	for (const vector < T > vec : mat) {
		printVector (vec);
	}
	cout << endl;
}

const ll INF = 1e18L + 5;

template < typename T >
void min_self (T& a, T b) {
	a = min (a, b);
}

template < typename T >
void max_self (T& a, T b) {
	a = max (a, b);
}

template < typename T >
void add_self (T & a, T b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

template < typename T >
void sub_self (T & a, T b) {
	a -= b;
	if (a < 0) {
		a += MOD;
	}
}

ll mul (int a, int b) {
	return ((ll) a * b) % MOD;
}

const int mx = 1e5 + 5;
vector < int > g[mx];

pair < int, int > dfs (int root, int parent) {
	int white = 1, black = 1;
	for (int u : g[root]) {
		if (u != parent) {
			pair  < int, int > p = dfs (u, root);
			white = mul (white, p.first + p.second);
			black = mul (black, p.first);
		}
	}
	return make_pair (white, black);
}

int main() {
	int n, a, b;
	scanf ("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf ("%d%d", &a, &b);
		g[a].push_back (b);
		g[b].push_back (a);
	}
	pair < int, int > ans = dfs (1, -1);
	add_self (ans.first, ans.second);
	printf ("%d\n",ans.first);
	return 0;
}



Measured memory_bytes: 12672
#include <iostream>

#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;

int main() {
    int x, a;
    cin >> x >> a;

    if (x < a) {
        cout << 0 << endl;
    } else if (x >= a) {
        cout << 10 << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int countChange(char cmpChar[], string orgStr){

    int cnt = 0;
    for(int i=0; i<orgStr.length(); i++){
        if(i%2 == 0){
            if(cmpChar[0] != orgStr[i]) cnt++;
        }else{
            if(cmpChar[1] != orgStr[i]) cnt++;
        }
    }
    return cnt;
}

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

    char cmpChar1[] = {'1','0'};
    char cmpChar2[] = {'0','1'};
    int cnt = min(countChange(cmpChar1, s),countChange(cmpChar2, s));

    cout << cnt << endl;
    return 0;
}

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

int main()
{
    int A,B;
    cin >> A >> B;
    int plugTotal = 0;
    int plugCount = 1;
    while(plugCount < B){
        plugCount--;
        plugCount += A;
        plugTotal ++;


        }
    cout << plugTotal << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{   int n,m,s; 
    scanf("%d%d",&n,&m);
		s=n-2*m;
		if(s>0)
		printf("%d\n",s);
		else
		printf("0\n");
} 

Measured memory_bytes: 128
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

sx, sy, tx,ty = getList()
xdis = tx-sx
ydis = ty-sy

move = []
move = move + ["R"] * xdis
move = move + ["U"] * ydis
move = move + ["L"] * xdis
move = move + ["D"] * ydis
move = move + ["D"]
move = move + ["R"] * (xdis+1)
move = move + ["U"] * (ydis+1)
move = move + ["L"]
move = move + ["U"]
move = move + ["L"] * (xdis+1)
move = move + ["D"] * (ydis+1)
move = move + ["R"]

print("".join(move))

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int a,b,c;
    cin>>b>>a>>c;
    cout<<min(a/b,c)<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <iomanip>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

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

    vector<vector<int>> v(N);
    vector<int> H(N);

    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }
    for(int i = 0; i < M; i++) {
        int tmp_1, tmp_2;
        cin >> tmp_1 >> tmp_2;

        v[tmp_1-1].push_back(tmp_2-1);
        v[tmp_2-1].push_back(tmp_1-1);
    }

    int ret = 0;
    bool top = false;
    for(int i = 0; i < N; i++) {
        top = true;
        // cout << i << ":" ;
        for(int j = 0; j < v[i].size(); j++) {
            if(H[i] <= H[v[i][j]]) {
                // cout << j << " is higher";
                top = false;
                break;
            }
        }
        // cout << endl;
        if(top == true) ret++;
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 8804
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

A,B,C,K = gets_i_list

if A >= K
  puts K
elsif A + B >= K
  puts A
else
  c = K - A - B
  puts A - c
end


Measured memory_bytes: 14492
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
  int n, cnt;
  ll ans = 0LL;
  map<pair<int, int>, ll> g;
  ll x;
  string s, t;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cnt = 0;
    cin >> s;
    t = "";
    int y = -1;
    x = 0;
    for (int j = 0; j < s.length(); j++) {
      if (s[j] == '.') {
        s += "000000000";
        break;
      }
      if (j == s.length() - 1) {
        s += ".000000000";
      }
    }
    for (int j = 0; j < s.length(); j++) {
      if (s[j] == '.') {
        y = 1;
      } else {
        x *= 10LL;
        x += s[j] - '0';
        if (y == 1) {
          cnt++;
          if (cnt == 9) {
            break;
          }
        }
      }
    }
    int a = 0, b = 0;
    while (x % 2 == 0) {
      a++;
      x /= 2LL;
    }
    while (x % 5 == 0) {
      b++;
      x /= 5LL;
    }
    g[{min(a - cnt, 20), min(b - cnt, 20)}]++;
  }
  for (int i = -10; i <= 20; i++) {
    for (int j = -10; j <= 20; j++) {
      for (int k = -10; k <= 20; k++) {
        for (int l = -10; l <= 20; l++) {
          if (g[{i, j}] && g[{k, l}] && i + k >= 0 && j + l >= 0) {
            ans += g[{i, j}] * g[{k, l}];
            if (i == k && j == l) {
              ans -= g[{i, j}];
            }
          }
        }
      }
    }
  }
  cout << ans / 2 << endl;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
#define N 2000066
int n;
int flag;
int now;
int a[200006];
long long ans;
int main()
{
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)
    {
        if(now<a[i])
        {
            flag=1;
            break;
        }
        if(a[i]==0)now=0;
        now++;
    }
    for(int i=n-1;i>=0;i--)
    {
        if(i==n-1)
        {
            now=a[i];
        }
        else{
            now--;
            if(a[i]<now)
            {
                flag=1;
                break;
            }
            now=a[i];
        }
    }
    if(flag)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(int i=n-1;i>=0;i--)
    {
        if(i==n-1||a[i]>=a[i+1])
        {
            ans+=a[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define tam 310000
#define se second
#define fi first
#define forr(i,p,n) for(ll i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;
int val[tam];
int main()
{
    string txt;
    cin>>txt;
    forr(i,'a','z'+1)
    {
        forr(j,0,txt.size())
        if (txt[j]==i)
            val[j]=1;
        else
            val[j]=-1;
        int sum=0,comienzo=0;
        forr(j,0,txt.size())
            {
                sum+=val[j];
                if (sum<0)
                {
                    comienzo=j+1;
                    sum=0;
                }
                else
                {
                    if (j-comienzo>0&& sum>0)
                    {
                        cout<<comienzo+1<<" "<<j+1<<endl;
                        return 0;
                    }
                }
            }
    }
    cout<<-1<<" -1\n";
}

Measured memory_bytes: 896