akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

long long fact[300009], factinv[300009], mod = 998244353;

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

void init() {
	fact[0] = 1; for (int i = 1; i <= 300000; i++) fact[i] = (fact[i - 1] * i) % mod;
	for (int i = 0; i <= 300000; i++) factinv[i] = Div(1, fact[i], mod);
}

long long ncr(long long n, long long r) {
	if (r < 0 || n < r) return 0;
	return (fact[n] * factinv[r] % mod) * factinv[n - r] % mod;
}

long long N, M, cnt, p1, p2, L1[100009], L2[100009]; string A, B, C, D;

void dels() {
	cnt = 0; p1 = 0; p2 = 0;
	for (int i = 0; i < 100009; i++) { L1[i] = 0; L2[i] = 0; }
}

long long solve() {
	dels();
	for (int i = 0; i < N; i++) { if (A[i] == '1' || B[i] == '1') cnt++; }
	for (int i = 0; i < M; i++) { if (C[i] == '1') p1++; if (D[i] == '1') p2++; }

	int v = 0; L1[0] = 1;
	for (int i = 0; i < N; i++) {
		if (A[i] == '1') v++;
		if (B[i] == '1') v++;
		L1[i + 1] = ncr(v + p1 - 1, p1 - 1);
		bool flag = false; if (v == 0) flag = true;
		if (flag == true && p1 == 0) L1[i + 1] = 1;
	}
	v = 0; L2[N - 1] = 1;
	for (int i = N - 1; i >= 1; i--) {
		if (A[i] == '1') v++;
		if (B[i] == '1') v++;
		L2[i - 1] = ncr(v + p2 - 1, p2 - 1);
		bool flag = false; if (v == 0) flag = true;
		if (flag == true && p2 == 0) L2[i - 1] = 1;
	}
	long long ret = 0, ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (A[i] == '1' || B[i] == '1') ret += L2[i];
		ret %= mod;
		if (A[i] == '1' && B[i] == '1') ans += L1[i] * ret;
		if (A[i] == '1' || B[i] == '1') ans += L1[i] * ret;
		ans %= mod;
		if (A[i] == '1' && B[i] == '1') ret *= 2;
	}
	return ans;
}

int main() {
	init();
	cin >> N >> M >> A >> B >> C >> D;
	int rem = 0;
	for (int i = 0; i < N; i++) { rem += (A[i] - '0'); rem += (B[i] - '0'); }
	for (int i = 0; i < M; i++) { rem += (C[i] - '0'); rem += (D[i] - '0'); }
	if (rem == 0) {
		cout << "1" << endl;
		return 0;
	}

	long long c1 = solve(); swap(N, M); swap(A, C); swap(B, D);
	long long c2 = solve(); swap(N, M); swap(A, C); swap(B, D);
	cout << (c1 + c2) % mod << endl;
	return 0;
}

Measured memory_bytes: 7040
while 1:
    try:
        A = input()
        a = len(A)
        C='JOI'
        D='IOI'
        c=len(C)
        d=len(D)
        s=0
        for i in range(a-c+1):
            if C == A[i:i+c]:    #a[i:j]→[a[i], a[i+1], a[i+2], ..., a[j-1]]
                s+=1
        print(s)
        t=0
        for i in range(a-d+1):
            if D == A[i:i+d]:    #a[i:j]→[a[i], a[i+1], a[i+2], ..., a[j-1]]
                t+=1
        print(t)
    except EOFError:break


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n;
  cin >> n;
  int a[n+1];
  int b[n];
  for(int i=0;i<n+1;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  
  int64_t count = 0;
  for(int i=0;i<n;i++){
    int x = a[i];
    int y = b[i];
    int z = 0;
    x -= y;
    if(x<0){
      x = 0;
      z = a[i];
    }
    else{
      z = y;
    }
    a[i] = x;
    b[i] = y-z;
    count += z;
    x = a[i+1];
    y = b[i];
    z = 0;
    x -= y;
    if(x<0){
      x = 0;
      z = a[i+1];
    }
    else{
      z = y;
    }
    a[i+1] = x;
    b[i] = y-z;
    count += z;
  }

  cout << count << endl;
  return 0;
}



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


