akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int c[3][3];
    bool judge=true;
    rep(i,3){
        rep(j,3){
            cin>>c[i][j];
        }
    }
    int x,y,z;
    for(int i=0;i<2;i++){
        for(int j=i+1;j<3;j++){
            x=c[i][0]-c[j][0];
            y=c[i][1]-c[j][1];
            z=c[i][2]-c[j][2];
            if(!(x==y && y==z)){
                judge=false;
            }
        }
    }
    for(int i=0;i<2;i++){
        for(int j=i+1;j<3;j++){
            x=c[0][i]-c[0][j];
            y=c[1][i]-c[1][j];
            z=c[2][i]-c[2][j];
            if(!(x==y && y==z)){
                judge=false;
            }
        }
    }
    if(judge){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int N, K;

int main() {
  cin >> N >> K;
  int ans = K;
  rep(i, 0, N - 1) { ans *= (K - 1); }
  cout << ans << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  int n,k;
  cin>>n>>k;
  int q[n],p,l[n];
  for(int i=0;i<n;i++){
    cin>>p;
    q[p]=i;
    l[i]=p;
  }
  set<int> s,s2;
  int u[n]={},w[n]={};
  for(int i=0;i<n;i++){
    auto itr =s.upper_bound(q[i]);
    if(itr!=s.end()){
      
      if(*itr>q[i]+k)u[q[i]]=1;
    }else{
      if(q[i]+k+1<=n)u[q[i]]=1;
    }
    s.insert(q[i]);

  }
  for(int i=n-1;i>=0;i--){
    auto itr =s2.lower_bound(-1*q[i]);
    if(itr!=s2.end()){
     // cerr<<*itr<<q[i]<<' ';
      if(q[i]-k>=0&&-1*(*itr)<q[i]-k){w[q[i]-k]=1;}
    }else{
      if(q[i]-k>=0){w[q[i]-k]=1; }
    }
    s2.insert(-1*q[i]);
  }
  int ans=n-k+1,y=0,x=0;
  for(int i=1;i<k;i++)if(l[i-1]<l[i])y++;
  for(int i=0;i<n-k;i++){
    if(y==k-1)x++;
    else{
    if(u[i]==1&&w[i]==1)ans--;
    }
 //   cerr<<endl<<u[i]<<' '<<w[i];
   if(l[i]<l[i+1])y--;
   if(i+k<n&&l[i+k-1]<l[i+k])y++;
  }
  if(y==k-1)x++;
 // cerr<<x;
 if(x==0) cout<<ans;
 else cout<<ans-x+1;



  
  return 0;
}


Measured memory_bytes: 27264
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ----------- debug ---------- */

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p);

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 30;
const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T extgcd(T a, T b, T& x, T& y) {
    if (a < b) return extgcd(b, a, y, x);

    if (b > 0) {
        T g = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
        return g;
    } else {
        x = 1, y = 0;
        return a;
    }
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b % MOD;
    if (n % 2 == 0) {
        return mypow(b * b % MOD, n / 2);
    } else {
        return mypow(b, n - 1) * b % MOD;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

template <typename T>
T iceil(T n, T d) {
    return (n + d - 1) / d;
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    ll ans = 0;

    int r = 0, sum = 0;
    int ldig = 0, rdig = 0, lten = 1, rten = 1;

    // l<10^8
    for (int l = 1; l < 100000000; ++l) {
        if (l == lten) ++ldig, lten *= 10;

        while (sum < S) {
            ++r;
            if (r == rten) ++rdig, rten *= 10;
            sum += rdig;
        }

        if (sum == S) ++ans;
        sum -= ldig;
    }

    // 以降、区間長で総当たり
    for (int t = 1; t * 9 <= S; ++t) {
        int d = S / t;

        if (S % t == 0) {  // f(l)=f(r)=dの場合
            ans += mypow(10LL, d - 1) * 9 - t + 1 + MOD;
        } else {  // f(l)=f(r)-1=dの場合
            ++ans;
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#define NUMBER 10000
using namespace std;
int main() 
{
    int  i, num;
    long a[NUMBER];
    cin >> num;
    for(i = 0; i < num; i++) {
            cin >> a[i];
    }
 
    long min, max, sum;
    min = max = sum = a[0];
    for(i = 1; i < num; i++) {
            if(a[i] > max) {
                max = a[i];
            }
            if(a[i] < min) {
                min = a[i];
            }
            sum += a[i];
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3156
#include <stdio.h>
int main(void){
  int n,h,w;
  scanf("%d%d%d",&n,&h,&w);
  int a,b,s=0;
  int i=0;
  for(;i<n;i++){
    scanf("%d%d",&a,&b);
    s += ((a>=h) && (b>=w));
  }
  printf("%d",s);
}

Measured memory_bytes: 128
#pragma GCC optimize("O3", "unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	int n; cin >> n;
	if (n & 1) {
		cout << "No" << endl;
		return 0;
	}
	string s; cin >> s;
	cout << (s.substr(0, n / 2) == s.substr(n / 2, n / 2) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

l = list(map(int ,input().split()))
ans = 0  
for i in  range(5) :
    if l[i] == 0  :
        ans = i

print(ans +1)
                    

                
                
            
                
                                   
                    
                    
               
                    
            
            
        








        
                
                  
                
            
            
    
    
        


Measured memory_bytes: 9156
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
int main() {
	std::string s, t; std::cin >> s >> t;
	t.pop_back();
	std::cout << (s == t ? "Yes\n" : "No\n");
}


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



using namespace std;
using ll = long long;


int gcd(ll a, ll b) {
    if(min(a, b) == 0)return max(a, b);
    return gcd(min(a, b), max(a, b)%min(a, b));
}

vector<bool> sosu(1000010, 0);

bool gcdc(ll n) {
    queue<ll> q;
    for(int i = 2; i*i <= n; i++) {
        if(n%i) {
            continue;
        }
        bool check = 0;
        while(n % i == 0) {
            check = 1;
            n /= i;
        }
        q.push(i);
    }
    if(n != 1) {
        q.push(n);
    }
    while(q.size() > 0) {
        if(sosu.at((q.front()))) {
            return 0;
        }
        sosu.at(q.front()) = 1;
        q.pop();
    }
    return 1;
}

using namespace std;
using ll = long long;

int main() {
    ll N = 0;
    cin >> N;
    int each = 0;
    int all = 1;
    vector<ll> A(N,0);
    for(ll i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for(int i = 0; i < N - 1; i++) {
        ll memo = gcd(A.at(i), A.at(i + 1));
        if(memo == 1) {
            each = 1;
            break;
        } else {
            A.at(i + 1) = memo;
        }
    }
    
    for(int i = 0; i < N; i++) {
        if(!gcdc(A.at(i))) {
            all = 0;
            break;
        }
    }




    if(all) {
        cout << "pairwise coprime" << endl;
    } else if(each) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }



    

    return 0;
}

Measured memory_bytes: 11096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] a = new int[n];
		int[] s = new int[n];
		long sum = 0;
		long count1 = 0,count2 = 0;
		for(int i=0;i<n;i++){
			a[i] = scanner.nextInt();
		}

		for(int i=0;i<n;i++){
			if(i % 2 == 0 && sum + a[i] <= 0){
				count1 += Math.abs(sum + a[i] - 1);
				sum = 1;
			}else if(i % 2 == 1 && sum + a[i] >= 0){
				count1 += sum + a[i] + 1;
				sum = -1;
			}else{
				sum += a[i];
			}
		}
		sum = 0;
		for(int i=0;i<n;i++){
			if(i % 2 == 1 && sum + a[i] <= 0){
				count2 += Math.abs(sum + a[i] -1);
				sum = 1;
			}else if(i % 2 == 0 && sum + a[i] >= 0){
				count2 += sum + a[i] + 1;
				sum = -1;
			}else{
				sum += a[i];
			}
		}

		System.out.println(Math.min(count1,count2));

	}

}


Measured memory_bytes: 62364
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
//---------------------------

template<typename T>
void remove(vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
int N;
pair<int,int> red[101],blue[101];

int func(int a){
  int mx=-1;int p=0;
  REP(i,N){
    if(red[i].second>mx && red[i].first<blue[a].first && red[i].second<blue[a].second){
      mx=red[i].second;p=i;
    }
  }
  if(mx!=-1){
    red[p].first=red[p].second=blue[a].first=blue[a].second=-5;
    return 1;
  }
  return 0;
}

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>N;
  REP(i,N){
    cin>>red[i].first>>red[i].second;
  }
  REP(i,N){
    cin>>blue[i].first>>blue[i].second;
  }


  sort(blue, blue+N);
  int count = 0;
  REP(i,N){
    count += func(i);
  }
  P(count);
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		try {
			int w = Integer.parseInt(br.readLine());
			int n = Integer.parseInt(br.readLine());
			int amida[] = new int[w];
			for (int i=0;i<w;i++) amida[i] = i+1;
			for (int i=0;i<n;i++) {
				StringTokenizer st = new StringTokenizer(br.readLine(),",");
				int a = Integer.parseInt(st.nextToken());
				int b = Integer.parseInt(st.nextToken());
				amida[a-1] = amida[a-1]^amida[b-1];
				amida[b-1] = amida[a-1]^amida[b-1];
				amida[a-1] = amida[a-1]^amida[b-1];
			}
			for (int i=0;i<w;i++) System.out.println(amida[i]);
		} catch (Exception e) {
			System.out.println("Exception!");
		}
	}
}

Measured memory_bytes: 16872
h, w = gets.split.map(&:to_i)
board = Array.new(h) do |i|
  gets.chomp
end

dx = [0, 0, -1, -1, -1, 1,  1, 1 ]
dy = [1, -1, 0,  1, -1, 0, -1, 1 ]

h.times do |i|
  w.times do |j|
    next if board[i][j] == '#'
    cnt = 0

    8.times do |k|
      ni = i + dx[k]
      nj = j + dy[k]
      next if (ni < 0 || h <= ni)
      next if (nj < 0 || w <= nj)
      cnt += 1 if board[ni][nj] == '#'
    end
    board[i][j] = cnt.to_s
  end
end

board.each do |s|
  puts s
end

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

int main() {
	string A, B;
	cin >> A >> B;
	if(A.size()==B.size()){
	    int i;
	    for(i=0; i<A.size(); ++i){
	        if(A[i]!=B[i]){
	            if(A[i]>B[i]) cout << "GREATER" << endl;
	            else cout << "LESS" << endl;
	            break;
	        }
	    }
	    if(i==A.size()) cout << "EQUAL" << endl;
	}
	else if(A.size()>B.size()) cout << "GREATER" << endl;
	else cout << "LESS" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int size, i, j, temp;
    cin>>size;

    int arr[size];
    for(i=0; i<size; i++)
    {
        cin>>arr[i];
        if(i<size-1)
            cout<<arr[i]<<" ";
        else
            cout<<arr[i];
    }
    cout<<endl;
    for(i=1; i<size; i++)
    {
        temp=arr[i];
        j=i-1;
        while((temp<arr[j]) && (j>=0))
        {
            arr[j+1]=arr[j];
            j=j-1;
        }
        arr[j+1]=temp;
        for(int k=0; k<size; k++)
        {
            if(k<size-1)
                cout<<arr[k]<<" ";
            else
                cout<<arr[k];
        }
        cout<<endl;

    }

}



Measured memory_bytes: 3088
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
	int a, b, c, d, n, m;
	while (cin >> n) {
		m = 0;
		for (a = 0;a < 10;a++) {
			for (b = 0;b < 10;b++) {
				for (c = 0;c < 10;c++) {
					for (d = 0;d < 10;d++) {
						if (a + b + c + d == n)
							m++;
					}
				}
			}
		}
		cout << m << endl;
	}
}

Measured memory_bytes: 1164
#pragma region

#ifdef LOCAL
#define debug cout
#else
#define debug \
    if (0) cout
#endif

#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[ ";
    for (auto e : v) os << e << " ";
    return os << "]";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
    return os << "( " << x.first << ", " << x.second << " )";
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
    return is >> x.first >> x.second;
}

void solve();

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    solve();
}

#pragma endregion

void solve() {
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size(), vector<int>(t.size(), 0));
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) {
                if (i && j)
                    dp[i][j] = 1 + dp[i - 1][j - 1];
                else
                    dp[i][j] = 1;
            } else {
                if (i) dp[i][j] = dp[i - 1][j];
                if (j) dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            }
        }
    }
    int n = s.size() - 1, m = t.size() - 1;
    stack<char> v;
    while (n >= 0 && m >= 0) {
        if (s[n] == t[m]) {
            v.push(s[n]);
            --n, --m;
        } else if (n && dp[n][m] == dp[n - 1][m]) {
            --n;
        } else {
            --m;
        }
    }
    while (!v.empty()) {
        cout << v.top();
        v.pop();
    }
    cout << "\n";
}

