akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

long long modpow(long long x,long long n,long long mod)
{
  if(n==0)return 1;
  long long res=modpow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  ll mod= 998244353;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int sa=0;
  rep(i,n)sa+=a[i];
  int l=sa/2;
  vector<ll>dp(l+1,0LL);
  dp[0]=1;
  rep(i,n)
  {
    for(int j=l-a[i];j>=0;j--)
    {
      if(dp[j]==0)continue;
      dp[j+a[i]]+=dp[j]*2;
    }
    if(i%18==0||i==n-1)rep(j,l+1)dp[j]%=mod;
  }
  rep(i,l+1)if(dp[i]<0)dp[i]+=mod;
  ll res=modpow(3,n,mod);
  rep(i,l+1)dp[i]=(mod-dp[i])*3;
  for(auto i:dp)res+=i;
  res%=mod;
  if(!(sa&1))
  {
    fill(all(dp),0LL);
    dp[0]=1;
    rep(i,n)
    {
      for(int j=l-a[i];j>=0;j--)
      {
        if(dp[j]==0)continue;
        dp[j+a[i]]+=dp[j];
      }
      if(i%28==0||i==n-1)rep(j,l+1)dp[j]%=mod;
    }
    res+=dp.back()*3;
  }
  cout<<res%mod<<endl;


  return 0;

}


Measured memory_bytes: 640
import math
l,r = list(map(int, input().split()))

mi = 9999
for i in range(min(r-l+1,2019)):
    ll = l+i
    for j in range(min(r-l+1,2019)):
        if(i<=j):
            continue
        rr = l+j
        mi = min((ll*rr)%2019,mi)
print(mi)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int p=1;
    map<char,long long>m;
    set<char>so;
    set<char>::iterator it;
    for(int i=0;i<s.size();i++)
    {
        m[s[i]]+=1;
        so.insert(s[i]);
    }
    for(it=so.begin();it!=so.end();it++)
    {
        if(m[*it]%2!=0)
        {
            p=0;
            break;
        }
    }
    if(p==0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int N;
    int p[50];
    cin >> N;
    REP(i, N) cin >> p[i];
    int cnt = 0;
    REP(i, N){
        if(p[i] != i + 1) cnt++;
    }
    if(cnt <= 2) PRINT("YES");
    else PRINT("NO");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, M;

	cin >> N>> M;
	
	vector<int> A;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		N -= a;
	}
	if (N < 0) {
		cout << -1;
	}
	else {
		cout << N;
	}
}

Measured memory_bytes: 3616
import collections
N = int(input())
A = list(map(int,input().split()))
sameNumber = collections.Counter(A)
total = 0
for n in sameNumber:
  total += sameNumber[n] * (sameNumber[n]-1)

def count(val):
  if sameNumber[val] > 1:
    return (total -2 * (sameNumber[val]-1)) //2
  return total //2

for n in A:
  print(count(n))

Measured memory_bytes: 26780
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>


typedef long long llong;
using namespace std;
#define MAX 100010

struct city {
	int P;
	int num;
};
int main() {
	int N, M;
	int P,Y;
	priority_queue<pair<int, int>,vector<pair<int,int>>,greater<pair<int,int>>> PQ[MAX];
	pair<int, int> elem[MAX];
	struct city city[MAX];

	
	scanf("%d %d", &N, &M);

	for (int i = 1; i <= M; i++) {
		scanf("%d %d", &P, &Y);
		elem[i].first = Y;
		elem[i].second = i;
		PQ[P].push(elem[i]);
		city[i].P = P;
	}
	for (int i = 1; i <= N; i++) {
		int cnt = 1;
		while (PQ[i].size() > 0) {
			city[PQ[i].top().second].num = cnt;
			cnt++;
			PQ[i].pop();
		
		}
	}
	for (int i = 1; i <= M; i++) {
		printf("%06d%06d\n", city[i].P, city[i].num);
	}
	return 0;
}


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

#define pb push_back
#define fi first
#define se second
#define mem(x,n) memset(x,n,sizeof(x))
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define foreach(it,l) for(auto it=(l).begin();it!=(l).end();it++)
#define pnl printf("\n")
#define endl '\n'
#define len(x) (x).length()

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<int> VI;
const double EPS=1e-10;
//const double PI=acos(-1.0);
const int INF=1<<30;
const LL LLINF=1ll<<60;
const int MOD=1e9+7;
const int xx[8]={1,0,-1,0,1,-1,1,-1};
const int yy[8]={0,1,0,-1,-1,1,1,-1};

void fastio(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); }

/***********************************\
     _____ _             _
    /  __ \ |           (_)
    | /  \/ | __ _ _ __  _  ___
    | |   | |/ _` | '_ \| |/ _ \
    | \__/\ | (_| | |_) | |  __/
     \____/_|\__,_| .__/|_|\___|
                  | |
                  |_|
\***********************************/

