akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;
int x,y,o=0;
int main()
{
    cin>>x>>y;
    if (x>0 && y>0 && x>y){cout<<abs(x-y)+2<<endl;return 0;}
    if (x==0)
    {
        if (y<0) cout<<abs(x-y)+1<<endl;
        if (y>0) cout<<abs(x-y)<<endl;
        return 0;
    }
    if (y==0)
    {
        if (x>0) cout<<abs(x-y)+1<<endl;
        else cout<<abs(x-y)<<endl;
        return 0;
    }
    if (x<0 && y<0 && x<y) {cout<<abs(x-y)<<endl;return 0;}
    if (x<0&&y<0) o+=2;
    if (x>0&&y<0 || x<0&&y>0) o++;
    x=abs(x);y=abs(y);
    o+=abs(x-y);
    cout<<o<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>

using namespace std;

int main(void){
  long int K,A,B,i,n=1;
  scanf("%ld%ld%ld", &K,&A,&B);
  if(B-A<=1){
    n+=K;
    printf("%ld",n);
    return 0;
  }else{
    for(i=0;i<K;i++){
      if(n<A) n+=1;
      else{
        if((K-i)==1){
          n+=1;
          break;
        }else if((K-i)%2==0){
          n+=((K-i)/2)*(B-A);
          break;
  	    }else{
          n+=((K-i)/2)*(B-A)+1;
          break;
        }
      }
    }
    printf("%ld",n);
    return 0;
  }
}

Measured memory_bytes: 128
const main = (txt: any): void => {
  const input = txt.split('\n')
  for (const i in input) {
    if (Number(i) > 0) {
      console.log(input[i])
      console.log(input[i])
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

int main() {
  int X;
  long long ans,r,g,b;
  ans=0;
  cin >>X;
  string S;
  cin>>S;
  r=0;
  g=0;
  b=0;
  for(int i=0;i<X;i++){
          if(S[i]=='R'){
        r++;
      }      if(S[i]=='G'){
        g++;
      }      if(S[i]=='B'){
        b++;
      }
  }
  ans=r*g*b;
  for(int i=0;i<X;i++){
    for(int j=i+1;2*j-i<X;j++){
      if(S[i]!=S[j]&&S[j]!=S[2*j-i]&&S[i]!=S[2*j-i]){
        ans--;
      }
    }
  }
     cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

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

const int N = 1e5 + 500;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

ll s1,s2,op,s3,s4;
int a[N],b[N],n,opa[N],opb[N];

int main(){
    scanf("%d",&n);
    for(int i = 0;i<n;i++)
        scanf("%d",a+i),s1 += a[i];
    for(int i = 0;i<n;i++)
        scanf("%d",b+i),s2 += b[i];
    for(int i = 0;i<n;i++){
        int x = b[i] - a[i];
        if(x > 0){
            opa[i] = x / 2;
            if(x % 2 == 1)
                opa[i]++,opb[i]++;
        }
        else{
            opb[i] += -x;
        }
        s3 += (ll)opa[i];
        s4 += (ll)opb[i];
    }
    op = s2 - s1;
    if((op - s3) * 2!= (op - s4) || s3 > op || s4 > op) printf("No\n");
    else printf("Yes\n");
}


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

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    while(true){
        int n,m;
        cin >> n >> m;
        if(n==0) break;
        vector<double> maxi(n,1.0);
        vector<vector<double> > M(n,vector<double>(n));
        rep(i,n) rep(j,n) cin >> M[i][j];
        for(int i=0;i<m-1;i++){
            vector<double> next(n,-1);
            for(int j=0;j<n;j++){
                for(int k=0;k<n;k++){
                    next[k] = max(next[k],maxi[j] * M[j][k]);
                }
            }
            maxi = next;
        }
        cout << fixed << setprecision(2) << *max_element(all(maxi)) << endl;
    }
    return 0;
}

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

typedef long long ll;

vector<int> a, b, x, y, p;
vector<ll> ans;
int n;

void dfs(int ind){
    if(ind == n){
        int pop = a.size() + b.size();
        ll tmp = 0;
        for(int i = 0; i < n; i++){
            int diff = min(abs(x[i]), abs(y[i]));
            for(int j : a)  diff = min(diff, abs(j-x[i]));
            for(int j : b)  diff = min(diff, abs(j-y[i]));
            tmp += (ll)diff * p[i];
        }
        ans[pop] = min(ans[pop], tmp);
        return;
    }
    a.push_back(x[ind]);
    dfs(ind+1);
    a.pop_back();
    b.push_back(y[ind]);
    dfs(ind+1);
    b.pop_back();
    dfs(ind+1);
}

int main(){
    cin >> n;
    x.resize(n);
    y.resize(n);
    p.resize(n);
    ans.resize(n+1, 1ll<<60);
    for(int i = 0; i < n; i++)  cin >> x[i] >> y[i] >> p[i];
    dfs(0);
    for(int i = 0; i < n+1; i++)  cout << ans[i] << endl;
    return 0;
}

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

int main(){
  int n;
  int cnt=0;
  int flag=false;
  cin >> n;
  rep(i, n){
    int d1, d2;
    cin >> d1 >> d2;
    if(d1==d2)cnt++;
    else cnt=0;
    if(cnt>2)flag=true;
  }
  if(flag)cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	//sort(a.begin(),a.end());
	ll n,x=0;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		x += a[i];
	}
	for (ll i = 1; i < n; i += 2) {
		x -= 2 * a[i];
	}
	for (ll i = 0; i < n; i++) {
		cout << x << endl;
		x = 2 * a[i] - x;
	}

	return 0; 
}









Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

struct UnionFind {
	vector<int>d;

	UnionFind(int N) :d(N, -1) {}

	int find(int x) {
		if (d[x] < 0)return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return false;
		if (d[x] > d[y])swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return -d[find(x)];
	}
};

int main() {
	init();
	
	int N, M; cin >> N >> M;
	UnionFind uf(N);
	vector<vector<pair<int, int>>>vec(N);
	vector<int>cnt(M);
	rep(i, 0, M) {
		int a, y; cin >> a >> y;
		vec[a - 1].push_back(make_pair(y, i));
		cnt[i] = a;
	}
	rep(i, 0, N) {
		if (vec[i].size() != 0) {
			sort(all(vec[i]));
		}
	}
	map<int, int>mp;
	rep(i, 0, N) {
		rep(j, 0, vec[i].size()) {
			int y = vec[i][j].second;
			mp[y] = j + 1;
		}
	}
	rep(i, 0, M) {
		string num = to_string(cnt[i]), year = to_string(mp[i]);
		string ans = string(12, '0');
		rep(i, 0, num.size()) {
			ans[5 - i] = num[num.size() - 1 - i];
		}
		rep(i, 0, year.size()) {
			ans[11 - i] = year[year.size() - 1 - i];
		}
		cout << ans << "\n";
	}

	return 0;
}

Measured memory_bytes: 12416
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

ll dp[20005][256];

int main(void) {
    int i,j;
    int n, m;
    while(cin >> n >> m, n+m){
        vi c(m),x(n);
        rep(i,m) cin >> c[i];
        rep(i,n) cin >> x[i];
        rep(i,n+1)rep(j,256)
            dp[i][j] = (ll)INF*INF;
        dp[0][128] = 0;
        int k;
        rep(i,n)rep(j,256)rep(k,m){
            ll t = j + c[k];
            if(t < 0) t = 0;
            if(t > 255) t = 255;
            dp[i+1][t] = min(dp[i+1][t], dp[i][j] + (t-x[i])*(t-x[i]));
        }
        ll ans = (ll)INF*INF;
        rep(i,256)
            ans = min(ans, dp[n][i]);
        cout << ans << endl;
    }
}



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

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000'000'007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
	IOS

	string st;
	cin >> st;
	ll n = st.size();
	vector<vector<ll>> dp(n + 10, vector<ll>(13,0));
	dp[0][0] = 1;
	for(int i = 1; i <= n; ++i){
		if(st[i - 1] == '?'){
			for(int cur_num = 0; cur_num < 10; ++cur_num)
			{
				for (int j = 0; j < 13; ++j)
				{
					dp[i][(j * 10 + cur_num) % 13] += dp[i - 1][j];
					dp[i][(j * 10 + cur_num) % 13] %= MOD;
				}
			}
		}else{
			ll cur_num = st[i - 1] - '0';
			for(int j = 0; j < 13; ++j){
				dp[i][(j * 10 + cur_num) % 13] += dp[i - 1][j];
				dp[i][(j * 10 + cur_num) % 13] %= MOD;
			}
		}
	}
	cout << dp[n][5];
	return 0;
}

Measured memory_bytes: 13648
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let a = read::<usize>();
    let b = read::<usize>();

    if b * 2 >= a {
        println!("{}", 0)
    } else {
        println!("{}", a - b * 2)
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REPF(i, a, n) for (int i = (a); i < (int)(n); i++)
#define REP(i, n) REPF(i, 0, n)
#define ALL(x) begin(x),end(x)
#define SZ(x) (int)(x.size())

vector<bool> isp;
void init_prime(int N) {
    isp = vector<bool>(N, true);
    isp[0] = isp[1] = false;
    REPF(i, 2, N) {
        if (i * i > N) break;
        if (!isp[i]) continue;
        REPF(j, 2, N) {
            if (i * j >= N) break;
            isp[i * j] = false;
        }
    }
}
signed main() {
    init_prime(10000007);
    int N;
    cin >> N;

    int ans = 0;
    REPF(i, 3, N + 1) {
        if (!isp[i]) continue;
        if (isp[i + 2]) {
            ans += 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define ll long long
#define li long int
#define ld long double
#define pl pair<long long, long long>
#define pi pair<int, int>
#define ppl pair<pl, ll>
#define ppi pair<int, pi>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LLFOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define MOD 1000000007
#define M2 998244353
//std::cout <<setprecision(30) << av << endl;
using namespace std;
ll h[200000];
ll a[200000];
ll b[200000];
int cnt(ll arr[], ll x, int n) {

  ll *low = lower_bound(arr, arr+n, x);
  if (low == (arr + n) || *low != x)
     return 0;
  ll *high = upper_bound(low, arr+n, x);
  return high - low;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
       int n;
       cin >> n;
       FOR(i, 0, n){
        cin >> h[i];
       }
       FOR(i, 0, n){
        a[i]=h[i]+(ll)i+1LL;
       }
       FOR(i, 0, n){
        b[i]=(ll)i+1LL-h[i];
       }
       sort(a, a+n);
       sort(b, b+n);
       ll ans=0;

       FOR(i, 0, n){
        ans+=(ll)cnt(b, a[i], n);
       }
       cout << ans<< endl;

    }
}


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

const ll maxs = 5e5+5;
const ll lmaxs = 20;
ll mod = 998244353;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

ll fact[maxs];
ll ifact[maxs];

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

ll add(ll a,ll b){
    return (a+b)%mod;
}

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = mul(res,x);
        x = mul(x,x);
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}

void pre(){
    fact[0] = 1;
    ifact[0] = 1;
    for(ll i=1;i<maxs;i++){
        fact[i] = mul(fact[i-1],i);
        ifact[i] = inv(fact[i]);
    }
}

ll ncr(ll n,ll r){
    ll tmp = mul(fact[n],ifact[n-r]);
    return mul(tmp,ifact[r]);   
}

void solve(){
    ll n,m,k;
    cin >> n >> m >> k;    
    
    ll ans=0;
    for(ll i=0;i<=k;i++){

        ll rem = n-i;
        ll tmp = fast(m-1,rem-1);
        tmp = mul(tmp , m);
        ll tmp2 = ncr(n-1,i);
        //cout << tmp << " " << tmp2 << endl;
        ans = add( ans , mul(tmp,tmp2) );
    } 
    cout << ans ;
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

int main(){
    int i,max=-1,max_1=-1,max_2=-1,a;
    for(i=0;i<=9;i++){
        cin >> a;
        if(a>max){
            max_2=max_1;
            max_1=max;
            max=a;
        }
        else if(a>max_1){
            max_2=max_1;
            max_1=a;
        }
        else if(a>max_2){
            max_2=a;
        }
    }
    cout << max << endl << max_1 << endl << max_2 << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,multiset<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    multiset<ll> left = {-INF}, right = {INF};
    ll val = 0;
    rep(i,q){
        ll a,b,c;
        cin >> a;
        if(a == 1){
            cin >> b >> c;
            ll l = *(--left.end()), r = *right.begin();
            if(l <= b && b <= r){
                left.insert(b), right.insert(b);
                val += c;
            }else if(b < l){
                left.erase(--left.end());
                left.insert(b), left.insert(b);
                right.insert(l);
                val += (l-b)+c;
            }else{
                right.erase(right.begin());
                right.insert(b), right.insert(b);
                left.insert(r);
                val += (b-r)+c;
            }
        }else{
            cout << *(--left.end()) << " " << val << "\n";
        }
    }
    // show(left), show(right);
    return 0;
}


Measured memory_bytes: 19072
calc = input().split(" ")

nums = []
subTotal = 0

for i in range(len(calc)):
    if calc[i].isdigit():
        nums.append(int(calc[i]))
    else:
        b = nums.pop()
        a = nums.pop()

        if calc[i] == "+":
            subTotal = a + b
        elif calc[i] == "-":
            subTotal = a - b
        elif calc[i] == "*":
            subTotal = a * b
        
        nums.append(subTotal)

print(" ".join(map(str,nums)))

Measured memory_bytes: 7644
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.buffer.readline()[:-1].decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

n=int(input())
ans=n//2
if n%2==1:
    pass
else:
    ans-=1
print(ans)

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

const int dx[2][7] = {{0, 1, 1, 0, -1, -1, 0}, {0, 1, 1, 0, -1, -1, 0}};
const int dy[2][7] = {{1, 0, -1, -1, -1, 0, 0}, {1, 1, 0, -1, 0, 1, 0}};
const int K = 128;

struct State {
	int x, y, t, sum;
};

int sx, sy, gx, gy, lx, ly;
int ng[256][256];
int dist[256][256][6];

int solve()
{
	deque<State> dq;
	fill_n(**dist, 256 * 256 * 6, 1 << 28);
	
	dist[sx + K][sy + K][6] = 0;
	dq.push_back({sx, sy, 0, 0});
	
	while (dq.size()){
		State c = dq[0]; dq.pop_front();
		if (dist[c.x + K][c.y + K][c.t] < c.sum) continue;
		
		for (int dir = 0; dir < 7; dir++){
			int nx = c.x + dx[c.x & 1][dir];
			int ny = c.y + dy[c.x & 1][dir];
			int nt = (c.t + 1) % 6;
			int ig = dir != abs(c.x * c.y * c.t) % 6;
			int nsum = c.sum + ig;
			if (abs(nx) > lx) continue;
			if (abs(ny) > ly) continue;
			if (ng[nx + K][ny + K]) continue;
			if (dist[nx + K][ny + K][nt] <= nsum) continue;
			
			dist[nx + K][ny + K][nt] = nsum;
			if (ig) dq.push_back({nx, ny, nt, nsum});
			else dq.push_front({nx, ny, nt, nsum});
		}
	}
	
	int res = 1 << 28;
	for (int i = 0; i < 6; i++){
		res = min(res, dist[gx + K][gy + K][i]);
	}
	
	if (res == 1 << 28) return -1;
	return res;
}

int main()
{
	cin >> sx >> sy >> gx >> gy;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		ng[x + K][y + K] = 1;
	}
	cin >> lx >> ly;
	printf("%d\n", solve());
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

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

   int N;
   cin>>N;
   vector<int>a(N);
   for(int i=0;i<N;i++)cin>>a[i];
   bool flg = false;
   for(int i=0;i<N;i++){
      if(a[i]%2)flg = true;
   }
   if(flg)cout<<"first"<<endl;
   else cout<<"second"<<endl;
   return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<cstring>
#define SF scanf
#define PF printf
#define MAXN 60
using namespace std;
typedef long long ll;
bool used[MAXN],vis[MAXN];
ll ans;
int A[MAXN],B[MAXN],n;
bool w[MAXN][MAXN];
void build(){
    for(int i=1;i<=50;i++)
        if(used[i]==1){
            for(int j=0;j<=50;j++)
                w[j][j%i]=1;
        }
}
void dfs(int x){
    vis[x]=1;
    for(int i=0;i<=50;i++)
        if(w[x][i]==1&&vis[i]==0)
            dfs(i);
}
bool check(){
    for(int i=0;i<n;i++){
        memset(vis,0,sizeof vis);
        dfs(A[i]);
        if(vis[B[i]]==0)
            return 0;
    }
    return 1;
}
int main(){
    SF("%d",&n);
    for(int i=0;i<n;i++)
        SF("%d",&A[i]);
    for(int i=0;i<n;i++)
        SF("%d",&B[i]);
    for(int i=1;i<=50;i++)
        used[i]=1;
    build();
    if(check()==0){
        PF("-1\n");
        return 0;
    }
    for(int i=50;i>=0;i--){
        memset(w,0,sizeof w);
        used[i]=0;
        build();
        if(check()==0){
            used[i]=1;
            ans+=(1ll<<i);
        }
    }
    PF("%lld",ans);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	
	public static int lcs(String a, String b, int n, int k) {
		
		int[][] arr = new int[n+1][k+1];
		for (int i = 0; i <= n; i++) 
        { 
            for (int j = 0; j <= k; j++) 
            { 
                if (i == 0 || j == 0) {
                    arr[i][j] = 0; 
                }
                else if (a.charAt(i-1) == b.charAt(j-1)) { 
                    arr[i][j] = arr[i-1][j-1] + 1; 
                }
                else {
                    arr[i][j] = Math.max(arr[i-1][j], arr[i][j-1]); 
                }
            } 
        }
        int count = 0;
        int i = n;
        int j = k; 
        while (i > 0 && j > 0) 
        { 
            if (a.charAt(i-1) == b.charAt(j-1)) 
            { 
                count++;  
                i--;  
                j--;      
            } 
            else if (arr[i-1][j] > arr[i][j-1]) 
                i--; 
            else
                j--; 
        } 
        
        return count;
        
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sets = in.nextInt();
		for(int i = 0; i < sets; i++) {
			String a = in.next();
			String b = in.next();
			int result = lcs(a, b, a.length(), b.length());
			System.out.println(result);
		}
		
		in.close();
	}

}


Measured memory_bytes: 66244
#include <iostream>
using namespace std;
#define ll long long
ll a,b,c,sum;
int main()
{
	cin >> a >> b >> c; // a=normal,b=antidotes,c=poison
	
	if(c>a+b)
	cout << a+2*b+1;
	else
	cout << c+b;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()
arr = ["hon", "pon", "bon"]
arr2 = [1, 1, 0, 2, 0, 0, 1, 0, 1, 0]
print(arr[arr2[N % 10]])


Measured memory_bytes: 9068
#include<cstdio>
#include<algorithm>

int land[100][100];
int max_num;

using namespace std;

void saiki(int x,int y,int step);//xとyでjoi太郎君の場所を保存

int main(void)
{
	int tate,yoko;
	while(scanf("%d%d",&yoko,&tate))
	{
		if(tate == 0 && yoko == 0) break;
		for(int i = 0;i < tate;i++)
		{
			for(int j = 0;j < yoko;j++)
			{
				scanf("%d",&land[i][j]);
			}
		}
		for(int i = 0;i < tate;i++)
		{
			for(int j = 0;j < yoko;j++)
			{
				if(land[i][j] == 1)
				{
					saiki(j,i,1);
				}
			}
		}
		printf("%d\n",max_num);
		max_num = 0;
	}
	return 0;
}

void saiki(int x,int y,int step)
{
	static int flag[100][100] = {{0}};
	flag[y][x] = 1;
	
	if(y != 0 && land[y-1][x] == 1 && flag[y-1][x] == 0)
	{
		saiki(x,y-1,step+1);
	}
	

	if(x != 0 && land[y][x-1] == 1 && flag[y][x-1] == 0)
	{
		saiki(x-1,y,step+1);
	}

	if(land[y+1][x] == 1 && flag[y+1][x] == 0)
	{
		saiki(x,y+1,step+1);
	}

	if(land[y][x+1] == 1 && flag[y][x+1] == 0)
	{
		saiki(x + 1,y,step+1);
	}

	flag[y][x] = 0;
	if(step > max_num) max_num = step;
	return;
}

Measured memory_bytes: 1092
/*
 *
 *
 */

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

#define endl "\n"
#define FSP(n) cout << fixed << setprecision(n);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ALL(v) (v).begin(), (v).end();
#define SORT(v) sort(ALL(v));
#define REV(v) reverse(ALL(v));
static inline ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b);}
static inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
#define prepare cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);

void solve() {
    string S;
    cin >> S;
    bool answer = false;
    if (S[2] == S[3] && S[4] == S[5]) {
        answer = true;
    }
    if (answer == true) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
    prepare
    solve();
}


Measured memory_bytes: 256
import numpy as np
N, M = list(map(int,input().split()))
H = list(map(int,input().split()))
l = np.ones(N)
for i in range(M):
  A, B = list(map(int,input().split()))
  A = A -1
  B = B -1
  if H[B] - H[A] < 0:
    l[B] = 0
  elif H[B] - H[A] > 0:
    l[A] = 0
  else:
    l[A] = 0
    l[B] = 0
print(int(l.sum()))

Measured memory_bytes: 38556
#include <stdio.h>

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

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

    cout << r*r <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D,N,M;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  N = s.size();
  string t(s);
  string u(s);
  int st = 0;
  int su = 0;
  for(int i = 0; i < N; i++) {
    if(i % 2 == 0) {
      t[i] = '0';
      u[i] = '1';
      //if(s[i] != '0') st++;
      //if(s[i] != '1') su++;
    } else {
      t[i] = '1';
      u[i] = '0';
      //if(s[i] != '1') st++;
      //if(s[i] != '0') su++;
    }
  }

  for(int i = 0; i < N; i++) {
    if(s[i] != t[i]) st++;
    if(s[i] != u[i]) su++;
  }
  cout << min(st, su);



  return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <numeric>
#include <string>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <deque>
#include <stdlib.h>
#include<cmath>
#define N 200003
using namespace std;
int u[N] , v[N] , dis[N];
int main()
{
    int n , m;
    scanf("%d%d",&n,&m);

    int i , inf = 99999999;
    for (i=1; i<=m; i++)  scanf("%d%d",&u[i],&v[i]);
    for (i=1; i<=n; i++)  dis[i] = inf;
    dis[1] = 0;

    for (int k=1; k<=n-1; i++)
    {
        bool flag = false;
        for (i=1; i<=m; i++)
        {
            if (dis[v[i]] > dis[u[i]] + 1)
            {
                dis[v[i]] = dis[u[i]] + 1;
                flag = true;
            }
            if (dis[u[i]] > dis[v[i]] + 1)
            {
                dis[u[i]] = dis[v[i]] + 1;
                flag = true;
            }
        }
        if (!flag)  break;
    }

    if (dis[n] <= 2)  cout << "POSSIBLE" << endl;
    else  cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	forn(i, n) cin >> a[i];
	if(count(all(a), 0) > 0) {
		cout << 0 << endl;
		return 0;
	}
	ll res = 1;
	forn(i, n) {
		if(a[i] <= 1000*1ll*1000*1000*1000*1000*1000/res)
			res *= a[i];
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3960
#include <iostream>
#include <queue>
using namespace std;
#define MAX_H 1000
#define MAX_W 1000
#define INF 100000000

typedef pair<int, int> P;

char a[MAX_H][MAX_W];
int d[MAX_H][MAX_W];
int h, w, n;
int sx, sy;
int gx, gy;

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

int bfs() {
  int count = 0;
  for (int k = 1; k <= n; k++) {
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++)
	d[i][j] = INF;

    queue<P> que;
    que.push(P(sx, sy));
    d[sy][sx] = 0;

    while (!que.empty()) {
      P p = que.front();
      que.pop();
      if (p.first == gx && p.second == gy) {
	count += d[p.second][p.first];
	break;
      }

      for (int i = 0; i < 4; i++) {
	int nx = p.first + dx[i], ny = p.second + dy[i];
	if (0 <= nx && nx < w && 0 <= ny && ny < h && a[ny][nx] != 'X' &&
	    d[ny][nx] == INF) {
	  que.push(P(nx, ny));
	  d[ny][nx] = d[p.second][p.first] + 1;
	}
      }
    }
    sx = gx;
    sy = gy;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
	if (a[i][j] == k + 1 + '0') {
	  gx = j;
	  gy = i;
	}
      }
    }
  }
  return count;
}

int main() {
  cin >> h >> w >> n;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      cin >> a[i][j];

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == 'S') {
	sx = j;
	sy = i;
      } else if (a[i][j] == '1') {
	gx = j;
	gy = i;
      }
    }
  }

  int ans = bfs();
  cout << ans << endl;

  return 0;
}

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