Measured memory_bytes: 35584
import java.io.*;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			String[] spl = line.split(" ");
			int m = Integer.parseInt(spl[0]);
			int f = Integer.parseInt(spl[1]);
			int r = Integer.parseInt(spl[2]);
			if ( m == -1  && f == -1 && r == -1) {break;}
			if ( m == -1 || f == -1) {
				System.out.println("F");
			}else if( m + f >= 80){
				System.out.println("A");
			}else if( m + f >= 65){
				System.out.println("B");
			}else if( m + f >= 50 || ( m + f >=30) && r >= 50){
				System.out.println("C");
			}else if( m + f >= 30){
				System.out.println("D");
			}else{
				System.out.println("F");
			}
		}
	}
}

Measured memory_bytes: 24440
x,y = gets.split
c = 0
x = x.to_i
y = y.to_i

if x < y
	c = c + y
	y = y - 1
elsif 
	c = c + x
	x = x - 1
end

if x < y
	c = c + y
elsif 
	c = c + x
end

puts c


Measured memory_bytes: 1788
BLD = [[[0 for k in xrange(10)] for i in xrange(3)] for j in xrange(4)]

for i in xrange(input()):
    b, f, r, v = map(int, raw_input().split())
    BLD[b-1][f-1][r-1] += v

for b in xrange(4):
    for f in xrange(3):
        print ' ' + ' '.join(map(str, BLD[b][f]))
    if b != 3:
        print '####################'