int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(b-a <=k && c-a <=k && d-a <=k && e-a <=k && c-b <=k && d-b <=k && e-b <=k && d-c <=k && e-c <=k && e-d <=k){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()
passed = 0
foregin_passed = 0

for i in range(N):
    if S[i] == 'a':
        if passed < A + B:
            passed += 1
            print("Yes")
        else:
            print("No")
    elif S[i] == 'b':
        if passed < A + B and foregin_passed < B:
            passed += 1
            foregin_passed += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")


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

int main(){
    int a,b,C;
    cin >> a >> b >> C;
    double S,L,h,c,PI;
    PI = acos(-1.0);
    c = (C * PI )/180.0;
    S = 0.5*a*b*sin(c);
    double d =sqrt(a*a+b*b-2*a*b*cos(c));
    L = a + b + d;
    h = 2*S/a;
    printf("%lf\n%lf\n%lf\n",S,L,h);
    
    return 0;
    
}


Measured memory_bytes: 3392
L = []
for i in range(3) :
    L.append(list(map(int,input().split())))
flag = 0
for j in range(L[0][0]+1) :
    a1 = j
    b1 = L[0][0]-a1
    a2 = L[1][0]-b1
    b2 = L[1][1]-a2
    a3 = L[2][0]-b1
    b3 = L[2][2]-a3
    if (a1+b2) == L[0][1] and (a1+b3) == L[0][2] and (a2+b3) == L[1][2] and (a3+b2) == L[2][1] :
        flag += 1
        break
if flag == 1 :
    print("Yes")
else :
    print("No")


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());

	int ans = 1e9;
	for (int i = 0; i <= n-k; i++) {
		ans = min(ans, h[i+k-1] - h[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main
{
  public static void main(String args[])
  {
    int[] t = {1, 2, 3};
    
    Scanner std = new Scanner(System.in);
    int a = std.nextInt();
    for(int i = 0; i < 3; i++)
    {
      if(t[i] == a)
      {
        t[i] = 0;
      }
    }
    int b = std.nextInt();
    for(int i = 0; i < 3; i++)
    {
      if(t[i] == b)
      {
        t[i] = 0;
      }
    }
    for(int i = 0; i < 3; i++)
    {
      if(t[i] != 0)
      {
        System.out.println(t[i]);
      }
    }
  }
}
    

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    auto check = [&](int l, int r){
        if(l==r){
            if(a[l-1]<a[l] && a[l]>a[l+1]) return 3;
            if(a[l-1]>a[l] && a[l]<a[l+1]) return 4;
            return -1;
        }

        if(a[l-1]<a[l] && a[r]>a[r+1]) return 0;
        if(a[l-1]>a[l] && a[r]<a[r+1]) return 1;
        if(a[l-1]<a[l] && a[r]<a[r+1]) return 2;
        if(a[l-1]>a[l] && a[r]>a[r+1]) return 2;
        return -1;
    };

    int ct[5]={};

    int i=1;
    while(i<n-1){
        int j = i;
        while(j<n-1 && a[i]==a[j]) ++j;
        --j;

        int res = check(i,j);
        if(res != -1) ++ct[res];

        i = j+1;
    }

    rep(z,5) cout << ct[z] << " \n"[z==4];
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

int gcd(int x,int y){
    if (y==0) return x;
    else return gcd(y,x%y);
}

int main(){
    int n;
  	cin>>n;
  	int ans=(n/2)*((n+1)/2);
    
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

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

    int finding = 1;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if(a[i]==finding)
        {
            count++;
            finding++;
        }
    }
    cout << (count != 0 ? n - count : -1) << endl;

}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] S = new string[N];
		int[]T = new int[N];
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			S[i] = str[0];
			T[i] = int.Parse(str[1]);
		}
		string X = Console.ReadLine();
		bool flag = false;
		long ans = 0;
		for(var i=0;i<N;i++){
			if(flag){
				ans += T[i];
			}
			if(S[i]==X){
				flag = true;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main(){
    string s;
    cin >> s;
    int k;
    cin >> k;
    vector<string> v;
    rep(i,s.size()){
        for(int j = 1; i+j <= s.size( )&& j <= 5; j++)v.push_back(s.substr(i,j));
    }
    sort(v.begin(),v.end());
    unique(v.begin(),v.end());
    cout << v[k-1] << endl;
}


Measured memory_bytes: 1660
#include<iostream>
using namespace std;
#define ll long long int
int main()
{
  ll n;
  cin>>n;
  ll i,j,cnt=0;
  ll a[n+1];
  ll b[n];
  for(i=0;i<n+1;i++)
  {
  	cin>>a[i];
  }
  for(i=0;i<n;i++)
  {
  	cin>>b[i];
  }
  i=0;
  j=0;
  /*while(i!=n or j!=n+1)
  {
  	if(>1)
  	{
  		
  	}
  	if(b[i]>a[j])
  	{
  		b[i]-=a[j];
  		cnt+=a[j];
  		j++;
  		continue;
  	}
  	else if(b[i]==a[j])
  	{
  		i++;
  		j++;
  		cnt+=b[i];
  		continue;
  	}
  	else
  	{
  		a[j]-=b[i];
  		cnt+=b[i];
  		i++;
  	}
  }*/
  for(i=0;i<n;i++)
  {
  	if(b[i]<a[i]+a[i+1])
  	{
  		if(a[i]>=b[i])
  		{
  			cnt+=b[i];
  			continue;
  		}
  		else
  		{
  			cnt+=a[i];
  			b[i]-=a[i];
  			if(a[i+1]>=b[i])
  			{
  				a[i+1]-=b[i];
  				cnt+=b[i];
  			}
  			else
  			{
  				cnt+=a[i+1];
  				a[i+1]=0;
  				continue;
  			}
  		}
  	}
  	else if(b[i]>=a[i]+a[i+1])
  	{
  		cnt+=a[i]+a[i+1];
  		a[i+1]=0;
  	}
  	
  }
  cout<<cnt;
}

Measured memory_bytes: 1792
/*
    Code written by Talant I.D.
*/

#include <bits/stdc++.h>

using namespace std;

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

#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define sz(v) int(v.size())
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);

inline bool isvowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}

