akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    string s;
    cin >> s;
    int len = LEN(s);
    int a,b;
    REP(i,len){
        if(s[i]=='A'){
            a = i;
            break;
        }
    }
    RREP(i,len){
        if(s[i]=='Z'){
            b = i;
            break;
        }
    }
    cout << b-a+1 << endl;
    return 0;
}

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

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}



int main()
{
    int n;
    cin>>n;
    vector<int>h(n);
    for(int i=0;i<n;i++)cin>>h[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    // 左からi番目のマスの数値をx_iとし、y_i = x_i+1 - x_iとする。
    // 制約より、-d <= y_i <= -c or c <= y_i <= d とかける。
    // sum(y_i) = sum(x_i+1 - x_i) = x_n-1 - x_0 = b - a
    // 上記(1)を満たすy_iが存在すれば、条件を満たすx_iも存在するといえる。

    // -d <= y_i <= cとなるiがm個、c <= y_i <= dとなるiがn-1-m個あるとして、
    // (n-1-m)c - md <= sum(y_i) = b - a <= (n-1-m)d - mc
    // が成り立つmが1つでもあれば、条件を満たす数列の作成が可能である。
    const ll diff = b - a;
    for(ll i=0; i<n; i++){
        if(((n-1-i)*c - i*d <= diff) && (diff <= (n-1-i)*d - i*c)){
            YES();
            return 0;
        }
    }
    NO();
}

Measured memory_bytes: 3600
#include <bits/stdc++.h> 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;

ll Manhattan(ll x1, ll y1, ll x2, ll y2){
    return abs(x1 - x2) + abs(y1 - y2);
}

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n),b(n); 
    rep(i,n) cin >> a[i] >> b[i];
    vector<ll> c(m),d(m);
    rep(i,m) cin >> c[i] >> d[i];

    vector<int> cp(n,0);
    rep(i,n){
        ll min_dist = 1e10;
        rep(j,m){
            ll dist = Manhattan(a[i],b[i],c[j],d[j]);
            if(dist<min_dist){
                min_dist = dist;
                cp[i] = j+1;
            }
        }
    }
    rep(i,n) cout(cp[i]);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define maxn 105
using namespace std;

bool has[maxn];

int main(int argc, char** argv)
{
	int x, n;
	scanf("%d%d", &x, &n);
	while(n--)
	{
		int t;
		scanf("%d", &t);
		has[t] = true;
	}
	int l = x, r = x;
	while(l >= 0 && has[l]) l --;
	while(has[r]) r ++;
	if((x - l) > (r - x)) l = r;
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
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...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   map<string,int>m;
   for(int i=0;i<n;i++)
   {
       string s;
       cin>>s;
       sort(all(s));
       m[s]++;
   }
   int ans=0;
   for(auto it=m.begin();it!=m.end();it++)
   {
       int x=it->S;
       ans+=(x*(x-1))/2;
   }
   cout<<ans<<endl;
}


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

#define N 6
#define R 50
#define INT_EMAX  1000000
#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )

const int w[ N ] = {   12,   10,   15,   5,   3,   2 };
const int v[ N ] = { 1870, 1520, 2244, 850, 550, 380 };

int k_operafan[ N ][ R + 1 ];

int dpFSA (
  int n,
  int r
  )
{
  if ( r < 0 )  return ( INT_EMAX );
  else if ( ~k_operafan[ n ][ r ] ) ;
  else if ( n >= N - 1 )
  {
    k_operafan[ n ][ r ] = !!( r % w[ n ] )
                         ? INT_EMAX
                         : v[ n ] * ( r / w[ n ] );
  }
  else
  { 
    int res;
    int c;

    res = dpFSA ( n + 1, r );
    for ( c = 1; r - w[ n ] * ( c - 1 ) > 0; ++c )
    {
      int t = dpFSA ( n + 1, r - w[ n ] * c )
            + v[ n ] * c;
      res = MIN( res, t );
    }

    k_operafan[ n ][ r ] = res;
  }

  return ( k_operafan[ n ][ r ] );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  memset ( k_operafan, -1, sizeof ( k_operafan ) );

  for ( ; ; )
  {
    int r;

    scanf ( "%d", &r );
    if ( !( r ) ) break ;
    r /= 100;

    printf ( "%d\n", dpFSA ( 0, r ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = sc.next();
            }

            int max = 0;
            HashMap<String, Integer> map = new HashMap<>();
            for (int i = 0; i < N; i++) {
                Integer count = map.get(S[i]);
                if (count == null) {
                    count = 1;
                } else {
                    count = count + 1;
                }

                map.put(S[i], count);

                if (count > max) {
                    max = count;
                }
            }

            List<String> list = new ArrayList<>();
            for (Entry<String, Integer> entry : map.entrySet()) {
                if (entry.getValue() == max) {
                    list.add(entry.getKey());
                }
            }

            Collections.sort(list);

            for (String s : list) {
                System.out.println(s);
            }
        }
    }

}