int main() {
    long long  a,b,c,k;
    cin>>a>>b>>c>>k;
    long long sum =0;

    if(a<k){
        sum+=a;
        k-=a;
        if(k!=0) {
            k-=b;
        }
        
        if(k!=0) {
            sum-=k;
        }
        
    }
    else if(k == a) {
        sum+= a;
    }
    else{
        sum+=k;
    }
    
    cout << sum ;
	return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

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

	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());
		int[] w = new int[n];
		int m = (1<<30) * -1;
		int j = 0;
		for (int i = 0; i < n; i++) {
			w[i] = Integer.parseInt(reader.readLine());
			m = Math.max(m, w[i]);
			j += w[i];
		}
		reader.close();

		int i = m;
		while (i <= j) {
			int guess = i + (j - i) / 2;
			if (allocate(n, w, k, guess) < 0) {
				i = guess + 1;
			} else {
				j = guess - 1;
			}
		}
		System.out.println(i);
	}

	private int allocate(int n, int[] w, int k, int p) {
		int load = 0;
		int cnt = 1;
		for (int i = 0; i < n; i++) {
			if (load + w[i] > p) {
				cnt++;
				if (cnt > k) return -1;
				load = 0;
			}
			load += w[i];
		}
		return 0;
	}
}


Measured memory_bytes: 35484
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define complex complex228
#define count count228
#define sin sin228
#define list list228

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int M, D;
	cin >> M >> D;
	int cnt = 0;
	for (int m = 1; m <= M; ++m) {
		for (int d = 10; d <= D; ++d) {
			int a = d % 10;
			int b = (d / 10) % 10;
			if (min(a,b)>=2 && a * b == m) ++cnt;
		}
	}
	cout << cnt << '\n';
	return 0;
} // kek ;
// Ого! Кажетсья это $#@!



















