akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }







void solve(){
    ll k;
    ll n;
    ll a[200010];
    cin>>k>>n;
    rep(i,n) cin>>a[i];
    ll ans=LLINF;
    rep(i,n){
        if(i==0){
            ll b=max(a[1]-a[0],a[0]+k-a[n-1]);
            chmin(ans,k-b);
        }
        else if(i==n-1){
            ll b=a[n-1]-a[n-2];
            chmin(ans,k-b);
        }
        else{
            chmin(ans,k-max(a[i+1]-a[i],a[i]-a[i-1]));
        }
    }
    cout<<ans<<endl;
}




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


    solve(); 


    return 0;
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;

//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define SORT(V) sort((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//def function
//------------------------------------------
int N, Q;
string s;
string t, d;

bool dier(int pos){

  char S = s.at(pos);
  int finpos = pos;

  REP(i, Q){
    if(S==t.at(i)){
      if(d.at(i)=='R'){
        finpos++;
      }else{
        finpos--;
      }

    if(finpos==N) return true;
    if(finpos==-1) return false;
    S = s.at(finpos);
  }
}
  return false;
}

bool diel(int pos){

  char S = s.at(pos);
  int finpos = pos;

  REP(i, Q){
    if(S==t.at(i)){
      if(d.at(i)=='L'){
        finpos--;
      }else{
        finpos++;
      }

    if(finpos==-1) return true;
    if(finpos==N) return false;
    S = s.at(finpos);
  }
}
  return false;
}


//main
//------------------------------------------

int main(){

  cin >> N >> Q;
  cin >> s;
  REP(i, Q){
    char a, b;
    cin >> a >> b;
    t.pb(a);
    d.pb(b);
  }


  //にぶたん．探索回数はlog_2(10^5)~16.6
  int left = -1, right = N;
  REP(i, 20){
    int mid=(left + right)/2;
    if(dier(mid)){
      right=mid;
    }else{
      left=mid;
    }
  }

  int ansr=right;

  left = -1;
  right = N;
  REP(i, 20){
    int mid=(left + right)/2;
    if(diel(mid)){
      left=mid;
    }else{
      right=mid;
    }
  }

  int ansl=left;

  cout << ansr-ansl-1 << endl;

}


Measured memory_bytes: 1024
using System;

class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split();
        var n = int.Parse(nm[0]);
        var m = int.Parse(nm[1]);
        var a = new int[m];
        var b = new int[m];
        for (int i = 0; i < m; i++)
        {
            var ab = Console.ReadLine().Split();
            a[i] = int.Parse(ab[0]) - 1;
            b[i] = int.Parse(ab[1]) - 1;
        }

        var union = new UnionFind(n);
        var ans = new long[m + 1];
        ans[m] = (long)n * (n - 1) / 2;
        for (var i = m - 1; 0 <= i; i--)
        {
            ans[i] = ans[i + 1];
            var size = (long)union.size(a[i]) * union.size(b[i]);
            if (union.connect(a[i], b[i]))
            {
                ans[i] -= size;
            }
        }

        for (int i = 1; i <= m; i++)
        {
            Console.WriteLine(ans[i]);
        }
    }
}

class UnionFind
{
    int[] parent;

    public UnionFind(int n)
    {
        parent = new int[n];
        for (int i = 0; i < n; i++) parent[i] = -1;
    }

    public int root(int x)
    {
        if (parent[x] < 0) return x;
        else return parent[x] = root(parent[x]);
    }

    public int size(int x)
    {
        return -parent[root(x)];
    }

    public bool connect(int x, int y)
    {
        x = root(x);
        y = root(y);

        if (x == y) return false;

        if (size(x) < size(y)) { var t = x; x = y; y = t; }

        parent[x] += parent[y];
        parent[y] = x;
        return true;
    }
}


Measured memory_bytes: 17992
import numpy as np

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.append(0)


result = 0

for i in range(n):
    if a[i] <= b[i]:
        result += a[i]
        if a[i]+a[i+1] < b[i]:
            result += a[i+1]
            a[i+1] = 0
        else:
            diff = a[i]+a[i+1] - b[i]
            result += (a[i+1] - diff)
            a[i+1] = diff
    else:
        result += b[i]
        
print(result)


