akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    ll N, M, K; cin >> N >> M >> K;

    deque<ll> deqa, deqb, deqab;
    vector<ll> sa(N), sb(M);

    ll A, B;

    rep(i, N) {
        cin >> A;
        deqa.push_back(A);
    }

    rep(i, M) {
        cin >> B;
        deqb.push_back(B);
    }

    sa[0] = deqa[0];

    for (ll i = 1; i < N; ++i) {
        sa[i] = sa[i - 1] + deqa[i];
    }

    sb[0] = deqb[0];

    for (ll i = 1; i < M; ++i) {
        sb[i] = sb[i - 1] + deqb[i];
    }

    auto kk = upper_bound(all(sb), K);
    deqab.push_back((ll)(kk - sb.begin()));

    rep(i, N) {
        if (sa[i] > K) { break; }
        else {
            auto kk = upper_bound(all(sb), K - sa[i]);
            deqab.push_back(i + 1 + (ll)(kk - sb.begin()));
        }
    }

    if (deqab.size() == 0) {
        cout << 0 << endl;
        return 0;
    }

    sort(all(deqab));
    cout << deqab[deqab.size() - 1] << endl;

}

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

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

  int len = s.length();
  bool digitFlg = false;
  bool upperFlg = false;
  bool lowerFlg = false;

  for(int i = 0; i < len; i++){
    if(isdigit(s[i]))      digitFlg = true;
    else if(isupper(s[i])) upperFlg = true;
    else if(islower(s[i])) lowerFlg = true;
  }

  if(len >= 6 && digitFlg && upperFlg && lowerFlg){
    cout << "VALID" << endl;
  }
  else{
    cout << "INVALID" << endl;
  }
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;int n=s.size(),ans;
	ans=n;
	for(int i=1;i<n;i++)
		if(s[i]!=s[i-1])
			ans=min(ans,max(i,n-i));
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d %d",&a,&b);
  if(a>b){
    d=a;
    a=b;
    b=d;
  }
  c=a%b;
  while(c!=0){
    a=b;
    b=c;
    c=a%b;
  }
  printf("%d\n",b);
  return 0;
}