Measured memory_bytes: 6380
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

ll gcd(ll x,ll y){
    x = x%y;
    return x == 0 ? y : gcd(y,x);
}
ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}



int main(){
 
    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    double ans = w*h/2.0;
    cout << fixed << setprecision(10) << ans << " ";
    if(2 * x == w && 2 * y == h){
        cout << 1 << endl;        
    }else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 3188
a=int(input())
def Isprime(n):
    if n==2:
        return 1
    for i in range(n-2):
        if n%(i+2)==0:
            return 0
    return 1
k=0
while k<a:
    if Isprime(a+k)==1:
        print(a+k)
        break
    else:
        k+=1

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b;
    cin>>a>>b;
    if((a%500)<=b)
    {
        cout<<"Yes"<<NL;
    }
    else{
        cout<<"No"<<NL;
    }
    return 0;
}


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

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


Measured memory_bytes: 640
N = int(input())
X = N / 1.08
N_new = int(X) * 1.08
N_new_2 = (int(X) + 1) * 1.08

if X % 1 == 0:
    print(int(X))
elif int(N_new) == N or int(N_new_2) == N:
    print(int(X)+1)
          
else:
    print(":(")

Measured memory_bytes: 3060
def foo
  while input = gets
    x1, y1, x2, y2, x3, y3, x4, y4 = input.split(',').map(&:to_f)
    v31 = [x3-x1, y3-y1]
    v21 = [x2-x1, y2-y1]
    cp1 = v31[0] * v21[1] - v31[1] * v21[0]

    v42 = [x4-x2, y4-y2]
    v32 = [x3-x2, y3-y2]
    cp2 = v42[0] * v32[1] - v42[1] * v32[0]

    v13 = [x1-x3, y1-y3]
    v43 = [x4-x3, y4-y3]
    cp3 = v13[0] * v43[1] - v13[1] * v43[0]

    v24 = [x2-x4, y2-y4]
    v14 = [x1-x4, y1-y4]
    cp4 = v24[0] * v14[1] - v24[1] * v14[0]

    cps = [cp1, cp2, cp3, cp4]
    if cps.all? { |i| i < 0 } || cps.all? { |i| i > 0 }
      puts 'YES'
    else
      puts 'NO'
    end
  end