inline bool isprime(int n){
    if(n < 2 || (n%2 == 0 && n != 2)) return false;
    for(int i = 3; i*i <= n; i += 2)
        if(n%i == 0) return false;
    return true;
}

const int INF = 1000000000;

ll dp[51][3001];
vector <vector <int>> graph(51);
int a[101], b[101], c[51], d[51], roadIndex[51][51];

void solve(int node, int coins){
    queue <pii> K;
    K.push(mp(node, coins));
    dp[node][coins] = 0;

    while(sz(K)){
        int v = K.front().first, bal = K.front().second;
        K.pop();

        for(auto to : graph[v]){
            int ind = roadIndex[v][to];
            if(bal >= a[ind] && dp[to][bal-a[ind]] > dp[v][bal]+b[ind]){
                dp[to][bal-a[ind]] = dp[v][bal]+b[ind];
                K.push(mp(to, bal-a[ind]));
            }
        }

        ll exCoins = min((ll)bal+c[v], 3000ll);
        if(dp[v][exCoins] > dp[v][bal]+d[v]){
            dp[v][exCoins] = dp[v][bal]+d[v];
            K.push(mp(v, exCoins));
        }
    }
}

int main(){
    do_not_disturb

    int n, m, s, i, j;
    cin >> n >> m >> s;
    for(i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v >> a[i] >> b[i];
        roadIndex[u][v] = roadIndex[v][u] = i;
        graph[u].pb(v);
        graph[v].pb(u);
    }

    s = min(s, 3000);
    for(i = 1; i <= n; i++){
        cin >> c[i] >> d[i];
        for(j = 0; j <= 3000; j++)
            dp[i][j] = ll(INF)*ll(INF);
    }
    dp[1][s] = 0;
    solve(1, s);

    for(i = 2; i <= n; i++){
        ll ans = ll(INF)*ll(INF);
        for(j = 0; j < 3001; j++)
            ans = min(ans, dp[i][j]);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 5216
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e8;
char a[200010];
int main(){
	ll n;
	cin>>n;
	cin>>a;
	ll i,r=0,w=0;
	for(i=0;i<n;i++){
		if(a[i]=='R')
			r++;
		else
			w++;
	}
	if(w==0)
		cout<<"0";
	else{
		ll s=0;
		for(i=0;i<r;i++)
			if(a[i]!='R')
				s++;
		cout<<s;
	}
	
}


Measured memory_bytes: 3760
//https://arc103.contest.atcoder.jp/tasks/arc103_c

#include<bits/stdc++.h>
const int N = 1e5 + 5;
using namespace std;

char s[N];
int n;

int main(){
    scanf("%s", s+1);
    n = strlen(s+1);
    for (int i = 1; i < n; i++) if (s[i] != s[n-i]) return printf("-1"), 0;
    if (s[n] == '1' || s[1] == '0') return printf("-1"), 0;
    int last = 1, root = 1, cnt = 1;
    for (int i = 2; i < n; i++){
        if (s[i] == '0') continue;
        printf("%d %d\n", ++cnt, root);
        root = cnt;
        while (cnt < i) printf("%d %d\n", ++cnt, root);
    }
    printf("%d %d\n", ++cnt, root);
}


Measured memory_bytes: 1536
// Bismillah .Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const ll mx = 1e18;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s,p;
    cin>>s>>p;
    ll ans =0;
    for(int i=0;i<s.size();i++)
        if(s[i]!=p[i])
        ans++;
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int b[N];
  for(int i=0;i<N;i++)cin >> b[i];
  
  
  for(int i=0;i<N;i++){
    if(i-b[i]+1<0){
      cout << -1 << endl;
      return 0;
    }
    
    if(b[i]!=1){
      int date = b[i];
      for(int j=0;j<date-1;j++){b[i-j]=b[i-j-1];}
 b[i-date+1]=date;
    
  
    }
        

  }
  
  for(int i=N-1;i>=0;i--)cout << b[i] <<endl;
}
    
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod=1000000007;
long long ans,n,s,a[200005];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	
	for(int i=n-1;i>=1;i--)
	{
		s=(s+a[i+1])%mod;
		ans=(a[i]*s+ans)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  // ここにプログラムを追記
  int N;
  cin >> N;
  int sen, hyaku, juu, ichi;
  int vsen, vhyaku,vjuu;
  sen = N/1000;
  vsen = sen * 1000;
  hyaku = (N - vsen)/100;
  vhyaku = hyaku * 100;
  juu = (N - vsen - vhyaku)/10;
  vjuu = juu * 10;
  ichi = (N - vsen - vhyaku - vjuu);
  int count;
  count = 0;
  if (sen == hyaku && hyaku == juu){
  	cout << "Yes" << endl;
  }
  
  else if (hyaku == juu && hyaku == ichi){
  	cout << "Yes" << endl;
  }
  
  else{
  	cout << "No" << endl;
  }
  
  
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int ans=3;
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(a==b) {
			if(b!=c) {
				ans=2;
			}else {
				ans=1;
			}
		}else if(b==c) {
			if(c!=a) {
				ans=2;
			}
		}else if(c==a) {
			if(a!=b) {
				ans=2;
			}
		}

		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> H(N + 1, 0), A(M, 0), B(M, 0);
  vector<bool> C(N + 1, true);
  int ans = 0;

  for (size_t i = 1; i <= N; i++) {
    cin >> H[i];
  }
  for (size_t i = 0; i < M; i++) {
    cin >> A[i] >>B[i];
  }

  for (size_t i = 0; i < M; i++) {
    if (H[A[i]] <= H[B[i]]) {
      C[A[i]] = false;
    }
    if(H[B[i]] <= H[A[i]]){
      C[B[i]] = false;
    }
  }

  for (size_t i = 1; i <= N; i++) {
    if (C[i] == true){
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4564
import java.util.Scanner;

public class Main {

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

		selectionSort(A);
		sc.close();

	}

	private static void selectionSort(int[] A) {
		int cnt = 0;

		for (int i = 0; i < A.length - 1; i++ ) {
			int mini = i;
			for (int j = i + 1; j < A.length; j++ ) {

				if ( A[j] < A[mini] ) {
					mini = j;
				}
			}

				if (mini != i) {
					int tmp = A[i];
					A[i] = A[mini];
					A[mini] = tmp;
					cnt++;
				}
		}

		for (int k = 0; k < A.length; k++ ) {
			System.out.print(A[k]);
			if(k < A.length -1) {
				System.out.print(" ");
			}

		}
		System.out.println();
		System.out.println(cnt);

	}

	private static int[] inpNum(int n) {
		int[] nums = new int[n];

		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
		}
		return nums;
	}

}


Measured memory_bytes: 26276
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;

string S;

int main() {
	cin >> S;
	map<char, int> mp;
	for (int i = 0; i < 4; i++)
		mp[S[i]]++;
	bool isYes = true;
	for (int i = 0; i < 4; i++)
		if (mp[S[i]] != 2)
			isYes = false;
	cout << (isYes ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      	long x = 0, y = 0;
		long n = sc.nextLong();
      	for (long i = 1; i*i <= n; i++) { 
          if (n%i == 0) {
             x = i;     
             y = n/i;
          }
        }      
        System.out.println(x+y-2); 
	}
}

Measured memory_bytes: 23892
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, m, s, ans = 0;
  scanf("%lld%lld", &n, &m);
  vector<ll> vec[m];
  ll p[m];
  bool now, b;
  for(i = 0; i < m; ++i) {
    scanf("%lld", &k);
    for(j = 0; j < k; ++j) scanf("%lld", &s), vec[i].push_back(--s);
  }
  for(i = 0; i < m; ++i) scanf("%lld", &p[i]);
  for(i = 0; i < (1 << n); ++i) {
    b = true;
    for(j = 0; j < m; ++j) {
      now = false;
      for(k = 0; k < vec[j].size(); ++k) if((i >> vec[j][k]) & 1) now = !now;
      if(now != p[j]) b = false;
    }
    if(b) ++ans;
  }
  printf("%lld", ans);
  return 0;
}

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

class B
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = h[0], k = h[1];

		long x = 1;
		Console.WriteLine(Enumerable.Range(1, 31).First(i => (x *= k) > n));
	}
}