Measured memory_bytes: 2144
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  
  string s;cin>>s;
  if(s == "Sunny")cout << "Cloudy" << endl;
  if(s == "Cloudy")cout << "Rainy" << endl;
  if(s == "Rainy")cout << "Sunny" << endl;

}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) int((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()

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

	int tc=1;
	// cin>>tc;
	fo(q, tc)
	{
		int x;
      	cin>>x;
      	if(x>=30) on("Yes");
      	else on("No");
	}
	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	
	if(a + b + c >= 22) cout << "bust";
	else cout << "win";
	
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
count = 0
for a in A:
 if (a % 2 == 0 and a % 3 != 0) and (a % 2 == 0 and a % 5 != 0):
   count = count + 1

if count >= 1 :
 print('DENIED')
else:
 print('APPROVED')

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  int cnt=0;
  while(cin>>n,n){
    cnt++;
    cout<<"Case "<<cnt<<":"<<endl;
    vector<vector<int> >in(n*2-1,vector<int>(n*2-1));
    int c=2;
    int x,y;
    in[0][0]=1;
    loop(i,1,n){
      x=0;y=i*2-1;
      while(1){
	if(x>=0&&x<n&&y>=0&&y<n){
	  in[x][y]=c;
	  c++;
	}
	x++;y--;
	if(y==-1)break;
      }
      x=i*2;y=0;
      while(1){
	if(x>=0&&x<n&&y>=0&&y<n){
	  in[x][y]=c;
	  c++;
	}
	x--;y++;
	if(x==-1)break;
      }	
    }
    rep(i,n){
      rep(j,n)
	printf("%3d",in[i][j]);
      cout<<endl;
    }
  }
}

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

int main() {
  string s;
  cin >> s;
  int n = s.length();
  int ans = n;
  for (int i = 1; i < n; ++i)
    if (s[i] != s[i - 1]) ans = min(ans, max(i, n - i));
  cout << ans << endl;
}


Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;

int main()
{
	//ll A, B;
	//cin >> A >> B;

	//ll x = A * B;
	//if (A < B)
	//{
	//	ll tmp = A;
	//	A = B;
	//	B = tmp;
	//}

	//ll r = A % B;
	//while (r != 0)
	//{
	//	A = B;
	//	B = r;
	//	r = A % B;
	//}
	//cout << x / B << endl;

	ll N;
	vector<ll> a;
	cin >> N;
	for (ll i = 0; i < N; i++)
	{
		int x; cin >> x;
		a.push_back(x);
	}
	
	int f = 0;
	ll cnt = 1;
	ll dest = 0;
	for (ll i = 0; i < N; i++)
	{
		if (a[i] == 1)
		{
			f = 1;
		}
		if (cnt == a[i])
		{
			cnt++;
			continue;
		}
		dest++;
	}

	if (f == 0)
	{
		cout << -1 << endl;
	}
	else
		cout << dest << endl;

	return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
int n, m, nxt[N];
string s;
int main() {
    cin >> n >> m >> s;
    int p = n;
    for(int i = n; i >= 0; i--) {
        if(s[i] == '0') p=i;
        nxt[i] = p;
    }
    vector<int> ans;
    int now = n;
    while(now > 0) {
        if(now - m <= 0) {
            ans.push_back(now);
            break;
        }
        int nn = nxt[now-m];
        if(nn >= now) {
            ans.clear();
            break;
        }
        ans.push_back(now - nn);
        now = nn;
    }
    if(ans.empty()) cout << -1 << '\n';
    else {
        reverse(ans.begin(), ans.end());
        int sz = ans.size();
        for(int i = 0; i < sz; i++) {
            cout << ans[i] << " \n"[i==sz-1];
        }
    }
    return 0;
}

Measured memory_bytes: 1528
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int n;
vector<int> a[100];
int dist[100];
const int INF = 100000000;

int main() {
  cin >> n;
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    rep(i, y) {
      int z;
      cin >> z;
      a[x-1].push_back(z-1);
    }
  }

    rep(i, n) {
      dist[i] = INF;
    }
    dist[0] = 0;

    queue<int> que;

    que.push(0);
    while(que.size()) {
      int p = que.front();
      que.pop();

      for(int i = 0; i < a[p].size(); i++) {
        if(dist[a[p][i]] > dist[p] + 1) {
          dist[a[p][i]] = dist[p] + 1;
          que.push(a[p][i]);
        }
      }
    }

  rep(i, n) {
    if(dist[i] != INF) cout << i + 1 << " " << dist[i] << endl;
    else cout << i + 1 << " " << -1 << endl;
  }
    

  return 0;
}


Measured memory_bytes: 3156
import java.util.*;

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

        char[] c = new char[N];
        for(int i = 0; i < N; i++){
            c[i] = S.charAt(i);
        }
        int ans = 0;
        for(int i = 0; i < N - 1; i++){
            if(c[i] != c[i+1]) ans++;
        }

        System.out.println(ans+1);
    }
}

Measured memory_bytes: 26260
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,K,A[1010],sum,maxx,num[1010],suml[1010],sumr[1010],last;
void work(int i) {
	for(int j=1; j<=n; j++) {
		int res=(A[j]/i)*i;
		num[j]=A[j]-res;
	}
	sort(num+1,num+1+n);
	suml[0]=0,sumr[n+1]=0;
	int tmp=2e9+7;
	for(int j=1; j<=n; j++)suml[j]=suml[j-1]+num[j];
	for(int j=n; j>=1; j--)sumr[j]=sumr[j+1]+i-num[j];
	for(int j=0; j<=n; j++) {
		int res=max(suml[j],sumr[j+1]);
		tmp=min(tmp,res);
	}
	if(tmp<=K) {
		last=max(last,i);
	}
}
signed main() {
	scanf("%lld %lld",&n,&K);
	for(int i=1; i<=n; i++)scanf("%lld",&A[i]),sum+=A[i],maxx=max(maxx,A[i]);
	for(int i=1; i*i<=sum; i++) {
		if(sum%i!=0)continue;
		work(i);
		work(sum/i);
	}
	cout<<last;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        v:[u64;2],
    }
    let mut i:u64 = 1;
    while pow(v[1], i) <= v[0]{
        i+=1;
    }
    println!("{}",i)
}