Measured memory_bytes: 77764
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N,Q;
string s;
int L[26], R[26];
char t[200000], d[200000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>Q;
    cin>>s;
    rep(i,0,Q) cin>>t[i]>>d[i];
    int ok=-1, ng=N;
    while(ng-ok>1){
        int mid=(ok+ng)/2;
        rep(i,0,Q){
            if(mid==0&&t[i]==s[0]&&d[i]=='L'){
                ok=(ok+ng)/2;
                break;
            }
            else if(t[i]==s[mid]){
                if(d[i]=='L') mid--;
                else mid++;
            }
            if(i==Q-1) ng=(ok+ng)/2;
        }
    }
    int ans=N-ok-1;
    ok=N, ng=-1;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        rep(i,0,Q){
            if(mid==N-1&&t[i]==s[N-1]&&d[i]=='R'){
                ok=(ok+ng)/2;
                break;
            }
            else if(t[i]==s[mid]){
                if(d[i]=='L') mid--;
                else mid++;
            }
            if(i==Q-1) ng=(ok+ng)/2;
        }
    }
    cout <<ans+ok-N<<"\n";
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vb vector<bool>
#define PB push_back
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=s; i>=e; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<ll>())
#define arrasort(arr,n) sort(arr,arr+n)
#define arrdsort(arr,n) sort(arr,arr+n,greater<ll>())

#define F first
#define S second

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define mz(a,val)   memset(a,val,sizeof(a))
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007

void file()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

// code starts here


int main()
{
    // file();

    ll t;
    t = 1;

    //cin >> t;
    while (t--)
    {
        ll h, w, k;
        cin >> h >> w >> k;
        char s[h][w];
        for (ll i = 0; i < h; i++)
            for (ll j = 0; j < w; j++)
                cin >> s[i][j];
        ll hp = pow(2, h) - 1;
        ll wp = pow(2, w) - 1;

        ll ans = 0;
        for (ll i = 0; i <= hp; i++)
        {
            for (ll j = 0; j <= wp; j++)
            {

                ll cnt = 0;
                for (ll r = 0; r < h; r++)
                {
                    ll mask = 1 << r;
                    if (mask & i)
                        continue;
                    for (ll c = 0; c < w; c++)
                    {
                        ll mask2 = 1 << c;
                        if (mask2 & j)
                            continue;
                        if (s[r][c] == '#')
                            cnt++;
                    }
                }
                if (cnt == k)
                    ans++;
            }
        }




        cout << ans;



    }
    return 0;
}

Measured memory_bytes: 4044
#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
using namespace std;

#define pa pair<int,int>
#define sc(n) scanf("%d",&n)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define mem(a,b) memset(a,b,sizeof a)

const  int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

typedef long long ll;
typedef long double ld;

int n, t;
int a[N];