Measured memory_bytes: 28016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

char toLowerCase(char c){
  if(isLowerCase(c)){
    return c;
  }else{
    return c+'a'-'A';
  }
}
char toUpperCase(char c){
  if(isLowerCase(c)){
    return c-('a'-'A');
  }else{
    return c;
  }
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,k;cin>>n>>k;
  map<int,int> mp;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    mp[a]++;
  }
  int s=mp.size();
  if(s<=k){
    cout<<0<<endl;
  }else{
    int r=s-k;
    map<int,vector<int>> ans;
    for(auto it:mp){
      int val=it.second;
      ans[val].push_back(it.first);
    }
    int a=0;
    auto it=ans.begin();
    for(auto it:ans){
      int c=it.second.size();
      if(c<=r){
        a+=it.first*c;
        r-=c;
      }else{
        a+=it.first*r;
        r=0;
      }
      if(r==0){
        break;
      }
    }
    cout<<a<<endl;
  }
  return 0;
}


Measured memory_bytes: 14048
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

map<string,int> mm;

int perseMolecule(const string &str){
  if(str.size() == 0) return 0;
  //cout << "molecule: " << str << endl;
  if(str[0] == '('){
    int d = 1;
    int pos = 1;
    while(true){
      if(str[pos] == '(') d++;
      if(str[pos] == ')') d--;
      if(d == 0) break;
      pos++;
    }
    string str1 = str.substr(1,pos-1);
    int ret    = perseMolecule(str1);
    if(pos + 1 != str.size()){
      string str2 = str.substr(pos+1);
      if(isdigit(str2[0])){
        int p = 1;
        int t = str2[0] - '0';
        if(str2.size() != 1 && isdigit(str2[1])){
          t = t*10 + str2[1] - '0';
          p = 2;
        }
        ret *= t;
        str2 = str2.substr(p);
      }
      ret += perseMolecule(str2);
    }
    return ret;
  }else{
    string str1,str2;
    if(str.size() != 1 && islower(str[1])){
      str1 = str.substr(0,2);
      str2 = str.substr(2);
    }else{
      str1 = str.substr(0,1);
      str2 = str.substr(1);
    }
    if(mm.count(str1) == 0) throw "error";
    //cout << str1 << ": " << mm[str1] << endl;
    int ret = mm[str1];
    if(str2.size()!=0 && isdigit(str2[0])){
      int p = 1;
      int t = str2[0] - '0';
      if(str2.size() != 1 && isdigit(str2[1])){
        t = t*10 + str2[1] - '0';
        p = 2;
      }
      ret *= t;
      str2 = str2.substr(p);
    }
    ret += perseMolecule(str2);
    return ret;
  }
}

