akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    std::vector<int> v((n+2));
    for (int i = 0; i < n; i++) {
        cin>>v[i];
    }
    set<int>set1;
    map<int, int>mp1,mp2;
    for (int i = 0; i < n; i++) {
        int diff = i-v[i];
        //dump(diff);
        set1.insert(diff);        
         mp1[diff]++;
    }
    ll int cnt = 0;
    for (int i = 0; i < n; i++) {
        int sum = (i+v[i]);
        //dump(sum);
        if(set1.count(sum)){
            mp2[sum]++;
            //cnt++;
        }
    }
    for(auto it : mp1){
        cnt +=((ll)it.second * mp2[it.first]);
    }
    cout<<cnt<<"\n";
    return 0;
}


Measured memory_bytes: 29920
def count_2(n):
	d = 2
	c = 1
	while d <= n:
		d *= 2
		c += 1
	
	prev_count = 0
	total_count = 0
	
	while d >= 2:
		count = n // d
#		print(">", d, count, c)
		total_count += (count - prev_count) * c
		prev_count = count
		d //= 2
		c -= 1
	
	return total_count


def count_5(n):
	d = 5
	c = 1
	while d <= n:
		d *= 5
		c += 1
	
	prev_count = 0
	total_count = 0
	
	while d >= 5:
		count = n // d
#		print(">", d, count, c)
		total_count += (count // 2 - prev_count // 2) * c
		prev_count = count
		d //= 5
		c -= 1
	
	return total_count

def count_0(n):
	if n % 2 == 0:
		count2 = count_2(n)
		count5 = count_5(n)
		return min(count2, count5)
	else:
		return 0
print(count_0(int(input())))


Measured memory_bytes: 3064
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    m,d = LI()
    ans = 0
    for i in range(1,m+1):
        for j in range(1,d+1):
            d1 = j%10
            d2 = j//10
            if d1 >= 2 and d2 >= 2 and d1*d2 == i:
                ans += 1
    print(ans)
    return

#B
def B():
    def add(i):
        while i <= m:
            bit[i] += 1
            i += i&-i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res

    n,k = LI()
    m = 2000
    a = LI()
    bit = [0]*(m+1)
    ans = 0
    for i in range(n):
        ans += (i-sum(a[i]))*k
        add(a[i])
    inv = pow(2,mod-2,mod)
    for i in range(n):
        ans += sum(a[i]-1)*k*(k-1)*inv%mod
    print(ans%mod)
    return

#C
def C():
    n = I()
    s = S()
    if "W" in (s[0],s[-1]):
        print(0)
        return
    d = [0]
    for i in range(1,2*n):
        if s[i] == s[i-1]:
            d.append(1-d[-1])
        else:
            d.append(d[-1])
    if sum(d) != n:
        print(0)
        return
    ans = 1
    s = 0
    for i in d:
        if not i:
            s += 1
        else:
            ans *= s
            s -= 1
            ans %= mod
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print(ans)
    return

#D
def D():
    n = I()
    m = n.bit_length()
    v = [[0]*n for i in range(n)]
    for i in range(n):
        for j in range(n):
            k = i^j
            for l in range(m):
                if k&(1<<l):
                    v[i][j] = l+1
                    break
    for i in range(n-1):
        print(*v[i][i+1:])
    return

#E
def E():

    return

#F
def F():

    return

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


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

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next());
        Set<Integer> a = new HashSet<>();
        for (int i = 0; i < n; i++) {
            a.add(Integer.parseInt(sc.next()));
        }

        // 主処理
        String result = n == a.size() ? "YES" : "NO";

        // 出力
        System.out.println(result);
        sc.close();
    }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	int N, M; cin >> N >> M;
	VI vertex(N,0);
	FOR(i, 0, M) {
		int a, b; cin >> a >> b;
		a--, b--;
		vertex[a]++;
		vertex[b]++;
	}
	FOR(i, 0, N) {
		cout << vertex[i] << endl;
	}
	

	return 0;
}


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