fn pow(x:u64, y:u64) -> u64{
    let mut i = 0;
    let mut result = 1;
    while i < y{
        result *= x;
        i+=1;
    }
    result
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void build() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};


int main() {
    string s;
    cin >> s;
    int n = s.size();

    CumulativeSum cs(n);

    rep(i, n) {
        if (s[i] == 'W') cs.set(i, 1);
    }
    cs.build();

    ll ans = 0;
    rep(i, n) {
        if (s[i] == 'B') {
            ll now = cs.getSectionSum(i + 1, n);
            ans += now;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6736
n, t = map(int, input().split())
l = [int(i)for i in input().split()]

if t <= 1 or all(a >= b for a, b in zip(l, l[1:])):
    print(0)
else:
    mini = float("inf")
    maxp = 0
    maxc = 0
    for n in l:
        if n - mini > maxp:
            maxp = n - mini
            maxc = 1
        elif n - mini == maxp:
            maxp = n - mini
            maxc += 1
        mini = min(mini, n)
    print(maxc)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
int dis[250][250];
using namespace std;
signed main(){
	int n,m,r;
	cin>>n>>m>>r;
	vector<int> dt;
	for(int i=0;i<r;i++){
		int x;
		cin>>x;
		dt.pb(x);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i==j)dis[i][j]=0;
			else dis[i][j] = inf;
		}
	}
	for(int i=0;i<m;i++){
		int x,y,d;
		cin>>x>>y>>d;
		dis[x][y] = min( dis[x][y] , d);
		dis[y][x] = min( dis[y][x] , d);
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				dis[i][j] = min( dis[i][j], dis[i][k]+dis[k][j]);
			}
		}
	}
	int ans = inf;
	vector<int> perm;
	for(int i=1;i<=r;i++){
		perm.pb(i);
	}
	do{
		int tmp = 0;
		for(int i=0;i<r-1;i++){
			tmp += dis[ dt[perm[i]-1] ][ dt[perm[i+1]-1] ];
		}
		if( ans > tmp)ans = tmp;
	}while(next_permutation(perm.begin(),perm.end()));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import numpy

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
cnt=0
for i in range(n-1):
    for j in range(i + 1, n):
        a = numpy.array(x[i])
        b = numpy.array(x[j])
        num=numpy.linalg.norm(a-b)
        if num.is_integer() == True:
            cnt += 1
print(cnt)

Measured memory_bytes: 12496
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void) {

	int k, num = 0;

	string s;

	cin >> s;

	for (k = 0; k < s.size(); k++) {
		if (s.at(k) == '1')num++;
//		cout << s.at(k) << "\n";
	}

	cout << num << "\n";

	return 0;
}

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

map<ll, int> cnt;

int main() {
    ll a[2];

    scanf("%lld%lld", &a[0], &a[1]);

    for(int k = 0; k < 2; k++) {
	    for(ll i = 2; i*i <= a[k]; i++) {
	    	if(a[k]%i == 0) {
	    		cnt[i]++;
	    		while(a[k]%i == 0)
	    			a[k] /= i;
	    	}
	    }
	    if(a[k] > 1) cnt[a[k]]++;
	}

	set<ll> S;
	for(auto& x : cnt) {
		if(x.ss == 2) S.insert(x.ff);
	}

	printf("%d\n", S.size()+1);

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int h,n,a;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

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

	cin >> h >> n;
	REP(i, n) {
		int a;
		cin >> a;
		h -= a;
	}
	cout << (h <= 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;


const int mod=1e9+7;

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n) {
        int a;
        cin>>a;
        v[i]=a;
    }
    map<int,int> mp;
    mp[0]=3;
    ll ans=1;
    rep(i,n){
        auto itr=mp.find(v[i]);
        if (itr!=mp.end()){
            int v=itr->second;
            ans*=v;ans%=mod;v--;
            itr->second=v;
            int k=itr->first;k++;
            mp[k]++;
            
        }else{
            cout<<0;
            return 0;
        }
    }
    
    
    cout<<ans<<endl;
    
    return 0;
}


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

using namespace std;

template<typename T>
struct BinaryIndexedTree {
    vector<T> data;

    BinaryIndexedTree(int sz) {
        data.assign(++sz, 0);
    }