int main(){
  string str;
  while(cin >> str, str != "END_OF_FIRST_PART"){
    int n; cin >> n;
    mm[str] = n;
  }

  while(cin >> str, str != "0"){
    try{
      cout << perseMolecule(str) << endl;
    }catch(...){
      cout << "UNKNOWN" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};


const int MAX = 510000;
const int mod = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    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;
    }
}

// 二項係数計算
ll 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;
}
//a^n (mod m)
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//mod mでの a の逆元を求める
ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int x; cin>>x;
  	cout << (x^1) << endl;
}


Measured memory_bytes: 3552
W,H,N=map(int,input().split())
W0=0
H0=0
for i in range(N):
    x1,y1,a1=map(int,input().split())
    if a1 ==1 and W0<x1:
        W0=x1
    elif a1==2 and W>x1:
        W=x1
    elif a1==3 and H0<y1:
        H0=y1
    elif a1==4 and H>y1:
        H=y1

if W-W0>0 and H-H0>0:
    print((W-W0)*(H-H0))
else:
    print(0)

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

typedef long long ll;
typedef long double ld;

int main() {
  int W,N;
  cin >> W >> N;
  vector<ll> dp(W+1,100000000000);
  for (int i = 0; i < W+1; i++) {
  }
  dp[0] = 0;
  int w,v;
  for (int i = 0; i < N; i++) {
    cin >> w >> v;
    for (int j = 0; j < W+1; j++) {
      dp[j] = min(dp[j], dp[max(0,j-w)]+v);
    }
  }
  cout << dp[W] << endl;
  return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<=n;i++)
typedef int long long ll;
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int s[n+1];
    s[0]=1;
    for(int i=1;i<=n;i++){
        s[i]=min(s[i-1]+k,s[i-1]*2);
       
    }
    
    cout<<s[n]<<endl;
return 0;
}


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

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

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const double eps = 1e-9;
const ll N = 1e5 + 10;
const int M = 1e9 + 7;
const ll MAX = 1e18 + eps;
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};


int main() {
    ll a;
    double b;
    cin >> a >> b;
    ll c = (ll)(b * 100.0 + eps);
    cout << (a * c) / 100 << endl;
}