int main(){
    int N,ans=0;
    int M;
    scanf("%d %d",&N,&M);
    int menu[M+1];
    int i,j,t;
    for(i=1;i<=M;i++) menu[i]=0;
    for(i=0;i<N;i++){
        int K;
        scanf("%d",&K);
        for(j=0;j<K;j++){
            scanf("%d",&t);
            menu[t] += 1;
        }
    }
    for(i=1;i<=M;i++) if(menu[i]==N) ans+=1;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <cstdio>

using namespace std;
using ll = long long;

#define rep(i, n)  for (ll i = 0; i < (n); i++)
#define INF 100000000

ll H, W, K;
vector<string> S;

vector<ll> divs(13, 0);


bool sat(const vector<ll> &whites) {
  ll cnt = 0;

  rep(i, H) { // 切れ目の数なので
    cnt += whites[i];

    if (cnt > K) {
      return false;
    }

    if (divs[i] > 0)  {
      cnt = 0;
    }
  }

  return true;
}

ll check() {
  ll cut = 0;
  bool ate = false;

  vector<ll> whites(10, 0);

  for (ll w = 0; w < W; w++) {
    rep(h, H) {
      if (S[h][w] == '1') {
        whites[h]++;
      }
    }

    if (sat(whites)) {
      ate = true;
    } else { //  unsat
      if (ate == false) {
        return INF; // impossible
      }

//      printf("cut at %lld\n", w);

      // cut and start from last bite
      cut++;
      w -= 1;
      ate = false;

      fill(whites.begin(), whites.end(), 0);
    }
  }
  return cut;
}

// void show() {
//   rep(i, H-1) {
//     printf("%lld ", divs[i]);
//   }
// }

ll search(ll h) {
  if (h >= H - 1) {
    ll c = check();
    ll a = accumulate(divs.begin(), divs.end(), 0LL);

//    show();
//    printf("a = %lld, c = %lld\n", a, c);

    return c + a;
  }

  ll tmp = search(h + 1);
  // make move
  divs[h] = 1;
  ll tmp2 = search(h + 1);
  divs[h] = 0;

  return min(tmp, tmp2);
}


int main() {
  cin >> H >> W >> K;

  rep(i, H) {
    string tmp; cin >> tmp;
    S.push_back(tmp);
  }

  ll result = search(0);

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 888
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
    int  r, g, b, n, ans = 0 ; 
    cin >> r >> g >> b >> n ; 
    for (int i=0;i<=n/r;i++){
        int s=i*r;
        for (int j=0;j<=(n-s)/g;j++){
            int rem = n - (s+j*g);
            if (rem%b==0 ) ans++;
           // cout << i << " " << j << " " << rem/b << endl;
        }
    }
    cout << ans << endl; 
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main()

{
int a,b,c;

cin >> a>>b;

if(a == 1 && b==2)
{
c=3;
}

else if(a == 1 && b==3)
{
c=2;
}

else if(a == 2 && b==1)
{
c=3;
}

else if(a == 2 && b==3)
{
c=1;
}

else if(a == 3 && b==1)
{
c=2;
}

else if(a == 3 && b==2)
{
c=1;
}

cout <<c<< endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	ss := make([]string, 0)
	for i := 0; i < n; i++ {
		s := 0
		for j := i; j < n; j++ {
			s += as[j]
			ss = append(ss, fmt.Sprintf("%050b", s))
		}
	}

	exs := make([]int, len(ss))
	ans := 0
	for i := 0; i < 50; i++ {
		cnt := 0
		for j, s := range ss {
			if exs[j] == 0 && s[i] == '1' {
				cnt++
			}
		}
		if cnt < k {
			continue
		}

		ans += 1 << (50 - i - 1)
		for j, s := range ss {
			if exs[j] == 0 && s[i] == '0' {
				exs[j] = 1
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 58920
import sys
import math
import itertools
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N,T = I()
ans = 10**9
for i in range(N):
    c,t = I()
    if t > T:
        continue
    ans = min(ans,c)
if ans == 10**9:
    ans = 'TLE'
print(ans)

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

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N+1), cnt(N+1, 0);
    rep(i, 1, N+1) cin >> a[i];

    ll M = 0;
    for(ll i = N; i > 0; i--){
        ll al = 0;
        for(ll j = 2*i; j <= N; j += i){
            al += cnt[j];
        }
        if(al % 2 != a[i] % 2){
            cnt[i]++;
            M++;
        }
    }
    cout << M << endl;
    rep(i, 1, N+1){
        if(cnt[i] == 1) cout << i << " ";
    }
    if(M != 0) cout << endl;
    return 0;
}

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

int main(){
    list<int> L;
    
    int n,a;
    string command;
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> command;
        if(command=="insert"){
            cin >> a;
            L.push_front(a);
        }else if(command=="delete"){
            cin >> a;
            for(list<int>::iterator it=L.begin(); it!=L.end(); it++){
                if(*it==a){
                    L.erase(it);
                    break;
                }
            }
        }else if(command=="deleteFirst"){
            L.pop_front();
        }else if(command=="deleteLast"){
            L.pop_back();
        }
    }
    
    int i=0;
    for(list<int>::iterator it=L.begin(); it!=L.end(); it++){
        if(i++) cout <<  ' ';
        cout << *it;
    }
    
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 34312
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define mp make_pair
const ll inf = 1e18;
const int nax = 2e6 + 7;

using namespace std;

int main(int argc,char ** argv){
	dhoom;
	int n , m;
  	cin >> n >> m;
  	cout << (n * (n - 1) + m * (m-1)) /2 << endl;
	return 0;
}


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

int main(){
    int n,m;

    cin>>n>>m;

    int a[n][m];

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int b[m];

    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    
    int c[n];

    for(int i=0;i<n;i++){
        c[i]=0; 
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            c[i]+=a[i][j]*b[j];  
        }
    }
    
    for(int i=0;i<n;i++){
        cout<<c[i]<<endl;
    }

}


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

int main(){
	int n;
	int a[110000];
	cin >> n;
	int cnt = 0;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		if(a[i] % 2 != 0) cnt++;
	}
	if(cnt % 2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}
/*
vvi CON(ll n,ll r) {
  vvi v(n+1,vi(n+1,0));
  rep(i,(ll)v.size()){
    v[i][0]=1;
    v[i][i]=1;
  }
  rep(j,(ll)v.size()){
    rep(k,j){
      v[j][k]=v[j-1][k-1]+v[j-1][k];
    }
  }
  return v;
}
*/
void solve() {
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  REP(i,k,n+2){
    ans=(ans+i*(n-i+1)+1)%mod;
  }
  out(ans);
}

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


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

int p[50];
void init(){rep(i,26) p[i]=i;}
int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
void unite(int a,int b){a=find(a),b=find(b),p[a]=b;}
bool same(int a,int b){return find(a)==find(b);}

int main(){
	string r,a;
	while(cin >> r >> a){
		if(r=="0") break;
		int hit=0,blow=0;
		rep(i,4)rep(j,4) if(r[i]==a[j]) blow++;
		rep(i,4) if(r[i]==a[i]) hit++;
		cout << hit << " " << blow-hit << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
#include<stdio.h>

int main()
{
	printf("1x1=1\n1x2=2\n1x3=3\n1x4=4\n1x5=5\n1x6=6\n1x7=7\n1x8=8\n1x9=9\n");
	printf("2x1=2\n2x2=4\n2x3=6\n2x4=8\n2x5=10\n2x6=12\n2x7=14\n2x8=16\n2x9=18\n");
	printf("3x1=3\n3x2=6\n3x3=9\n3x4=12\n3x5=15\n3x6=18\n3x7=21\n3x8=24\n3x9=27\n");
	printf("4x1=4\n4x2=8\n4x3=12\n4x4=16\n4x5=20\n4x6=24\n4x7=28\n4x8=32\n4x9=36\n");
	printf("5x1=5\n5x2=10\n5x3=15\n5x4=20\n5x5=25\n5x6=30\n5x7=35\n5x8=40\n5x9=45\n");
	printf("6x1=6\n6x2=12\n6x3=18\n6x4=24\n6x5=30\n6x6=36\n6x7=42\n6x8=48\n6x9=54\n");
	printf("7x1=7\n7x2=14\n7x3=21\n7x4=28\n7x5=35\n7x6=42\n7x7=49\n7x8=56\n7x9=63\n");
	printf("8x1=8\n8x2=16\n8x3=24\n8x4=32\n8x5=40\n8x6=48\n8x7=56\n8x8=64\n8x9=72\n");
	printf("9x1=9\n9x2=18\n9x3=27\n9x4=36\n9x5=45\n9x6=54\n9x7=63\n9x8=72\n9x9=81\n");
	
	return 0;
}


Measured memory_bytes: 1864
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

int main() {
    int n;
    cin>>n;
    vector<int> arr(n);

    long long int sum = 0;

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

    long long int ans = 0;

    for(int i=0; i<n; i++) {
        ans = (ans+((arr[i]%MOD)*((sum-arr[i])%MOD))%MOD)%MOD;
        sum = sum-arr[i];
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4032
#include <stdio.h>


int main(){
	int n;
	int a;
	long int min=1000000,max=-1000000;
	long int sum=0;

	scanf("%d",&n);

	for(int i=0;i<n;i++){
		scanf("%d",&a);
		if(min > a){
			min = a;
		}
		if(max < a){
			max = a;
		}
		sum+=a;
	}

	printf("%d %d %ld\n",min,max,sum);
	

	return 0;
}


Measured memory_bytes: 2112
/*
 N/(K + (K-1) + (K-1)…)切り上げ
 (N-1)/(K-1)
 ((N-1)+(K-1)-1)/(K-1)
 */
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    cout << ((N-1)+(K-1)-1)/(K-1) << endl;
}


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

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))




int main(){
    LL N,A,B;
    cin>>N>>A>>B;
    LL res=0;
    LL X2;
    vector<LL>X;
    REP(i,N){
        LL X1;cin>>X1;
        if(i!=0){
            X.PB(X1-X2);
        }
        X2=X1;
    }
    REP(i,N-1){
        res+=min(A*X[i],B);
    }
    cout<<res<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int X1, Y1, X2, Y2, X3, Y3, X4, Y4;
    cin >> X1 >> Y1 >> X2 >> Y2;
    int x = X2 - X1, y = Y2 - Y1;
    int tx, ty;
    int nx = X2, ny = Y2;

    for(int i = 0; i < 2; i++) {
        tx = x;
        ty = y;
        x = -1*ty;
        y = tx;
        nx += x;
        ny += y;
        cout << nx << ' ' << ny;
        if(!i) {
            cout << ' ';
        }
    }
    cout << endl;




    return 0;
}

Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int cumsum[60 * 60 * 24];
int to_sec(string S){
  return stoi(S.substr(0, 2)) * 60 * 60 + stoi(S.substr(3, 2)) * 60 + stoi(S.substr(6,2));
}

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){
      break;
    }

    for(int i = 0; i < 60 * 60 * 24; i++){
      cumsum[i] = 0;
    }

    for(int i = 0; i < n; i++){
      string s1;
      string s2;
      cin >> s1 >> s2;
      cumsum[to_sec(s1)] ++;
      cumsum[to_sec(s2)] --;
    }

    for(int i = 1; i < 60 * 60 * 24; i++){
      cumsum[i] += cumsum[i - 1];
    }

    int ans = 0;
    for(int i = 0; i < 60 * 60 * 24; i++){
      ans = max(ans, cumsum[i]);
    }
    cout << ans << endl;
  }
  return 0;
}



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

int main(){
  string str;
  cin >> str;
  bool flag = false;
  while(1){
    if(str.empty()){
      flag = true;
      break;
    }
    char s = str[0];
    str.erase(0,1);
    int pos = str.find(s);
    if(pos == -1)
      break;
    else
      str.erase(pos, 1);
  }
  
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll c=0;
    rep(i,n){
        ll t;cin>>t;
        if(t%2==1)c++;
    }
    YN(c%2==0);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(), A.end());
    if (A[0] == 5 && A[1] == 5 && A[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    public Program() { }

    Scanner cin;

    void myon()
    {
        cin = new Scanner();

        int n = cin.nextInt();
        string a = cin.next();
        string b = cin.next();

        for (int i = 0; i < n; i++)
        {
            Console.Write($"{a[i]}{b[i]}");
        }
        Console.WriteLine();
    }


    static void Main(string[] args)
    {
        new Program().myon();
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
const ll LINF=4000000000000000010;
ll n;
ll a[100010],s[100010];
ll f[2000010],fi[2000010];
ll mod_pow(ll x,ll n,ll mod){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret=ret*x%mod;
        }
        x=x*x%mod;
        n>>=1;
    }
    return ret;
}

void fact(ll n){
	f[0]=1;
	for(ll i=1;i<=n;i++){
		f[i]=f[i-1]*i%MOD;
	}
	fi[n]=mod_pow(f[n],MOD-2,MOD);
	for(ll i=n-1;i>=0;i--){		
		fi[i]=fi[i+1]*(i+1)%MOD;
	}
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    fact(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        s[i]=f[n]*mod_pow(i+1,MOD-2,MOD);
        s[i]%=MOD;
        sum+=s[i];
        sum%=MOD;
    }
    int id=1;
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=a[i]*sum;
        ans%=MOD;
        sum+=s[id];
        sum+=MOD-s[n-id];
        sum%=MOD;
        id++;
    }
    cout<<ans<<endl;
}	


Measured memory_bytes: 7168
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

vector<pair<int,string> > country(20);
int n;

void mysort(){
	int i,j;
	for(i=0;i<n;i++){
		for(j=0;j<n-1;j++){
			if(country[j].first<country[j+1].first){
				pair<int,string> buf;
				buf=country[j];
				country[j]=country[j+1];
				country[j+1]=buf;
			}
		}
	}
}

int main() {
	bool f=true;
	while(n=in()){
		if(!f){cout<<endl;}f=false;
		int i;
		int win,lose,draw;
		string str;
		for(i=0;i<n;i++){
			cin>>str>>win>>lose>>draw;
			country[i]=mp(win*3+draw,str);
		}
		mysort();
		for(i=0;i<n;i++){
			cout<<country[i].second<<","<<country[i].first<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_076_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 i      PIC 9(2).

    01 board  PIC 9(11) VALUE 1.

    01 N      PIC 9(2).
    01 K      PIC 9(2).

    01 ans    PIC X(11).

    01 ZS     PIC Z(12)9.
    01 DUMMY  PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.
    ACCEPT K.

    PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
        COMPUTE board = FUNCTION MIN (board * 2, board + K)
    END-PERFORM.

    MOVE board TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


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

using namespace std;

int main()
{
    int K, S;
    int X, Y, Z;
    cin >> K >> S;

    int count = 0;
    for (int x = 0; x <= K; x++)
    {
        for (int y = 0; y <= K; y++)
        {
            int z = S - x - y;
            if (z >= 0 && z <= K)
                count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String args[]) {
		Stack<Integer> myStack = new Stack<Integer>();
		
		Scanner in = new Scanner(System.in);
		String problem = in.nextLine();
		
		Scanner problemScanner = new Scanner(problem);
		
		while(problemScanner.hasNext()) {
			if(problemScanner.hasNextInt()) {
				myStack.push(problemScanner.nextInt());
			}
			else {
				String operator = problemScanner.next();
				
				int a = myStack.pop();
				int b = myStack.pop();
				
				switch(operator) {
				case "+" : myStack.push(a + b);
				break;
				case "-" : myStack.push(b - a);
				break;
				case "*" : myStack.push(b * a);
				break;
				default : break;
				}
			}
			
			
		}
		
		System.out.println(myStack.pop());
		
		
		
		
	}

}


Measured memory_bytes: 26816
"""k = int(input())
A = [0] * k

i = 1
r = 0
while r < k:
    if i <= 9:
        A[r] = i
        r = r + 1
    else:
        for j in range(len(str(i)) - 1):
            if not (-1 <= int(str(i)[j]) - int(str(i)[j + 1]) <= 1):
                break
            if j == len(str(i)) - 2:
                A[r] = i
                r = r + 1

    i = i + 1

print(A[k - 1])"""

k = int(input())
A = [1] * k
i = 0
j = 0
treat = [-1, 0, 1]

while i < k:
    if i < 9:
        A[i] = i + 1
        i = i + 1
    else:
        for l in range(3):
            if l == 0 and str(A[j])[-1] == "0":
                continue
            elif l == 2 and str(A[j])[-1] == "9":
                continue
            else:
                A[i] = int(str(A[j]) + str(int(str(A[j])[-1]) + treat[l]))
                i = i + 1

            if i == k:
                break
        j = j + 1

print(A[-1])

Measured memory_bytes: 6900
import math
def factorize(x):
    if x==0 or x==1:
        return set()
    return factorize(x//mind[x])|{mind[x]}

N=int(input())
A=sorted(map(int,input().split()))
m=max(A)
arr=[True]*(m+1)
mind=[i for i in range(m+1)]
arr[0],arr[1]=False,False
for i in range(2,m+1):
    if arr[i]==False:
        continue
    for j in range(2,m+1):
        if i*j>m:
            break
        arr[i*j]=False
        mind[i*j]=min(mind[i*j],i)
isok=True
s=set()
for i in range(N):
    t=factorize(A[i])
    for k in t:
        if k in s:
            isok=False
            break
        s.add(k)
    if not isok:
        break
if isok:
    print('pairwise coprime')
    exit()
T=A[0]
for i in range(1,N):
    T=math.gcd(T,A[i])

if T==1:
    print('setwise coprime')
else:
    print('not coprime')

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

string bfs(queue<string> &q,ll k) {
    ll cou = 0;

    while (!q.empty()) {
        string str = q.front(); q.pop();  // キューの先頭を取り出す
        // cout << "str:" << str << endl;
        if(cou >= k)return str;
        cou+=1;

        // 上下左右 4 方向を探索．進むことができればキューに格納する．
        for (ll i = 0; i <= 9; ++i) {
            if(str == ""){
                if(i == 0)continue;
                string next = "";
                next += (char)('0' + i);
                // cout << "next:" << next << endl;
                q.push(next);
            }else{
                int temp = str[str.size()-1] - '0'; 
                if(0 > temp || temp > 9 || (abs(temp - i) > 1))continue;                
                string next = str + (char)(i + '0');
                // cout << "next:" << next << endl;
                q.push(next);
            }
            
        }
    }
    return "none";
}

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

    ll k;
    cin >> k;

    if(k == 1){
        cout << 1 << endl;
        return 0;
    }

    queue<string> q;
    q.push("");
    string ans = bfs(q,k);

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

Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
string a[300],b[300];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)	cin>>a[i],b[i].resize(n);
	int ans=0;
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				b[i][j]=a[i][(j+k)%n];
		bool ok=true;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				if(b[i][j]!=b[j][i])
					ok=false;
		ans+=ok;
	}
	cout<<ans*n<<endl;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    char s[3];
    cin >> s;
    char f=0;
    for(int i=0;i<3;i++){
        if(s[i]=='7') f=1;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)
int main() { 
  string s;cin >> s;
  s[3] = '8';
  cout << s << endl;
}


Measured memory_bytes: 256
# Import
from collections import deque

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
A, B = read_tupple([int,int])
print(A*B)

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

int Q ;
long long int L , R , DP[65][2] , A[65][2];
void pre(){
    DP[0][0] = DP[0][1] = 1 ;
    for(int i=1;i<=64;i++){
        DP[i][0] = (DP[i-1][0]+DP[i-1][1]) ;
        DP[i][1] = (DP[i-1][0]+DP[i-1][1]) ;
    }
}

void solve(){
    long long sum = 0 ;
    for(int i=63;i>=0;i--){
        A[i][0] += sum ;
        if(L & (1LL << i)){
            A[i][0] += (L - DP[i][0]) ;
            sum += (DP[i][0]/2) ;
            L -= DP[i][0] ;
        }
    }
    R ++ ;
    sum = 0 ;
    for(int i=63;i>=0;i--){
        A[i][1] += sum ;
        if(R & (1LL << i)){
            A[i][1] += (R - DP[i][1]) ;
            sum += (DP[i][1]/2) ;
            R -= DP[i][1] ;
        }
    }
    sum = 0 ;
    for(int i=63;i>=0;i--){
        A[i][1] -= A[i][0] ;
        A[i][1] %= 2 ;
        if(A[i][1])
            sum += (1LL << i) ;
    }
    cout << sum << endl ;
}
int main(){
    pre() ;
  	Q=1;
    while(Q -- ){
        cin >> L >>  R ;
        solve() ;
    }
    return 0 ;
}

Measured memory_bytes: 256
package main
 
import "fmt"
 
var a, b, c, d int
func main() {
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)

	for {
		c -= b
		if c <= 0 {
			fmt.Println("Yes")
			return
		}
		a -= d
		if a <= 0 {
			fmt.Println("No")
			return
		}
	}
}

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

int main() {
	
	int n, m;
	cin >> n;
	map<string, int> s;
	rep(i, n){
		string tmp;
		cin >> tmp;
		if(s.count(tmp)){
			s[tmp]++;
		}else{
			s[tmp] = 1;
		}
	}
	cin >> m;
	map<string, int> t;
	rep(i, m){
		string tmp;
		cin >> tmp;
		if(t.count(tmp)){
			t[tmp]++;
		}else{
			t[tmp] = 1;
		}
	}
	for(auto p: t){
		if(s.count(p.first)){
			s[p.first] -= p.second;
		}
	}
	int ans = 0;
	for(auto p: s){
		if(ans < p.second) ans = p.second;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>

struct Card{
	char a;
	int x;
};

int partition(Card a[], int p, int r){
	int i = p - 1;
	int x = a[r].x;
	for (int j = p; j < r; j++){
		if (a[j].x <= x){
			i++;
			Card tmp = a[i];
			a[i] = a[j];
			a[j] = tmp;
		}
	}
	Card tmp = a[i+1];
	a[i+1] = a[r];
	a[r] = tmp;
	return i+1;
}

void quickSort(Card a[], int p, int r){
	if (p < r){
		int q = partition(a, p, r);
		quickSort(a, p, q-1);
		quickSort(a, q+1, r);
	}
}

void Merge(Card a[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	Card* L = new Card[n1+1];
	Card* R = new Card[n2+1];
	for ( int i = 0; i < n1; i++) L[i] = a[left + i];
	L[n1].x = INT_MAX;
	for (int i = 0; i < n2; i++) R[i] = a[mid + i];
	R[n2].x = INT_MAX;
	int i = 0;
	int j = 0;
	while(i < n1 || j < n2){
		if (L[i].x <= R[j].x){
			a[left + i + j] = L[i];
			i++;
		}
		else{
			a[left + i + j] = R[j];
			j++;
		}
	}
}

void MergeSort(Card a[], int left, int right){
	if (left + 1 < right){
		int mid = (left + right) / 2;
		MergeSort(a, left, mid);
		MergeSort(a, mid, right);
		Merge(a, left, mid, right);
	}
}

int main(){
	int n;
	scanf("%d", &n);
	Card A[1000000];
	Card B[1000000];
	char S[10];
	int v;
	for (int i = 0; i < n; i++) {
		scanf("%s %d", S, &v);
		A[i].a = B[i].a = S[0];
		A[i].x = B[i].x = v;
	}
	quickSort(A, 0, n-1); 
	MergeSort(B, 0, n);
	for (int i = 0; i < n; i++){
		if (A[i].a != B[i].a){
			printf("Not stable\n");
			break;
		}
		if (i == n-1) printf("Stable\n");
	}
	for (int i = 0; i < n; i++) printf("%c %d\n", A[i].a, A[i].x);
}


Measured memory_bytes: 21400
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 1000000000000000000
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 200001;
const ll M = 21;
struct point {
    ll x, y, sol;
    bool operator == (point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (point b)
    {
        return !(*this == b);
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x,ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans;
    }
    else ans = fast_exp(x, n - 1) * x;
    return ans;
}
ll a[N], b[N], c[N], o[N], z[N];
vector<int> tree[N];
ll solve(ll x, ll p)
{
    ll ans = 0;
    for(auto i:tree[x])
    {
        if(i != p)
        {
            a[i] = min(a[i], a[x]);
            ans += solve(i, x);
            o[x] += o[i];
            z[x] += z[i];
        }
    }
    if(b[x] != c[x])
    {
        if(b[x]) o[x]++;
        else z[x]++;
    }
    if(o[x] && z[x])
    {
        ans += 2 * a[x] * min(o[x], z[x]);
        ll y = min(o[x], z[x]);
        o[x] -= y;
        z[x] -= y;
    }
    return ans;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, x = 0, y = 0, ans = 1, k;
        cin >> n;
        long double tmp = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> x;
            if(x == 0)
            {
                ans = 0;
                y = 0;
                break;
            }
            if(x && ans <= (ll_max + x - 1) / x)
                ans = ans * x;
            else y = 1;
        }
        if(y || ans > ll_max) ans = -1;
        cout << ans << "\n";
     }
     return 0;
}


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

int main()
{
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;
    
    for(;;) {
        C -= B;
        if(C <= 0) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
        A -= D;
        if(A <= 0) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

string ba[100];
int dist[100][100][1<<5];
int cost[100][100];
int maki[100][100];

struct P {
  int y, x, S, d;
  P(int y, int x, int S, int d) : y(y),x(x),S(S),d(d) {}
};
bool operator<(const P &a, const P &b) {
  return a.d > b.d;
}

int main() {
  int h,w;
  while(cin>>w>>h) {
    REP(i,h)cin>>ba[i];
    priority_queue<P> Q;
    memset(dist,-1,sizeof(dist));
    int num = 0;
    REP(i,h)REP(j,w)cost[i][j]=1;
    REP(i,h) {
      REP(j,w) {
        if (ba[i][j] == 'S') {
          Q.push(P(i,j,0,0));
          dist[i][j][0] = 0;
        } else if(ba[i][j] == '#') {
          for (int dx = -3; dx<=3; ++dx) {
            for (int dy = -3; dy<=3; ++dy) {
              int ii = i+dy;
              int jj = j+dx;
              if (ii<0||ii>=h||jj<0||jj>=w) continue;
              cost[ii][jj] = max(cost[ii][jj], 4-max(abs(dx),abs(dy)));
            }
          }
        } else if (ba[i][j] == 'M') {
          maki[i][j] = num++;
        }
      }
    }
    const int dy[] = {-1,0,1,0};
    const int dx[] = {0,1,0,-1};

    int ans = -1;
    // REP(i,h) {
    //   REP(j,w)cout << cost[i][j];
    //   cout << endl;
    // }
    
    while(!Q.empty()) {
      P p = Q.top(); Q.pop();
      int S = p.S;

      //cout << p.y << " " << p.x << " " <<  S << " " << p.d << endl;
      
      if (dist[p.y][p.x][S] < p.d) continue;
      
      if (ba[p.y][p.x] == 'G' && S == ((1<<num)-1)) {
        ans = dist[p.y][p.x][S];
        break;
      }
      REP(i,4) {
        int yy = p.y + dy[i];
        int xx = p.x + dx[i];

        if (yy<0||yy>=h||xx<0||xx>=w) continue;
        if (ba[yy][xx] == '#') continue;
        int T = S;
        if (ba[yy][xx] == 'M') T |= 1<<maki[yy][xx];
        int dis = dist[p.y][p.x][S] + cost[p.y][p.x];
        if (dist[yy][xx][T] == -1 || dist[yy][xx][T] > dis) {
          dist[yy][xx][T] = dis;
          Q.push(P(yy,xx,T,dis));
        }
      }
    }
    cout << ans << endl;
  }
}

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

int main(){
    int n;
    long int x;
    cin>>n>>x;
    long int a[n];
    long int n_t = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        if(a[i]>x){
            n_t += a[i]-x;
            a[i] = x;
        }
        if(a[i]+a[i+1]>x){
            n_t += a[i]+a[i+1]-x;
            a[i+1] -= a[i]+a[i+1]-x;
        }
    }
    cout<<n_t<<endl;
    return 0;
}

Measured memory_bytes: 4348
#include <iostream>
#include <cstring>
using namespace std;
typedef long long LL;

LL Count(int l, int r, LL d) {
    if (l >= r) return (d == 0) ? (l == r ? 10 : 1) : 0;
    if (d % 10 == 0) return (l == 1 ? 9 : 10) * Count(l + 1, r - 1, d / 10);
    LL diff = d % 10 - 10;
    LL powe = 1;
    for (int i = 1; i <= r - l; ++i) powe *= 10;
    LL nd = d - diff + diff * powe;
    return ((l == 1 ? 9 : 10) + diff) * Count(l + 1, r - 1, abs(nd) / 10);
}

int main() {
    int d;
    cin >> d;
    LL ans = 0;
    for (int len = 2; len <= 18; ++len) ans += Count(1, len, d);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define m 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   int n;
   cin>>n;
   long long a[n+1];
   long long b[n+1];
   a[0]=0;
   b[0]=0;
   for(int i=1;i<=n;i++){
    cin>>a[i];
    b[i]=a[i]+b[i-1];
   }
   long long sum=0;
   for(int i=1;i<=n;i++){
     sum+=((a[i]%m)*((b[n]-b[i])%m))%m;
   }
   cout<<sum%m<<"\n";

}

Measured memory_bytes: 6776
def stairs(N):
    dp = [0] * (N + 5)
    dp[0] = 1
    for i in range(N + 1):
        dp[i + 1] += dp[i]
        dp[i + 2] += dp[i]
        dp[i + 3] += dp[i]

    d, v = divmod(dp[N], 10)
    days = d + 1 if v else d
    d, v = divmod(days, 365)
    years = d + 1 if v else d
    print(years)


while True:
    N = int(input())
    if N == 0:
        exit()
    stairs(N)



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

int main() {
  int n; cin >>n;
  vector<pair<int,int>>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i].first;
    a[i].second=i+1;
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    if(i!=n-1)cout<<a[i].second<<" ";
    else cout<<a[i].second<<endl;
  }
  return 0;
}

Measured memory_bytes: 1536
N, K = map(int, input().split())
MOD = 10**9 + 7

if K < N:
    print(0)
else:
    p = q = 1
    for i in range(N):
        p = p * (K-i) % MOD
        q = q * (i+1) % MOD

    print(p * pow(q, MOD-2, MOD) % MOD)



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

int main(int argc, const char * argv[]) {
    // insert code here...
    string s;
    cin >> s;
    
    char first = s.at(0);
    reverse(s.begin(), s.end());
    char end = s.at(0);
    int a = s.size() - 2;
    
    cout << first << a << end << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,j,h,w;

  scanf("%d%d",&h,&w);
  while(h!=0 || w!=0){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d%d",&h,&w);
  }

  return 0;
}

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

using namespace std;
#define ll long long int
#define pb push_back
#define rep(i, a, v) for(int i = a; i <= v; ++i)
#define vi vector<int>
#define vll vector<ll>
#define maxi 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
const double pie = 3.1415926535;
const string spaces = "    ";

const int max_size = 1e5 + 4;
int dp[max_size];
array<vi, max_size> adj; 

int FindAns(int start){
    if(dp[start] != -1)
        return dp[start];
    int answer = 0;
    for(int neigh : adj[start]){
        answer = max(answer, FindAns(neigh) + 1);
    }
    dp[start] = answer;
    return answer;
}

int main(){
    cout.tie(0);
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m;
    int u, v;

    cin >> n >> m;
    
    for(int i = 0; i < max_size; ++i)
        dp[i] = -1;
    
    for(int i = 0; i < m; ++i){
        cin >> u >> v;
        adj[u].pb(v);
    }

    int ans = -1;
    for(int i = 1; i <= n; ++i){
        ans = max(FindAns(i), ans);
    }

    cout << ans << "\n";
    return 0;

}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n, x, t;
    double tmp;
    
    cin >> n >> x >> t;
  
    tmp = ceil((double)n / x);
    
  	cout << (int)tmp * t << endl;
    
 	return 0;
}


Measured memory_bytes: 3592