Measured memory_bytes: 256
// Problem : D - Knapsack 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 100005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int dp[105][maxn];
void solve()
{
	int n,W,ans=0;
	cin >> n >> W;
	rep(i,1,n+1)
	{
		int v,w;
		cin >> w >> v;
		rep(j,1,W+1)
		{
			dp[i][j]=max(dp[i][j],dp[i-1][j]);
			if(w <= j)
				dp[i][j]=max(dp[i][j],v+dp[i-1][j-w]);
			if(j == W)
				ans = max(ans,dp[i][j]);
		}
	}
	cout << ans;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 81776
#include <iostream>

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

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

    ll pat[N + 1][K + 1];
    ll sum[N + 1][K];
    fill(pat[0], pat[1], 0);
    pat[0][0] = 1;

    for (int i = 1; i <= N; ++i) {
        sum[i - 1][0] = pat[i - 1][0];
        for (int k = 1; k <= K; ++k) {
            sum[i - 1][k] = (sum[i - 1][k - 1] + pat[i - 1][k]) % MOD;
        }

        fill(pat[i], pat[i + 1], 0);

        int a;
        cin >> a;

        for (int k = 0; k <= K; ++k) {
            pat[i][k] += sum[i - 1][k] - (k > a ? sum[i - 1][k - a - 1] : 0) + MOD;
            pat[i][k] %= MOD;
        }
    }

    cout << pat[N][K] << endl;
    return 0;
}