    T sum(int k) {
        T ret = 0;
        for (++k; k > 0; k -= k & -k) ret += data[k];
        return (ret);
    }

    void add(int k, T x) {
        for (++k; k < data.size(); k += k & -k) data[k] += x;
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> white(n), black(n);
    for (int i = 0; i < 2 * n; i++) {
        char c;
        int a;
        cin >> c >> a;
        if (c == 'W')white[a - 1] = i;
        else black[a - 1] = i;
    }

    vector<vector<int>> dp(n + 1, vector<int>(n + 1, 1145141919));
    dp[0][0] = 0;

    BinaryIndexedTree<int> onlyBlack(2 * n + 1);
    for (int alreadyBlack = 0; alreadyBlack <= n; alreadyBlack++) {
        BinaryIndexedTree<int> BIT = onlyBlack;
        for (int alreadyWhite = 0; alreadyWhite <= n; alreadyWhite++) {
            if (alreadyBlack < n) {
                int cost = dp[alreadyBlack][alreadyWhite] + (BIT.sum(2 * n) - BIT.sum(black[alreadyBlack]));
                dp[alreadyBlack + 1][alreadyWhite] = min(dp[alreadyBlack + 1][alreadyWhite], cost);
            }
            if (alreadyWhite < n) {
                int cost = dp[alreadyBlack][alreadyWhite] + (BIT.sum(2 * n) - BIT.sum(white[alreadyWhite]));
                dp[alreadyBlack][alreadyWhite + 1] = min(dp[alreadyBlack][alreadyWhite + 1], cost);
            }

            if (alreadyWhite < n)BIT.add(white[alreadyWhite], 1);
        }
        if (alreadyBlack < n)onlyBlack.add(black[alreadyBlack], 1);
    }

    cout << dp[n][n] << endl;
    return 0;
}

Measured memory_bytes: 16000
n, m, x = map(int, input().split())
ans = 10000000
bs = []
for i in range(n):
    bs.append(tuple(map(int, input().split())))

for i in range(2**n):
    a = [0]*m
    c = 0
    for j in range(n):
        if (i>>j)&1:
            c += bs[j][0]
            for k in range(m):
                a[k]+=bs[j][k+1]
    if all([ai >= x for ai in a]):
        ans = min(ans,c)
if ans == 10000000:
    print(-1)
else:
    print(ans)

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

std::vector<long long int> enum_div(long long int n) {
    std::vector<long long int> ret;
    for(long long int i=1 ; i*i<=n ; ++i) {
        if(n%i == 0) {
            ret.push_back(i);
            if(i!=1 && i*i!=n) {
                ret.push_back(n/i);
            }
        }
    }
    ret.push_back(n);
    return ret;
}

int main() {
    long long int n, ans = 0;
    cin >> n;
    vector<long long int> div = enum_div(n);
    set<long long int> st;
    for(int i = 0 ; i < div.size(); ++i) {
        long long int x = div[i];
        st.insert(x-1);
        st.insert(x);
        st.insert(x+1);
    }
    st.erase(0);
    st.erase(1);
    for (auto itr = st.begin(); itr != st.end(); ++itr) {
        long long int x = *itr;
        if(n/x == n%x) ans += x;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n;
V<pii> v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int a, b;
    cin >> a >> b;
    v.pb(mp(b, a));
  }
  sort(all(v));
  ll s = 0;
  for(pii p:v) if((s+=p.se) > p.fi){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

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

int main() {
  long t,n,m,a,b;
  cin >> t;
  for(long i=0;i<t;i++) {
    cin >> n >> m >> a >> b;
    cout << floor_sum(n,m,a,b) << endl;
  }
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    int ans = 0;
    for(int i = 1; i + 1 < n; i++) {
        vector<int> nums({a[i - 1], a[i], a[i + 1]});
        sort(nums.begin(), nums.end());
        ans += nums[1] == a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  double r; cin >>r;
  double s = r * r * M_PI;
  double l = 2 * r * M_PI;
  cout <<fixed <<setprecision(12);
  cout <<s <<" " <<l <<endl;
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n;
    vi x(n),y(n),t(n);
    REP(i,n) {
        cin>>t[i]>>x[i]>>y[i];
    }
    if(t[0]>=x[0]+y[0]&&((t[0]-(x[0]+y[0]))%2==0)){
        ;
    }else{
        cout << "No" << endl;
        return 0;
    }
    REP(i,n-1) {
        ll a=t[i+1]-t[i];
        ll b = abs(x[i+1]-x[i]);
        ll c = abs(y[i+1]-y[i]);
        if(a>=b+c&&((a-(b+c))%2)==0){
            ;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
}

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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int h,w,n; cin >> h >> w >> n;
  map<pii,int> mp; // (x,y)を左上とする正方形が何回出るか

  rep(k,n){
    int a,b; cin >> a >> b;

    rep(i,3) rep(j,3){
      int x = a - i, y = b - j; // 影響のある正方形が
      if(1 <= x and x <= h - 2 and 1 <= y and y <= w - 2){ // はみ出ていないなら
	mp[pii(x,y)]++;
      }
    }
  }

  vi ans(9);
  for(auto x : mp){
    //cout << x.fst.fst << " " << x.fst.snd << " " << x.snd << endl;
    ans[x.snd-1]++;
  }

  cout << (ll)(h - 2) * (w - 2) - SUM(ans) << endl;
  rep(i,9) cout << ans[i] << endl;
}

Measured memory_bytes: 56448
w, h, n = map(int, input().split())

list = [0, w, 0, h]

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and list[0] <= x:
        list[0] = x
    elif a == 2 and list[1] >= x:
        list[1] = x
    elif a == 3 and list[2] <= y:
        list[2] = y
    elif a == 4 and list[3] >= y:
        list[3] = y
    else:
        pass

if list[0] > list[1] or list[2] > list[3]:
    print(0)
else:
    print((list[0] - list[1]) * (list[2] - list[3]))

Measured memory_bytes: 9120
#include <stdio.h>
int main()
{
	int x[10];
	int i,j;
	int tmp;
	
	for(i=0;i<10;i++)
		scanf("%d",&x[i]);
	for(i=0;i<10;i++){
		for(j=i;j<10;j++){
			if(x[i] < x[j]){
				tmp = x[i];
				x[i] = x[j];
				x[j] = tmp;
			}
		}
	}
	
	for(i=0;i<3;i++)
		printf("%d\n",x[i]);
	
	return 0;
}

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

int main(){
	int N, Y;
	cin >> N >> Y;
	for(int x = 0; x <= N; x++){
		for(int y = 0; y <= N-x; y++){
			if(10*x + 5*y + N-x-y == Y/1000){
				cout << x << " "<< y << " " << N-x-y << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll f[33][MAX];

int main(void) {
  ll i, j, k, l;
  
  ll N;
  cin >> N;
  ll C;
  cin >> C;
  
  for(i=0; i<N; i++) {
    ll s, t, c;
    cin >> s >> t >> c;
    t++; c--;
    f[c][s]++;
    f[c][t]--;
  }
  
  for(i=0; i<C; i++) {
    for(j=1; j<MAX; j++) f[i][j]+=f[i][j-1];
    for(j=1; j<MAX; j++) if(f[i][j]>=2) f[i][j]=1;
  }
  
  ll ans=0;
  for(j=1; j<MAX; j++) {
    ll t=0;
    for(i=0; i<C; i++) t+=f[i][j];
    chmax(ans, t);
  }
  
  pt(ans);
  
}




Measured memory_bytes: 24832
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	char bw[10], *pt;
	int board[3][3], i, j, k, m, sum[9],f;
	while (~fscanf(stdin, "%s", bw)!=NULL) {
		getchar();
		pt = bw;
		j = m = k = 0;
		memset(board, '\0', sizeof(board));
		while (*pt) {
			if (*pt == 'o') board[j / 3][k++ % 3] = 1;
			else if (*pt == 'x') board[j / 3][k++ % 3] = -1;
			else board[j / 3][k++] = 0;
			pt++;
			j++;
		}
		for (k = 0, i = 0; k < 3; k++, i += 2) {
			sum[i] = board[k][0] + board[k][1] + board[k][2];
			sum[i + 1] = board[0][k] + board[1][k] + board[2][k];
		}
		sum[i]=board[1][1] + board[0][0] + board[2][2];
		sum[i+1]=board[1][1] + board[0][2] + board[2][0];
		f = 0;
		for (i = 0; i < 9; i++) {
			if (sum[i] == 3) { f = 1; break; }
			else if (sum[i] == -3) { f = 2; break; }
		}
		P(c, f == 1 ? 'o' : f == 2 ? 'x' : 'd');

	}
	return 0;
}

Measured memory_bytes: 548
def getTriangleArea(x1, y1, x2, y2, x3, y3): # returns the area of triangle determined by provided 3 points
  ux = x2-x1
  uy = y2-y1
  vx = x3-x1
  vy = y3-y1
  return abs(ux*vy-vx*uy)/2

inputs=[]
while True:
  try:
    inputs.append(list(map(float,input().split())))
  except EOFError:
    break

for i in inputs:
  x1, y1, x2, y2, x3, y3, xp, yp = i
  if getTriangleArea(x1, y1, x2, y2, x3, y3)==getTriangleArea(x1, y1, x2, y2, xp, yp)+getTriangleArea(x2, y2, x3, y3, xp, yp)+getTriangleArea(x3, y3, x1, y1, xp, yp):
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 7440
/////////////////////////////////////////////template 1
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define ll long long

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

    int a, b;
    cin >> a >> b;
    int sol = ceil(a / 0.08);
    if (floor(sol * 0.08) == a && floor(sol * 0.1) == b)
        cout << sol << endl;
    else
    {
        sol = ceil(b / 0.1);
        if (floor(sol * 0.08) == a && floor(sol * 0.1) == b)
            cout << sol << endl;
        else
            cout << -1 << endl;
    }

    return 0;
}

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

using namespace std;

pair<double, int> a[10001];

int main(){
    int n;
    scanf("%d", &n);
    int T, A;
    scanf("%d%d", &T, &A);
    for(int i = 1; i <= n; i++){
        scanf("%lf", &a[i].first);
        a[i].first = T - a[i].first * 0.006;
        a[i].first = fabs(a[i].first - A);
        a[i].second = i;
    }
    sort(a + 1, a + n + 1);
    printf("%d\n", a[1].second);
    return 0;
}


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

using namespace std;

bool solve(){
    int n;
    cin>>n;
    if(n==0)return false;
    int tx=10,ty=10;
    vector<pair<int,int>> g(n);
    for (int i = 0; i < n; ++i) {
        int a,b;
        cin>>a>>b;
        g[i]=make_pair(a,b);
    }
    int m;
    cin>>m;
    vector<bool> totta(n,false);
    for (int i = 0; i < m; ++i) {
        char c;
        cin>>c;
        int d;
        cin>>d;
        for (int k = 0; k < d; ++k) {
            if(c=='N'){
                ty++;
            }
            else if(c=='E'){
                tx++;
            }
            else if(c=='S'){
                ty--;
            }
            else if(c=='W'){
                tx--;
            }
            else{
                return false;
            }
            for (int j = 0; j < n; ++j) {
                if(g[j].first==tx&&g[j].second==ty)totta[j]=true;
            }
        }
    }
    for(auto i:totta){
        if(!i){
            cout<<"No"<<endl;
            return true;
        }
    }
    cout<<"Yes"<<endl;
    return true;
}

int main(){
    while(solve());
    return 0;
}


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

const long long F = (2e5) * (1e9);

int main()
{
    long long n;
	cin >> n;
	long long* a = new long long[n];
	long long* sum = new long long[n];
    cin >> a[0];
    sum[0] = a[0];
    long long tot = a[0];
    for(int i = 1;i < n;i++)
    {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
        tot += a[i];
    }
    long long Min = F;
    for(int i = 0;i < n - 1;i++)
    {
        if(Min > abs(2 * sum[i] - tot))
            Min = abs(2 * sum[i] - tot);
    }
    cout << Min << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
#define ll long long 
#define N 1000000007
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    ll ans = 0;
    
    rep(i, 0, 60) {
        ll x = 0;
        rep(j, 0, n) {
            if(a[j] >> i&1) x++;
        }
        ll now = x*(n-x)%N;
        rep(j, 0, i) {
            now = now*2%N;
        }
        ans += now;
        ans %= N;
    }

    cout << ans << endl;

}

Measured memory_bytes: 2560
def ncr(n, r):
    r = min(n - r, r)
    up = 1
    down = 1
    for i in range(r):
        up *= (n - i)
        down *= (i + 1)
    return up // down


def seq(x):
    s = 0
    for i in range(1, x):
        j = i * 2
        if j > x:
            break
        s += ncr(x, j)
    return s


def ins(total, p):
    s = 0
    for i in range(p + 1):
        s += ncr(p, i) * ncr(total - p, i)
    return s

ans = []
N = int(input())
k = 1

for i in range(41, 0, -1):
    x = seq(i)
    if N >= x:
        for j in range(i):
            ans.append(k)
        N -= x
        k += 1
        break

size = len(ans)
s = size // 2
while N > 90:
    m = 0
    t = 0
    for i in range(s + 1):
        tmp = ins(size, i)
        if tmp > N:
            break
        if tmp > t:
            t = tmp
            m = i
    N -= t
    ans.insert(m, k)
    ans.append(k)
    k += 1

while N > 0:
    for i in range(41, 0, -1):
        x = seq(i)
        if N >= x:
            for j in range(i):
                ans.append(k)
            N -= x
            k += 1
            break
print(len(ans))
print(" ".join([str(x) for x in ans]))


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

int r,s,p;

ll point(char c){ 
  if( c == 'r'){ return p;}
  else if( c == 's'){ return r;}
  else{ return s;}
  
}


int main(){ 
  
  int n,k; cin >> n >> k;
  cin >> r >> s >> p;
  string T; cin >> T;
  
  vector<bool> used(n,false);
  
  ll ans = 0;
  
  for(int i = 0; i < n; i++){ 
    // iを起点にK個ずつの部分列を調べていく
    if(used[i] ){ continue;}
    
    string res = "";
    
    for(int j = i; j < n; j += k){
      if(used[j]){ continue;}
      used[j] = true;
     res += T[j];
    }
    
    
    int m = (int)res.size();
    
    int head = 0;
    int tail = 0;
    
    while( head < m  && tail < m){ 
      
      if( res[head] != res[tail]){  ans += point(res[head]);  tail++; head++; continue;}
      
      while( tail < m && res[head] == res[tail] ){ tail++;}
     
      ans += ((tail-head+1)/2)*point(res[head]);
      
      head = tail;
      
    }
    
  
    
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 640
//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright © 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
typedef long long int  bigint ;
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;
 
using namespace std;

int main(){
    FAST() ;
    int N ; cin >> N ;
    bigint sum = 0 ; bigint arr[N] ;
    bigint minus = INT_MAX ;
    for( int i = 0 ; i < N ; i++ ){
        cin >> arr[i] ;
        sum += arr[i] ;
        if( arr[i] % 10 != 0 ){
            minus = min( minus , arr[i] ) ;
        }
    }
    if( sum % 10 != 0 ){
        cout << sum << endl ;
    }
    else if( minus == INT_MAX ){
        cout << 0 << endl ;
    }
    else
        cout << sum - minus << endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;
    if(A==B)
        cout<<"Draw";
    else if(A==1)
        cout<<"Alice";
    else if(B==1)
        cout<<"Bob";
    else if(A>B)
        cout<<"Alice";
    else
        cout<<"Bob";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double xa, ya, xb, yb, xc, yc, xd, yd;
	double ta, tb, tc, td;
	
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF){
		
		ta = (xb - xd) * (ya - yb) + (yb - yd) * (xb - xa);
		tb = (xb - xd) * (yc - yb) + (yb - yd) * (xb - xc);
		tc = (xa - xc) * (yb - ya) + (ya - yc) * (xa - xb);
		td = (xa - xc) * (yd - ya) + (ya - yc) * (xa - xd);
		
		if (ta * tb < 0 && tc * td < 0) printf("YES\n");
		
		else printf("NO\n");
	}
	
	return (0);
}

Measured memory_bytes: 608
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
void err() {
  cout << "No" << endl;
  exit(0);
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  a--;
  b--;
  c--;
  d--;
  string s;
  cin >> s;
  for (int i = a; i + 1 <= c; i++) {
    if (s[i] == '#' && s[i + 1] == '#') {
      err();
    }
  }
  for (int i = b; i + 1 <= d; i++) {
    if (s[i] == '#' && s[i + 1] == '#') {
      err();
    }
  }
  if (c < d) {
    cout << "Yes" << endl;
    return 0;
  }
  int cnt = 0;
  for (int i = b - 1; i <= d + 1; i++) {
    if (s[i] == '.') cnt++;
    if (s[i] == '#') cnt = 0;
    if (cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

int main()
{
    string S;
    getline(cin,S);
    int count=0;
    if(S.find("R",0)<3)
    {
        int count=1;
        int n=S.length();
        for(int i=0; i<n; i++)
        {
            if(S[i]=='R')
            {
                if( i<n)
                {

                    if(S[i]==S[i+1])
                    {
                        count++;
                    }
                }
            }
        }
        cout<<count;

    }
    else
    {
        cout<<count;
    }

    return 0;
}


Measured memory_bytes: 3604
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	ll n; cin >> n;
	ll x , m; cin >> x >> m;
	ll co[m] = {};
	ll now = 1, here = x;
	ll rot, st;
	while(1){
		if(co[here] !=0){
			rot = now - co[here];
			st = co[here];
			break;
		}
		co[here] = now;
		now ++;
		here = (here*here)%m;
	}
	ll rop;
	ll rest;
	if(st + rot < n){
		rop = (n - st + 1) / rot;
		rest = st - 1 + (n - st + 1) % rot;
	}
	else{
		rop = 0;
		rest = n;
	}
	now = 1, here = x;
	while(1){
		if(co[here] != now){
			break;
		}
		if(now <= rest) ans += here;
		if(co[here] < st) tmp = 0;
		else tmp += here;
		now ++;
		here = (here*here)%m;
	}
	//cout << rest << " " <<  ans << " " << rop << " " << tmp << endl;
	cout << ans + (ll)rop * (ll)tmp << endl;
}

Measured memory_bytes: 4400
object Main extends App {
  val n = scala.io.StdIn.readLine.toInt
  val v = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val c = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  println((0 until n).map(i => List(v(i) - c(i), 0).max).sum)
}


Measured memory_bytes: 27340
n = int(input())
h = list(map(int, input().split()))

ans = 0
while True:
    zf = True
    zc = 0

    for i, v in enumerate(h):
        if v <= 0:
            zf = True
            zc = zc + 1
        elif v > 0 and zf:
            ans = ans + 1
            zf = False

        h[i] = h[i] - 1

    if zc == len(h):
        break

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

#define INF  -10000000000

int main()
{
    int n,k;
    string s;
    vector<pair<int,int>> p;
    
    cin >> n >> k;
    cin >> s;
    
    int st,en;
    int m = 0;
    for (int i = 0;i < n;i++){
        if (i == 0){
            if (s[i] == '0'){
                st = 0;
                m = 1;
            }
        }
        if (i >= 1 && s[i-1] == '1' && s[i] == '0'){
            st = i;
            m = 1;
        }
        if (i >= 1 && s[i-1] == '0' && s[i] == '1'){
            en = i-1;
            p.push_back(make_pair(st,en));
            m = 0;
        }
    }
    if (m == 1){
        p.push_back(make_pair(st,n-1));
    }
    
    if (p.size() <= k){
        cout << n << endl;
    }
    else {
        int ans = -1;
        int res;
        for (auto i = 0;i <= p.size()-k;i++){
            if (i == 0){
                res = p[k+i].first;
            }
            else if (i == p.size()-k){
                res = n-p[i-1].second-1;
            }
            else {
                res = p[k+i].first-p[i-1].second-1;
            }
            ans = max(ans,res);
        }
        cout << ans << endl;
    }
    
}


Measured memory_bytes: 1020
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
    int n,m,d;
    cin>>n>>m>>d;
    double ret = d!=0? (ll)(n-d)*(m-1)*2.0/((ll)n*n):1.0*(m-1)/n;
    printf("%.7f\n",ret);
	return 0;
}



Measured memory_bytes: 256
package main

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

func rectangle(a, b int) (int, int) {
	return a * b, (a + b) * 2
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	a := nextInt(scanner)
	b := nextInt(scanner)
	fmt.Println(rectangle(a, b))
}



Measured memory_bytes: 1088