Measured memory_bytes: 27276
#include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, char const *argv[])
{
    int h = 1;
    int w = 1;

    while(true)
    {
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}




Measured memory_bytes: 3076
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <float.h>
#include <math.h>

#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

typedef long long ll;

int main()
{
	ll a, b, c;

	scanf("%lld %lld %lld", &a, &b, &c);

	if (a + b >= (c - 1)) {
		printf("%lld\n", b + c);
	} else {
		printf("%lld\n", a + b + b + 1, c);
	}

	return 0;
}


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

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

    int N;
    cin >> N;

    N %= 10;

    if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
        cout << "hon" << endl;
    } else if(N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}

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


#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;


int main() {
  int n,temp,hh;
  int p = 0;
  cin >> n;
  int x[n],y[n],h[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      do {
      hh = h[p] + fabs(x[p]-i) + fabs(y[p]-j);
      p++;
    } while (h[p-1] == 0 && p != n);
      p = 0;
      // hh = (h[0] + fabs(x[0]-i) + fabs(y[0]-j) > 0) ? h[0] + fabs(x[0]-i) + fabs(y[0]-j) : 0;
      for (int k = 0; k < n; k++) {
        temp = hh - fabs(x[k]-i) - fabs(y[k]-j) > 0 ? hh - fabs(x[k]-i) - fabs(y[k]-j) : 0;
        if(h[k] != temp) {
          break;
        }
        if(k == n-1) {
          cout << i << ' ' << j << ' ' << hh << ' ' << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int d[3];
    REP(i,3)R(d[i]);
    sort(d,d+3);
    W(d[2]*10+d[1]+d[0]);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n;cin >> n;
    vl v(n);rep(i,n)cin >> v[i];
    ll maxi=-inf,mini=INF;
    ll p,t;
    rep(i,n){
        if(chmax(maxi,v[i]))p=i;
        if(chmin(mini,v[i]))t=i;
    }
    if(maxi<0){
        cout << n-1 <<endl;
        rep(i,n-1){
            cout << n-i <<" " << n-i-1 <<endl;
        }
        return 0;
    }
    if(mini>0){
        cout << n-1 <<endl;
        rep(i,n-1){
            cout << i+1 <<" " << i+2 <<endl;
        }
        return 0;
    }
    cout << 2*n-2 <<endl;
    if(-mini<maxi){
        rep(i,n){
            if(i==p)continue;
            cout << p+1 <<" " << i+1 <<endl;
        }
        rep(i,n-1){
            cout << i+1 <<" " << i+2 <<endl;
        }       
    }
    else{
        rep(i,n){
            if(i==t)continue;
            cout << t+1 <<" " << i+1 <<endl;
        }
        rep(i,n-1){
            cout << n-i <<" " << n-i-1 <<endl;
        }
    }
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int MAXW = 30;
const int MAXH = 30;

// right, down, left, up 
int dh[4] = {0, +1, 0, -1};
int dw[4] = {+1, 0, -1, 0};

bool s[MAXH][MAXW][4];
int dist[MAXH][MAXW];
int w, h;

vector<int> ans;

void init(){
    for(int i=0;i<MAXH;i++){
        for(int j=0;j<MAXW;j++){
            for(int k=0;k<4;k++){
                s[i][j][k] = true;
            }
            dist[i][j] = 0;
        }
    }
}

void dfs(int ch, int cw, int d){
    dist[ch][cw] = d;
    for(int i=0;i<4;i++){
        if(ch + dh[i] <= 0 || ch + dh[i] > h || cw + dw[i] <= 0 || cw + dw[i] > w) continue;
        if(s[ch][cw][i] && dist[ch + dh[i]][cw + dw[i]] == 0){
            dfs(ch + dh[i], cw + dw[i], d + 1);
        }
    }
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    while(1){
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        init();
        for(int i=0;i<h;i++){
            for(int j=0;j<w-1;j++){
                int f; cin >> f;
                if(f){
                    s[i][j][0] = false;
                    s[i][j+1][2] = false;
                }
            }
            if(i == h-1) break;
            for(int j=0;j<w;j++){
                int f; cin >> f;
                if(f){
                    s[i][j][1] = false;
                    s[i+1][j][3] = false;
                }
            }
        }
        // dfs
        queue<pair<int, int> > Q;
        dist[0][0] = 1;
        Q.push(make_pair(0, 0));
        while(!Q.empty()){
            pair<int, int> p = Q.front();
            Q.pop();
            for(int i=0;i<4;i++){
                int ch = p.first, cw = p.second;
                int nh = ch + dh[i];
                int nw = cw + dw[i];
                if(nh < 0 || nh >= h || nw < 0 || nw >= w) continue;
                if(s[ch][cw][i] && dist[nh][nw] == 0){
                    dist[nh][nw] = dist[ch][cw] + 1;
                    Q.push(make_pair(nh, nw));
                }
            }
        }
        ans.push_back(dist[h-1][w-1]);
    }
    for(int a: ans) cout << a << endl;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define vll vector<ll>
#define G vector<vll >
#define F first
#define S second
#define pll pair<ll,ll>
#define FOR1(i,a) for(i=0;i<=a;i++)
#define FOR2(i,a,b) for(i=a;i<=b;i++)
#define endl '\n'
#define clr(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define rll read_ll();
#ifndef ONLINE_JUDGE
#define gc getchar
#define pc putchar
#else
#define gc getchar_unlocked
#define pc putchar_unlocked
#endif
typedef long long ll;
ll read_ll(){char c=gc();while((c<'0'||c>'9')&&c!='-')c=gc();ll ret=0;int neg=0;if(c=='-')neg=1,c=gc();while(c>='0'&&c<='9'){ret=10*ret+c-48;c=gc();}return neg?-ret:ret;}

int main()
{
	ll H,W;
	cin>>H>>W;
	// if((int)H%3==0||(int)W%3==0)
	// {
	// 	cout<<"0";return 0;
	// }
	ll mini=INT_MAX,i;
	if(H<W)swap(H,W);
	ll area=H*W;
	for(i=1;i<=H;i++)
		{
			ll second=((W%2==0)?W/2*(H-i):(W/2+1)*(H-i)) ;
			// if( W/2*(H-i) <=second&&second<=i*W)
			ll minia=min(second,min(W/2*(H-i),i*W));
			ll maxima=max(second,max(W/2*(H-i),i*W));
			// cout<<W/2*(H-i)<<"<="<<second<<"<="<<i*W<<"-"<<i<<" "<<abs( maxima-minia )<<">"<<mini<<endl;
			if(abs( maxima-minia)<mini)
			{
				// cout<<i<<" * "<<W<<":"<<i*W<<" "<<abs( maxima-minia )<<endl;
			mini=abs( maxima-minia );
			}
		}
	
		for(i=1;i<=H;i++)
		{
			ll second=(((H-i)%2==0)?(H-i)/2*W:((H-i)/2+1)*W) ;
			// if( W/2*(H-i) <=second&&second<=i*W)
			ll minia=min(second,min((H-i)/2*W,i*W));
			ll maxima=max(second,max((H-i)/2*W,i*W));
			// cout<<W/2*(H-i)<<"<="<<second<<"<="<<i*W<<"-"<<i<<" "<<abs( maxima-minia )<<">"<<mini<<endl;
			if(abs( maxima-minia)<mini)
			{
				// cout<<i<<" * "<<W<<":"<<i*W<<" "<<abs( maxima-minia )<<endl;
			mini=abs( maxima-minia );
			}
		}
		swap(H,W);
		for(i=1;i<=H;i++)
		{
			ll second=((W%2==0)?W/2*(H-i):(W/2+1)*(H-i)) ;
			// if( W/2*(H-i) <=second&&second<=i*W)
			ll minia=min(second,min(W/2*(H-i),i*W));
			ll maxima=max(second,max(W/2*(H-i),i*W));
			// cout<<W/2*(H-i)<<"<="<<second<<"<="<<i*W<<"-"<<i<<" "<<abs( maxima-minia )<<">"<<mini<<endl;
			if(abs( maxima-minia)<mini)
			{
				// cout<<i<<" * "<<W<<":"<<i*W<<" "<<abs( maxima-minia )<<endl;
			mini=abs( maxima-minia );
			}
		}
	
		for(i=1;i<=H;i++)
		{
			ll second=(((H-i)%2==0)?(H-i)/2*W:((H-i)/2+1)*W) ;
			// if( W/2*(H-i) <=second&&second<=i*W)
			ll minia=min(second,min((H-i)/2*W,i*W));
			ll maxima=max(second,max((H-i)/2*W,i*W));
			// cout<<W/2*(H-i)<<"<="<<second<<"<="<<i*W<<"-"<<i<<" "<<abs( maxima-minia )<<">"<<mini<<endl;
			if(abs( maxima-minia)<mini)
			{
				// cout<<i<<" * "<<W<<":"<<i*W<<" "<<abs( maxima-minia )<<endl;
			mini=abs( maxima-minia );
			}
		}
	cout<<mini;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
import string

def main():
    s = input().strip()
    n = len(s)
    m = {}
    for c in string.ascii_lowercase:
        t = list(s[:])
        count = 0
        while True:
            if len(set(t)) == 1:
                m[c] = count
                break
            for i in range(len(t) - 1):
                if t[i] == c or t[i+1] == c:
                    t[i] = c
            t = t[:len(t) - 1]
            count += 1
    print(min(m.values()))

if __name__ == '__main__':
    main()


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

int main(){
  vector<int> n(3);
  for(int i = 0; i < 3; i++){
    cin >> n.at(i);
  }
  sort(n.begin(), n.end());
  reverse(n.begin(), n.end());
  cout << 10 * n.at(0) + n.at(1) + n.at(2) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4.2")
 
#include <cstdio>
#include <unordered_map>
#include <deque>
#include <algorithm>
using namespace std;
typedef int key;
 
int main(){
	int r,c,n;
	scanf("%d%d%d",&r,&c,&n);
	unordered_map<key,deque<pair<key,long long>>>m;
	for(;n;n--){
		int s1,s2,d;
		scanf("%d%d%d",&s1,&s2,&d);
		m[s1].emplace_back(s2+r,d);
		m[s2+r].emplace_back(s1,-d);
	}
	for(;!m.empty();){
		long long a=-1LL<<61,b=1LL<<61;
		auto s=m.begin()->first;
		deque<pair<key,long long>>st={{s,0}};
		unordered_map<key,long long>memo={{s,0}};
		for(;!st.empty();){
			auto p=*st.begin();st.pop_front();
			auto cur=p.first;long long d=p.second;
			memo[cur]=d;
			if(cur<=r)a=max(a,d);
			else b=min(b,d);
			for(auto &e:m[cur]){
				if(memo.find(e.first)==memo.end()){
					st.emplace_back(e.first,d+e.second);
				}else if(memo[e.first]!=d+e.second){
					puts("No");
					return 0;
				}
			}
		}
		if(a>b){
			puts("No");
			return 0;
		}
		for(auto &e:memo)m.erase(m.find(e.first));
	}
	puts("Yes");
}

Measured memory_bytes: 156788
#include <bits/stdc++.h>
using namespace std;
int a , b;
int main() {
	cin >> a >> b;
	if(a > b) for(register int i = 1; i <= a; ++i)
			cout << b;
	else for(register int i = 1; i <= b; ++i)
		cout << a;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll n,m;
vector<bitset<26> > seg(1050000,0);
void segstart(void){
    for(ll i=1;;i*=2){
        if(n<=i){m=i;break;}
    }
    m--;n+=m;
    string s;
    cin>>s;
    for(ll i=m;i<n;i++)seg[i]=(1<<(s[i-m]-'a'));
    for(int i=m-1;i>=0;i--){
        seg[i]=seg[2*i+1]|seg[2*i+2];
    }
}
void update(ll a,char b){
    a+=m;
    seg[a]=(1<<(b-'a'));
    while(a){
        a=(a-1)/2;
        seg[a]=seg[2*a+1]|seg[2*a+2];
    }
}
ll ans(ll a,ll b){
    a+=m;b+=m;
    bitset<26> ret(0);
    while(1){
        if(a==b){
            ret|=seg[a];
            break;
        }
        if(b==a+1){
            ret|=seg[a];
            ret|=seg[b];
            break;
        }
        if(a%2)a/=2;
        else{
            ret|=seg[a];
            a/=2;
        }
        if(b%2){
            ret|=seg[b];
            b/=2;b--;
        }
        else{b/=2;b--;}
    }
    return ret.count();
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> v;
    cin>>n;
    segstart();
    int q,a,b,d;
    char c;
    cin>>q;
    while(q--){
        cin>>a>>b;b--;
        if(a==1){
            cin>>c;
            update(b,c);
        }else{
            cin>>d;
            d--;
            v.pb(ans(b,d));
        }
    }
    ll maki=v.size();
    for(int i=0;i<maki;i++){
        cout<<v[i] <<endl;
    }
    return 0;
}


Measured memory_bytes: 9364
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    A, B, C, X, Y = LI()
    if X > Y:
        X, Y = Y, X
        A, B = B, A
    money_a_b = X * A + Y * B
    money_b_c = (Y - X) * B + (2 * X) * C
    money_c = Y * 2 * C
    ans = min(money_a_b, money_b_c, money_c)
    print(ans)

main()



Measured memory_bytes: 6224
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long m = sc.nextLong();
    long[] a = new long[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }

    Main abc150D = new Main();
    System.out.println(abc150D.solve(m, a));
  }

  public Long solve(long m, long[] a) {
    long multi = 1L;
    for (int i = 0; i < a.length; i++) {
      multi = lcm(multi, a[i] / 2);
    }
    for (int i = 0; i < a.length; i++) {
      if (multi % a[i] == 0) {
        return 0L;
      }
    }
    long ret = 0L;
    for (int i = 1; i <= m / multi; i++) {
      if (i % 2 == 1) {
        ret += 1L;
      }
    }
    return ret;
  }

  private long lcm(long a, long b) {
    if(b > a) {
      return lcm(b, a);
    }
    return a / gcd(a, b) * b;
  }

  private long gcd(long a, long b) {
    if (b > a) {
      return gcd(b, a);
    }
    if (a == b) {
      return a;
    }
    long ret = a;
    while(b != 0) {
      ret = b;
      b = a % b;
      a = ret;
    }
    return ret;
  }

  private long multiplue(long a, long b) {
    long ret = a > b ? a : b;
    long unit = a > b ? a : b;
    long base = a > b ? b : a;
    while (ret % base != 0) {
      ret += unit;
    }
    return ret;
  }
}


Measured memory_bytes: 51024
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    x,n = LI()
    if x < n:
        print(0)
    else:
        print(10)
    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()


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

int main(){
    int n;
    cin >> n;

    int ans = 0;

    for(int i = 1;i <= n;i++){
        int x;
        cin >> x;
        if((x%2 == 1)&&(i%2 == 1)) ans++;
    }

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

Measured memory_bytes: 3640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    
    ll A[N]; F0R(i, N) cin >> A[i];
/*    if (N % 2 == 0) {
        ll X = 0, Y = 0;
        F0R(i, N) {
            if (i % 2) {
                X+=A[i];
            } else {
                Y+=A[i];
            }
        }
        cout << max(X, Y) << nl; return 0;
    }*/
    ll pref[N][2];
    pref[0][0] = A[0];
    pref[1][0] = A[1];
    for (int i = 2; i < N; i++) {
        pref[i][0] = pref[i-2][0] + A[i];
    }
    pref[N-2][1] = A[N-2];
    pref[N-1][1] = A[N-1];
    for (int i = N-3; i >= 0; i --) {
        pref[i][1] = pref[i+2][1] + A[i];
    }


    ll dp[N][3];
    F0R(i, N) F0R(j, 3) dp[i][j] = -1000000000000000;
    dp[0][0] = A[0]; 
    dp[0][1] = 0;
    dp[1][1] = max(A[1], A[0]);
    dp[1][2] = 0;
    if (N > 2) dp[2][0] = A[0] + A[2];
    if (N > 2) dp[2][2] = max(A[0], max(A[1], A[2]));

    FOR(i, 3, N) {
        F0R(j, 3) {
            if (j > 0) {
                dp[i][j] = max(dp[i][j], dp[i-1][j-1]);
            }
            dp[i][j] = max(dp[i][j], A[i] + dp[i-2][j]);
        }
    }
    cout << dp[N-1][(N%2)+1] << nl;

/*    //case 0a: all odds
    ans = max(ans, pref[N-3][0]);
    ans = max(ans, pref[2][1]);
    //case 0b: all evens
    ans = max(ans, pref[1][1]);
    //case 1: all but one odd
    for (int i = 0; i < N-4; i+=2) {
        ans = max(ans, pref[i][0] + pref[i+4][1]);
    }
    //case 2: all odds, then some even
    for (int i = 0; i < N-3; i += 2) {
        ans = max(ans, pref[i][0] + pref[i+3][1]);
    }
    //case 2: all evens, then some odds
    for (int i = 1; i < N-3; i+=2) {
        ans = max(ans, pref[i][0] + pref[i+3][1]);
    }*/

	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  int x,y;
  int n,k;cin>>n>>k;
  int ans=0;
  cin>>x>>y;
  if(k>n)ans=x*n;
  else{
    ans=x*k;
    ans+=y*(n-k);
  }
  cout<<ans<<endl;
  return 0;
}



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

#define LL long long
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1; char c=getchar();
	for (;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}

int main(){
	int N=read();
	string s;
	cin>>s;
	for (int i=0;i<s.size();++i){
		int c=s[i]-'A';
		c+=N; if (c>25) c-=26;
		cout<<(char)(c+'A');
	} cout<<endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

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

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

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(d2==1){
        cout<<"1";
        return 0;
    }
    cout<<"0";
	exit(0);
}


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

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

	private static final long MOD = 998_244_353L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), s = scanner.nextInt();
			int[] a = new int[n + 1];
			IntStream.rangeClosed(1, n).forEach(i -> a[i] = scanner.nextInt());
			long[][] dp = new long[n + 1][s + 1];
			Arrays.fill(dp[0], 0L);
			dp[0][0] = 1L;
			IntStream.rangeClosed(1, n).forEach(i -> {
				IntStream.range(0, Math.min(a[i], s + 1)).forEach(j -> dp[i][j] = 2 * dp[i - 1][j] % MOD);
				IntStream.rangeClosed(a[i], s)
						.forEach(j -> dp[i][j] = (2 * dp[i - 1][j] % MOD + dp[i - 1][j - a[i]]) % MOD);
			});
			System.out.println(dp[n][s]);
		}
	}
}


Measured memory_bytes: 110500
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Apr 28 17:00:12 2018
//
package main

import "fmt"

var X, Y int64

func main() {
	fmt.Scan(&X, &Y)

	if X%Y == 0 {
		fmt.Println(-1)
		return
	}

	for i := int64(1); ; i++ {
		if X*i%Y != 0 {
			fmt.Println(X * i)
			return
		}
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int m,a,b;
bool prime[100001];
vector<int> pp;
int main(void){
	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(int i=2;i<=100000;i++){
		if(prime[i]){
			pp.push_back(i);
			for(int j=i*2;j<=100000;j+=i){
				prime[j]=false;
			}
		}
	}
	while(1){
		scanf("%d %d %d",&m,&a,&b);
		if(m+a+b==0)break;
		int rp=0,rq=0;
		for(int i=0;i<pp.size();i++){
			if(pp[i]*pp[i]>m)break;
			for(int j=i;j<pp.size();j++){
				if(pp[i]*pp[j]>m)break;
				if(a*pp[j]>b*pp[i])continue;
				if(rp*rq<pp[i]*pp[j]){
					rp=pp[i];
					rq=pp[j];
				}
			}
		}
		printf("%d %d\n",rp,rq);
	}
	return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const int M = 1e7;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];

  vector<vector<int>> l(h,vector<int>(w,0)), r(h,vector<int>(w,0));
  vector<vector<int>> t(h,vector<int>(w,0)), b(h,vector<int>(w,0));

  rep(i,h) {
    int c = 0;
    rep(j,w) {
      if (s[i][j] == '#') {
        l[i][j] = 0;
        c = 0;
      } else {
        l[i][j] = c;
        c++;
      }
    }
  }

  rep(i,h) {
    int c = 0;
    rep(j,w) {
      if (s[i][w-j-1] == '#') {
        r[i][w-j-1] = 0;
        c = 0;
      } else {
        r[i][w-j-1] = c;
        c++;
      }
    }
  }

  rep(j,w) {
    int c = 0;
    rep(i,h) {
      if (s[i][j] == '#') {
        t[i][j] = 0;
        c = 0;
      } else {
        t[i][j] = c;
        c++;
      }
    }
  }

  rep(j,w) {
    int c = 0;
    rep(i,h) {
      if (s[h-i-1][j] == '#') {
        b[h-i-1][j] = 0;
        c = 0;
      } else {
        b[h-i-1][j] = c;
        c++;
      }
    }
  }

  int ans = 0;
  rep(i,h) rep(j,w) {
    if (s[i][j] != '#') ans = max(ans, t[i][j]+b[i][j]+l[i][j]+r[i][j]+1);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 73740
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

int H[N];
int dp[N];

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf("%d", H + i);
	dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		dp[i] = INF;
		for (int j = 1; j <= k && i - j > 0; j++) {
			dp[i] = min(dp[i - j] + abs(H[i] - H[i - j]), dp[i]);
		}
	}
	printf("%d\n", dp[n]);
	return 0;
}
		

Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	int n=read(),m=read(),ans=0;
	rep(i,1,m) {int x=read(); ans+=x;}
	if(ans>n) puts("-1"); else cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

int search(int A[],int n,int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key)i++;
    return i != n;
}

int main() {
    int k,s,ans=0;
    cin >> k >> s;
    for(int i = 0;i <= k;i++){
        for(int j = 0;j <= k;j++){
                if(s - (i+j) >= 0 && s - (i+j) <= k){
                    ans++;
                }
        }
    }
    cout << ans;
}




Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main()
{
    int n, k;
    cin >> n;
    cin >> k;

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

    int dist_sum = 0;
    for (int i = 0; i < n; i++) {
        dist_sum += 2 * min(x[i], abs(x[i] - k));
    }
    cout << dist_sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define SZ(x)       i64(x.size())
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a && (a=b, true);}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a && (a=b, true);}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

class Ruisekiwa : public vector<i64> { // {{{
    using super = vector<i64>;
    using super::super; // コンストラクタを継承

public:
    inline void build() {
        const auto sz = super::size();
        for (int i = 1; i < sz; ++i) (*this)[i] += (*this)[i-1];
    }

    inline i64 sum(int r) const {
        return (r < 0) ? 0 : (*this)[r];
    }

    inline i64 sum(int l, int r) const {
        return sum(r) - sum(l - 1);
    }

    inline int lower_bound(i64 key) const {
        return std::lower_bound(super::begin(), super::end(), key) - super::begin();
    }
};
// }}}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    i64 W;
    i64 w[105], v[105];

    cin >> N >> W;
    rep(i, N) {
        cin >> w[i] >> v[i];
    }

    const i64 minw = w[0];

    Ruisekiwa cum[5];
    rep(i, N) {
        cum[w[i] - minw].push_back(v[i]);
    }
    rep(i, 4) {
        sort(all(cum[i]), greater<>());
        cum[i].build();
    }

    trace(cum[0]);
    trace(cum[1]);
    trace(cum[2]);
    trace(cum[3]);

    i64 ans = 0;

    reps(a, 0, SZ(cum[0])) {
        reps(b, 0, SZ(cum[1])) {
            reps(c, 0, SZ(cum[2])) {
                reps(d, 0, SZ(cum[3])) {
                    const i64 sumW =
                        (minw + 0) * a +
                        (minw + 1) * b +
                        (minw + 2) * c +
                        (minw + 3) * d;

                    if (sumW > W) continue;
                    chmax(ans, cum[0].sum(a-1) + cum[1].sum(b-1) + cum[2].sum(c-1) + cum[3].sum(d-1));
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s=input()
count=0
if len(s) % 2 == 1:
	for i in range(len(s)//2):
		if not s[i] == s[-i-1]:
			count+=1
else:
	for i in range(len(s)//2):
		if not s[i] == s[-i-1]:
			count+=1
print(count)

Measured memory_bytes: 3064
using System;

class Program
{
    static int[] a;

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
 
        a = new int[n];
 
        string[] input = Console.ReadLine().Split(' ');
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = int.Parse(input[i]);
        }
 
        SelectSort();
    }
 
    static void SelectSort()
    {
        int count = 0;
 
		for (int i = 0; i < a.Length; i++)
		{
			int min = i;

			for (int j = i+1; j < a.Length; j++)
			{
				if (a[j] < a[min])
				{
					min = j;
				}
			}

			if (i != min)
			{ 
				int buf = a[i];
				a[i] = a[min];
				a[min] = buf;

				count ++;
			}
		}
 
        string output = "";
        for (int i = 0; i < a.Length; i++)
        {
            output += a[i] + ((i == a.Length-1) ? "" : " ");
        }
 
        Console.WriteLine(output);
        Console.WriteLine(count);
    }
}



Measured memory_bytes: 17916
# import math
# import statistics
# import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
f = list(map(int,input().split()))
# g = [int(input()) for _ in range(N)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen

count=0
ma=0
ans={}

for i in range(len(f)-1):
    if f[i+1]<=f[i]:
        count+=1
    else:
        ma=max(ma,count)
        count=0

if count>=1:
    ma=max(ma,count)

print(ma)

Measured memory_bytes: 20708
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll int
#define mod 1000000007
#define F first
#define S second
#define mk make_pair
char a[100001]={0};
int ar[21][21]={0};
int main()
{	
	string s;
	cin>>s;
	vector<char>v;
	for(int i=0;i<(int)s.size();i++)
	{
		a[s[i]]=1;
	}
	for(char i='a';i<='z';i++)
	{
		if(a[i]==0)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}

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

#define REP(i,j,k) for( int i = j; i < k; i++ )
#define rep(i,j) REP(i,0,j)

using namespace std;

typedef vector<int> VI;
typedef vector< VI > VVI;

int main(){
	
	int N,M,C;
	
	cin >> N >> M >> C;
	
	VI B(M);
	VVI A( N, VI(M) );
	
	rep(j,M) cin >> B[j];
	rep(i,N) rep(j,M) cin >> A[i][j];
	
	int cnt = 0;
	
	rep(i,N){
		
		int tmp = C;
		rep(j,M) tmp += A[i][j] * B[j];
		if(tmp>0) cnt++;
		
	}
	
	cout << cnt << endl;
	
	return 0;
	
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int K,A,B;
    cin>>K>>A>>B;


    int ans=1;
    int tmp=min(K,A-1);
    ans+=tmp;
    K-=tmp;

    if(B-A>=2){
        ans+=(B-A)*(K/2)+(K%2);
    }
    else ans+=K;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 n;
  while(cin >> n, n) {
    vector<i64> a(n);
    rep(i,0,n) cin >> a[i];
    sort(all(a));
    i64 sum = 0;
    rep(i,1,n-1) sum +=a[i];
    cout << sum / (n - 2) << endl;
  }
}



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

int main()
{
    int n; cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        int p; cin >> p;
        if (p != i) cnt++;
    }
    cout << ((cnt == 0 || cnt == 2) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = [int(input()) for _ in range(N)]


if N % 2 == 1:
    L = sorted(L, reverse=True)
    minority = N//2
    majority = N - minority
    A = sum(L[:minority])*2 - sum(L[minority:])*2+sum(L[minority:minority+2])
    B = sum(L[:majority])*2 - sum(L[majority:])*2 - sum(L[majority-2:majority])
    ans = max(A, B)
else:
    L = sorted(L)
    C = sum(L[:N//2])*2 - sum(L[N//2:])*2 + L[N//2]-L[N//2-1]
    D = -C
    ans = max(C, D)
    pass
print(ans)


Measured memory_bytes: 52440
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9)+7;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<Long> fl = getFactorialList(Math.max(n,m));
        if(Math.abs(m-n) > 1){
            System.out.println(0);
        }else if(n == m){
            System.out.println((fl.get(n-1) * fl.get(m-1)) % mod * 2 % mod);
        }else{
            System.out.println(fl.get(n-1) * fl.get(m-1) % mod);
        }
        
    }
    
    public static ArrayList<Long> getFactorialList(int n){
        long mod = (long)Math.pow(10,9)+7;
        ArrayList<Long> ret = new ArrayList<Long>();
        if(n <= 0){
            return ret;
        }
        long now = 1;
        for(int i = 1; i <= n; i++){
            now *= i;
            now %= mod;
            ret.add(now);
        }
        return ret;
    }
}

Measured memory_bytes: 25940
/*
 © 2020-09-13 21:16:02 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;
const lli MOD = 1E9 + 7;
lli fpow(lli x, lli y){
  lli res = 1;
  while(y > 0){
    if(y & 1) res = res * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return (res + MOD) % MOD;
}
int main(){ _
  lli n; cin >> n;
  lli foo = 1, bar = 1, faa = 1;
  cout << (fpow(10, n) - (2ll * fpow(9, n) % MOD - fpow(8, n) + MOD) % MOD + MOD) % MOD << ENDL;
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c1 = sc.nextLine();
		String c2 = sc.nextLine();
		String c3 = sc.nextLine();

		System.out.println(c1.substring(0, 1) + c2.substring(1, 2) + c3.substring(2, 3));

		sc.close();
	}
}

Measured memory_bytes: 21332