Measured memory_bytes: 157312
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		// 文字列の入力
		int[] d = new int[a];
		for(int i = 0; i < a; i++){
			d[i] = sc.nextInt();
		}
		int b = d[0];
		long c = 0;
		 
		for(int i = 0; i < a; i++){
			if(d[i] > b){
				b = d[i];
			}
			c += b - d[i];
		}
		System.out.println(c);
		
		
	}
}

Measured memory_bytes: 60008
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))
N = int(input())
A = inpl()
X = defaultdict(int)
Y = defaultdict(int)
for i in range(N):
    x = A[i] + i
    y = A[i] - i
    X[x] += 1
    if y < 0:
        Y[y] += 1
ans = 0
for y, k in Y.items():
    ans += k * X[-y]
print(ans)


Measured memory_bytes: 117932
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#pragma GCC optimize "trapv"
#define endl '\n'
#define fi first
#define sec second
#define pb push_back 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF INT_MAX
#define LINF LONG_LONG_MAX
void solve(){
	int l,r,d;
	cin>>l>>r>>d;
	cout<<r/d-(l-1)/d<<endl;
}
int main(){
	fio;
    int test;
    //cin>>test;
    test=1;
    while(test--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string C0,C1,C2;
  cin >> C0 >> C1 >> C2;
  cout << C0[0] << C1[1] << C2[2] << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$a = array();
for ($i=1; $i<=$n; $i++){ 
  // code...
  if ($i%3 == 0 && $i%5 == 0) {
    // code...
    $a[] = 'FizzBuzz';
  }elseif ($i%3 == 0) {
    // code...
    $a[] = 'Fizz';
  }elseif ($i%5 == 0) {
    // code...
    $a[] = 'Buzz';
  }else {
    // code...
    $a[] = $i;
  }
}

echo array_sum($a);  

Measured memory_bytes: 49672
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=1e5,MOD=1e9+7;
ll N,A,B,C,fact[MAX_N*2+1],ifact[MAX_N*2+1];
//ll dp[MAX_N+1][MAX_N+1];
ll mpw(ll n,ll m){
	ll r=1;
	while(m){
		if(m&1){
			r*=n;
			r%=MOD;
		}
		n*=n;
		n%=MOD;
		m>>=1;
	}
	return r;
}
ll minv(ll n){
	return mpw(n,MOD-2);
}
ll cmb(ll n,ll m){
	return fact[n]*ifact[m]%MOD*ifact[n-m]%MOD;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>A>>B>>C;
	fact[0]=1;
	REP(i,N*2){
		fact[i+1]=fact[i]*(i+1)%MOD;
	}
	ifact[N*2]=minv(fact[N*2]);
	for(ll i=N*2-1;i>=0;i--){
		ifact[i]=ifact[i+1]*(i+1)%MOD;
	}
	ll a=A*minv(100-C)%MOD,b=B*minv(100-C)%MOD,c=100*minv(100-C)%MOD;
	if(a==0){
		swap(a,b);
		swap(A,B);
	}
	ll ans=0;
	if(b>0){
		FOR(i,1,N+1){
			ans+=cmb(2*N-i-1,N-1)*i%MOD*c%MOD*minv(mpw(a,i))%MOD;
			ans%=MOD;
		}
		FOR(i,1,N+1){
			ans+=cmb(2*N-i-1,N-1)*i%MOD*c%MOD*minv(mpw(b,i))%MOD;
			ans%=MOD;		
		}
		ans=MOD-ans;
		ans%=MOD;
		ans*=mpw(a,N);
		ans%=MOD;
		ans*=mpw(b,N);
		ans%=MOD;
		ans+=c*2*N%MOD;
		ans%=MOD;
	}else{
		ans=2*N*c%MOD+(MOD-c*N%MOD*mpw(a,N)%MOD);
		ans%=MOD;
	}
	cout<<ans<<endl;
	/*
	REP(i,N+1){
		dp[i][0]=MOD-i*c%MOD*minv(mpw(a,i))%MOD;
		dp[i][0]%=MOD;
		dp[0][i]=MOD-i*c%MOD*minv(mpw(b,i))%MOD;
		dp[i][0]%=MOD;
	}
	FOR(i,1,N+1){
		FOR(j,1,N+1){
			dp[i][j]=dp[i-1][j]+dp[i][j-1];
//			dp[i][j]=a*dp[i-1][j]%MOD+b*dp[i][j-1]%MOD+c;
			dp[i][j]%=MOD;
		}
	}
	cout<<(dp[N][N]*mpw(a,N)%MOD*mpw(b,N)%MOD+2*N*c%MOD)%MOD<<endl;
	*/
}

Measured memory_bytes: 3328
import collections
N = int(input())
S = input()
S_list = [S[i] for i in range(N)]
S_c = collections.Counter(S_list)
list12 = []
list1 = []

ans = 0
for i in range(N-2):
    s1 = S_list[i]

    S_c[s1] = S_c[s1]-1
    if s1 in list1:
        continue

    S_c23 = S_c.copy()
    list1.append(s1)
    for j in range(i+1,N-1):
        s2 = S_list[j]
        
        S_c23[s2] = S_c23[s2] - 1
        if (s1+s2) in list12:
            continue
        else:
            list12.append(s1+s2)
            for key in S_c23.keys():
                if S_c23[key] != 0:
                    ans+=1
print(ans)

Measured memory_bytes: 76568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n;cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  if(a[0]==0LL){
    cout<<0;return 0;
  }
  ll s=1LL;
  rep(i,n){
    if(a[i]>1000000000000000000/s){
      cout<<-1;return 0;
    }
    s*=a[i];
  }
  cout<<s;
}

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

using namespace std;

int powerOf2(int n)	{
	int res = 0;
	while (n % 2 == 0)	{
		res++;
		n /= 2;
	}
	return res;
}

int main()	{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)	{
		cin >> a[i];
	}
	int pow2 = 1e9;
	for (int i = 0; i < n; i++)	{
		pow2 = min(pow2, powerOf2(a[i]));
	}	
	cout << pow2 << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
using namespace std;
int n, m, i, j, k, t, Max=0;
int a[100010]={0}; 
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>t;
		a[t]++;	
	}
	for(i=0;i<=100000;i++){
		Max=max(Max,a[i]+a[i+1]+a[i+2]);
	}
	cout<<Max;
	return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    abc073c()
}