int main()
{
	scanf("%d", &n);
	int ans = 0;
	fo(i, 1, n)
	{
		int sum = 0;
		int tmp = i;
		while (tmp)
		{
			sum++;
			tmp /= 10;
		}
		if (sum & 1)
			ans++;
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N, Y;
    cin >> N >> Y;
    REP(x, N + 1) {
        REP(y, N + 1) {
            if (x + y > N)
                continue;
            int z   = N - x - y;
            int sum = 10000 * x + 5000 * y + 1000 * z;
            if (sum == Y) {
                cout << x << " " << y << " " << z;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int MOD=1e9+7;
int main() {
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	int sum=0;
	for(int i=n-1;i>=n-k;i--){
		sum+=arr[i];
	}
	cout<<sum;
}

Measured memory_bytes: 256
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  //$BDm$K2?I$$+$NF0J*$,$$$^$9!#(B
  //$B$3$l$i$O$=$l$>$l!"(B 2 $BK\$NB-$r;}$DDa$+(B 4 $BK\$NB-$r;}$D55$N$$$:$l$+$G$9!#(B
  //$B9b66$/$s$O!"!VDm$NF0J*$NAm?t$O(B X $BI$$G!"$=$l$i$NB-$NAm?t$O(B Y $BK\$G$"$k!W$HH/8@(B
  int x,y,j;cin>>x>>y;
  rep(i,x+1){
    j=x-i;
    //cout<<i<<" "<<j<<endl;
    if(i+j<=x&&i*2+j*4==y){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum[ohara],pos,k,q,l,r;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>q>>s;
    rep(i,n){
        if(s[i]=='A'&&s[i+1]=='C'){
            sum[i+2]++;
        }
    }
    rrep(i,1,n+5)sum[i]+=sum[i-1];
    rep(i,q){
        cin>>l>>r;
        Cout(sum[r]-sum[l]);
    }
    return 0;
}


Measured memory_bytes: 1872
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro with-output-buffer (&body body)
  "Buffers all outputs to *STANDARD-OUTPUT* and flushes them to
*STANDARD-OUTPUT* at the end. Note that only BASE-CHAR is allowed."
  (let ((out (gensym)))
    `(let ((,out (make-string-output-stream :element-type 'base-char)))
       (let ((*standard-output* ,out))
         ,@body)
       (write-string (get-output-stream-string ,out)))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun feasible-p (n)
  (let* ((d (+ 1 (* 8 n)))
         (sqrt (isqrt d)))
    (if (= d (* sqrt sqrt))
        (floor (+ 1 sqrt) 2)
        nil)))

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (k (feasible-p n)))
    (if (not k)
        (progn
          (write-line "No")
          (return-from main))
        (let ((current-number 1)
              (poses (make-array k :element-type 'uint32))
              (res (make-array (list k (- k 1)) :element-type 'uint32)))
          (dotimes (i k) (setf (aref poses i) i))
          (dotimes (current-subset k)
            (dotimes (i (- k 1))
              (if (< i current-subset)
                  (progn (setf (aref res current-subset i)
                               (aref res i (aref poses i)))
                         (incf (aref poses i)))
                  (progn (setf (aref res current-subset i) current-number)
                         (incf current-number)))))
          (with-output-buffer
            (write-line "Yes")
            (println k)
            (dotimes (s k)
              (write (- k 1))
              (write-char #\ )
              (dotimes (i (- k 1) (terpri))
                (unless (zerop i)
                  (write-char #\ ))
                (write (aref res s i)))))))))

#-swank(main)


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

int main(){
    int N;
    cin >> N;
    map<string,ll> m;
    rep(i,N) {
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        m[s]++;
    }
    ll res = 0;
    for(auto e : m) {
        if(e.second != 1) res += e.second * (e.second - 1) / 2;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
long long n,k,mod=1e9+7;
struct matrix{
	long long x[100][100];	
}mat;
matrix matrixidentity(long long sz)
{
	matrix res;
	for(int i=0;i<=sz;i++)
	{
		for(int j=0;j<=sz;j++)
		{
			res.x[i][j] = 0;
			if(i==j) res.x[i][j] = 1;
		}
	}
	return res;
}
matrix multiplication(matrix a,matrix b,int sz,long long md)
{
	matrix res;
	for(int i=0;i<sz;i++)
	{
		for(int j=0;j<sz;j++)
		{
			res.x[i][j] = 0;
			for(int k=0;k<sz;k++)
			{
				res.x[i][j]+=(a.x[i][k]%md*b.x[k][j]%md)%md;
				res.x[i][j]%=md;
			}
		}
	}
	return res;
}
matrix matpow(matrix a,long long p,long long md)
{
	matrix res;
	res = matrixidentity(n);
	while(p)
	{
		if(p%2) res = multiplication(res,a,n,md);
		
		a = multiplication(a,a,n,md);
		p/=2;
	}
	
	return res;
}
int main()
{
	scanf("%lld %lld",&n,&k);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			scanf("%lld",&mat.x[i][j]);
		}
	}
	mat = matpow(mat,k,mod);
	//mat = multiplication(mat,mat,n,mod);
	long long ans = 0;
//	printf("\n");
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			ans+=mat.x[i][j]%mod;
			ans%=mod;
			//printf("%lld ",mat.x[i][j]);
		}
		//printf("\n");
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b;
  cin >> a >> b;
  int sum = b;
  int s = 0, t = abs(b); 
  for(int i=1; i<a; i++) { 
	if( t > abs(b + i) ){ s = i; t = abs(b + i); }
    sum += (b + i);
  }
  cout << (sum - (b + s)) << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/arc088/editorial.pdf
・一番真ん中に近い境界の、始点か終点の遠い方の距離が最適
・中央付近から順に境界を1つずつ減らして最終的に全0にできる。
"""

S = input()

dist = float('inf')
for i in range(1, len(S)):
    if S[i] != S[i-1]:
        # 境界を見つけたら、始点か終点の遠い方の距離を取る
        tmp = max(i, len(S)-i)
        # この値が小さい程中央に近い位置
        if tmp < dist:
            dist = tmp
# 境界が1つもないなら、文字列の長さをそのまま使える
if dist == float('inf'):
    dist = len(S)

print(dist)


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int n,i;
  cin >> n >> i;
  cout << n-i+1 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>

#define MAX_NUM (1000000)

int main(void)
{
  static bool searchList[MAX_NUM];
  static bool isPrime[MAX_NUM];
  static int primeNum[MAX_NUM];
  
  double maxSq = sqrt((double)(MAX_NUM - 1));
  
  for (int i = 2; i <= maxSq + 1; i++) {
    if (!searchList[i]) {
      isPrime[i] = true;
      for (int j = 2; j < MAX_NUM; j++) {
        if (j % i == 0) {
          searchList[j] = true;
        }
      }
    }
  }
  
  for (int i = maxSq + 2; i < MAX_NUM; i++) {
    if (!searchList[i]) {
      isPrime[i] = true;
    }
  }
  
  
  for (int i = 2; i < MAX_NUM; i++) {
    primeNum[i] = isPrime[i] ? primeNum[i - 1] + 1 : primeNum[i - 1];
  }
  
  int n;
  while (std::cin >> n) {
    std::cout << primeNum[n] << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 7020
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,c=0,p=0;
  int b[10000];
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
  }
  for(int i=0;i<a;i++){
    if(p<=b[i]) c++,p=max(p,b[i]);
  }
  cout<<c<<"\n";
}

Measured memory_bytes: 256
n, a, b = list(map(int, input().split()))
ans = 0

for i in range(1, n + 1):
    # 割とスッキリ書けた
    digit_sum = sum(map(int, list(str(i))))

    if a <= digit_sum and digit_sum <= b:
        ans += i

print(ans)

Measured memory_bytes: 2940
import sys

sys.setrecursionlimit(1000000)


def dfs(cur, par, g, d):
    pars[cur] = par
    for to in g[cur]:
        if to == par:
            continue
        d[to] = d[cur]+1
        md[cur] = max(md[cur], dfs(to, cur, g, d)+1)
    return md[cur]


n, u, v = map(int, input().split())
u -= 1
v -= 1
g = []
for i in range(n):
    g.append([])
for i in range(n-1):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
d = []
md = []
pars = []
f = []
for i in range(n):
    d.append(-1)
    md.append(0)
    pars.append(-1)
    f.append(False)
d[u] = 0
dfs(u, -1, g, d)
cur = v
while cur != u:
    f[cur] = True
    cur = pars[cur]
f[u] = True
res = d[v]-1
for i in range(n):
    if f[i] and d[i]*2 < d[v]:
        for to in g[i]:
            if to == pars[i] or f[to]:
                continue
            res = max(res, md[to]+1+d[v]-d[i] - 1)
print(res)


Measured memory_bytes: 98704
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>

#define maxn 200010
int a[maxn], b[maxn];
std::set<int> s;
int main()
{
	int n, k; scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	for (int i = 2; i <= n; ++i)
		b[i] = b[i - 1] + (a[i] > a[i - 1]);
	bool st = 0;
	for (int i = 1; i <= k; ++i)
		s.insert(a[i]);
	int ans = 1;
	if (b[k] == k - 1) st = 1;
	for (int i = k + 1; i <= n; ++i)
	{
		bool sorted = b[i] - b[i - k + 1] == k - 1;
//		printf("%d\n", sorted);
		{
			s.insert(a[i]);
			if (!(a[i - k] == *s.begin() && a[i] == *s.rbegin()))
			{
				if (!sorted || !st)
				{
					++ans;
					st |= sorted;
				}
			}
			s.erase(a[i - k]);
		}
	}
	printf("%d\n", ans );
	return 0;
}

Measured memory_bytes: 11136
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000
#define pr1(a) cout << a << endl
#define pr2(a,b)cout << a <<  " " <<b<< endl
#define pr3(a,b,c) cout << a <<" " << b << " " << c << endl

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

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

const int maxn = 2000009;
string s;
bool chk(int l, int r){
    int m = (r-l)/2;

    for(int i = l, j = 0;i<=(l+m);i++,j++){
        if(s[i]!=s[r-j]){
            return false;
        }
    }

    return true;
}
void solve(){
    
   cin >> s;

   int n = s.size();

   bool flag1 = chk(0, n-1);
   bool flag2,flag3;

   flag2 = chk(0, (n-1)/2 - 1);
   flag3 = chk((n+3)/2-1, n-1);

   //cout << flag1 << " " << flag2 << " " << flag3 << endl;
   if(flag1&&flag2&&flag3) cout << "Yes" << endl;
   else cout << "No" << endl;
    

} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        
        solve();
        //cout << endl;
    }
    return 0;
} 

 


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		




int main() {

	ll k;
	cin >> k;
	cout << 50 << endl;
	VLL v(50, 49);

	REP(i, 50)v[i] += k / 50;

	REP(i, k % 50) {
		v[i] += 51;
		REP(j, 50)v[j]--;
	}

	REP(i, 50)cout << v[i] << ' ';
	cout << endl;

	
	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

// 提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine(); // String Sを受け取る
		String T = sc.nextLine(); // String Tを受け取る
		sc.close(); // 標準入力を終了

		int ansm = T.length(); // Sを書き換える文字数の最小値

		//Sの何文字目から調べるかを全探索する
		for(int i = 0; i <= S.length() - T.length(); i++) {
			String cs = S.substring(i);
			int diff = 0; // SとTで一致しない文字数
			for(int j = 0; j < T.length(); j++) {
				if(!checkStr(cs, T, j)) {
					diff += 1;
				}
			}
			if(diff < ansm) ansm = diff; // 最小値更新
		}
		System.out.println(ansm);

	}

	// 文字列Xと文字列Yを比較し、指定したインデックスの文字が等しいか求める関数
	public static boolean checkStr(String X, String Y, int c) {
		char cX = X.charAt(c);
		char cY = Y.charAt(c);
		return cX == cY;
	}
}

Measured memory_bytes: 36668
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
int sum=0;
for(int i=0;i<n;i++)
    sum+=arr[i];
int c=0;

int ans=sum;
for(int i=0;i<n-1;i++)
{
    c+=arr[i];
    int l=sum-c;
    int mid=(l+c)/2;
    int res=abs(mid-c)+abs(mid-l);
    ans=min(ans,res);
}
cout<<ans<<endl;


















    return 0;
}


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

int N, D, X;
int dp[11][100100];

int knapsak(vector<int> w, vector<int> v, int W){
    memset(dp, 0, sizeof(dp));
    
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(j < w[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]] + v[i]);
            }
        }
    }
    return dp[N][W] + W;
}

int main (){
    cin >> N >> D >> X;
    vector<vector<int>> P(D, vector<int>(N));
    for(auto &p: P) for(auto &v: p)
        cin >> v;
    
    for(int i=0; i<D-1; i++){
        vector<int> w(N), v(N);
        for(int j=0; j<N; j++){
            w[j] = P[i][j];
            v[j] = P[i+1][j] - P[i][j];
        }
        X = knapsak(w, v, X);
    }
    
    cout << X << endl;
    
    return 0;
}

Measured memory_bytes: 7432
/*This is the solution from Ling2Feng1,
  no matter AC or not.
  OJ:AtCoder
  ProblemID:ARC088D
  Date:2017/12/23
*/
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>
using namespace std;

inline void ReadInt(int &num){
	num=0;
	int f=1;
	char c=getchar();
	while(!isdigit(c)){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(isdigit(c)){
		num=num*10+(c-'0');
		c=getchar();
	}
	num=num*f;
	return;
}

inline void ReadLong(long long &num){
	num=0;
	int f=1;
	char c=getchar();
	while(!isdigit(c)){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(isdigit(c)){
		num=num*10+(c-'0');
		c=getchar();
	}
	num=num*f;
	return;
}

long long i,x,y;

int main(){
	ReadLong(x);
	ReadLong(y);
	for(i=0;x<=y;i++) x*=2;
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[-1 for _ in range(W + 1)] for _ in range(N + 1)]
for i in dp:
    i[0] = 0
dp[0] = [0 for _ in range(W + 1)]

for i in range(1, N + 1):
    for l in range(1, W + 1):
        if l - wv[i - 1][0] < 0:
            dp[i][l] = dp[i - 1][l]
        else:
            dp[i][l] = max(dp[i - 1][l], dp[i - 1][l - wv[i - 1][0]] + wv[i - 1][1])
print(dp[N][W])


Measured memory_bytes: 171656
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Edge{
public:
    int to, cap, cost, rev;
    Edge(){};
    Edge(int to0, int cap0, int cost0){to = to0; cap = cap0, cost = cost0;}
    Edge(int to0, int cap0, int cost0, int rev0){to = to0; cap = cap0; cost = cost0; rev = rev0;}
};

int minCostFlow(const vector<vector<Edge> >& edges0, int source, int sink, int flow)
{
    int n = edges0.size();
    vector<vector<Edge> > edges(n);
    for(int i=0; i<n; ++i){
        for(unsigned j=0; j<edges0[i].size(); ++j){
            const Edge& e = edges0[i][j];
            edges[i].push_back(Edge(e.to, e.cap, e.cost, edges[e.to].size()));
            edges[e.to].push_back(Edge(i, 0, -e.cost, edges[i].size()-1));
        }
    }

    vector<int> h(n, 0);
    vector<int> prevV(n);
    vector<int> prevE(n);

    int ret = 0;
    while(flow > 0){
        vector<int> dist(n, INT_MAX);
        dist[source] = 0;
        priority_queue<pair<int,int> ,vector<pair<int,int> >, greater<pair<int,int> > > q;
        q.push(make_pair(0, source));

        while(!q.empty()){
            pair<int, int> p = q.top();
            q.pop();
            int v = p.second;
            if(dist[v] < p.first)
                continue;
            for(unsigned i=0; i<edges[v].size(); ++i){
                Edge e = edges[v][i];
                if(e.cap > 0 && dist[v] + e.cost + h[v] - h[e.to] < dist[e.to]){
                    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                    prevV[e.to] = v;
                    prevE[e.to] = i;
                    q.push(make_pair(dist[e.to], e.to));
                }
            }
        }
        if(dist[sink] == INT_MAX){
            return -1;
        }
        for(int i=0; i<n; ++i)
            h[i] += dist[i];

        int g = flow;
        for(int i=sink; i!=source; i=prevV[i])
            g = min(g, edges[prevV[i]][prevE[i]].cap);
        for(int i=sink; i!=source; i=prevV[i]){
            Edge& e = edges[prevV[i]][prevE[i]];
            e.cap -= g;
            edges[i][e.rev].cap += g;
        }
        flow -= g;
        ret += g * h[sink];
    }
    return ret;
}

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

    vector<vector<Edge> > edges(2*n+2);
    for(int i=0; i<n; ++i){
        edges[0].push_back(Edge(i+2, 1, 0));
        edges[i+n+2].push_back(Edge(1, 1, 0));
        for(int j=0; j<n; ++j){
            if(p[i] != j + 1)
                edges[i+2].push_back(Edge(j+n+2, 1, abs(i-j) * p[i]));
        }
    }
    cout << minCostFlow(edges, 0, 1, n) << endl;

    return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < n; i++){
        cout << s[i] << t[i];
    }

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
array = [0]*(10**5+ 1)

for i in range(N):
  a, b = map(int, input().split())
  array[a]+= b
  
S = 0
i = 0

while S < K:
  S+= array[i]
  i+= 1
  
print(i- 1)

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

int main(int argc, const char * argv[]) {
    
    int r, D, x200[11];
    int i;
    
    cin >> r >> D >> x200[0];
    
    for(i=1; i<=10; i++){
        x200[i] = r * x200[i-1] - D;
        cout << x200[i] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
import heapq
from collections import defaultdict


def solve(N, klrs):
    # ベースの嬉しさは sum_i min(Li, Ri)
    # (1) Li > Ri なるラクダ
    #   なるべく先頭側に寄せることで追加の嬉しさを獲得できる
    # (2) Li < Ri なるラクダ
    #   なるべく末尾側に寄せることで追加の嬉しさを獲得できる
    # => (1), (2) それぞれで追加できる嬉しさの最大値を求めてベースに足す
    left_camels, right_camels = defaultdict(list), defaultdict(list)
    for i, (k, l, r) in enumerate(klrs):
        if l > r:
            left_camels[k].append(i)
        elif l < r:
            right_camels[k + 1].append(i)
    # (1)
    que = []
    for k in range(N):
        for i in left_camels[k]:
            _, l, r = klrs[i]
            heapq.heappush(que, l - r)
        while len(que) > k + 1:
            heapq.heappop(que)
    p_1 = 0
    while len(que) > 0:
        p_1 += heapq.heappop(que)    
    # (2)
    que = []
    for k in range(N - 1, -1, -1):
        for i in right_camels[k]:
            _, l, r = klrs[i]
            heapq.heappush(que, r - l)
        while len(que) > N - k:
            heapq.heappop(que)
    p_2 = 0
    while len(que) > 0:
        p_2 += heapq.heappop(que)
    return p_1 + p_2 + sum(min(l, r) for _, l, r in klrs)


def main():
    T = int(input())
    ans = [0] * T
    for t in range(T):
        N = int(input())
        klrs = list()
        for _ in range(N):
            k, l, r = map(int, input().split())
            klrs.append([k - 1, l, r])
        ans[t] = solve(N, klrs)
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

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

#define ll long long
#define MOD 1000000007
#define MAX 1000000000000000000

int digit(ll a){
    int co=0;
    while(a!=0){
        a /= 10;
        co++;
    }
    return co;
}


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

    vector<ll> a(n);
    vector<int> d(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());

    ll sum=1;int cd=0;int j=0;
    for(int i=0;i<n;i++){
        sum*=a.at(i);
        if(cd+digit(a.at(i))-1>=19&&sum!=MAX){
            j=1;
            break;
        }
        cd= digit(sum);
        if(sum>MAX){
            j=1;
            break;
        }
    }
    if(j==1){
        cout<<-1<<endl;
    }else{
        cout<<sum<<endl;
    }



}


Measured memory_bytes: 4576
#include<bits/stdc++.h>
#define INF 9003372036854775807LL
#define mod 998244353
#define SYOU(x) fixed<<setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
lol n,m,k;
string s[100];
bool f(int x,int y){
  if(x<0||y<0) return false;
  if(x>=n||y>=m) return false;
  bool a;
  if(s[x][y]=='.') a=false;
  else a=true;
  return a;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m;
  for(int i=0;i<n;i++){
    cin >>s[i];
  }
  bool ans=true;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(s[i][j]=='#'){
        bool a=false;
        a|=f(i-1,j);
        a|=f(i+1,j);
        a|=f(i,j-1);
        a|=f(i,j+1);
        if(!a) ans=false;
      }
    }
  }
  if(ans) cout <<"Yes\n";
  else cout <<"No\n";
  return (0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

#include <iostream>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a == b)
    cout << "a == b" << endl;
  else
    a < b ? cout << "a < b" << endl : cout << "a > b" << endl;
  return 0;
}



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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		B[i] = A[i] - (i + 1);
	}
	sort(B.begin(), B.end());
	int b;
	if (N % 2 == 0)
		b = (B[N / 2 - 1] + B[N / 2]) / 2;
	else
		b = B[(N - 1)/ 2];
	long ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += abs(A[i] - (b + i + 1));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
int main()
{
	int i = 0,N = 0,sum = 0,a = 0;

	i=1;
	scanf ("%d",&N);
	
	for (i = 1;i <= N;i++){
		
		a=a+i;
		}
		printf("%d",a);
	
	return 0;
	}

Measured memory_bytes: 128
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
#define chmax(a,b) if(a<b)a=b
const int N=17;

int n,m;
int g[N][N];
int cost[1<<N];
int dp[N][1<<N],dp2[1<<N];

int main()
{
	
	scanf("%d%d",&n,&m);
	while(m--)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		u--; v--;
		g[u][v]=g[v][u]=w;
	}
	for(int mask=0;mask<(1<<n);mask++)
	for(int u=0;u<n;u++)
	for(int v=u+1;v<n;v++)
		if(mask&(1<<u) && mask&(1<<v)) cost[mask]+=g[u][v];
	memset(dp,-1,sizeof(dp));
	for(int mask=1;mask<(1<<n);mask+=2)
		dp[0][mask]=cost[mask];
	for(int mask=1;mask<(1<<(n-1));mask+=2)
	for(int i=0;i<n-1;i++) if(dp[i][mask]!=-1)
	for(int j=0;j<n;j++)
	{
		if(!g[i][j]) continue;
		if(mask&(1<<j)) continue;
		chmax(dp[j][mask|(1<<j)],dp[i][mask]+g[i][j]);
	}
	memset(dp2,-1,sizeof(dp2));
	for(int mask=1;mask<(1<<n);mask+=2)
		dp2[mask]=dp[n-1][mask];
	for(int mask=1+(1<<(n-1));mask<(1<<n);mask+=2) if(dp2[mask]!=-1)
	for(int i=0;i<n;i++) if(mask&(1<<i))
	{
		int _=(1<<n)-1-mask;
		for(int mask2=_;mask2>0;mask2=(mask2-1)&_)
			chmax(dp2[mask|mask2],dp2[mask]+cost[mask2|(1<<i)]);
	}
	printf("%d\n",cost[(1<<n)-1]-dp2[(1<<n)-1]);
	
	return 0;
}

Measured memory_bytes: 9600
from collections import deque
N,D,A = map(int,input().split())
enemy = []
for i in range(N):
    C,B = map(int,input().split())
    enemy.append([C,B])
enemy.sort()
count = 0
chk_deque = deque()
total = 0
for i in range(N):
    if enemy[i][0] < D*2:
        demand =  (enemy[i][1]-1)//A + 1
        if demand > count :
            chk_deque.append([enemy[i][0],demand-count])
            total += demand - count
            count = demand
    else:
        for j in range(len(chk_deque)):
            a = chk_deque.popleft()
            if a[0] +2*D < enemy[i][0] :
                count -= a[1]
            else:
                chk_deque.appendleft(a)
                break
        demand =  (enemy[i][1]-1)//A + 1
        if demand > count :
            chk_deque.append([enemy[i][0],demand-count])
            total += demand - count
            count = demand
print(total)


Measured memory_bytes: 83544
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]


int main(){
  ll a,b ,n;
  ll z;
  
  scanf("%lld%lld%lld", &a, &b, &n);

  z = MIN(n, b-1);

  printf("%lld\n", (a*z/b));

  return 0;
}

Measured memory_bytes: 1728
a = str(input())
if a == "SUN":
    print("7")
elif a == "MON":
    print("6")
elif a == "TUE":
    print("5")
elif a == "WED":
    print("4")
elif a == "THU":
    print("3")
elif a == ("FRI"):
    print("2")
else:
    print("1")
    


Measured memory_bytes: 2940
#include <stdio.h>

int main(int argc, char *args[])
{
	int x[3001]; 
	int y[3001];
	int c;
	int i;
	int t;

	for( i=0; i<=3000; i++ ) {
		scanf("%d %d", &x[i], &y[i]);

		if( x[i] == 0 && y[i] == 0 ) {
			break;
		}

	}

	for( c=0; c < i; c++ ) {
		if( x[c] > y[c] ) {
			t = x[c];
			x[c] = y[c];
			y[c] = t;
		}
		printf("%d %d\n", x[c], y[c]);
	}

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<double> vec(N);
  rep(i, N) cin >> vec[i];
  
  sort(vec.begin(), vec.end());
  
  double ans = vec[0];
  
  for(int i = 1; i < N; i++){
    ans = (ans + vec[i])/2 ;
  }
  
  cout << ans << endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;i++){
        cin>>d.at(i);
        }
    int ans,t=d.at(0);
    ans=1;
    for(int i=1;i<n;i++){
        t=min(t,d.at(i));
        if(t==d.at(i)){ans++;}
        }
    cout<<ans<<endl;
    }


Measured memory_bytes: 1024
k = gets.chomp.to_i

sum=0
k.times do |aa|
  a = aa+1
  k.times do |bb|
    b = bb+1
    k.times do |cc|
      c = cc+1
      gcd_tmp = a.gcd(b).gcd(c)  
      sum += gcd_tmp
    end
  end
end
puts sum

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


int main()
{

    int n;
    cin>>n;

    map<string,int> wk;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(wk.count(s))
            wk.at(s)++;
        else
            wk[s]=1;
    }

    cout<<wk.size()<<endl;

    return 0;
}   

Measured memory_bytes: 19228
n = int(input())
a = list(map(int, input().split()))
nl = []
for i in range(n):
  bn = bin(a[i])
  nl.append(bn[2:])
count = 0
for i in range(len(nl)):
  lnl = list(nl[i])
  rlnl = lnl[::-1]
  bil = [i for i, x in enumerate(rlnl) if x == '1']
  count += bil[0]
print(count)

Measured memory_bytes: 4396