end

foo

Measured memory_bytes: 8676
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




// 高速に n^m (mod p) を求める
long long POW(long long n, long long m, long long p){
    if(m == 0){
        return 1;
    }
    if(m % 2 == 0){
        long long tmp = POW(n, m / 2, p) % p;
        return tmp * tmp % p;
    }
    else{
        return n * POW(n, m - 1, p) % p;
    }
}

vector<ll> fact(200005);
ll comb(ll n, ll r){
    return fact[n] * POW(fact[r], 1e9 + 5, MOD) % MOD * POW(fact[n - r], 1e9 + 5, MOD) % MOD;
}

int main() {
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    
    fact[0] = 1;
    for(ll i = 1; i <= 200000; i++){
        fact[i] = fact[i - 1] * i % MOD;
    }
    
    ll ans = 0;
    for(ll i = b; i < w; i++){
        ans += comb(h - a - 1 + i, i) * comb(a - 1 + w - 1 - i, a - 1) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
N,X = input().split()
N,X = int(N), int(X)
answer = X+ (N-X)


def rhombus(N,X):
  	
    if X==1: 
        return N*2-1
    if X==0:
        return 0

    if N%X == 0:
        return X*(N//X)*2-X
      
    else: 
        k = N//X
        return k*2*X + rhombus(X,N-(k*X))

      

answer = answer + rhombus(N-X,X)
print(answer)

Measured memory_bytes: 9140
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n, m;
		int[][] result;
		while((n = sc.nextInt()) != 0){
			m = sc.nextInt();
			result = new int[m][2];
			for(int i = 0; i < m; i++){
				result[i][1] = i + 1;
			}
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++){
					result[j][0] += sc.nextInt();
				}
			}
			Arrays.sort(result, new Comparator<int[]>(){
				public int compare(int[] a, int[] b){
					if(a[0] == b[0]){
						return a[1] - b[1];
					}
					return b[0] - a[0];
				}
			});
			System.out.print(result[0][1]);
			for(int i = 1; i < m; i++){
				System.out.print(" " + result[i][1]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define LL long long

int main() {
  LL A,B,C,D;
  cin>>A>>B>>C>>D;
   if(D<0&&A>0){
   cout<<A*D<<endl;
 }
 else if(B<0&&C>0){
   cout<<B*C<<endl;
 }
 else if(A*C<B*D){
  cout<<B*D<<endl;
  }
  else if(A*C>B*D){
    cout<<A*C<<endl;
  }
  else if(A*C==B*D){
    cout<<A*C<<endl;
  }
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <set>
#include <numeric>

using namespace std;
int main() {
    int n, t, mini = 10000;
    cin >> n >> t;
    int c [n];
    int tt [n];
    for(int i = 0; i < n; i++){
        cin >> c[i] >> tt[i];
        if(tt[i] <= t){
            mini = min(mini, c[i]);
        }
    }

    if(mini == 10000){
        cout << "TLE" << endl;
    }
    else{
        cout << mini << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int m[12]={1,6,36,216,1296,7776,46656,9,81,729,6561,59049};
int dp[15][100010];
int main(){
  int n;
  cin>>n;
  rep(i,13){
    rep1(j,n){
      dp[i][j]=INF;
    }
  }
  rep(i,13){
    dp[i][0]=0;
  }
  rep1(i,12){
    rep1(j,n){
      if(j<m[i-1]){
	dp[i][j]=dp[i-1][j];
      }
      else{
	dp[i][j]=min(dp[i][j-m[i-1]]+1,dp[i-1][j]);
      }
    }
  }
  prin(dp[12][n]);
  


  

  return 0;
}


Measured memory_bytes: 5376
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		String s = st.nextToken();
        System.out.println(s.charAt(2)==s.charAt(3)
                         &&s.charAt(4)==s.charAt(5)?"Yes":"No");
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<set>
#include<queue>

using namespace std;

typedef pair<int,int> PII;
typedef long long ll;

int main(){

	string line;
	getline(cin,line);

	string ans;
	int j=0;
	for(int i=0;i<line.size();i++){
		if(line[i] == ','||line[i] == ' '||line[i] == '.'){
			if(i-j>=3&&i-j<=6){
				ans += " "+line.substr(j,i-j);
			}
			j = i+1;
		}
	}

	ans = ans.substr(1);
	cout<<ans<<endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define pb push_back
#define ff first
#define ss second
#define SIZE 1000001
#define INF int(2e9 + 9)
#define BIG_INF ll(4e18 + 9)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define _sz(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

//#pragma GCC optimize("Ofast")

ll binpow(ll a, ll b, ll mod = BIG_INF)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= mod;
        res %= mod;
    }
    res %= mod;
    return res;
}




int T = 1, n, a, b, c, d;
string s;

map<string, bool> used;

const int mod = 2019;


void solve()
{
    cin >> s;
    reverse(all(s));
    vector<int> pref(_sz(s) + 1, 0);
    int d = 1;
    vector<int> cnt(2020, 0);
    cnt[0]++;
    for(int i = 0; i < _sz(s); i++)
    {
        pref[i + 1] = (d * (s[i] - '0') % mod + pref[i]) % mod;
        cnt[pref[i + 1]]++;
        d = d * 10 % mod;
    }

    ll ans = 0;

    for(int& c: cnt)
    {
        ans += c * (c - 1) / 2;
    }

    cout << ans;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

//    cin >> T;

    while(T--)
    {
        solve();
    }




    return 0;
}


Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)

int main(){
    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}





Measured memory_bytes: 256
//ABC072C
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	int a[114514] = {}, p = 0;
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		if (k >= 1)a[k - 1]++;
		a[k]++;
		a[k + 1]++;
		p = max(p, k);
	}
	int ans = 0;
	for (int i = 0; i <= p; i++) {
		ans = max(ans, a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
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++)
typedef long long ll;

int main() {
    string N;
    cin >> N;
    if (N[0] == N[1] && N[1] == N[2]) {
        cout << "Yes" << endl;
    }
    else if (N[1] == N[2] && N[2] == N[3])
    {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;
import java.util.Arrays;

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

		int n = sc.nextInt();
		int m = sc.nextInt();

		int[] aCity = new int[n];
		int[] bCity = new int[m];

		int x = sc.nextInt();
		int y = sc.nextInt();

		for(int i = 0; i < n; i++) {
			aCity[i] = sc.nextInt();
		}
		for(int i = 0; i < m; i++) {
			bCity[i] = sc.nextInt();
		}

		Arrays.sort(aCity);
		Arrays.sort(bCity);

		int aRightEdge = aCity[n - 1];
		int bLeftEdge = bCity[0];

		if(aRightEdge > bLeftEdge) {
			System.out.println("War");
			return;
		}

		boolean f = false;
		for(int i = aRightEdge; i <= bLeftEdge; i++) {
			int z = i;
			if(x < z && z <= y) {
				if(aRightEdge < z && z <= bLeftEdge) {
					f = true;
					break;
				}
			}
		}

		if(f) {
			System.out.println("No War");
		}
		else {
			System.out.println("War");
		}
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int X = - A - B + C + D;
  if (X == 0) {
    cout << "Balanced" << endl;
  }
  else if(X < 0) {
    cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
}
}

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

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

  x = a * b;
  
  if(x % 2 == 0){
    cout << "Even" << endl;
  }else if(x % 2 == 1){
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
  //if(y==0) return x;
  //return gcd(y, x%y);
//}
//sort小さい順(昇順)
//g++ code.cpp   ./a.out 
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(a>=c){
    cout << c << endl;
    return 0;
  }
  else if(a+b==60){
    cout << "-1" << endl;
    return 0;
  } 
  else{
    rep(i,1000){
      rep(j,10000){
        if(i*a+b*i<=c+60*j && c+60*j<=(i+1)*a+b*i){
          cout << c+60*j << endl;
          return 0;
        }  
      }
    }
    cout << -1 << endl;
  }
}




Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <iomanip>
#include <stdlib.h>
using namespace std;
int main(){
    bool a[4][13];
	for(int i=0;i<4;i++)
		for(int j=0;j<13;j++)
			a[i][j]=false;
	int n,b;
	char c;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c>>b;
		if(c=='S')
			a[0][b-1]=true;
		if(c=='H')
			a[1][b-1]=true;
		if(c=='C')
			a[2][b-1]=true;
		if(c=='D')
			a[3][b-1]=true;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++){
			if(a[i][j]==false){
				if(i==0)
					cout<<"S "<<j+1<<endl;
				if(i==1)
					cout<<"H "<<j+1<<endl;
				if(i==2)
					cout<<"C "<<j+1<<endl;
				if(i==3)
					cout<<"D "<<j+1<<endl;
			}
		}
	}
	return 0;
}

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

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	int MOD = 1000000007;
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int n;
	int[] a;
	void Solve()
	{
		n = F();
		a = G();
		WriteLine(Min(Calc(true), Calc(false)));
	}
	long Calc(bool pos)
	{
		var ans = 0L;
		var sum = 0L;
		for (var i = 0; i < n; i++)
		{
			sum += a[i];
			if (pos && sum <= 0)
			{
				ans += 1 - sum;
				sum = 1;
			}
			else if (!pos && sum >= 0)
			{
				ans += 1 + sum;
				sum = -1;
			}
			pos = !pos;
		}
		return ans;
	}
}

Measured memory_bytes: 27996
#!/usr/bin/python

# AtCoder Beginner Contest 077
# A - Rotation

from sys import stdin

def solve(s1, s2):
    for i in range(len(s1)):
        if s1[i] != s2[- 1 - i]: return "NO"
    return "YES"

s1 = stdin.readline().strip()
s2 = stdin.readline().strip()
if len(s1) != 3 or len(s2) != 3: raise
print(solve(s1, s2))

Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define INF 1010101010
#define MOD 1000000007
#define LL long long

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n, k; cin>>n>>k;
  ll ans = 0;
  rep(i, n) {
    ll h; cin>>h;
    if (h >= k) ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int h[100006], d[100006];

int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 1; i <= N; i++) {
    cin >> h[i];
    if(i == 1) d[1] = 0;
    else {
      d[i] = 2000000019;
      for (int j = 1; j <= K; j++) {
        if (i - j > 0) {
          d[i] = min(d[i], d[i - j] + abs(h[i] - h[i - j]));
        }
      }
    }
  }
  cout << d[N] << endl;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int N;
        ll D, X, Y;
        cin >>N >>D;
        D *=D;
        int S=0;
        Rep0(i, N) {
                cin >>X >>Y;
                if (D>=X*X+Y*Y)
                        S++;
        }
        cout <<S <<endl;
        return 0;
}

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

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N+1), B(N);
  for(int i = 0; i < N+1; i++){
    cin >> A.at(i);
  }
  ll m = 0;
  for(int i = 0; i < N; i++){
    cin >> B.at(i);
    m += B.at(i);
  }

  for(int i = 0; i < N; i++){
    B.at(i) -= min(B.at(i), A.at(i));
    ll n = min(B.at(i), A.at(i+1));
    B.at(i) -= n;
    A.at(i+1) -= n;
  }
  ll x = 0;
  for(int i = 0; i < N; i++){
    x += B.at(i);
  }

  cout << m - x << endl;

}

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