Measured memory_bytes: 3724
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
long long util(vector<int>&w,vector<int>&v,int W)
{
  int n=w.size();
  long long dp[n+1][W+1];
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=W;j++)
    dp[i][j]=0;
  }
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=W;j++)
    {
      if(w[i-1]>j)
      dp[i][j]=dp[i-1][j];
      else
      {
        dp[i][j]=max(dp[i-1][j],(long long)v[i-1]+dp[i-1][j-w[i-1]]);
      }
    }
  }
  return dp[n][W];
}
int main()
{
  int n,W;
  cin>>n>>W;
  vector<int> w,v;
  for(int i=0;i<n;i++)
  {
    int tw,tv;
    cin>>tw>>tv;
    w.push_back(tw);
    v.push_back(tv);
  }
  long long ans=util(w,v,W);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 79104
#include<iostream>
#include<algorithm>
#include<string.h>

using namespace std;

bool isPalindrome(string s) {
	string x = s;
	reverse(x.begin(), x.end());
	if (x == s) {
		return true;
	}
	return false;
}

int main() {

	string S;
	cin >> S;

	string A, B;
	A = S.substr(0, ((int)(S.length()) - 1) / 2);
	B = S.substr(((int)(S.length()) + 3) / 2 - 1, (int)(S.length()) - (((int)(S.length()) + 3) / 2 - 1));

	if (isPalindrome(S) && isPalindrome(A) && isPalindrome(B)) {
		cout << "Yes";
	}
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
long long a[100010];
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)scanf("%lld",&a[i]);
int zero=0;
for(int i=0;i<n;i++)if(a[i]==0)zero++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod=1;
for(int i=0;i<n;i++){
if(a[i] <=1000000000000000000/prod){
// This condition is equivalent to prod*a[i]<=10ˆ18
prod*=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod);
}

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

using namespace std;

int main () {
  int n;
  cin >> n;
  vector<int> as(n + 1, 0);
  vector<int> ans(0);
  ans.reserve(n);
  for (int i = 0; i < n; i++) { cin >> as[i+1]; }

  vector<int> memo(n + 1, 0);
  for (int idx = n; idx > 0; idx--) {
    int sum = 0;
    for (int i = idx + idx; i <= n; i += idx) {
      sum += memo[i];
    }
    if (sum % 2 != as[idx]) {
      memo[idx] = 1;
      ans.push_back(idx);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    if (i != 0) {
      cout << " ";
    }
    cout << ans[i];
  }
  if (ans.size() > 0) {
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
N = int(input())
W = [input() for _ in range(N)]
ans = 'Yes'
if len(W) != len(set(W)): ans = 'No'
tail = W[0][-1]
for i in range(1, N):
    head = W[i][0]
    if (tail != head): ans = 'No'
    tail = W[i][-1]
print(ans)


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

int main(void) {
	char tango[1025];
	int outed=0;
	while(1) {
		if(scanf("%s",tango)==-1)break;
		if(strchr(tango,'.'))*strchr(tango,'.')=0;
		if(strchr(tango,','))*strchr(tango,',')=0;
		if(strlen(tango)>=3 && strlen(tango)<=6) {
			printf(" %s"+!outed,tango);
			outed=1;
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 0
class Social{
	private static void execFeelBadSearch (bool[] feelBadBunny, /* const */int[][] boat, int mainKey, int subKey) {// const????????§???????????????????????¨??????
		for (int i = 0; i < boat.Length; ++i) {
			bool hasMainBunny = false; // mainKey????????????????????£?????????????????????
			bool hasSubBunny  = false; // subKey ????????????????????£?????????????????????
			for (int j = 0; j < boat[i].Length; ++j) {
				if (boat[i][j] == mainKey) hasMainBunny = true;
				if (boat[i][j] == subKey ) hasSubBunny  = true;
			}
			if (hasMainBunny && hasSubBunny) { //???????????????????????£???
				feelBadBunny[mainKey] = true; feelBadBunny[subKey] = true;
				break;
			} else if (hasMainBunny || hasSubBunny) { //?????£??????????????£????????????????????????????????????????????¨????????????????´¢?????????
				break;
			}
		}
	}
	
	public static void Main()
	{
		string[] inputNumsStr = System.Console.ReadLine().Split(' ');
		int bunnyNum = int.Parse(inputNumsStr[0]);
		int boatNum  = int.Parse(inputNumsStr[1]);
		
		int[][] boat = new int[boatNum][]; //?????£??°????????????
		for (int i = 0; i < boatNum; ++i) { // ??????????????????????????????
			string[] inputStr = System.Console.ReadLine().Split(' ');
			int inputNum = int.Parse(inputStr[0]);
			boat[i] = new int[inputNum];
			for (int j = 0; j < inputNum; ++j) {
				boat[i][j] = int.Parse(inputStr[j + 1]);
			}
		}
		
		int worsePairNum = int.Parse(System.Console.ReadLine());
		bool[] feelBadBunny = new bool[bunnyNum + 1]; // C#??????????????????false?????\??£?????????????????????????????£???C++?????????????????????
		for (int i = 0; i < worsePairNum; ++i) { // ??????????´¢
			string[] inputStr = System.Console.ReadLine().Split(' ');
			int mainNum = int.Parse(inputStr[0]); // ?????????ID??????1
			int subNum  = int.Parse(inputStr[1]); // ??§?????£????????£??????ID??§??????????????°???????????????????°??????????????????????
			execFeelBadSearch(feelBadBunny, boat, mainNum, subNum); //?????¢???????????£????????????feelBadBunny?????´??°?????????
		}
		
		int count = 0;
		for (int i = 0; i <= bunnyNum; ++i) { //???????????????????????????????????????
			count += feelBadBunny[i] ? 1 : 0;
		}
		System.Console.WriteLine("{0}", count);
	}
};

Measured memory_bytes: 9296
s = input();
t = input();
ans = len(t);

for i in range(0,len(s)-len(t)+1):
    count = 0;
    substr = s[i:len(t)+i];
    # print(substr);
    for j in range(0,len(t)):
        if substr[j] == t[j]:
            count += 1;
        # print(count);
        if ans > len(t)-count:
            ans = len(t) - count;

print(ans)
    


Measured memory_bytes: 9036
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
X = [[-10**2 for __ in range(W)] for _ in range(H)]
Y = [[-10**2 for __ in range(W)] for _ in range(H)]
for y in range(H):
  last_x = -1
  for x in range(W):
    if S[y][x] == "#":
      for t in range(last_x+1,x):
        X[y][t] = x-1-last_x
      last_x = x
  for t in range(last_x+1,W):
    X[y][t] = W-1-last_x
for x in range(W):
  last_y = -1
  for y in range(H):
    if S[y][x] == "#":
      for t in range(last_y+1,y):
        Y[t][x] = y-1-last_y
      last_y = y
  for t in range(last_y+1,H):
    Y[t][x] = H-1-last_y
ans = 0
for y in range(H):
  for x in range(W):
    ans = max(ans, Y[y][x]+X[y][x])
print(ans-1)


Measured memory_bytes: 251272
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e5+5,inf=1e9+10;
int a[maxn];
int main(){
    int i,n,p,q;
    scanf("%d",&n);
    for (i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a,a+n);
    q=a[n-1];
    for (i=n-1;i;i--) a[i]=a[i]-a[i-1]+1;
    a[0]=inf;
    for (i=1;i<n-1;i++) if (a[i]==1&&(a[i+1]&1)){
        a[i]++; a[i+1]--;
    }
    p=n-1;
    while (q>a[p]) q-=a[p--];
    if ((a[p]&1)&&q==a[p]) puts("First");
    else puts((q&1)?"Second":"First");
    return 0;
}

Measured memory_bytes: 640
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] elements = br.readLine().split(" ");
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(elements[i]);
        }

        int key;
        int i, j, k;
        String output;
        printArray(A, N);
        for (i = 1; i < N; i++) {
            key = A[i];
            j = i - 1;
            while (j >= 0 && A[j] > key) {
                A[j+1] = A[j];
                j--;
            }
            A[j+1] = key;

            printArray(A, N);
        }
    }

    public static void printArray (int[] array, int length) {
        String output = "";
        for (int i = 0; i < length; i++) {
            output += array[i];
            if (i != length-1) {
                output += " ";
            }
        }
        System.out.println(output);
    }
}

Measured memory_bytes: 58584
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int a,b,c; cin>>a>>b>>c;
	cout << max(0,c-(a-b));

	
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long cache[87] = {0};

long long Lucas(int n) {
  for (int i = 2; i <= n; ++i) {
    cache[i] = cache[i - 1] + cache[i - 2];
  }
  return cache[n];
}

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

  int N;
  cin >> N;

  cache[0] = 2;
  cache[1] = 1;
  cout << Lucas(N) << endl;

  return 0;
}

Measured memory_bytes: 256
def gcd(A,B):
    if A==B:
        output=A
    n=max(A,B)
    m=min(A,B)
    r=100
    while r>0:
        r=n%m
        n=m
        m=r
    return n

def div(A,B,C):
    n1=A%C
    if n1==0:
        ans1=A//C
    else:
        ans1=A//C+1
    n2=B%C
    if n2==0:
        ans2=B//C
    else:
        ans2=(B-B%C)//C
    d=ans2-ans1+1
    if d>=1:
        ans3=d
    else:
        ans3=0
    return ans3

A,B,C,D=map(int,input().split())
num1=div(A,B,C)
num2=div(A,B,D)
n=gcd(C,D)
lcm=C*D//n
num3=div(A,B,lcm)
lastanswer=(B-A+1)-(num1+num2-num3)
print(lastanswer)


Measured memory_bytes: 3064
import fractions
A,B,C,D = map(int,input().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

ans=B-A+1
ans-=B//C-(A-1)//C
ans-=B//D-(A-1)//D
E=lcm(C,D)
ans+=B//E-(A-1)//E
print(ans)

Measured memory_bytes: 63980
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int A = Integer.parseInt(sc.next());
      int B = Integer.parseInt(sc.next());
      int a = A + B;
      int b = A - B;
      int c = A * B;
      int result = Math.max(a, Math.max(b, c));

      System.out.println(result);
    }
  }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
struct O{int l,r,x;}b[200005];
int x,y,t,n,m,e[100005],a[100005]; char S[100005];
void add(int &u,int v){
	if (!v) return;
	if (!u) {u=v; return;}
	if (b[u].x<b[v].x){
		add(b[u].r,v);
		swap(b[u].l,b[u].r);
	}else{
		add(b[v].r,u);
		swap(b[v].l,b[v].r);
		u=v;
	}
}
int main(){
	scanf("%s",S+1); n=strlen(S+1);
	for (int i=1;i<=n;++i) a[i]+=S[i]-'a',a[i+1]-=S[i]-'a';
	scanf("%d",&m);
	for (int i=1;i<=m;++i){
		scanf("%d%d",&x,&y);
		b[++t].x=y;
		add(e[x],t);
	}
	for (int i=1;i<=n+1>>1;++i){
		b[++t].x=n-i+1;
		add(e[i],t);
	}
	for (int i=1;i<=n;++i){
		a[i]%=26;
		while (e[i]&&b[e[i]].x<i) add(b[e[i]].l,b[e[i]].r),e[i]=b[e[i]].l;
		if (!e[i]){
			if (a[i]) {puts("NO"); return 0;}
			continue;
		}
		t=b[e[i]].x;
		a[t+1]+=a[i]; a[i]=0;
		add(e[t+1],b[e[i]].l);
		add(e[t+1],b[e[i]].r);
	}
	puts("YES");
	return 0;
}

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

int main() {
  int res = 0;
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < a.length(); ++i) 
    res += (a[i] != b[i]);
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3804
import bisect
import collections
import functools
import heapq
import math
from collections import deque
from collections import defaultdict
MOD = 10**9+7

N = int(input())
A = [0]*N
B = [0]*N
C = [[0]*2 for _ in range(N)]
zero = 0
no_inf = 0
inf = 0
for i in range(N):
    A[i],B[i] = map(int,(input().split()))
    if A[i] == 0 and B[i] == 0:
        C[i] = (0,0)
        zero += 1
    elif A[i] == 0:
        C[i] = (0,0)
        no_inf += 1
    elif B[i] == 0:
        C[i] = (0,0)
        inf += 1
    elif B[i] > 0:
        g = math.gcd(A[i],B[i])
        C[i] = (A[i]//g,B[i]//g)
    else:
        g = math.gcd(A[i],B[i])
        C[i] = (-A[i]//g,-B[i]//g)

d = defaultdict(int)

for i in range(N):
    if C[i] != (0,0):
        d[C[i]] += 1

ans = 1
for k in d.keys():
    if k[0] > 0:
        if (-k[1],k[0]) in d:
            ans *= pow(2,d[k],MOD) + pow(2,d[(-k[1],k[0])],MOD) -1
            d[k],d[(-k[1],k[0])] = 0,0
        else:
            ans *= pow(2,d[k],MOD)
    else:
        if (k[1],-k[0]) in d:
            ans *= pow(2,d[k],MOD) + pow(2,d[(k[1],-k[0])],MOD) -1
            d[k],d[(k[1],-k[0])] = 0,0
        else:
            ans *= pow(2,d[k],MOD)

ans *= pow(2,no_inf,MOD) + pow(2,inf,MOD) -1
print((ans+zero-1)%MOD)

Measured memory_bytes: 147832
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 510, mo = 1000000007 ;
using namespace std ;

int n, m, col, e, ter[N], nxt[N], lnk[N], id[N], cnt, top, ans, d[N] ;
bool vis[N], ins[N], h[N] ;
int dfn[N], low[N], st[N] ;
struct edge {
	int x, y ; 
} E[N] ;

int gcd(int x, int y) {
	return (y ? gcd(y, x % y) : x) ;
}

void add(int x, int y, int z) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e, id[e] = z ;
}

inline int INP(int x) {
	if (!h[x]) {
		h[x] = true ;
		d[++ d[0]] = x ;
		return 1 ;
	}
	return 0 ;
}

inline void OUP() {
	rep(i, 1, d[0]) {
		h[d[i]] = false ;
	}
}

inline int mul(int a, int b) {
	int ans = 1, w = a % mo ;
	for ( ; b; b /= 2) {
		if (b & 1) ans = (ll) ans * w % mo ;
		w = (ll) w * w % mo ;
	}
	return ans ;
} 

inline int calc_cir(int x) {
	int res = 0 ; 
	rep(i, 0, x - 1) {
		res = (res + mul(col, gcd(i, x))) % mo ;
	}
	res = (ll) res * mul(x, mo - 2) % mo ;
	return res ;
}

inline int C(int x, int y) {
	int res = 1 ;
	rep(i, 2, x) res = (ll) res * i % mo ;
	rep(i, 2, y) res = (ll) res * mul(i, mo - 2) % mo ;
	rep(i, 2, x - y) res = (ll) res * mul(i, mo - 2) % mo ;
	return res ;
}

inline int calc_u(int x) {
	return C(col + x - 1, col - 1) ;
}

void dfs(int p, int las) {
	//printf("----- V : %d\n", p) ;
	dfn[p] = low[p] = ++ cnt ;
	for (int i = lnk[p]; i; i = nxt[i]) {
		if (!dfn[ter[i]]) {
			st[++ top] = id[i], ins[id[i]] = true, vis[id[i]] = false ;
			dfs(ter[i], p) ;
			low[p] = min(low[p], low[ter[i]]) ;
			if (low[ter[i]] >= dfn[p]) {
				int poi = 0, ed = 0 ;
				d[0] = 0 ;
				for ( ; ; ) {
					poi += INP(E[st[top]].x) ;
					poi += INP(E[st[top]].y) ;
					++ ed ;
					ins[st[top]] = false ;
					-- top ;
					if (st[top + 1] == id[i]) break ;
				}
				OUP() ;
				if (poi == ed) ans = (ll) ans * calc_cir(ed) % mo /*, printf("Find ---- poi = %d ; ed = %d ; ans *= %d\n", poi, ed, calc_cir(ed)) */;
					else ans = (ll) ans * calc_u(ed) % mo /*, printf("Find ---- poi = %d ; ed = %d ; ans *= %d\n", poi, ed, calc_u(ed))*/ ;
			}
		} else {
			if (vis[id[i]]) {
				vis[id[i]] = false ;
				st[++ top] = id[i] ;
				ins[id[i]] = true ;
			}
			if (ins[id[i]]) low[p] = min(low[p], dfn[ter[i]]) ;
		}
	}
}

int main() {
	scanf("%d%d%d", &n, &m, &col) ;
	int x, y ;
	rep(i, 1, m) {
		scanf("%d%d", &x, &y) ;
		add(x, y, i), add(y, x, i) ;
		E[i].x = x, E[i].y = y ;
	}
	memset(vis, true, sizeof(vis)) ;
	memset(ins, false, sizeof(ins)) ;
	ans = 1 ;
	cnt = top = 0 ;
	rep(i, 1, n) if (!dfn[i]) {
		dfs(i, 0) ;
	}
	printf("%d\n", (ans + mo) % mo) ;
	return 0 ; 
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
int n;
int a[100010];
vi v;
string s;
int main()
{
	ll d;
	cin>>d>>n;
	rep(i,n)
	{
		cin>>a[i];
		d-=a[i];
	}
	if(d>=0)
	{
		cout<<d;
	}
	else
	{
		cout<<"-1";
	}
    return 0;
}

Measured memory_bytes: 3676