int asd[100005];

int main(){
	int tc;
	scanf("%d",&tc);
	for(int i=0;i<tc;i++){
		scanf("%d",&asd[i]);
	}
	
	sort(asd,asd+tc);
	int cnt=1;
	for(int i=1;i<tc;i++){
		if(asd[i]!=asd[i-1])cnt++;
	}
	printf("%d",cnt);		
	return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextBigDecimal()
    val b = sc.nextBigDecimal()
    println(problem169c(a, b))
}

fun problem169c(a: BigDecimal, b: BigDecimal): String {
    return a.multiply(b.multiply(100.toBigDecimal())).div(100.toBigDecimal()).toString().split(".")[0]
}

Measured memory_bytes: 39448
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 998244353;
const long double PI = acos(-1);
const long long N = 2e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll n, x, m;
	cin >> n >> x >> m;
	if(x == 0 || m == 1)
	{
		cout << x << '\n';
		return;
	}
	ll ans = x, prev = x, curr = 0;
	vector<bool> done(m+1, 0);
	done[x] = 1;
	ll ind = 0;
	for(ll i = 2; i <= n; i++)
	{
		curr = prev * prev % m;
		if(done[curr])
		{
			ind = i;
			break;
		}
		done[curr] = 1;
		ans = curr + ans;
		prev = curr;
		if(curr == 0)
			break;
	}
	if(ind == 0 || curr == 0)
	{
		cout << ans << '\n';
		return;
	}
	ll left = n - ind + 1;
	ll z = curr;
	vector<ll> vv = {curr};
	ll sum = curr;
	while(1)
	{
		z = z * z % m;
		if(z == curr)
			break;
		sum += z;
		vv.push_back(z);
	}
	ll nn = vv.size();
	// cout << ind << ' ' << left << ' ' << nn << ' '; 
	ll tot = left / nn;
	// cout << sum * tot << ' ';
	ans = ans + sum * tot;
	left = left % nn;
	for(int i = 0; i < left; i++)
	{
		ans += vv[i];
	}
	cout << ans << '\n';
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll t,a,b,i,j,k,n,x;
     string s;
     cin>>s;
     ll c=0;
     for(i=0;i<s.length()-1;i++)
     {
         if(s[i]!=s[i+1])
         {
             c++;
         }
     }
     cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3748
#include <cstdio>

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int n = 0;
    for(int i = a; i <= b; i++) {
        if (c % i == 0) {
            n++;
        }
    }

    printf("%d\n", n);

    return 0;
}