vector<lint> dist;
const lint INF = 1e18;
struct  edge{lint to, cost;};
vector<edge> G[100010];

void dfs(lint now, lint ago, lint depth){
  dist[now] = depth;
  for(lint i = 0; i < G[now].size(); i++){
    lint next = G[now][i].to;
    if(next == ago) continue;
    dfs(next, now, depth + G[now][i].cost);
  }
}

signed main(){
  lint N; cin >> N;
  for(lint i = 1; i < N; i++){
    lint a, b, c; cin >> a >> b >> c; --a; --b;
    G[a].push_back(edge{b, c}); G[b].push_back(edge{a, c});
  }
  dist.resize(N, 0);
  lint Q, K; cin >> Q >> K;
  dfs(K - 1, -1, 0);
  for(lint i = 0; i < Q; i++){
    lint x, y; cin >> x >> y;
    lint ans = dist[x - 1] + dist[y - 1];
    cout << ans << "\n";
  }
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define eb emplace_back

int main()
{
    ll N, K;
    cin >> N >> K;
    vec p(N);
    REP(i,0,N) cin >> p[i];
    ASC(p);
    ll sum = 0;
    REP(i,0,K) sum += p[i];
    PR(sum);
    return 0;
}

/*



*/

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n;
    cin >> n;
    string s; cin >> s;
    int ans = 1;
    char now = s[0];
    repSE(i,1,s.size()) {
        if (s[i] != now) {
            ans ++; now = s[i];
        }
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

// 最大二部マッチング
// O(V(V+E))
class BipartiteMatching
{
    int size;
    vector<vector<int>> g;
    vector<int> match;
    vector<bool> used;
    bool dfs(int v)
    {
        used[v] = true;
        for (const auto &u : g[v])
        {
            int w = match[u];
            if (w < 0 || (!used[w] && dfs(w)))
            {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }

  public:
    BipartiteMatching(int v) : size(v), g(v), match(v), used(v) {}
    void add_edge(int u, int v)
    {
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int maximum_matching(void)
    {
        int res = 0;
        fill(begin(match), end(match), -1);
        for (int v = 0; v < size; ++v)
        {
            if (match[v] >= 0)
                continue;
            fill(begin(used), end(used), 0);
            if (dfs(v))
                ++res;
        }
        return res;
    }
};

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

    int x, y, e;
    cin >> x >> y >> e;
    BipartiteMatching bm(x + y);
    while (e--)
    {
        int a, b;
        cin >> a >> b;
        bm.add_edge(a, x + b);
    }
    cout << bm.maximum_matching() << endl;
}


Measured memory_bytes: 3248
import heapq

N, M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

NG = []

for i in range(M):
  a, b = [int(j) for j in input().split()]
  if H[a-1] < H[b-1]:
    NG.append(a)
  elif H[a-1] > H[b-1]:
    NG.append(b)
  else:
    NG.append(a)
    NG.append(b)
NG = set(NG)
#print(NG)
print(N - len(NG))

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

int main(){
    long long n,k,a,b;

    cin >> n >> k;

    a = n%k;
    b = k - a;

    if(a>=b){
        cout << b << endl;
    }else{
        cout << a << endl;
    }
    
    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 std;
using namespace __gnu_pbds;
#define light ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define REPE(i,a,b) for(ll i = a; i <= b; i++)
#define REPR(i,a,b) for(ll i = a; i >= b; i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
const double pi = 2*acos(0.0);
const int INF = 1e9+1;
const int MOD = 1e9+7;
const int MOD1 = 998244353;

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll inverse(ll base, ll exp, ll mod) {
   return modExp(base, exp - 2, mod);
}

bool compare(const pair<int,int> &i, const pair<int,int> &j) {
   return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

void test() {
   int n, k;
   cin >> n >> k;
   vector<int> a(n);
   REP(i,0,n) cin >> a[i];

   vector<int> dp(n, INT_MAX);
   dp[0] = 0;
   for(int i = 0; i < n; i++) {
      for(int j = 1; j <= k; j++) {
         if(i+j <= n-1) {
            dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]));
         }
      }
   }
   cout << dp[n-1];
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   light;
   cout.precision(15);
   cout << fixed;

   int t = 1;
   //cin >> t;
   for(int i = 1; i <= t; i++) {
      //cout << "Case #" << i << ": ";
      test();
   }
   return 0;
}


Measured memory_bytes: 3948
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	int n, cnt = 0; cin >> n;

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

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

	if (n % 2 == 0) {
		if (d[n / 2] - d[n / 2 - 1] > 0) {
			cnt = d[n / 2] - d[n / 2 - 1];
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;

int main()
{   
    int a, b;
    string num;
    cin >> num;
    for(int i = 0; i < 3; i++){
        if(num[i] == num[i + 1]){
            cout << "Bad" << endl;
            break;
        }
        if(i == 2){
            cout << "Good" << endl;
        }
    }
    
    return 0;

}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;


int main(){
    string s;
    cin >> s;
    ll n = s.size();

    char t[2] = {'g', 'p'};
    ll sum = 0;
    ll v[n];
    rep(i, n){
        if(s[i] == t[0])    sum++;
        else                sum--;
        v[i] = sum;
    }

    cout << v[n-1]/2 << endl;


    return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

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

        int ans = a - (2 * b);
        if (ans > 0) {
            System.out.println(ans);
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 23636
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int collatz(int n){
	int ans = 0;
	while(n!=1){
		if(n%2)n = n * 3 + 1;
		else n = n/2;
		ans++;
	}
	return ans;
}
int main(){
	int n;
	while(cin >> n , n)
		cout << collatz(n) << endl;
}

Measured memory_bytes: 0