akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    double T,X;cin>>T>>X;
    cout<<setprecision(10)<<T/X<<endl;
}


Measured memory_bytes: 3716
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


//変数
int N, K;
vector<ll> x;






//サブ関数
//入力
void input()
{
	cin >> N >> K;
	REP(i, N) {
		ll a;
		cin >> a;
		x.push_back(a);
	}
}


//計算
void calc()
{
	ll res = INFL;

	int center = N;
	REP(i, N) {
		if (x[i] >= 0) {
			center = i;
			break;
		}
	}

	if (center != N && x[center] == 0) {
		K--;
		x.erase(x.begin() + center);
		N--;
	}

	REP(i, K+1) {
		if (center - i < 0)continue;
		if (N <= center + K - i - 1)continue;

		ll l = (i == 0 ? 0ll : -x[center - i]);;
		ll r = (i == K ? 0ll : x[center + K - i - 1]);

		ll tmp = min(l, r) * 2ll + max(l, r);
		res = min(res, tmp);
	}
	cout << res << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


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

int main()
{
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if (e-a<=k){
    cout<< "Yay! "<<endl;
  }else{
    cout<<":("<<endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define ci(n,a)   ll a[n]; rep(i,(n)) cin>>a[i];
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define mp(a,b)   make_pair(a,b)
#define yn(a)     cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

map<ll,ll> t;

ll q(ll z){
    if(z==1){t[1]++;return 1;}
    if(z==2){t[1]++;t[2]++;return 3;}
    if(z==3)return 0;
    if(z==4){t[4]++;return 4;}
    if(z<=0)return 0;
    ll ans,i;
    for(i=1;i<=10000000000000;i*=2){
        if(z<i*2)break;
    }
    ans=((z-i+1)%2)*i;
    t[i]+=(z-i+1)%2;
    z-=i;
    
    ans+=q(z);
    return ans;
}




int main(int argc,char* argv[]) 
{
    ll a,b,ans=0;
    cin>>a>>b;
    ll x=q(b),y=q(a-1);
    for(auto s:t) ans+=s.first*(s.second%2);
    cout<<ans<<endl;
  //cin>>a;cout<<q(a)<<endl;
    return 0;
}


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

int main(){
	int A, B, K;
	cin >> A >> B >> K;
	if(A > B) swap(A, B);
	int cnt = 0;
	for(int i = A; i > 0; i--){
		if(A % i == 0 && B % i == 0) cnt++;
		if(cnt == K){
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
constexpr int DEBUG = 0;
using namespace std;
struct rob {
  int x;
  int l;
  int x_l;
  rob(int _x, int _l) {
    x = _x;
    l = _l;
    x_l = _x - _l;
  }
};
bool comp(const rob &a, const rob &b) {
  return a.x_l > b.x_l;
}
int main() {
  int n;
  cin >> n;
  vector<rob> r;
  for (int i = 0; i < n; i++) {
      int xi, li;
      cin >> xi >> li;
      r.push_back(rob(xi, li));
  }
  sort(r.begin(), r.end(), comp);
  
  if (DEBUG >= 1) {
      for (int i = 0; i < r.size(); i++) {
          cout << r[i].x << " " << r[i].l << " " << r[i].x_l << endl;
      }
  }
  
  int count = 1;
  int border = r[0].x_l;
  for (int i = 1; i < r.size(); i++) {
      if (border < r[i].x + r[i].l)
          continue;
      count++;
      border = r[i].x_l;
  }
  
  cout << count << endl;
  
  return 0;
}

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
	string s;
	cin >> s;
	int n = s.size();
	s64 res = 0;
	int cnt = 0;
	FOR(i,n) {
		if (s[i] == 'B') res += (n-i-1), cnt++;
	}
	cout << (res-((s64)cnt)*(cnt-1)/2) << endl;
    return 0;
}


Measured memory_bytes: 640
s = input()
n = len(s)
if n%2 == 0:
  a = n//2 - 1
  b = n//2
  c = 2
  d = s[a]
  if s[b] != d:
    print(n//2)
    quit()
else:
  a = n//2
  b = n//2
  c = 1
  d = s[a]
while a-1 >= 0 and s[a-1] == d and s[b+1] == d:
  a -= 1
  b += 1
  c += 2
print(n-(n-c)//2)

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

vector<int> adj[200005];
bool vis[200005];
int maxi=0;

int dfs(int u){
    int ans = 0;
    if(!vis[u]){
            ans++;
            vis[u] = true;
            for(auto v: adj[u]){
            ans += dfs(v);
            }
    }
    return ans;
}

void solve(){

    //ifstream myfile;
    //myfile.open("sample.txt");
    int n,m;
    cin >> n >> m;
    memset(vis, false, sizeof(vis));

    int a;
    int b;
    while(m--){
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    for(int i=0;i<n;i++){
        if(!vis[i]){
            maxi=max(maxi,dfs(i));
            }
        }
        cout<<maxi;
    return;
}

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


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


int main (){
    int N, L;
    cin>>N>>L;
    if(L>-1){
        cout<<(L+N+L)*(N-1)/2<<endl;
    }
    else if(L+N-1<1){
        cout<<(L+L+N-2)*(N-1)/2<<endl;
    }
    else {
        cout<<(L+L+N-1)*N/2<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll n,p,q,C[500001],ans=0,temp=0;
    cin>>n>>p>>q;
    rep(i,n) cin>>C[i],ans+=C[i];
    vec A;
    rep(i,n) A.push_back(p*q-C[i]),q--;
    sort(all(A),greater<int>());
    temp=ans;
    rep(i,n) temp=temp+A[i]+2*p*i,ans=max(ans,temp);
    cout<<ans<<"\n";
}


Measured memory_bytes: 10980
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
using namespace std;
#define REP(i,n); for(int i = 0;i < (int)(n);i++)

int main() {
	int n, b;
	cin >> n;
	vector<int> A;
	REP(i,n){
		cin >> b;
		A.push_back(b);
	}
	sort(A.begin(), A.end());

	REP(i, n-1){
		if(A[i] == A[i+1]){
			cout <<"NO";
			return 0;
		}
	}
	cout << "YES";

	return(0);
}


Measured memory_bytes: 1400
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m,v,p=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
# print(A)
B=A[:]
A.append(inf)
for i in range(n-1):
    B[i+1]+=B[i]
i=0
while i < n:
    count=1
    while A[i]==A[i+1]:
        i+=1; count+=1
    K=v-p-(i)
    # print(i,K,ans)
    if i>=n-p:
        ans+=count; i+=1
        continue
    if K<=0:
        if bisect.bisect_right(A,A[i]+m)>=n-p+1:
            ans += count
            i+=1
        else:
            i+=1
    else:
        if A[n-p]>A[i]+m:
            i+=1
        else:
            S=B[n-p]-B[i]
            if (A[i]+m)*(n-p-i)>=S+K*m:
                ans+=count
                i+=1
            else: i+=1
print(ans)

Measured memory_bytes: 69360
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iostream>
#include <utility>
 
using namespace std;
using ll = long long;
using ld = long double;
using Vl = vector<ll>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
using vs = vector<string>;

#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)

ll N, W;
Vl w(N), v(N);
ll dp[101][100001]; //0

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> N >> W;
    w.resize(N);
    v.resize(N);
    ll maxValue = 0;
    REP(i,N){
        cin >> w[i] >> v[i];
        maxValue+=v[i];
    }


    REP(i,N) REP(vi,maxValue+1) dp[i][vi] = ll(1e18);//クソ重くしとく
    dp[0][0] = 0;

    REP(i,N) REP(vi,maxValue+1){
        if(vi>=v[i]){ //同価値で軽い人を入れる。
            dp[i+1][vi]=min(dp[i][vi],dp[i][vi-v[i]]+w[i]);
        } else { // 同価値のものが見つからないばやい
            dp[i+1][vi]=dp[i][vi];
        }
    }
    int ans=0; 
    REP(vi,maxValue+1){
        if(dp[N][vi]<=W)ans=vi; //viのときの重さ
    }

    cout << ans;
    
    return 0;
}

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


long long  INF=1000000000000000000;
using namespace std;


int main(){

long long N,H;
cin>>N>>H;

multimap<long long,int>sord;
long long a,b;
for(int i=0;i<N;i++){
cin>>a>>b;
sord.insert(make_pair(-a,1));
sord.insert(make_pair(-b,0));
}

long long ans=0;
auto iter=sord.begin();
while(H>0){
H+=iter->first;
ans++;
if(iter->second==0){
    iter++;
}
else{
    long long t=H/(-iter->first);
    ans+=t;
    H+=iter->first*t;
}

}


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

Measured memory_bytes: 12800
package main
 
import (
  "fmt"
)
 
func main() {
  var A, B string
  fmt.Scan(&A)
  fmt.Scan(&B)
  
  ans := "EQUAL"
  if len(A) > len(B) {
  	ans = "GREATER"
  }
  if len(A) < len(B){
  	ans = "LESS"
  }
  if len(A) == len(B){
    for i := 0; i < len(A); i++ {
      if A[i:i+1] == B[i:i+1] {
        continue;
      }
      if A[i:i+1] > B[i:i+1] {
  		ans = "GREATER"
        break
      }
      if A[i:i+1] < B[i:i+1] {
        ans = "LESS"
        break
      }
    }
  }
  
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1840
n,m,X,Y = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))

m_x = sorted(x,reverse=True)
m_y = sorted(y)

ans = "War"

for i in range(m_x[0]+1,m_y[0]+1):
    if X<i<=Y:
        ans = "No War"


print(ans)


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

int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    int i=1;
    for(i=1;i<1000;i++){
        if(i%2){
            c -= b;
            if(c<=0) break;
        }else{
            a -= d;
            if(a<=0) break;
        }
    }

    if(i%2){
        cout<<"Yes"<<endl;
    }else cout <<"No"<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N,Z,W;
	cin>>N>>Z>>W;
	VI A(N);
	REP(i,N)cin>>A[i];
	if(N==1)cout<<abs(A[0]-W)<<endl;
	else cout<<max(abs(A[N-1]-W),abs(A[N-2]-A[N-1]))<<endl;
	
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split('\n');

  var a = parseInt(input[0].split(' ')[0], 10);
  var b = parseInt(input[0].split(' ')[1], 10);
  var s = input[1];

  var regex = new RegExp(`^[0-9]{${a}}-[0-9]{${b}}$`, 'g');
  var f = s.match(regex);

  console.log(f == null ? 'No' : 'Yes');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
c={
    'S':[1]*13,
    'H':[1]*13,
    'C':[1]*13,
    'D':[1]*13
}
n=int(input())
for i in range(n):
    a,b=input().split()
    c[a][int(b)-1]=0
for i in ['S','H','C','D']:
    for j in range(13):
        if c[i][j]==1:
            print(i,j+1)



Measured memory_bytes: 5596
// #pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second
#define mod 1000000007

using namespace std;

int n, m, v;
ll a[110], b[110];
ll dp[110][100100];        

int main() {    
    // ifstream cin("tst.in");
    // ofstream cout("tst.out");
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i] >> b[i], v += b[i];

    for (int i = 0; i <= n; i++)
        for (int j = 1; j <= v; j++)
            dp[i][j] = 2e9;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= v; j++) 
            if (j - b[i] > 0 && dp[i - 1][j - b[i]] != 2e9)
                dp[i][j] = min(dp[i - 1][j - b[i]] + a[i], dp[i - 1][j]);
            else dp[i][j] = dp[i - 1][j];
        dp[i][b[i]] = min(dp[i][b[i]], a[i]);
    }

    for (int i = v; i > 0; i--)
        if (dp[n][i] <= m)
            return cout << i, 0;

    cout << 0;
    return 0;
}

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

int main(){

    string s;

    cin >> s;
    if(s[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    int count = 0;
    for(int i=2; i< s.length()-1; i++){
        if(s[i] == 'C'){
            count ++;
        }
    }

    if(count != 1){
        cout << "WA" << endl;
        return 0;
    }

    s.erase(s.begin());
    for(int i=0; i<s.length(); i++){
        if((s[i]-'a' > 25 || s[i] - 'a' < 0) && s[i] != 'C'){
            cout << "WA" << endl;
            return 0;
        }
    }

    cout << "AC" << endl;
    return 0;
}

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

#define IOS  ios_base::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed; 
#define fi first
#define mp make_pair
#define se second
#define pb push_back
#define be(x) (x).begin(), (x).end()
#define rbe(x) (x).rbegin(), (x).rend()
#define forn(i, a, n) for(int i = (int)(a); i < (int)(n); i++)   
#define endl "\n"

typedef long long ll;
typedef vector<ll> vl; 
typedef pair<int, int> pii;

int main(){
    IOS;
   
    float n; cin >> n;
    float res = 2*(3.14)*n;
    cout<<res;

    return 0;
}



Measured memory_bytes: 3796
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

// ModInt begin

using ll = long long;
template<ll mod>
struct ModInt {
    ll v;
    ll mod_pow(ll x, ll n) const {
        return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod;
    }
    ModInt(ll a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    ModInt operator+ ( const ModInt& b ) const {
        return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v));
    }
    ModInt operator- () const {
        return ModInt(-v);
    }
    ModInt operator- ( const ModInt& b ) const {
        return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v));
    }
    ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;}
    ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;}
    
    bool operator== ( const ModInt &b ) const {return v == b.v;}
    bool operator!= ( const ModInt &b ) const {return !(*this == b); }
    ModInt& operator+= ( const ModInt &b ) {
        v += b.v;
        if(v >= mod) v -= mod;
        return *this;
    }
    ModInt& operator-= ( const ModInt &b ) {
        v -= b.v;
        if(v < 0) v += mod;
        return *this;
    }
    ModInt& operator*= ( const ModInt &b ) {
        (v *= b.v) %= mod;
        return *this;
    }
    ModInt& operator/= ( const ModInt &b ) {
        (v *= mod_pow(b.v, mod-2)) %= mod;
        return *this;
    }
    ModInt pow(ll x) { return ModInt(mod_pow(v, x)); }
    // operator int() const { return int(v); }
    // operator long long int() const { return v; }
};

template<ll mod>
ostream& operator<< (ostream& out, ModInt<mod> a) {return out << a.v;}
template<ll mod>
istream& operator>> (istream& in, ModInt<mod>& a) {
    in >> a.v;
    return in;
}

// ModInt end

using mint = ModInt<998244353>;

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

    vector<int> A(N);
    for(int i=0; i<N; i++) A[ D[i] ]++;

    if(D[0] != 0 or A[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    mint ans(1);
    int max_val = *max_element(D.begin(), D.end());
    for(int i=1; i<=max_val; i++) {
        if(A[i] == 0) ans = mint(0);
        for(int j=0; j<A[i]; j++) {
            ans *= A[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
N,M=map(int, input().split())
A=list(map(int, input().split()))
import numpy
D=list(numpy.cumsum(A))
C={}
for i in D:
  d=i%M
  if d not in C:
    C[d]=1
  else:
    C[d]+=1
#print(C)

ans=0
for i in C.values():
  ans+=i*(i-1)//2
#余り0はそれ単独でok
if 0 in C:
  ans+=C[0]
print(ans)

Measured memory_bytes: 26280
n = gets.chomp
a = gets.chomp.split.map(&:to_i)

h = a.group_by(&:itself).map{ |key, value| [key, value.count] }.to_h

ans = 0
h.each do |k, v|
  if v >= k
    ans += v - k
  else
    ans += v
  end
end
p ans


Measured memory_bytes: 30852
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 100010
typedef pair<ll,pair<ll,ll> > P;
P t[N];
ll as[N],bs[N];
ll sum,x,y,z,n;
map<ll,ll> mp;
int main(){
  cin>>x>>y>>z;
  n=x+y+z,sum=0;
  lol(i,n){
    ll a,b,c;cin>>a>>b>>c;
    a-=c,b-=c,sum+=c;
    t[i]=make_pair(a-b,make_pair(a,b));
  }
  sort(t,t+n,greater<P>());
  
  ll now=0;
  lol(i,x){now+=t[i].second.first;mp[t[i].second.first]++;}
  as[x-1]=now;
  for(int i=x;i<n-1;i++){
    now+=t[i].second.first;
    mp[t[i].second.first]++;
    now-=mp.begin()->first;
    mp.begin()->second--;
    if(mp.begin()->second==0)mp.erase(mp.begin());
    as[i]=now;
  }
  
  mp.clear();
  now=0;
  reverse(t,t+n);
  lol(i,y){now+=t[i].second.second;mp[t[i].second.second]++;}
  bs[n-y-1]=now;
  for(int i=y;i<n-1;i++){
    now+=t[i].second.second;
    mp[t[i].second.second]++;
    now-=mp.begin()->first;
    mp.begin()->second--;
    if(mp.begin()->second==0)mp.erase(mp.begin());
    bs[n-i-2]=now;
  }
  
  ll ans=0;
  for(int i=x-1;i<=n-y-1;i++){
    ans=max(ans,sum+as[i]+bs[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	string s; cin >> s; //RW 형태가 되어야

	int redcnt = 0;
	for (int i = 0; i < N; i++)
		if (s[i] == 'R') redcnt++;
	
	int ans = 0;
	for (int i = 0; i < redcnt; i++)
		if (s[i] == 'W') ans++;

	cout << ans << '\n';
	return 0;
}

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

int main() {
    int64_t N;
    string c;
    cin >> N >> c;

    //Rの個数について累積和を取る
    vector<int64_t> sum_r(N + 1, 0);
    for (int64_t i = 0; i < N; i++) {
        sum_r[i + 1] = sum_r[i] + (c[i] == 'R');
    }

    int64_t ans = N;
    for (int64_t i = 0; i <= N; i++) {
        //左からi個Rが連続するように最終形を決めたときの回数
        //i個までは累積和
        int64_t left_white = i - sum_r[i];

        //右から持ってこれる数
        int64_t right_red = sum_r[N] - sum_r[i];

        int64_t curr_ans = 0;
        //まず左にできるだけ持っていく
        int64_t carry = min(left_white, right_red);
        curr_ans += carry;
        left_white -= carry;
        right_red -= carry;
        curr_ans += right_red + left_white;

        ans = min(ans, curr_ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 5240
N,K = gets.split.map(&:to_i)
R,S,P = gets.split.map(&:to_i)
T = gets.chomp

W = {"r" => P, "s" => R, "p" => S}
dp = Array.new(N, 1)

ans = N.times.inject(0) do |s, i|
  dp[i] = dp[i - K] + 1 if i >= K && T[i] == T[i - K]
  dp[i].odd? ? s + W[T[i]] : s
end
puts ans

Measured memory_bytes: 2812
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int n, w;
	cin >> n >> w;
	int dp[100001];
	for (int i = 0; i < 100001; i++) dp[i] = 0;
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		int v, w;
		cin >> v >> w;
		for (int j = 100000-w; j >=0; j--) {
			dp[j + w] = max(dp[j + w], dp[j]+v);
		}
	}
/*	for (int i = 0; i < 100001; i++) cout << dp[i] << " ";
	cout << endl;*/
	for (int i = 1; i < 100001; i++) dp[i] = max(dp[i], dp[i - 1]);
	cout << dp[w] << endl;
	return 0;
}

Measured memory_bytes: 3504
(* unihernandez22
 * https://atcoder.jp/contests/abc054/tasks/abc054_b
 * implementation
 * *)

Scanf.scanf "%d %d\n" @@ fun n m ->
    let a = Array.init n @@ fun _ -> Scanf.scanf "%s\n" @@ fun s -> s in
    let b = Array.init m @@ fun _ -> Scanf.scanf "%s\n" @@ fun s -> s in

    let valid = ref true in
    let ans = ref "No\n" in
    for i = 0 to n-m do
        for j = 0 to n-m do
            valid := true;
            for y = 0 to m-1 do
                if not (String.sub a.(i+y) j m = b.(y)) then
                    valid := false;
            done;
            if !valid then
                ans := "Yes\n";
        done;
    done;
    print_string !ans;;



Measured memory_bytes: 4352
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n = inp()
ans = ""
while n:
    n -= 1
    tmp = n % 26
    n //= 26
    ans = chr(97 + tmp) + ans
print(ans)


Measured memory_bytes: 68436
n = int(input())
a = list(map(int , input().split()))
for ai in a:
    if ai == 0:
        print(0)
        exit()
ans = 1
for ai in a:
    if ans <= 10 **18:
        ans *= ai
    else:
        print(-1)
        exit()
if ans <= 10 **18:
    print(ans)
else:
    print(-1)
    exit()

Measured memory_bytes: 84700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
// mp::cpp_int
// mp::cpp_dec_float_100



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll a, b, n;
  cin >> a >> b >> n;
  
  ll x = min(n, b-1);
  
  cout << (ll)(floor(a*x/b)-a*floor(x/b)) << "\n";
}

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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
const int mod = 1000000007;
const int bits = 60;

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

    int n; cin >> n;

    int64 x = 0;
    vector<int64> val(n);

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

    vector<int> order(bits);
    iota(order.begin(), order.end(), 0);

    sort(order.begin(), order.end(), [&](int u, int v){
        int bu = x >> u & 1;
        int bv = x >> v & 1;
        if (bu != bv)
            return bu < bv;
        return u > v;
    });

    vector<int64> gauss(bits);

    for (auto v : val) {
        for (auto b : order){
            if (v >> b & 1){
                if (gauss[b]){
                    v ^= gauss[b];
                } else {
                    gauss[b] = v;
                    break;
                }
            }
        }
    }

    int64 y = 0;

    for (auto b : order) {
        if (y >> b & 1)
            continue;

        if (gauss[b])
            y ^= gauss[b];
    }

    cout << (y + (y ^ x)) << endl;

    return 0;
}

Measured memory_bytes: 1024
//A - Don't be late
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

#define LL long long
#define Lowbit(X) (X&(-X))
#define Lson (X<<1)
#define Rson (X<<1|1)
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(LL i=A;i<=B;i++)
#define BOR(i,A,B) for(LL i=A;i>=B;i--)
#define FOR_SIDE(i,A) for(LL i=Head[A];i;i=Next[i])
#define INF 0x7fffffff
using namespace std;

int T,D,S; 

inline void File() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}

int main() {
    //File();
	scanf("%d %d %d",&D,&T,&S);
    if(D<=S*T) printf("Yes\n");
    else cout<<"No"<<endl;
	//fclose(stdin); fclose(stdout);
   // system("pause");
    return 0;
}


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

signed main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) return 0;
    auto sum = 0;
    for (int i = 2;; i++) {
      auto base = i * (i + 1) / 2;
      if (base > n) break;
      if ((base - n) % i == 0) sum++;
    }
    cout << sum << "\n";
  }
}

Measured memory_bytes: 3076
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
 
        scan.close();
      
      if((a+b)%2 == 0){
        System.out.println(""+(a+b)/2);
      }else{
        System.out.println("IMPOSSIBLE");
      }
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
vector<mint> sum(200010);
int main(){
    int n;cin >> n;
    vl c(n);
    rep(i,n) cin >> c[i];
    mint dp=1;
    rep(i,n){
        int x=c[i];
        if(i!=0&&c[i]==c[i-1]) continue;
        sum[x]+=dp;
        dp=sum[x];
    }
    cout << dp.x << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
typedef long long ll;

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

  int n; cin >> n;
  vector<int> backet(100010);
  int a;
  rep(i, n) {
    cin >> a;
    backet[a]++;
  }

  int ans = -1;
  for(int i = 1; i < backet.size()-1; i++) {
    int tmp = 0;
    if(backet[i-1] != 0) tmp += backet[i-1];
    if(backet[i]   != 0) tmp += backet[i];
    if(backet[i+1] != 0) tmp += backet[i+1];

    ans = max(ans, tmp);
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
const lli MAX=1e9+7;
 
int main()
{
    fast;
    int n;
    cin>>n;
    if(n%2==0 || n%5==0) cout<<-1<<"\n";
    else{
        lli num=7%n;
        int cnt=1;
        while(num!=0){
           num*=10;
           num+=7;
           num%=n;
           //cout<<num<<" "<<cnt<<"\n";
           cnt++;
        }
        cout<<cnt<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
 
using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
	llin(n);
	vllin3(a,b,c,n);
	vll am(n);
	vll bm(n);
	vll cm(n);
	am[0]=a[0];
	bm[0]=b[0];
	cm[0]=c[0];
	FOR(i,1,n-1){
		am[i]=max(bm[i-1],cm[i-1])+a[i];
		bm[i]=max(am[i-1],cm[i-1])+b[i];
		cm[i]=max(am[i-1],bm[i-1])+c[i];
	}
	sal(max(max(am[n-1],bm[n-1]),cm[n-1]));
}


Measured memory_bytes: 4992
n = int(input())
ans = [0 for _ in range(10001)]
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            v = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if v < 10001:
                ans[v] += 1

for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 74396
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;





int main(){
    ll n;
    cin>>n;
    vector<ll> a;
    for(int i=0;i<3*n;i++){
        ll b;
        cin>>b;
        a.push_back(b);
    }
    vector<ll> front,back;
    priority_queue<ll,vector<ll>,greater<ll>> f;
    priority_queue<ll> b;
    ll sum=0;
    for(ll i=0;i<n;i++){
        f.push(a[i]);
        sum+=a[i];
    }
    front.push_back(sum);
    for(ll i=n;i<2*n;i++){
        sum+=a[i];
        f.push(a[i]);
        sum-=f.top();
        f.pop();
        front.push_back(sum);
    }
    sum=0;
    for(ll i=3*n-1;i>=2*n;i--){
        b.push(a[i]);
        sum+=a[i];
    }
    back.push_back(sum);
    for(ll i=2*n-1;i>=n;i--){
        sum+=a[i];
        b.push(a[i]);
        sum-=b.top();
        b.pop();
        back.push_back(sum);
    }
    reverse(back.begin(),back.end());
    ll ans=-E;
    for(int i=0;i<back.size();i++){
        ans=max(ans,front[i]-back[i]);
    }
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 8428
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  auto T = vector<int>(N);
  auto A = vector<int>(N);
  REP(i, N) cin >> T[i];
  REP(i, N) cin >> A[i];

  auto err = []() {
    cout << 0 << endl;
    exit(0);
  };

  ll ans = 1;
  REP(i, N) {
    int tfix = -1;
    int afix = -1;
    if(i == 0 || T[i - 1] < T[i]) {
      tfix = T[i];
    }
    if(i == N - 1 || A[i] > A[i + 1]) {
      afix = A[i];
    }
    dump(i, afix, tfix, A[i], T[i]);
    if(afix != tfix && afix != -1 && tfix != -1) {
      err();
    } else if(afix != -1 && tfix == -1 && T[i] < afix) {
      err();
    } else if(tfix != -1 && afix == -1 && A[i] < tfix) {
      err();
    } else if(tfix == -1 && afix == -1) {
      ll num = min(A[i], T[i]);
      ans = ans * num % MOD;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
package main

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

// 行列の積
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	nml := strings.Split(sc.Text(), " ")
	n, _ := strconv.Atoi(nml[0])
	m, _ := strconv.Atoi(nml[1])
	l, _ := strconv.Atoi(nml[2])
	A := make([][]string, n)
	B := make([][]string, m)
	for i := 0; i < n; i++ {
		sc.Scan()
		A[i] = make([]string, m)
		for j, v := range strings.Split(sc.Text(), " ") {
			A[i][j] = v
		}
	}
	for i := 0; i < m; i++ {
		sc.Scan()
		B[i] = make([]string, l)
		for j, v := range strings.Split(sc.Text(), " ") {
			B[i][j] = v
		}
	}

	C := make([][]int64, n)
	for i := 0; i < n; i++ {
		C[i] = make([]int64, l)
		for j := 0; j < l; j++ {
			for k := 0; k < m; k++ {
				v1 := parseInt64(A[i][k])
				v2 := parseInt64(B[k][j])
				C[i][j] += v1 * v2
			}
		}
	}

	for _, x := range C {
		fmt.Printf("%v\n", strings.Trim(fmt.Sprint(x), "[]"))
	}
}

func parseInt64(s string) int64 {
	v, _ := strconv.ParseInt(s, 10, 64)
	return v
}



Measured memory_bytes: 2348
#include <iostream>

int main()
{
  int n;
  std::cin >> n;
  int h[n];
  for ( int i = 0; i < n; i++ ) std::cin >> h[i];
  int ans = 0;

  while (true) {
    bool all_zero = true;
    for ( int i = 0; i < n; i++ ) {
      if ( h[i] != 0 ) {
        if ( i == n-1 ) {
          ans += h[n-1];
          h[n-1] = 0;
          break;
        }
        int end = i+1;
        for ( int j = i+1; j < n; j++ ) {
          if ( h[j] == 0) {
            end = j;
            break;
          } else if ( j == n-1 ) {
            end = n;
          }
        }
        for ( int k = i; k < end; k++ ) {
          h[k]--;
        }
        all_zero = false;
      }
      if (!all_zero) break;
    }
    if ( all_zero ) break;
    ans++;
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    for (int i = 0; i < h-b; i++) {
        for (int j = 0; j < a; j++) {
            cout << 1;
        }
        for (int j = 0; j < w-a; j++) {
            cout << 0;
        }
        cout << endl;
    }
    for (int i = 0; i < b; i++) {
        for (int j = 0; j < a; j++) {
            cout << 0;
        }
        for (int j = 0; j < w-a; j++) {
            cout << 1;
        }
        cout << endl;
    }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){cout << "Yes" << endl;}
inline void No(){cout << "No" << endl;}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){cout << "YES" << endl;}
inline void NO(){cout << "NO" << endl;}
inline void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

vector<vector<int>> a;
int n, m;
int rec(set<int> &nbheld){
    vector<int> cnt(m+1, 0);
    rep(i, n){
        rep(j, m){
            if(nbheld.find(a[i][j]) == nbheld.end()){
                cnt[a[i][j]]++;
                break;
            }
        }
    }
    auto mx = max_element(cnt.begin(), cnt.end());
    if(*mx == 0) return INF;
    nbheld.insert((mx-cnt.begin()));
    return min(*mx, rec(nbheld));
}

int main(){
    
    scanf("%d%d", &n, &m);  
    a.resize(n, vector<int>(m));
    rep(i, n) rep(j, m) scanf("%d", &a[i][j]);

    set<int> nbheld;
    ppp(rec(nbheld)); 
    
    
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n;

int main() {
    cin >> n;
    int d = n % 1000;
    if (d == 0)
        cout << 0 << endl;
    else
        cout << 1000 - d << endl;
    return 0;
}


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

int main(){
  int n,m,ans[100]={},t;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    for(int j=0;j<2;j++){
      cin>>t;
      ans[t]++;
    }
  }
  for(int i=1;i<=n;i++){
    if(0<=ans[i]) cout<<ans[i]<<endl;
  }
}


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


int dfs(int,int,int,int);
int N;
int l[8];
int A, B, C;
int INF = 10000000;

int main(){

	cin >> N >> A >> B >> C;
	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}
	
	cout << dfs(0, 0, 0, 0) << endl;

	return 0;
}



int dfs(int i,int a,int b,int c) {

	//cout << "i:" << i << ",a:" << a << ",b:" << b << ",c:" << c << endl;

	if (i == N) {
		if (min(a, min(b,c)) > 0) {
			return abs(A - a) + abs(B - b) + abs(C - c) - 30;
		}
		else {
			return INF;
		}
	}
	
	
	int a1,a2,a3,a4;
	a1 = dfs(i + 1, a, b, c);
	a2 = dfs(i + 1, a + l[i], b, c) + 10;
	a3 = dfs(i + 1, a, b + l[i], c) + 10;
	a4 = dfs(i + 1, a, b, c + l[i]) + 10;


	return min(min(a1, a2), min(a3,a4));

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

long long int X, Y;

int main() {
    scanf("%lld%lld", &X, &Y);

    int ans = 0;
    while(X <= Y) {
        ans++;
        X *= 2;
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main() {

	int a; cin >> a;
	int b; cin >> b;
	int z = b - a;

	long h = 0;
	for (int i = 1; i <= z ; ++i){
		h += i;
	}

	cout << h - b;

}


Measured memory_bytes: 256
K,A,B = map(int,input().split())
if B - A <= 2 or K <= A:
    print(K+1)
    exit()
K -= A+1
ans = B
if K % 2 == 1:
    ans += 1
    K -= 1
ans += (B-A)*(K//2)
print(ans)

Measured memory_bytes: 3060
N,M = map(int,input().split())
S = input()[::-1]
ans = []
cur = 0
while cur < N:
    for i in range(1,min(M+1,N-cur+1))[::-1]:
        if S[cur+i] == '0':
            ans.append(i)
            cur += i
            break
    else:
        print(-1)
        exit()
print(*ans[::-1])

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


int main() {
    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <set>
#include <utility>
#include <map>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;


int main() {
    int N, M; cin >> N >> M;
    vector<int> D;
    
    for(int i=1; i<=(int)sqrt(M); i++){
        if(M%i == 0){
            D.push_back(i);
            D.push_back(M/i);
        }
    }
    
    int ans = 0;
    for(int d:D)
        if(d<=M/N) ans = max(ans, d);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int r=0,w=0;
  for(int i=0;i<n;i++)if(s.at(i)=='R')r++;
  int ans=max(r,w);
  for(int i=0;i<n;i++){
    if(s.at(i)=='R')r--;
    else w++;
    int now=max(r,w);
    ans=min(ans,now);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j;
    long long int sum=0;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        if(i%3==0 || i%5==0||i%15==0 )
        {
            continue;

        }
        sum=sum+i;
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 3624