Measured memory_bytes: 2760
/*input
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define N 300005
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() 
{
    off;
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(ll i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    ll dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    dp[1][0]=max(b[0],c[0])+a[1];
    dp[1][1]=max(a[0],c[0])+b[1];
    dp[1][2]=max(a[0],b[0])+c[1];
    for(ll i=2;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    // for(ll i=0;i<n;i++)
    // {
    //     for(ll j=0;j<3;j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集 
using ld = long double;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N; cin >> N;
  ll d; cin >> d;
  int ans = 0;
  REP(i,N){
    ll x, y; cin >> x >> y;
    if(d*d >= x*x + y*y){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		
		System.out.println(String.format("%c%d%c", s.charAt(0), s.length()-2, s.charAt(s.length()-1)));
	}
}


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

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;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const ll INF = 1LL << 60;



//大文字小文字気をつけろ


int main(){
  int n;
  cin >> n;
  int a[1000000];
  FOR(i,n){
    cin >> a[i];
  }
  int c=gcd(a[0],a[1]);
  FOR(i,n-2){
    c=gcd(c,a[i+2]);
  }

  cout << c << endl;

}


Measured memory_bytes: 2304
n,m,k=map(int,input().split())
end = 0
for i in range(0, n+1):
    for j in range(0, m+1):
        if m*i+n*j-2*(i*j)==k:
            print("Yes")
            end = 1
            break
    if end == 1:
        break
else:
    print("No")   

Measured memory_bytes: 3060
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll dp[110][310][110] = {0};
int main(void){
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N);
    vector<ll> v(N);
    vector<ll> dw(N);
    ll w0;
    ll minw = INF;
    for(int i = 0; i < N; i++){
        cin >> w[i] >> v[i];
        if(i == 0){
            w0 = w[i];
        }

        dw[i] = w[i] - w0;
    }

    for(int i = 0; i < N; i++){
        minw = min(minw, w[i]);
    }

    //cout << minw << endl;

    if(minw > W){
        cout << 0 << endl;
        return 0;
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j <= 3 * N; j++){
            for(int k = 0; k < N; k++){
                dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);

                if(j - dw[i] >= 0){
                    dp[i + 1][j][k + 1] = max(dp[i + 1][j][k + 1], dp[i][j - dw[i]][k] + v[i]);
                }
                //cout << dp[i][j][k] << endl;
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i <= 3 * N; i++){
        for(int j = 0; j <= N; j++){
            ll weight = i + w0 * j;
            if(W >= weight){
                ans = max(ans, dp[N][i][j]);
            }
        }
    }

    cout << ans << endl;
}

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

#define long long long int
using namespace std;


#ifdef JUDGE
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
using std::cin;
using std::cout;
#endif

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(6);

    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC");
    return 0;


}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        string S;
        cin >> S;
        rep(i, S.length()) cout << 'x';
        cout << endl;

        return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
int sum(int n)
{
    int m,s=0;
    while(n)
    {
        m=n%10;
        s+=m;
        n/=10;
    }
    return s;
}
signed main()
{   
    fastio();
    int t=1;
    //cin>>t;
    while(t--)
    {  
        int n;
        cin>>n;
        if(n%(sum(n))==0)
        cout<<"Yes";
        else
        cout<<"No";
    }
}
// 🍪 🍪 🍪


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int a[N]; rep(i,N) cin >> a[i];
  int now = 1;
  rep(i,N) if (a[i]==now) now++;
  int result = (now==1) ? -1 : N-(now-1);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1152
import java.util.Arrays;

public class Main {


  private static void solve() {
    int n = ni();
    int k = ni();

    int[] h = na(n);
    long[] dp = new long[n];
    Arrays.fill(dp, Long.MAX_VALUE);
    dp[0] = 0;
    for (int i = 1; i < n; i ++) {
      for (int j = 1; j <= k; j ++) {
        if (i - j >= 0)
          dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));
      }
    }
    System.out.println(dp[n - 1]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int main() {
  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<int64_t> A(4);
  
  A.at(0) = a * c;
  A.at(1) = a * d;
  A.at(2) = b * c;
  A.at(3) = b * d;
  
  sort(A.begin(), A.end());
  
  cout << A.at(3);

}

Measured memory_bytes: 3628
#include <stdio.h>

int main()
{
	int A, B, C;
	long long K;
	scanf("%d %d %d %lld", &A, &B, &C, &K);
	
	if (K % 2 == 0) printf("%d\n", A - B);
	else printf("%d\n", B - A);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
int n;
vector<int> a(50,0);

bool check(){
  bool f=1;
  REP(i,n-1) if(a.at(i)>a.at(i+1)) f=0;
  return f;
}

void sw(int i,int j){
  int tmp=a.at(i);
  a.at(i)=a.at(j);
  a.at(j)=tmp;
}

int main(){
  bool flag=0;
  cin>>n;
  REP(i,n) cin>>a.at(i);
  if(check()) flag=1;
  
  REP(i,n-1) for(int j=i+1;j<n;j++){
    sw(i,j);
    if(check()) flag=1;
    sw(i,j);
  }
  
  cout<<(flag?"YES":"NO");
}

Measured memory_bytes: 256
import java.util.*;

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

        List<Integer> gyou1 = new ArrayList<>();
        List<Integer> gyou2 = new ArrayList<>();
        List<Integer> gyou3 = new ArrayList<>();

        gyou1.add(sc.nextInt());
        gyou1.add(sc.nextInt());
        gyou1.add(sc.nextInt());
        gyou2.add(sc.nextInt());
        gyou2.add(sc.nextInt());
        gyou2.add(sc.nextInt());
        gyou3.add(sc.nextInt());
        gyou3.add(sc.nextInt());
        gyou3.add(sc.nextInt());

        List<Integer> retsu1 = new ArrayList<>();
        List<Integer> retsu2 = new ArrayList<>();
        List<Integer> retsu3 = new ArrayList<>();

        retsu1.add(gyou1.get(0));
        retsu1.add(gyou2.get(0));
        retsu1.add(gyou3.get(0));

        retsu2.add(gyou1.get(1));
        retsu2.add(gyou2.get(1));
        retsu2.add(gyou3.get(1));

        retsu3.add(gyou1.get(2));
        retsu3.add(gyou2.get(2));
        retsu3.add(gyou3.get(2));

        List<Integer> naname1 = new ArrayList<>();
        List<Integer> naname2 = new ArrayList<>();

        naname1.add(gyou1.get(0));
        naname1.add(gyou2.get(1));
        naname1.add(gyou3.get(2));

        naname2.add(gyou3.get(0));
        naname2.add(gyou2.get(1));
        naname2.add(gyou1.get(2));

        int selectNum = sc.nextInt();
        for(int i = 0; i < selectNum; i++){
            int check = sc.nextInt();

            for(int j = 0; j < 3; j++){
                if(check == gyou1.get(j)) gyou1.set(j, 101);
                if(check == gyou2.get(j)) gyou2.set(j, 101);
                if(check == gyou3.get(j)) gyou3.set(j, 101);

                if(check == retsu1.get(j)) retsu1.set(j, 101);
                if(check == retsu2.get(j)) retsu2.set(j, 101);
                if(check == retsu3.get(j)) retsu3.set(j, 101);

                if(check == naname1.get(j)) naname1.set(j, 101);
                if(check == naname2.get(j)) naname2.set(j, 101);
            }
            
        }

        boolean isBingo = false;

        if(gyou1.get(0) + gyou1.get(1) + gyou1.get(2) == 303){
            isBingo = true;
        }

        if(gyou2.get(0) + gyou2.get(1) + gyou2.get(2) == 303){
            isBingo = true;
        }

        if(gyou3.get(0) + gyou3.get(1) + gyou3.get(2) == 303){
            isBingo = true;
        }

        if(retsu1.get(0) + retsu1.get(1) + retsu1.get(2) == 303){
            isBingo = true;
        }

        if(retsu2.get(0) + retsu2.get(1) + retsu2.get(2) == 303){
            isBingo = true;
        }

        if(retsu3.get(0) + retsu3.get(1) + retsu3.get(2) == 303){
            isBingo = true;
        }

        if(naname1.get(0) + naname1.get(1) + naname1.get(2) == 303){
            isBingo = true;
        }

        if(naname2.get(0) + naname2.get(1) + naname2.get(2) == 303){
            isBingo = true;
        }
            
        if(isBingo) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	double y[1010], x[1010];
	double sy = 1, sx = 1;
	x[2] = 1.0, y[2] = 1.0;
	rep2(i,3,1001) {
		double len = sqrt(pow(sy,2.0) + pow(sx,2.0));
		double dy = sy - sy/len; double dx = sx - sx/len;
		double by = sy, bx = sx;
		sy = - (dx-bx) + by; sx = dy-by+bx;
		y[i] = sy, x[i] = sx;
	}
	int n;
	while(cin >> n && n != -1) {
		cout << x[n] << endl << y[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
let rec f i = function
    | 1 -> i+3
    | 2 -> i+3
    | 4 -> i+3
    | n when n mod 2 = 0 ->
        f (i+1) (n / 2)
    | n ->
        f (i+1) (n*3+1)

let () = Scanf.scanf "%d" @@ fun s -> Printf.printf "%d" (f 1 s)


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main() {
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a.at(i);
    
    vector<int>sums(n);
    rep(i,n){
        if(i==0) sums.at(i)=a.at(i);
        else sums.at(i)=sums.at(i-1)+a.at(i);
    }
    
    long long ans1=0;
    long long x=0;
    rep(i,n){
        int s=sums.at(i);
        s+=x;
        if(i%2==0&&s<=0){
            ans1+=1-s;
            x+=1-s;
        }
        if(i%2==1&&s>=0){
            ans1+=s+1;
            x+=-1-s;
        }
    }
    long long ans2=0;
    long long y=0;
    rep(i,n){
        int s=sums.at(i);
        s+=y;
        if(i%2==1&&s<=0){
            ans2+=1-s;
            y+=1-s;
        }
        if(i%2==0&&s>=0){
            ans2+=s+1;
            y+=-1-s;
        }
    }
    cout<<(min)(ans1,ans2)<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public void exec() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println((a<b && b<c)?"Yes":"No");
		sc.close();
	}

	public static void main(String[] args)  {
		new Main().exec();
	}
}

Measured memory_bytes: 26008
# encoding: utf-8
N, K = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

counts = []
view = 0
cnt = 0
for i, Ai in enumerate(A):
    if i == 0: view = Ai
    elif Ai > view:
        counts.append(cnt)
        view = Ai
        cnt = 0
    cnt += 1
else:
    counts.append(cnt)

counts.sort()

if len(counts) <= K: print(0)
else: print(sum(counts[:-K]))

Measured memory_bytes: 25644
#include <bits/stdc++.h>
using namespace std;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define watch(x) cout<<"->"<<#x<<": "<<x<<endl;
// #define int long long
const int INF = 1000000000;
const int MOD = 1000000007;
const double PI = 2*acos(0.0);
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int m,d;
	cin>>m>>d;
	int res = 0;
	for(int k=1;k<=m;k++)
	{
		int curr = 0;
		for(int i=22;i<=d&&i<=99;i++)
		{
			int x = i%10, y = i/10;
			if(x>=2&&y>=2&&x*y==k)
				++curr;
		}
		res+=curr; 
	}
	return cout<<res<<endl,0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef Wavator
#define de(...) fprintf(stderr, __VA_ARGS__), fflush(stderr);
#else
#define de(...) 98;
#endif
#define pb push_back
#define XX first
#define YY second
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<pair<int, int> > VPI;
const int N = 100005;

ll posDis[N], revDis[N];

struct bian
{
    int id, to, w;
};

vector<bian> zheng[N], fan[N],e[N];
bool vis[N];
string ans[N];
string soso="SOSO", sad = "SAD", happy = "HAPPY";



int clk,dfn[N],bridge[N],low[N];

void dfs(int u, int fa)
{
    dfn[u]=low[u]=++clk;
    for(auto &x: e[u])
    {
        int v = x.to;
        if (!dfn[v])
        {
            dfs(v,u);
            low[u]=min(low[v],low[u]);
            if(dfn[u] < low[v])
            {
                bridge[x.id]=1;
            }
        }
        else if(fa != v)
            low[u]=min(dfn[v],low[u]);
    }
}

int main()
{
#ifdef Wavator
    freopen("test.in", "r", stdin);
#endif
    int n, m;
    scanf("%d%d",&n,&m);



    for (int i = 0; i < m; ++i)
    {
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        zheng[u].push_back(bian{i,v,w});
        fan[v].push_back(bian{i,u,w});
    }

    priority_queue<pair<ll, int> > q;

    const ll inf = 1LL<<60LL;

    for (int i = 0; i <= n; ++i)
        posDis[i]=inf, revDis[i]=inf;

    q.push(make_pair(posDis[1]=0,1));

    while (!q.empty())
    {
        int u = q.top().second;
        q.pop();
        if (vis[u])
            continue;
        vis[u] = 1;
        for (auto &e: zheng[u])
        {
            ll c = e.w;
            if (posDis[e.to] > c + posDis[u])
            {

                posDis[e.to] = c + posDis[u];
                q.push(make_pair(-posDis[e.to],e.to));
            }
        }
    }



    memset(vis,0,sizeof(vis));

    q.push(make_pair(revDis[2]=0,2));

    while (!q.empty())
    {
        int u = q.top().second;
        q.pop();
        if (vis[u])
            continue;
        vis[u] = 1;
        for (auto &e: fan[u])
        {
            ll c = e.w;
            if (revDis[e.to] > revDis[u] + c)
            {
                revDis[e.to] = revDis[u] + c;
                q.push(make_pair(-revDis[e.to],e.to));
            }
        }
    }

    //for (int i = 1; i <= n; ++i) cerr  << revDis[i] << endl;

    for (int i = 1; i <= n; ++i)
        for (auto &x: zheng[i])
        {
            int v=x.to;
            if(posDis[v]+revDis[v]==posDis[2]&&posDis[i]+x.w==posDis[v])
            {
                e[i].push_back(x);
                e[v].push_back(bian{x.id,i,x.w});
            }
        }


    dfs(1,-1);



    for(int i = 1; i <= n; ++i)
    {
        for (auto &x: zheng[i])
        {
            if(bridge[x.id])
                ans[x.id]=sad;
            else if(posDis[x.to] + x.w + revDis[i] < posDis[2])
                ans[x.id]=happy;
            else
                ans[x.id]=soso;
        }
    }

    for(int i=0;i<m;++i)
        cout<<ans[i]<<endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    rep(i, m) cin >> a[i];

    int cnt1 = 0, cnt2 = 0;
    rep(i, m){
        if(a[i] < x) {
            cnt1++;
        }else{
            cnt2++;
        }
    }

    cout << min(cnt1, cnt2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<unordered_map>
#include<climits>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    unordered_map<int,int>ump1,ump2;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    for(int i=0;i<n;i+=2){
        ump1[v[i]]++;
    }
    for(int i=1;i<n;i+=2){
        ump2[v[i]]++;
    }
    int max1=0;
    int max2=0;
    int index1=0;
    int index2=0;
    for(auto it=ump1.begin();it!=ump1.end();it++){
        if(max1<=it->second){
            max2=max1;
            index2=index1;
            max1=it->second;
            index1=it->first;
        }
        else
        if(max2<it->second){
            max2=it->second;
            index2=it->first;
        }
    }
    int m1=0;
    int m2=0;
    int mindex1=0;
    int mindex2=0;
    for(auto it=ump2.begin();it!=ump2.end();it++){
        if(m1<=it->second){
            m2=m1;
            mindex2=mindex1;
            m1=it->second;
            mindex1=it->first;
        }
        else
        if(m2<it->second){
            m2=it->second;
            mindex2=it->first;
        }
    }
    int result=0;
    if(index1==mindex1){
        int f1=max1+m2;
        int f2=max2+m1;
        int result1=(v.size()-f1);
        int result2=(v.size()-f2);
        result=min(result1,result2);
    }
    else
    {
        result=(v.size()-m1-max1);
    }
    cout<<result;
}

Measured memory_bytes: 7876
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int a, b, c;
    std::cin>>a>>b>>c;

    std::string ans;
    if(b - a == c - b){
        ans = "YES";
    }else{
        ans = "NO";
    }
    std::cout<<ans<<std::endl;
    return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    int n;
    ll c;
    cin>>n>>c;
    vector<pair<ll,ll>> sushi(n);
    for(auto &a : sushi) cin>>a.first >> a.second;
    vector<pair<ll,ll>> lsum(n+1),rsum(n+1);
    
    for(int i=n-1;i>=0;--i){
        lsum[i] = {c-sushi[i].first,lsum[i+1].second + sushi[i].second}; 
    }
    rsum[0] = sushi[0];
    for(int i=0;i<n;++i){
        rsum[i+1] = {sushi[i+1].first,rsum[i].second + sushi[i+1].second};
    }
    vector<ll> lg(n+1),rg(n+1);
    for(int i=1;i<n;++i){
        rg[i] = max(rg[i-1],rsum[i-1].second - rsum[i-1].first);
    }
    for(int i=n-2;i>=0;--i){
        lg[i] = max(lg[i+1],lsum[i+1].second - lsum[i+1].first);
    }
    ll sum = 0ll;
    for(int i=0;i<n;++i){
        sum = max(sum,rsum[i].second - rsum[i].first + max(0ll,lg[i] - rsum[i].first));
    }
    for(int i=n-1;i>=0;--i){
        sum = max(sum,lsum[i].second - lsum[i].first + max(0ll,rg[i] - lsum[i].first));
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 6528
#include<iostream>


using namespace std;

int main() {
	char S[51];
	int N;
	cin >> N;
	cin >> S;
	int ans = 0;

	for (int i = 0; i < N - 2; i++) {
		if (S[i] == 'A') {
			if (S[i + 1] == 'B') {
				if (S[i + 2] == 'C') {
					ans += 1;
				}
			}
		}
	}

	cout << ans;

}

Measured memory_bytes: 256
n, l = map(int, input().split())
L = [[0, 0] for _ in range(n)]
for i in range(n):
    s = str(input())
    L[i][0] = s[0]
    L[i][1] = s
L.sort()
#print(L)
ans = ''
for i in range(n):
    ans += L[i][1]
print(ans)


Measured memory_bytes: 3060
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
  		String  str = sc.next();
        String ans = "";
        int a = Character.getNumericValue(str.charAt(0));
        int b = Character.getNumericValue(str.charAt(1));
        int c = Character.getNumericValue(str.charAt(2));
        int d = Character.getNumericValue(str.charAt(3));
        
        if(a+b+c+d==7){
            ans = ""+a+"+"+b+"+"+c+"+"+d+"=7";
        }else if(a+b+c-d==7){
            ans = ""+a+"+"+b+"+"+c+"-"+d+"=7";
        }else if(a+b-c+d==7){
            ans = ""+a+"+"+b+"-"+c+"+"+d+"=7";
        }else if(a+b-c-d==7){
            ans = ""+a+"+"+b+"-"+c+"-"+d+"=7";
        }else if(a-b+c+d==7){
            ans = ""+a+"-"+b+"+"+c+"+"+d+"=7";
        }else if(a-b+c-d==7){
            ans = ""+a+"-"+b+"+"+c+"-"+d+"=7";
        }else if(a-b-c+d==7){
            ans = ""+a+"-"+b+"-"+c+"+"+d+"=7";
        }else if(a-b-c-d==7){
            ans = ""+a+"-"+b+"-"+c+"-"+d+"=7";
        }
        
        
		System.out.println(ans);
   }
}


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

int main () {
	
	int n=0, x=0, i=0, y=0, j=0;
	vector <int> c, v;

	cin >> n;

	for (i=0; i<n; i++) {
		cin >> x;
		c.push_back(x);
	}

	for (i=0; i<n; i++) {
		cin >> x;
		v.push_back(x);
	}


	int res = 0;
	for (i=0; i<n; i++) {
		if (c[i]-v[i] > 0) res+= c[i]-v[i];
	}

	cout << res << endl;


	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var xab = Console.ReadLine().Split(' ');
        var x = int.Parse(xab[0]);
        var a = int.Parse(xab[1]);
        var b = int.Parse(xab[2]);

        if (Math.Abs(x - a) < Math.Abs(x - b))
        {
            Console.WriteLine("A");
        }
        else
        {
            Console.WriteLine("B");
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <queue>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <string>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
int n;
int h[N], e[N*2], ne[N*2], w[N], idx;
vector<int> path;
int res[N];
 
void add(int u, int v) {
    e[idx] = v;
    ne[idx] = h[u];
    h[u] = idx ++;
}
 
void dfs(int curr, int prev) {
    //cout << curr << endl;
    auto it = lower_bound(path.begin(), path.end(), w[curr]);
    int form = -1;
    int pos = it - path.begin();
    if(pos == path.size()) {
        path.push_back(w[curr]);
    } else {
        form = path[pos];
        path[pos] = w[curr];
    }
    res[curr] = path.size();
    for(int i = h[curr]; i!= -1; i = ne[i]) {
        int j = e[i];
        if(j != prev) {
            dfs(j, curr);
        }
    }
    if(form == -1) {
        path.pop_back();
    } else {
        path[pos] = form;
    }
 
}
 
int main(){
    memset(h, -1, sizeof h);
    int u, v;
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        cin >> w[i];
    }
    for(int i = 1; i < n; i ++) {
        cin >> u >> v;
        add(u, v);
        add(v, u);
    }
    dfs(1, -1);
    for(int i = 1; i <= n; i ++) {
        cout << res[i] << endl; 
    }
    return 0;
}


Measured memory_bytes: 23428
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  
  vp ab(n),cd(n);
  rep(i,n){
    int a,b;
    cin >> a >> b;
    ab[i]=P(a,b);
  }
  rep(i,n){
    int a,b;
    cin >> a >> b;
    cd[i]=P(a,b);
  }
  sort(all(ab));
  sort(all(cd));
  
  
  int ans=0;
  vector<bool>used(n,false);
  rep(i,n){
    auto blue=cd[i];
    int idx=-1;
    int ymax=-1;
    rep(j,n){
      auto red=ab[j];
      if(!used[j] && red.first<blue.first && red.second<blue.second && ymax<red.second){
        idx=j;
        ymax=red.second;
      }
    }
    if(idx!=-1){
      used[idx]=true;
      ans++;
    }
  }
  cout << ans << endl;
        
  
  return 0;     
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  string s; cin >> s;

  string ans;
  for(int i=0;i<SZ(s);++i) {
    if(s[i] == '0') {
      ans.push_back('0');
    } else if(s[i] == '1') {
      ans.push_back('1');
    } else if(ans != "") {
      ans.pop_back();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,i,x;
    scanf("%d%d",&n,&m);
    int a[m];
    x=n;
    for(i=0;i<m;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<m;i++)
    {
        x=x-a[i];
    }
    if(x>=0)
    {
        printf("%d\n",x);
    }
    else
    printf("-1\n");
}

Measured memory_bytes: 1760
#include <stdio.h>
#include <math.h>

int main(){
  int n_org;
  int S[ 10000 ] = {};
  int i = 0;

  scanf( "%d", &n_org );
  int n = n_org;

while( n != 0 ){
  //printf( "%d\n", n % ( -2 ) );
  //printf( "%d = ", n );
  if ( n % ( -2 ) < 0 ){
    S[ i ] = n - ( n / ( -2 ) + 1 ) * ( -2 );
    i++;
    n = n / ( -2 ) + 1;
   
  }else{
    S[ i ] = n % ( -2 );
    i++;
    n = n / ( -2 );
  }
  //printf( "%d ... %d\n", n, S[ i - 1 ] );
}
  if ( i == 0 ){
    printf( "%d\n", n );
    return 0;
  }
  int j;
  for ( j = i - 1; j >= 0; j-- ){
    printf( "%d", S[j] );
  }
  puts( "" );
  
  return 0;
}

Measured memory_bytes: 256
import io
import sys

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def IN_S():
  return input()


def IN_I():
  return int(input())


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


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
2000 3
'''


def MAIN():
  # T_IN()
  cmb_init(MOD)
  A()


def A():
  x = IN_L_I()
  n = x[0]
  k = x[1]

  res = []
  for i in range(1, k + 1):
    blue = f(k, i)

    # red = 0
    # red += f(n - k, i - 1)
    # red += f(n - k, i)
    # red += f(n - k, i)
    # red += f(n - k, i + 1)
    red = f2(n - k - (i - 1), i + 1)

    res.append((blue * red) % MOD)

  [print(i) for i in res]
  return None


def f(x: int, y: int):
  if x < y:
    return 0
  if x == y == 0:
    return 1
  if y < 1:
    return 0
  return f2(x - y, y)


def f2(x: int, y: int):
  return c(x + y - 1, y - 1)


def c(a: int, b: int):
  return cmb(a, b, MOD)


def track(func):
  def tracked(*args, **kwargs):
    result = func(*args, **kwargs)
    name = func.__name__
    arg_str = ",".join(repr(arg) for arg in args)
    print("%s(%s) -> %r" % (name, arg_str, result))
    return result

  return tracked


### CMB ###############################
def cmb(n, r, mod):
  if (r < 0 or r > n):
    return 0
  r = min(r, n - r)
  return g1[n] * g2[r] * g2[n - r] % mod


def cmb_init(mod):
  for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


N = 10 ** 4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

### CMB ###############################


MAIN()


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

int main()
{
    int n; cin>>n; int a[n],b[n]; 
    for(int i=0;i<n;i++) { cin>>a[i]; b[i]=a[i]; }
    sort(a,a+n); int cnt=0;
    for(int i=0;i<n;i++) 
    {
        if(a[i]!=b[i]) cnt++;
    }
    if(cnt>2) cout<<"NO";
    else cout<<"YES";
}


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

const int MAX_N = 1 << 17;

int n, dat[2* MAX_N-1];

void init(int n_){
	n=1;
	while( n< n_) n*=2;
	for(int i=0; i<2*n-1; i++) dat[i]= INT_MAX;

}

void update(int k, int a){
	k+=n-1;
	dat[k]= a;
	while(k >0){
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1], dat[k*2+2]);
	}
}

int query(int a, int b, int k ,int l , int r){
	if(r<=a || b<=l) return INT_MAX;
	
	if(a<=l&r<=b)return dat[k];

 	else{
		int vl = query(a,b,k*2+1,l,(l+r)/2);
		int vr = query(a,b,k*2+2,(l+r)/2,r);
		return min(vl,vr);
	}
}

int main(void){
	int N,Q;
	cin >>  N >> Q;
	init(N);
	for(int i=0;i<Q;i++){
		int com;
		cin >> com;
		if(com){
			int s,t;
			cin >> s >> t;
			cout << query(s,t+1,0,0,n) << endl;
		}else{
			int k,x;
			cin >> k >> x;
			update(k,x);
		}
	}
	return 0;
}

Measured memory_bytes: 2184
def expr(ns)
  #puts "ns=#{ns}"

  if ns.length == 1
    return (eval(ns[0]) == 10) ? ns[0] : nil
  end

  is = (0...ns.length).map{|i| i}

  is.permutation(2) do |i, j|
    ns0 = [0]
    is.each{|k| ns0.push(ns[k]) if k != i && k != j}

    for op in ["+", "-", "*"]
      ns0[0] = "(#{ns[i]}#{op}#{ns[j]})"
      ans = expr(ns0)
      return ans unless ans.nil?
    end
  end

  nil
end

### main

while (line = gets)
  ns = line.chomp.split(" ").map{|s| s.to_i }
  break if (ns[0] | ns[1] | ns[2] | ns[3]) == 0

  str = expr(ns)
  puts (str.nil?) ? "0" : str
end

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

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	
	var s,t string
	fmt.Scan(&s,&t)
	ls := len(s)

	next := [200001][26]int{}

	s = s + s
	
	for i := 2*ls-1; i >= 0; i-- {
		for j := 0; j < 26; j++ {
			next[i][j] = next[i+1][j]
		}
		next[i][s[i]-'a'] = i+1
	}

	ans := int64(0)
	n := int64(ls)

	for _, e := range t {
		c := e-'a'
		x := ans%n
		if next[x][c] == 0 {
			fmt.Println(-1)
			return
		}

		ans+=int64(next[x][c])-x
		
	}

	fmt.Println(ans)

}


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

int main(){
  int n,len;
  string str;

  while(cin >> n,n){
    string key = "I";
    for(int i = 0 ; i < n ; i++){
      key += "OI";
    }

    int cnt = 0;
    cin >> len >> str;
    for(int i = 0 ; i < len ; i++){
      string search = str.substr(i,key.size());
      if(search == key) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

int main() {
    int n; cin >> n;
    vector<vector<int64_t>> xyh(n,vector<int64_t>(3));
    rep(i,n){
        rep(j,3){
            cin >> xyh[i][j];
        }
    }
    int64_t ansx, ansy, ansh;
    bool bk = false;
    rep(cx,101){
        rep(cy,101){
            int64_t h = -1;
            int64_t maxh = 1e10;
            bool b = true;
            rep(i,n){
                int xi = xyh[i][0];
                int yi = xyh[i][1];
                int hi = xyh[i][2];

                if(hi == 0){
                    maxh = min(maxh,(int64_t)(abs(xi-cx)+abs(yi-cy)));
                    if(h > maxh){
                        b = false;
                        break;
                    }
                }
                else{
                    int64_t chi = hi + abs(xi-cx) + abs(yi-cy);
                    if(h > 0 && chi != h){
                        b = false;
                        break;
                    }
                    if(h == -1) h = chi;
                    if(h > maxh){
                        b = false;
                        break;
                    }
                }
            }
            if(b){
                if(h < 1) h = 1;
                if(h > maxh){
                    continue;
                }
                ansx = cx; ansy = cy; ansh = h;
                bk = true;
                break;
            }
        }
        if(bk) break;
    }

    cout << ansx << " " << ansy << " " << ansh << endl;
}


Measured memory_bytes: 256