fun abc073c() {
    val n = readLine()!!.toInt()
    val aList = (1..n).map { readLine()!!.toInt() }.toIntArray()

    val map = mutableMapOf<Int, Int>()
    aList.forEach { a ->
        map[a] = map[a]?.let { it + 1 } ?: 1
    }

    val answer = map.filter { it.value % 2 != 0 }.size

    println(answer)
}


Measured memory_bytes: 45464
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using P = pair<int,int>;
const int MOD = 1e9+7;
int n, m, l, r, x;
long long dp[305][305] = {1}, ans;
vector<P> p[305];
int main(){
	cin >> n >> m;
	rep(i,m){
		cin >> l >> r >> x;
		p[r-1].push_back(P(l,x));
	}
	rep(i,n){
		rep(j,i) rep(k,i) (dp[i][j] += dp[max(j,k)][min(j,k)]) %= MOD;
		for(P t: p[i]){
			tie(l,x) = t;
			rep(j,i+1) rep(k,j+1) if(x+(j<l)+(k<l)-3) dp[j][k] = 0;
		}
	}
	rep(i,n) rep(j,i) (ans += 6*dp[i][j]) %= MOD;
	cout << (ans + dp[0][0]*3) % MOD;
}

Measured memory_bytes: 1024
import copy
n = int(input())
x = list(map(int, input().split()))
y = copy.copy(x)
y.sort()
cen1 = y[(n-1)//2]
cen2 = y[n//2]
for i in range(n):
    if x[i] < y[n//2]:
        print(cen2)
    else:
        print(cen1)


Measured memory_bytes: 93128
H, W, M = list(map(int, input().split()))
h = [0] * H
w = [0] * W
s = set()
for i in range(M):
    x, y = list(map(int, input().split()))
    h[x - 1] += 1
    w[y - 1] += 1
    s.add((x-1, y-1))
hmax = max(h)
wmax = max(w)
hidx = []
for i, e in enumerate(h):
    if e == hmax:
        hidx.append(i)
widx = []
for i, e in enumerate(w):
    if e == wmax:
        widx.append(i)
l_flag = False
for i in hidx:
    for j in widx:
        if (i, j) not in s:
            l_flag = True
            break
    if l_flag:
        break
if l_flag:
    ans = hmax + wmax
else:
    ans = hmax + wmax - 1
print(ans)

Measured memory_bytes: 83540
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj0058/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/aoj0058/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		for (; sc.hasNext();) {
			double X[] = new double[4], Y[] = new double[4];
			for (int i = 0; i < 4; i++) {
				X[i] = sc.nextDouble();
				Y[i] = sc.nextDouble();
			}
			double dx1 = X[0] - X[1];
			double dy1 = Y[0] - Y[1];
			double dx2 = X[2] - X[3];
			double dy2 = Y[2] - Y[3];
			boolean res = abs(dx1 * dx2 + dy1 * dy2) < 1e-8;
			System.out.println(res ? "YES":"NO");
		}
	}

	void debug(Object... os) {
		System.err.println(deepToString(os));
	}
}

Measured memory_bytes: 12000
import Control.Monad
import Text.Printf

main :: IO ()
main = do
    [t, x] <- getDoubles
    printf "%.10f\n" (t / x::Double)

getLines :: Int -> IO [String]
getLines n = replicateM n getLine

getLinesInt :: Int -> IO [Int]
getLinesInt n = fmap read <$> getLines n

getInts :: IO [Int]
getInts = map (read :: String -> Int) . words <$> getLine

getDoubles :: IO [Double]
getDoubles = map (read :: String -> Double) . words <$> getLine

Measured memory_bytes: 508