akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

vint dp(100005, INF);

void Main() {
    int n, k;
    cin >> n >> k;

    vint h(n);
    rep(i, n) cin >> h[i];

    dp[0] = 0;
    
    rep(i, n) {
        for (int j = 1; j <= min(i, k); ++j) {
            chmin(dp[i], dp[i - j] + abs(h[i - j] - h[i]));

        }
    }

    cout << dp[n - 1] << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

		Set<Character> set = new HashSet<>();
		for(int i = 0; i < s.length(); i++) {
			set.add(s.charAt(i));
		}

		if(set.size() == 1) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

	}

}


Measured memory_bytes: 21712
N=int(input())
S=input()
R=S.count("R")
G=S.count("G")
B=S.count("B")
ans=R*G*B
for i in range(N):
    for j in range(i,N):
        k=j+j-i
        if k>=N:
            continue
        if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
            ans-=1
print(ans)

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

int main() {
  int n, r;
  cin >> n >> r;
  if(n >= 10) cout << r << endl;
  else cout << r + 100*(10 - n) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int a,b,c,d[100005] = {},n,m;
string s,t;

int main(){

    cin   >> s;
    map<char,int> ss;
    rep(i,0,4)ss[s[i]]++;

    if(sz(ss) == 2 && ss[s[0]] == 2)Yes;
    else No;
    
    return  0;
}


Measured memory_bytes: 256
fun main() {
    var s= readLine()!!
    var max=0
    var tmp=0
    for (chr in s){
        if (chr =='A' ||chr =='G' ||chr =='C' ||chr =='T' ){
            tmp++
        }else{
            if (max<tmp){
                max=tmp
            }
            tmp=0
        }
    }
    println(kotlin.math.max(max, tmp))
}

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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    bool isPal(string s){
        int n=s.size();
        for(int i=0;i<(n/2);i++){
            if(s[i]!=s[n-1-i])
                return false;
        }
        return true;
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int L;
        cin>>L;
        double k=L/(double)3;
        double ans=k*k*k;
        cout<<ans;
        return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////


matrix tr(200050,Vi(0));
vector<ll> tour;
void dfs(int v,int p){
    tour.pb(v);
    for(auto u:tr[v]){
        if(u!=p) dfs(u,v);
    }
    tour.pb(-v);
}
void solve(){
    ll n; 
    cin >> n;
    Vi a(n+1);
    Vi where(n+1);
    repi(i,1,n+1) cin >> a.at(i);
    tr[0].pb(1);
    tr[1].pb(0);
    rp(i,n-1){
        ll u,v;
        cin >> u >> v;
        tr[u].pb(v);
        tr[v].pb(u);
    }
    dfs(1,0);
    vector<stack<ll>> dp(n+1);
    vector<ll> ans(n+1); 
    rp(i,n+1) dp[i].push(INF);
    for(auto v:tour){
        if(v>0){
            ll ok=n,ng=0;
            ll mid=(ok+ng)/2;
            if(dp[0].top()>=a[v]){
                dp[0].push(a[v]);
                where[v]=0;
            }else{
                while(ok-ng>1){
                    if(dp[mid].top()>=a[v]) ok=mid;
                    else ng=mid;
                    mid=(ok+ng)/2;
                }
                dp[ok].push(a[v]);
                where[v]=ok;
            }
            ok=0; ng=n;
            mid=n/2;
            while(ng-ok>1){
                if(dp[mid].top()==INF) ng=mid;
                else ok=mid;
                mid=(ok+ng)/2;
            }
            ans[v]=ok+1;
        }else{
            v=-v;
            dp[where[v]].pop();
        }
    }
    repi(i,1,n+1){
        print(ans[i]);
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
} 

Measured memory_bytes: 168600
/*! path: /home/ts3min/work/tspro/src/contest/atcoder/msol2020/c.ts */!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";(function(e){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.main=void 0;const o=r(n(2)),u=n(3);function i(e){const t=u.getNextInt(e),n=t(),r=t(),o=[];for(let e=0;e<n;e++)o[e]=t();console.log(function({N:e,K:t,A:n}){const r=[];for(let o=t;o<e;o++)n[o-t]<n[o]?r.push("Yes"):r.push("No");return r}({N:n,K:r,A:o}).join("\n"))}if(t.main=i,n.c[n.s]===e){i(o.default.readFileSync("/dev/stdin","utf8"))}}).call(this,n(1)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){e.exports=require("fs")},function(e,t,n){"use strict";function*r(e){const t=e.split(/\s+/);for(const e of t)yield e}Object.defineProperty(t,"__esModule",{value:!0}),t.getNextBigInt=t.getNextInt=t.getNext=t.getIteratorWithParser=t.getIterator=void 0,t.getIterator=r,t.getIteratorWithParser=function*(e,t){const n=e.split(/\s+/);for(const e of n)yield t(e)},t.getNext=function(e){const t=r(e);return()=>t.next().value},t.getNextInt=function(e){const t=r(e);return()=>parseInt(t.next().value)},t.getNextBigInt=function(e){const t=r(e);return()=>BigInt(t.next().value)}}]);
//# sourceMappingURL=submit.js.map

Measured memory_bytes: 73792
#include<stdio.h>
int main()
{
    long long int n,m;
    long long int no,sum=0;
    scanf("%lld %lld",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%lld",&no);
        sum+=no;
    }
    
    if(sum<=n)
    {
        printf("%lld",n-sum);
    }else{
    printf("-1");
    }
    return 0;

}

Measured memory_bytes: 1736
s = input().rstrip()

def solve(s):
    rec = len(s)
    for c in 'abcdefghijklmnopqrstuvwxyz':
        if s == c * len(s):
            return 0
        if c not in s:
            continue
        rec = min(rec, solve_core(s, c))
    return rec

def solve_core(s, c):
    count = 0
    flag = True
    while (flag):
        count += 1
        news = []
        flag = False
        for i in range(0, len(s) - 1):
            if (s[i] == c or s[i + 1] == c):
                news.append(c)
            else:
                news.append('@')
                flag = True
        s = ''.join(news)
    return count


print(solve(s))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector <long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  long long ans = 0;
  for (int i = 1; i < N; i++) {
    if (A[i-1]>A[i]) {
      ans += (A[i-1]-A[i]);
      A[i] += (A[i-1]-A[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int N = 3004;
int dp[N][N];

string s, t;
string ans;

void go(int n, int m) {
    if (!n || !m)   return;
    if (s[n-1] == t[m-1])   ans += s[n-1], go(n-1, m-1);
    else if (dp[n-1][m] > dp[n][m-1])    go(n-1, m);
    else                                 go(n, m-1);
}

int main() {
    cin>>s>>t;

    int n = s.size();
    int m = t.size();

    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            if (s[i-1] == t[j-1])   dp[i][j] = 1 + dp[i-1][j-1];
            else                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);

    go(n, m);
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s ;
  cin >> s ;
  if(s[2]==s[3] && s[4]==s[5]){
    yes() ;
  }
  else{
    no() ;
  }
  
  
  
  return 0 ;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define MAX 200000
using namespace std;
int rsq[MAX+1];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int v[n+1];
	long long ans = 0;
	for(int i=1;i<=n;++i)
	{
		cin>>v[i];
		ans += (v[i]*1LL*rsq[i-1])%MOD;
		ans %= MOD;
		rsq[i] = (rsq[i-1]*1LL+v[i]*1LL)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	vi h(n+1);
	FOR(i,1,n+1){
		scanf("%d", &h[i]);
	}
	vvi adjList(n+1, vi());
	for(int i = 0; i < m; i++){
		int a, b;		
		scanf("%d %d", &a, &b);
		adjList[a].pb(b);
		adjList[b].pb(a);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		bool ok = true;
		for(int v : adjList[i]){
			if(h[v] >= h[i]){
				ok = false;
				break;
			}
		}
		if(ok) ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8708
#include<bits/stdc++.h>
#define M 3005
using namespace std;
int B[M],A[M];
int main(){
	int n,a;
	scanf("%d",&n);
	A[1]=A[2]=1;
	for(int i=2;i<n;i++)for(int j=i+1;j>=1;j--)A[j]=(A[j]+A[j-1])%n;
	for(int i=1;i<=n;i++)if((i&1))A[i]*=-1;
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		if(a){
			B[n]++;
			int num=1;
			for(int j=1;j<=n;j++){
				B[j]=((B[j]+num*A[j])%n+n)%n;
				num*=i;
				num%=n;
			}
		}
	}
	for(int i=n;i>=1;i--)printf("%d ",B[i]);
	return 0;
}

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
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; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

signed main(void){
    int a,b;cin>>a>>b;
    repi(i,1,1001){
        if(floor(i*0.08)==a&&floor(i*0.1)==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        ps: [i32; n],
    }
    let mut i = 0;
    let mut ans = 0;
    while i < n {
        if (i + 1) as i32 == ps[i] {
            ans += 1;
            i += 1;
        }
        i += 1;
    }
    println!("{}", ans);
}


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

int main(){
  ll N;
  cin >> N;
  ll ans = (1 + N - 1) * (N - 1) / 2;
  cout << ans << endl;
  
}


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

const ll mod=1000000007,MAX=200005,INF=1<<30;


ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

ll comb(ll a,ll b){
    ll ans=1;
    for(ll i=a;i>a-b;i--){
        ans=ans*i%mod;
    }
    for(ll i=1;i<=b;i++){
        ans=(ans*rui(i,mod-2))%mod;
    }
    return ans;
}

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

    int n, a, b; cin >> n >> a >> b;

    ll ans = rui(2,n) - 1;

    ans -= comb(n,a);

    ans -= comb(n,b);

    while(ans < 0) ans += mod;

    cout << ans << endl;

	
    
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;


int main() {
    int x, y, r;
    cin >> x >> y;

    if (x <= 3) {
        r += 4 - x;
    }
    if (y <= 3) {
        r += 4 - y;
    }

    if (x == 1 && y == 1) {
        r += 4;
    }

    cout << r * 100000 << endl;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll N, K;
    cin >> N >> K;
    Vl cnts(N);
    for (ll i = 0; i < N; i++) {
        int a;
        cin >> a;
        ++cnts[a - 1];
    }
    sort(cnts.begin(), cnts.end(), greater<ll>());

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        if (K > 0)
            --K;
        else {
            ans += cnts[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll a[3] = {};
    rep(i,n){
        if(s[i] == 'R')a[0]++;
        if(s[i] == 'G')a[1]++;
        if(s[i] == 'B')a[2]++;
    }

    ll ans = a[0] * a[1] * a[2];

    rep(i,n){
        srep(j,i+1,n){
            int k = j + (j - i);
            if(k >= n)continue;
            if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i])ans--;
        }
    }

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


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int N = 30, M = 410, inf = 1e9, dr[4] = { -1,0,1,0 }, dc[4] = { 0,-1,0,1 };
typedef long long ll;
const ll mod = (1e9 + 7);
int h, w, d[M][M];
string s[N];
int zip(int r, int c) { return r * w + c; }
void unzip(int z, int &r, int &c) { r = z / w; c = z % w; }
void mnm(int &a, int b) { a = min(a, b); }
void mxm(int &a, int b) { a = max(a, b); }
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> h >> w; for (int i = 0; i < h; ++i) cin >> s[i];
	for (int i = 0; i < w*h; ++i) {
		fill(d[i], d[i] + w * h, inf);
		d[i][i] = 0;
	}
	for (int i = 0; i < h; ++i)
		for (int j=0; j<w; ++j)
			if (s[i][j] == '.') {
				for (int k = 0; k < 4; ++k) {
					int ii = i + dr[k], jj = j + dc[k];
					if (ii >= 0 && ii < h && jj >= 0 && jj < w && s[ii][jj]=='.')
						d[zip(i, j)][zip(ii, jj)] = 1;
				}
			}
	for (int k = 0; k < w*h; ++k)
		for (int u = 0; u < w*h; ++u)
			for (int v = 0; v < w*h; ++v)
				mnm(d[u][v], d[u][k] + d[k][v]);
	int ans = 0;
	for (int i = 0; i < w*h; ++i) {
		int ma = 0;
		for (int j = 0; j < w*h; ++j) if (d[i][j] < inf)
			mxm(ma, d[i][j]);
		mxm(ans, ma);
	}
	cout << ans << endl;
}

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

int main() {
  int A, B, x, sum, c, d;
  cin >> A >> B;
  sum = 0;
  for (int i = 0; i < (B - A + 1); i++) {
    x = A + i;
    c = x % 100;
    d = x / 1000;
    if (c < 10) {
      if ((c * 10) == d) { 
        sum++;
      }
    }
    else {
      c = (c / 10) + (c % 10 * 10);
      if (c == d) {
        sum++;
      }
    }
  }
  cout << sum << endl;
} 

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int A[]=new int[3];
		for(int i=0;i<3;i++) A[i]=Integer.parseInt(in.next());
		
		int max=A[0], min=A[0];
		for(int i=1;i<3;i++) {
			if(max<A[i])max=A[i];
			if(min>A[i])min=A[i];
		}
		
		System.out.println(min+" "+max);
	}

}



Measured memory_bytes: 26304
n = int(input())
a = list(map(int, input().split()))

ans = 1
for i in a:
    if i == 0:
      	ans = 0

if ans != 0:
	for i in a:
		ans = ans*i
		if ans > 1000000000000000000:
			break

if ans <= 1000000000000000000:
	print(ans)
else:
  	print(-1)

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

int target[102];
int score[102];
int paper[102];

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>target[i];
		}
		
	for(int j=0;j<m;j++){
		for(int i=0;i<n;i++){
			cin>>paper[i];
			}
		for(int i=0;i<n;i++){
			if(target[j]==paper[i]){
				score[i]++;
				}
			else{score[target[j]-1]++;}	
			}	
		}
		
		for(int i=0;i<n;i++){
			cout<<score[i]<<endl;
			}
	return 0;
	}

Measured memory_bytes: 3048
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
template <typename T>
T gcd(T m, T n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
         r %= 1000000007;
         rr %= 1000000007;
    }
    r /= rr;
     r %= 1000000007;
    return r;
}
#define rep(a,b,c) for(ll a = b; a < c; ++i)
ll mod = 1000000007;
//---------------------------------------------------------------------------------------------------
ll f[101010];
void init() {
    f[0] = 1;
    rep(i, 1, 101010) f[i] = (f[i - 1] * i) % mod;
}
//---------------------------------------------------------------------------------------------------
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = f[n-k]; // = (n-k)!
    ll c = f[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * inv(bc)) % mod;
}
ll pow2_(ll n){
  
  ll div = 1000000007ll;
  ll ans = 0,k=2;
  {
    bitset<48> b(n);
    FOR(i,32){
      ans+=b[i]*k%div;
      ans%=div;
      k*=k;
      k%=div;
    }
  }
  return ans;
}
int main(){
  ll X;
  cin>>X;
  ll ans=0;
  ans+=X/500*1000;
  X%=500;
  ans+=X/5*5;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#dp7 #Grid 1

import sys
sys.setrecursionlimit(10000000)
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]
mod = 10**9+7

def h():
    h,w = LI()
    grid = [list(input()) for _ in range(h)]

    dp = [[0 for _ in range(w)] for _ in range(h)]
    dp[0][0] = 1
    for j in range(w-1):
        if grid[0][j+1] == '.':
            dp[0][j+1] += dp[0][j]
            dp[0][j+1] %= mod
    for i in range(h-1):
        if grid[i+1][0] == '.':
            dp[i+1][0] += dp[i][0]
            dp[i+1][0] %= mod
    #(i,j)が空マスであるとき(i-1,j)および(i,j-1)からの移動が考えられる
    for i in range(1,h):
        for j in range(1,w):
            if grid[i][j] == '.':
                dp[i][j] = dp[i-1][j] + dp[i][j-1]
                dp[i][j] %= mod
    print(dp[-1][-1])
if __name__ == '__main__':
    h()


Measured memory_bytes: 89564
#include <iostream>
#include <sstream>
#include <string>

int a[4], b[4];

void split(std::string s, std::string t) {
    a[0] = s[0]-'0'; b[0] = t[0]-'0';
    a[1] = s[2]-'0'; b[1] = t[2]-'0';
    a[2] = s[4]-'0'; b[2] = t[4]-'0';
    a[3] = s[6]-'0'; b[3] = t[6]-'0';
}

void solve() {
    int hit=0, blow=0;
    for (int i=0; i<4; i++) {
        for (int j=0; j<4; j++) {
            if (a[i] == b[j]) {
                if (i == j) {
                    hit++;
                } else {
                    blow++;
                }
            }
        }
    }
    std::cout << hit << ' ' << blow << std::endl;
}

int main(void) {
    std::string line_1, line_2;
    while (std::getline(std::cin, line_1)) {
        std::getline(std::cin, line_2);
        split(line_1, line_2);
        solve();
    }
}



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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    queue<ll> q;

    for (ll i = 1; i <= 9; i++)
    {
        q.push(i);
    }

    for (int i = 1; i < k; i++)
    {
        ll x = q.front();
        q.pop();
        ll m = x % 10;
        if (m != 0)
            q.push(10 * x + m - 1);

        q.push(10 * x + m);

        if (m != 9)
            q.push(10 * x + m + 1);
    }

    OP(q.front());

    return 0;
}

Measured memory_bytes: 1792
k = int(input())

ans = 0
def gcd(x,y):
    while y:
        x, y = y, x % y
    return x

for i in range(1,k+1):
    for j in range(1,k+1):
        for s in range(1,k+1):
            ans += gcd(gcd(i,j),s)

print(ans)

Measured memory_bytes: 79680
n,m=map(int,input().split())
a,b=[0]*n,[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
c,d=[0]*m,[0]*m
for i in range(m):
    c[i],d[i]=map(int,input().split())

for i in range(n):
    res=min(range(m),key=lambda j:abs(a[i]-c[j])+abs(b[i]-d[j]))
    print(res+1)


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

int main (){

  int a[101] , i = 0 , n = 0 , num = 0 ;

  cin >> n ;

  for ( i = 1 ; i <= n ; i++ ){

    cin >> num ;

    a[i] = num ;
}
  //cout << a[n];
  for ( i = n  ; i >= 1 ; i-- ){
    
     cout << a[i] ;
     if (i == 1)break;
       if (i){
     cout << " " ;
       }
    }    
  
  cout << "\n" ;

  return 0 ;

}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

int main(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n+m+1);
    set<int> st;
    rep(i,n){
        int k;
        cin>>k;
        rep(j,k){
            int x;
            cin>>x;
            --x;
            st.insert(x);
            uf.unite(i,n+x);
        }
    }
    if(uf.size(0)==n+st.size())cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3584
# Track and Field Competition

a1=Array.new()
a2=Array.new() #finalist
a3=Array.new()

24.times { |i|
  n, t=gets.split.map(&:to_f)
  a1<<[n, t]
  if i%8==7
    a1.sort_by! { |item| item[1] }
    a2=a2+a1[0..1]
    a3=a3+a1[2..-1]
    a1.clear
  end
}

a3.sort_by! { |item| item[1] }
a2=a2+a3[0..1]

a2.each { |each|
  puts "%d %.2f" % each
}

Measured memory_bytes: 6148
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

const int MAXN = 3005;
const int mod = 1e9 + 7;

inline void inc(int &x, int y) { x += y; if( x >= mod ) x -= mod; }

int n, m, dp[MAXN][MAXN][2], ans;

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d%d", &n, &m );
	for( int i = 1 ; i <= n ; i++ ) dp[ 0 ][ i ][ 0 ] = 1;
	dp[ 0 ][ 0 ][ 1 ] = 1;
	for( int i = 0 ; i < m ; i++ )
		for( int j = 0 ; j <= n ; j++ )
			for( int k = 0 ; k < 2 ; k++ ) if( int cur = dp[ i ][ j ][ k ] )
			{
				if( !j )
				{
					inc( dp[ i + 1 ][ j ][ 1 ], cur );
					inc( dp[ i + 1 ][ j + 1 ][ 1 ], cur );	
				}
				else if( j == n )
				{
					inc( dp[ i + 1 ][ j ][ k | ( j == 1 ) ], cur );
					inc( dp[ i + 1 ][ j - 1 ][ k | ( j == 1 ) ], cur );
				}
				else
				{
					inc( dp[ i + 1 ][ j ][ k ], cur );
					inc( dp[ i + 1 ][ j + 1 ][ k ], cur );
					inc( dp[ i + 1 ][ j ][ k | ( j == 1 ) ], cur );
					inc( dp[ i + 1 ][ j - 1 ][ k | ( j == 1 ) ], cur );
				}
			}
	for( int i = 0 ; i <= n ; i++ ) inc( ans, dp[ m ][ i ][ 1 ] );
	return printf( "%d\n", ans ), 0;
}


Measured memory_bytes: 70656
N, Y = map(int, input().split())

flag = False
for x in range(N + 1):
    for y in range(N + 1):
        z = N - x - y
        if x + y + z == N and z >= 0:
            if Y == 10000 * x + 5000 * y + 1000 * z:
                print(x, y, z)
                flag = True
                break
    if flag:
        break
if not flag:
    print(-1, -1, -1)


Measured memory_bytes: 3060
import random
import time
import copy

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    ans = []    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)
        
    random.seed(10)
    while time.time() - start < 1.9:
        cp = ans.copy()
        last_d = [0 for i in range(26)]
        score2 = 0  
        
        idx1 = random.randint(0,25)
        idx2 = random.randint(0,25)
        if random.randint(0,1):
            d1 = random.randint(0,D-1) 
            d2 = random.randint(0,D-1)
            if idx1 == idx2:
                continue
            if random.randint(0,1):
                ans[d1] = idx1
            else:
                ans[d1] = idx1
                ans[d2] = idx2
             
        #2値入れ替え
        elif random.randint(0,1):           
            d1 = random.randint(0,D-19) 
            d2 = random.randint(d1+1,d1+18)
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp1
            
        #3値入れ替え          
        else:
            d1 = random.randint(0,D-17) 
            d2 = random.randint(d1+1,d1+8)
            d3 = random.randint(d2+1,d2+8) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp3
                ans[d3] = tmp1
            else:
                ans[d1] = tmp3
                ans[d2] = tmp1
                ans[d3] = tmp2
            
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans = cp.copy()
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 10108
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b;
    cin>>a>>b;
    int s=-99999;
    chmax(s,a+b);
    chmax(s,a-b);
    chmax(s,a*b);
    cout<<s<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

const string YES = "Yes";
const string NO = "No";
int main(){
  int N, M; cin >> N >> M;
  if (N == M) cout << YES << endl;
  else cout << NO << endl;
}


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

int main(){
  long long n,ttl=0;cin>>n;
  vector<long long> x(n+2,0);
  REP(i,n){
    cin>>x.at(i+1);
    ttl+=abs(x.at(i+1)-x.at(i));
  }
  ttl+=abs(x.at(n));
  REP(i,n){
    long long tmp=0,s=x.at(i),t=x.at(i+1),g=x.at(i+2);
    if((t<=s&&s<=g)||(g<=s&&s<=t)) tmp=2*abs(s-t);
    else if((s<=g&&g<=t)||(t<=g&&g<=s)) tmp=2*abs(g-t); 
    cout<<ttl-tmp<<endl;
  }
}

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

int main(void){
    ll n;
    cin>>n;
    ll p[n];
    rep(0,i,n)cin>>p[i];
    ll minp=1e6;
    ll ans=0;
    rep(0,i,n){
        minp=min(p[i],minp);
        if(minp==p[i])++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll n;
    cin >> n;
    unsigned long long result = 1;
    bool flag = false;
    vector<ll> an(n);
    rep(i,n) cin >> an[i];
    rep(i,n){
        
        if(an[i] == 0) flag = false;
        else{
            if(result != result*an[i]/an[i] || result * an[i] > ll(1e18)) flag = true;
        }
        result *= an[i];
    }
    if(flag) cout << -1;
    else cout << result;
}

Measured memory_bytes: 3976
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	int n;
	cin >> n;
	int number[100];
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> number[i];
	}
	for (int i = 0; i < n -2; i++) {
		if ((number[i + 1] - number[i]) * (number[i + 1] - number[i + 2]) < 0) {
			count++;
		}
	}
	cout << count;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

char *demangle(const char *demangle)
{
    int status;
    return abi::__cxa_demangle(demangle, 0, 0, &status);
}

int main()
{
    while (1)
    {
        int N, M;
        cin >> N >> M;
        int ans = 0;
        if (N == 0 && M == 0)
            break;
        for (int i = 1; i < N - 1; i++)
        {
            for (int j = i + 1; j < N; j++)
            {
                if (1 <= M - i - j && M - i - j <= N && j < M - i - j)
                {
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}



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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ll n;
    cin >> n;

    vll a(n);
    REP(i, n) {
      cin >> a[i];
    }

    RSORT(a);

    ll total = 0;
    total += a[0];
    ll index = 1;
    REP(i, n - 2) {
      total += a[index];
      if(i % 2 != 0) {
        index++;
      }
    }

    COUT(total);
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


Measured memory_bytes: 4764
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a = 0,b = n;
	while(b)
	{
		a += b%10;
		b/=10;
	}
	if(n%a==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
// 2015/05/19 Tazoe

#include <iostream>
using namespace std;

bool is_prime[10000001];

int main()
{
	is_prime[0] = is_prime[1] = false;
	for(int i=2; i<10000001; i++){
		is_prime[i] = true;
	}

	for(int i=2; i*i<10000001; i++){
		if(is_prime[i]){
			for(int j=i*i; j<10000001; j+=i){
				is_prime[j] = false;
			}
		}
	}

	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		for(int i=n; i>=13; i--){
			if(is_prime[i] && is_prime[i-2] && is_prime[i-6] && is_prime[i-8]){
				cout << i << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 10924
#include <cctype>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int ans = 1e9;
	int n;
	cin>>n;
	vi a(n);
	rep(i, n ) cin>>a[i];
	for(int i = -100; i <= 100; i++){
		int t = 0;
		rep(j, n) t += (a[j]-i)*(a[j]-i);
		ans = min(ans, t);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

vi func(vi a, vi b) {
  int n = a.size();
  if (n == 0) return vector<int>();
  int pos = find(b.begin(), b.end(), a[0]) - b.begin();
  vi na1, nb1, na2, nb2;
  for (int i = 0; i < pos; i++) {
    na1.emplace_back(a[i + 1]);
    nb1.emplace_back(b[i]);
  }
  for (int i = 0; i < n - pos - 1; i++) {
    na2.emplace_back(a[pos + i + 1]);
    nb2.emplace_back(b[pos + i + 1]);
  }
  vi res;
  for (int i : func(na1, nb1)) {
    res.emplace_back(i);
  }
  for (int i : func(na2, nb2)) {
    res.emplace_back(i);
  }
  res.emplace_back(a[0]);
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  vi a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vi ans = func(a, b);
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " \n"[i + 1 == n];
  }

  return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define ll long long
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
int L;
int main()
{
	//cwk;
	scanf("%d",&L);
	double bc=double(L)/3.0;
	double ans=bc*bc*bc;
	printf("%.08lf\n",ans);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
void printRectangle(int H, int W){
    int i,j,k;
     
    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            k = i+j;
            if(k%2 == 0)  printf("#");
            else printf(".");
        }
        printf("\n");
    }
    printf("\n");
}
 
int main(void){
     
    int h,w;
     
    while(1){
        scanf("%d %d", &h, &w);
        if(h==0 && w==0) break;
        printRectangle(h, w);
    }
    return 0;
}

Measured memory_bytes: 572