akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int q;
    cin>>q;
    vector<int>b(q);
    vector<int>c(q);
    rep(i,q)cin>>b[i]>>c[i];
    vector<int>count(100005,0);
    long long sum=0;
    rep(i,n)sum+=a[i];
    rep(i,n)count[a[i]]++;

    rep(i,q)
    {
    sum+=(c[i]-b[i])*count[b[i]];
    count[c[i]]+=count[b[i]];
    count[b[i]]=0;
    cout<<sum<<endl;
    }
   
   


    return 0;
}


Measured memory_bytes: 4392
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = 0, a, b;
        String w, t;
        w = sc.next().toLowerCase();
        a = w.length();
        while(true){
        	t = sc.next();
        	b = t.length();
        	if(t.contains("END_OF_TEXT")) break;
        	if(a == b) {
        		if(t.toLowerCase().contains(w)) count++;
        	}
        }
        System.out.println(count);
        sc.close();
    }
}


Measured memory_bytes: 26248
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define MOD 1000000007
#define ll long long

using namespace std;
int main(){
  ll ans=0;
  int n;cin>>n;
  short flag[n*2]={};
  for(int i=0;i<n;i++){
    int a;cin>>a;
    flag[a]++;
  }
  int fl=1;
  for(int i=0;i<n;i++){
    if(flag[i]>=2&&i==0){
      fl=0;break;
    }else if(flag[i]>2){
      fl=0;break;
    }else if(flag[i]==1&&i!=0){
      fl=0;break;
    }
  }
  if(fl){
    int aa=1;
    for(int i=0;i<(n/2);i++){
      aa=aa*2%MOD;
    }
    cout<<aa<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
int main(){
    int N,M;
    std::cin >> N;
    std::vector<int> S(N);
    for(int i=0;i<N;i++){
        std::cin >> S[i];
    }
    std::cin >> M;
    std::vector<int> T(M);
    for(int i=0;i<M;i++){
        std::cin >> T[i];
    }
    int ans=0;
    for(int i=0;i<M;i++){
        for(int j=0;j<N;j++){
            if(S[j]==T[i]){
                ans++;
                break;
            }
            
        }
    }
    std::cout << ans << std::endl;
}


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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007LL
#define MOD2 998244353LL
const int INF = 1 << 28;


int f(int n) {
    if (n & 1) return 3 * n + 1;
    else return n / 2;
}

int main() {
    int s; cin >> s;
    int m = 1;
    set<int> T;
    T.insert(s);

    while (1) {
        s = f(s);
        m++;
        if (T.count(s)) break;
        else T.insert(s);
    }

    cout << m << endl;


}




Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()

import heapq
from collections import defaultdict
h = []
heapq.heapify(h)

n, m, s = list(map(int, input().split()))
a, b = [[None] * m for _ in range(2)]
c, d = [[None] * n for _ in range(2)]

ns = defaultdict(list)
uv2e = {}
for i in range(m):
    u,v,a[i],b[i] = list(map(int, input().split()))
    ns[u-1].append(v-1)
    ns[v-1].append(u-1)
    uv2e[u-1,v-1] = i
    uv2e[v-1,u-1] = i
for i in range(n):
    c[i], d[i] = list(map(int, input().split()))

maxs = max(a)*(n-1)
s = min(s, maxs)
state = (0, 0, s) # (距離, ノード, 銀貨枚数)
ans = [[None] * (maxs+1) for _ in range(n)]
heapq.heappush(h, state)
count = 0
while h:
    count += 1
    dd, u, ss = heapq.heappop(h)
#     print(dd, u, ss)
    if ans[u][ss] is not None and ans[u][ss] <= dd:
        continue
    ans[u][ss] = dd
    
    # グラフの隣接点
    for v in ns[u]:
        e= uv2e[u,v]
        if ss<a[e] or ans[v][ss-a[e]] is not None:
            continue
        heapq.heappush(h, (dd + b[e], v, ss-a[e]))
    # 両替
    if ss+c[u] <= maxs:
        heapq.heappush(h, (dd + d[u], u, ss+c[u]))
    elif ss < maxs:
        heapq.heappush(h, (dd + d[u], u, maxs))

for item in ans[1:]:
    print(min(item))


Measured memory_bytes: 124564
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	if s[2] == s[3] && s[4] == s[5] {
		fmt.Fprintln(writer, "Yes")
		return
	}
	fmt.Fprintln(writer, "No")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
//#include <boost/algorithm/string.hpp> 
using namespace std;
#define ll long long
#define ull unsigned long long
#define V vector<int>
#define VLL vector<ll>
#define VV vector<vector<ll>>
#define vec vector
#define P pair
#define scan(a) scanf("%d",&a)
#define print(a) printf("%d",a)
#define be(x) begin(x),end(x)
#define For(a) for(int i=0;i<a;i++)
#define Forin(j,a,b) for(int j=a;j<b;j++)
#define len(a) a.size()
#define pb push_back 
#define mp make_pair
#define Um unordered_map
#define Us unordered_set
#define F first
#define S second
#define mod 1000000007

void solve();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
   
    
    solve();
    cout<<"\n";
return 0;
}

void solve()
{
    ll n;
    cin>>n;
    ll c=0;
    for(int i=1;i<=n;i++){
       c+=(n)/i; 
       if(n%i==0)
       c--;
    }
    cout<<c;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define int long long
#define N 11
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
struct dat{
  int x,y,X,Y;
  bool contain(dat b){return (x<=b.x && b.X<=X) && (y<=b.y && b.Y<=Y);}
};

int h,w;
vector<dat> A;
typedef vector<vector<int> > V;


int count(const V &mp,dat a){
  int cnt = 0;
  for(int i=a.y;i<=a.Y;i++) cnt += count(mp[i].begin()+a.x,mp[i].begin()+a.X+1,1);
  return cnt;
}

bool contain0(V &mp,int x,int y,int X,int Y){return count(mp,(dat){x,y,X,Y}) == (X-x+1)*(Y-y+1);}

struct dat2{
  V mp;
  int cnt,cost;
};

dat2 getNx(dat2 t,dat a){
  t.cost++;
  for(int i=a.y;i<=a.Y;i++)
    for(int j=a.x;j<=a.X;j++){
      t.cnt -= t.mp[i][j];
      t.mp[i][j] = 0;
    }
  return t;
}

dat2 erase(dat2 t){
  int update = 1;
  while(update--){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
        if(t.mp[i][j] == 0)continue;
        int cnt = 0;
        dat tmp;
        for(dat a:A) if(a.contain((dat){j,i,j,i})) cnt++, tmp = a;
        if(cnt == 1) t = getNx(t,tmp),update = 1;
      }
  }
  return t;
}

typedef pair<int,int> P;
set<P> getErased(const V &mp,const dat &a){
  set<P> res;
  for(int i=a.y;i<=a.Y;i++)
    for(int j=a.x;j<=a.X;j++)
      if(mp[i][j]) res.insert(P(i,j));
  return res;
}

int bfs(V start){
  queue<dat2> Q;
  set<V> used;
  Q.push((dat2){start,count(start,(dat){0,0,w-1,h-1}),0});

  while(1){
    dat2 t = erase(Q.front());Q.pop();
    if(t.cnt == 0) return t.cost;
    if(used.count(t.mp))continue;
    used.insert(t.mp);

    dat nx;
    for(dat a:A) if(count(t.mp,a)) nx = a;
    set<P> S = getErased(t.mp,nx);
    for(dat a:A){
      set<P> s = getErased(t.mp,a);
      int cnt = 0;
      for(P p:s) cnt += S.count(p);
      if(cnt) Q.push(getNx(t,a));
    }
  }
}

signed main(){
  while(1){
    cin>>w>>h;
    if(w == 0 && h == 0)break;

    V mp = V(h,vector<int>(w));
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) cin>>mp[i][j];
    
    A.clear();
    for(int y=0;y<h;y++)
      for(int x=0;x<w;x++){
        dat a = (dat){-1,-1,-1,-1};
        for(int Y=y, X=x; Y<h && X<w ;Y++, X++) if(contain0(mp,x,y,X,Y)) a = (dat){x,y,X,Y};
        if(a.x != -1) A.push_back(a);
      }
    
    for(int i=0;i<(int)A.size();i++)
      for(int j=0;j<(int)A.size();j++) if(i!=j && A[i].contain(A[j]))A.erase(A.begin()+j--);
    cout<<bfs(mp)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<cstdio>
#include<string>
#include<set>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int dp[2005][2005][2];//a???n??????b???m????????§?????????(1,0)=(I,O)
int a, b; string c, d;
int main() {
	cin >> a >> b >> c >> d;
	c += " "; d += " ";
	for (int e = a + b-1; e >= 0; e--) {
		for(int x=0;x<=a;x++){
			int y = e - x;
			if (y >= 0 && y <= b) {
				int I = 0, O = 0;
				if (c[x] == 'I') {
					I = dp[x + 1][y][0] + 1;
				}
				else if(c[x]=='O') {
					O = dp[x + 1][y][1] + 1;
				}
				if (d[y] == 'I') {
					I = max(I,dp[x][y + 1][0] + 1);
				}
				else if (d[y] == 'O') {
					O = max(O,dp[x][y + 1][1] + 1);
				}
				dp[x][y][1] = I;
				dp[x][y][0] = O;
			}
		}
	}
	int MAX = 0;
	for (int p = 0; p <= a; p++) {
		for (int q = 0; q <= b; q++) {
			if ((dp[p][q][1] & 1) == 0)dp[p][q][1]--;
			MAX = max(MAX, dp[p][q][1]);
		}
	}
	cout << MAX << endl;
}

Measured memory_bytes: 34512
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int64_t H, W;
	cin >> H >> W;

	int64_t dif = H * W;
	for (int i = 1; i < H; i++) {
		int64_t a, b, c, x;
		a = i * W;
		//cout << "a:" << a << endl;
		
		if ((H - i) % 2 == 0) {
			b = (H - i) / 2 * W;
			//cout << "b:" << b << endl;
			x = abs(a - b);
			if (x < dif) dif = x;
		}

		b = (H - i) * (W / 2);
		c = (H - i) * (W - (W / 2));
		//cout << "b:" << b << endl;
		x = abs(max(max(a, b), c) - min(min(a, b), c));
		if (x < dif) dif = x;

		//cout << dif << endl;
	}

	for (int i = 1; i < W; i++) {
		int64_t a, b, c, x;
		a = i * H;

		if ((W - i) % 2 == 0) {
			b = (W - i) / 2 * H;
			x = abs(a - b);
			if (x < dif) dif = x;
		}

		b = (W - i) * (H / 2);
		c = (W - i) * (H - (H / 2));
		x = abs(max(max(a, b), c) - min(min(a, b), c));
		if (x < dif) dif = x;
	}

	cout << dif << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <math.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;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  int A[3][3];
  int B[3][3] = {0};
  REP(i,3) {
    REP(j,3) {
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  REP(i,N) {
    cin >> b[i];
  }
  REP(i,N) {
    REP(j,3) {
      REP(k,3) {
        if(b[i] == A[j][k]) {
          B[j][k] = 1;
        }
      }
    }
  }
  
  
  string ans = "No";

  if(B[0][0]==1&&B[0][1] == 1 && B[0][2] == 1) ans = "Yes";
  if(B[0][0]==1&&B[1][0] == 1 && B[2][0] == 1) ans = "Yes";
  if(B[0][0]==1&&B[1][1] == 1 && B[2][2] == 1) ans = "Yes";
  
  if(B[1][2]==1&&B[1][0] == 1 && B[1][1] == 1) ans = "Yes";
  if(B[1][2]==1&&B[0][2] == 1 && B[2][2] == 1) ans = "Yes";
  if(B[2][1]==1&&B[0][1] == 1 && B[1][1] == 1) ans = "Yes";
  if(B[2][1]==1&&B[2][0] == 1 && B[2][2] == 1) ans = "Yes";
  
  if(B[1][1]==1&&B[0][2] == 1 && B[2][0] == 1) ans = "Yes";
  cout << ans << endl;
  
  

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var list = new List<long>();
        list.Add(inp[2]);
        for (int i = 0; i < 10; i++)
        {
            list.Add(inp[0] * list.Last() - inp[1]);
        }
        for (int i = 1; i <= 10; i++)
        {
            Console.WriteLine(list[i]);
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <iomanip>


using namespace std;

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

    for(int i=1;i<s.size();i++){
        if(s[0]!=s[i]){
            cout<<"Yes";
            exit(0);
        }
    }
    cout<<"No";
}






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

using namespace std;
using ll = long long;

int main() {
  ll A, B; cin >> A >> B;
  ll g = __gcd(A, B);
  
  int ans = 1;
  if (g % 2 == 0) {
    ans++;
    while (g % 2 == 0) g >>= 1;
  }
  for (ll p = 3; p <= sqrt(g); p += 2) {
    if (g % p == 0) {
      ans++;
      while (g % p == 0) g /= p;
    }
  }
  if (g > 2) ans ++;
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli                      int long long
#define ull                      unsigned long long
#define ld                       long double
#define pi                       acos(-1)
#define pb                       push_back
#define pbk                      pop_back
#define mp                       make_pair
#define all(v)                   v.begin(),v.end()
#define ff                       first
#define ss                       second
#define pii                      pair<int,int>
#define gcd(a,b)                 __gcd(a,b)
#define lcm(a,b)                (a/gcd(a,b))*b
#define READ                     freopen("in.txt","r",stdin);
#define WRITE                    freopen("outer.txt","w",stdout);
#define sort(t)                  sort(t.begin(),t.end())
#define mem(a,b)                 memset(a,b,sizeof a)
#define t_c(t)                          for(int z=1;z<=t;z++)
#define p_c                             printf("Case %d: ",z)
#define LINE_PRINT_CASE          printf("Case %d:\n",z)
#define sf                       scanf
#define pf                       printf
#define dist(ax,ay,bx,by)        sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define MX                       100005
#define inf                      10000000000000000+7
#define M                        1000000002
#define MINI                     -1000000003
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move

//int kx[]={+2,+2,-2,-2,+1,+1,-1,-1};     //Knights move
//int ky[]={+1,-1,+1,-1,+2,-2,+2,-2};     //Knights move


//#define for(i,a,n)    for(int i=a;i<n;i++)
//it=myset.find(20);
//int a[8]= {0,0,-1,1,-1,1,-1,1};
//int b[8]= {-1,1,0,0,-1,1,1  ,-1};

int main()
{
   double w,h,x,y;
   lli n=0;
   scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
   double t1=w/2.0,t2=h/2.0;double area=(w*h)/2.0;
   printf("%.6f ",area);
   if(t1==x && t2==y)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

int mdigit(ll val) {
    int l = 0, r = 61;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        ll bit = (1LL << r) - (1LL << mid);
        (val & bit ? l : r) = mid;
    }
    return l;
}

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

    int T;
    cin >> T;
    for (int a = 0; a < T; ++a) {
        int N;
        cin >> N;
        vector<ll> A(N);
        for (int i = 0; i < N; ++i)
            cin >> A[i];
        string S;
        cin >> S;

        bool isok = true;
        vector<ll> v(61);
        for (int i = N - 1; i >= 0; --i) {
            int tmp;
            while (A[i] && v[tmp = mdigit(A[i])])
                A[i] ^= v[tmp];
            if (A[i]) {
                if (S[i] == '0')
                    v[tmp] = A[i];
                else {
                    isok = false;
                    break;
                }
            }
        }

        cout << !isok << '\n';
    }

    return 0;
}


Measured memory_bytes: 3580
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

/*
 * ref. http://drken1215.hatenablog.com/entry/2018/06/08/210000
 *
 * usage:
 *
 * Combination *c;
 * 
 * const int MOD = 1000000007;
 * const int MAX_N = 100000;
 * 
 * int main(void) {
 *     int n, k;
 *     cin >> n >> k;
 *     c = new Combination(2 * MAX_N, MOD);
 *     cout << c->com(n + k - 1, k) << endl;
 *     delete(c);
 *     return 0;
 * }
 */
class Combination {
    public:
        const int max;
        const int mod;
        vector<ll> fac, finv, inv;

        Combination(int max, int mod) : max(max), mod(mod), fac(max), finv(max), inv(max) {
            init();
        }

        ll com(int n, int k) {
            if (n < k) return 0LL;
            if (n < 0 || k < 0) return 0LL;
            // return (fac[n] * ((finv[k] * finv[n - k]) % mod)) % mod;
            return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
        }

    private:
        void init() {
            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for (int i = 2; i < max; i++){
                fac[i] = fac[i - 1] * i % mod;
                inv[i] = mod - inv[mod%i] * (mod / i) % mod;
                finv[i] = finv[i - 1] * inv[i] % mod;
            }
        }
};

Combination *c;

const int MOD = 1000000007;
const int MAX_N = 100000;

vector<ll> x;
vector<ll> v;

// ref. https://atcoder.jp/contests/dwacon6th-prelims/submissions/9421616
int main(void) {
    // use combination library just for fac and finv...
    c = new Combination(2 * MAX_N, MOD);

    ll N;
    cin >> N;

    x.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }

    // v[1] = 1! * (1) = 1
    // v[2] = 2! * (1 + 1/2) = 3 = 2 * v[1] + 1!
    // v[3] = 3! * (1 + 1/2 + 1/3) = 11 = 3 * v[2] + 2!
    // v[4] = 4! * (1 + 1/2 + 1/3 + 1/4) = 50 = 4 * v[3] + 3!
    // ...
    // v[n] = n * v[n - 1] + (n - 1)!
    v.resize(MAX_N + 1, 0);
    for (int i = 1; i <= MAX_N; i++) {
        v[i] = (1LL * i * v[i - 1] + c->fac[i - 1]) % MOD;
    }

    ll ans = 0;
    for (int i = 1; i <= N - 1; i++) {
        ll val = v[i];
        val = val * c->fac[N - 1] % MOD;
        val = val * c->finv[i] % MOD;
        ans = (ans + (val * (x[i] - x[i - 1]) % MOD)) % MOD;
    }

    cout << ans << endl;

    delete(c);
    return 0;
}


Measured memory_bytes: 6528
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn gcd(a: u64, b: u64) -> u64 {
    assert!(a != 0 || b != 0);
    if a == 0 {
        b
    } else {
        gcd(b % a, a)
    }
}

fn main() {
    input!{
        n: usize,
        a: [u64; n],
    }
    let mut l = vec![0; n];
    let mut r = vec![0; n];
    let mut ans = 0;
    l[0] = a[0];
    r[n - 1] = a[n - 1];

    for i in 1..n {
        l[i] = gcd(l[i - 1], a[i])
    }
    for i in (0..n - 1).rev() {
        r[i] = gcd(r[i + 1], a[i])
    }

    for i in 0..n {
        let acc: u64 = if i == 0 {
            r[1]
        } else if i == n - 1 {
            l[n - 2]
        } else {
            gcd(l[i - 1], r[i + 1])
        };
        ans = max(ans, acc);
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n;
  cin >> n;
  cout << 2 * 3.141592 * n << endl;
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    ll min = t.size();
    for (ll i = 0; i < s.size() - t.size() + 1; i++)
    {
        ll cnt = 0;
        for (ll j = 0; j < t.size(); j++)
        {
            if (s[i + j] != t[j])
                cnt++;
        }
        if (cnt < min)
            min = cnt;
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int qs;
  cin >> qs;
  multiset<ll, greater<ll>> left;
  left.insert(-1e18);
  multiset<ll> right;
  right.insert(1e18);
  ll y = 0;
  REP(i,0,qs) {
    int t;
    cin >> t;
    if (t == 2) {
      cout << *left.begin() << " " << y << endl;
    } else {
      ll a, b;
      cin >> a >> b;
      y += b;
      auto li = left.begin();
      auto ri = right.begin();
      if (*li <= a && a <= *ri) {
        left.insert(a);
        right.insert(a);
      } else if (a < *li) {
        y += *li - a;
        right.insert(*li);
        left.erase(li);
        left.insert(a);
        left.insert(a);
      } else {
        y += a - *ri;
        left.insert(*ri);
        right.erase(ri);
        right.insert(a);
        right.insert(a);
      }
    }
  }

  return 0;
}


Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
int modinverse(int a, int m=mod) 
{ 
    int m0 = m; 
    int y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    {
        int q = a / m; 
        int t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    int a[n],i,sum=0,ans=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        sum%=mod;
    }
    for(i=0;i<n;i++)
    {
        ans+=(a[i]*(sum-a[i]+mod))%mod;
        ans%=mod;
        sum-=a[i];
        sum=(sum%mod+mod)%mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5212
import numpy as np
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]
grid2 = []
ans = []
cur = 0
for a in grid:
    if "#" in a:
        grid2.append(a)
t_grid2 = np.array(grid2).T.tolist()
for a in t_grid2:
      if "#" in a:
        ans.append(a)
ans = np.array(ans).T.tolist()
for i in range(len(ans)):
  out = "".join(ans[i])
  print(out)

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

int main(){
  int n;
  cin >> n;
  cout << (n + 1) / 2 - 1<< endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  rep(i, k) {
    if (i%2) {
      b /= 2;
      a += b;
    } else {
      a /= 2;
      b += a;
    }
  }
  cout << a << ' ' << b << endl;
  return 0;
}

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

int N, K, A, B;

int dfs(vector< vector< vector<int> > >& dp,vector<bool>& dec, vector<int>& pasta,int pppasta,int ppasta,int n)
{
	if (n == N + 1)
		return 1;
	if (dp[pppasta][ppasta][n] != -1) {
		return dp[pppasta][ppasta][n];
	}
	dp[pppasta][ppasta][n] = 0;
	if (dec[n]) {
		if (n - 2 >= 0 && pppasta == ppasta && ppasta == pasta[n])
			return 0;
		else
			return dp[pppasta][ppasta][n] = dfs(dp, dec, pasta, ppasta, pasta[n], n + 1);
	}
	for (int i = 1; i <= 3; i++) {
		pasta[n] = i;
		if (n - 2 >= 0 && pppasta == ppasta && ppasta == pasta[n])
			continue;
		dp[pppasta][ppasta][n] += dfs(dp, dec, pasta, ppasta, pasta[n], n + 1);
	}
	dp[pppasta][ppasta][n] %= 10000;
	return dp[pppasta][ppasta][n];
}

int main()
{
	cin >> N >> K;
	vector<bool> dec(N + 1, false);
	vector<int> pasta(N + 1, 0);
	vector< vector< vector<int> > > dp(4, vector< vector<int> >(4, vector<int>(N + 1, -1)));
	for (int i = 0; i < K; i++) {
		cin >> A >> B;
		dec[A] = true;
		pasta[A] = B;
	}
	cout << dfs(dp, dec, pasta, 0, 0, 1) << endl;
	return 0;
}

Measured memory_bytes: 1228
for i in range(1,5+1) :
    n = int(input())
    x = 1000-n
    if n == 0 :
        break
    
    else :
        a = x//500
        b = (x-500*a)//100
        c = (x-500*a-100*b)//50
        d = (x-500*a-100*b-50*c)//10
        e = (x-500*a-100*b-50*c-10*d)//5
        f = x-500*a-100*b-50*c-10*d-5*e
        print(a+b+c+d+e+f)
        
        


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    sort(A.begin(),A.end());
    int max = A.at(N - 1);
    int hoge = 1000000000;
    int min,huga = (max + 1) / 2;
    for (int i = 0; i < N; i++) {
        if (A.at(i) <= huga) {
            if (huga - A.at(i) <= hoge) {
                hoge = huga - A.at(i);
                min = A.at(i);
            }
        }
        if (A.at(i) > huga) {
            if (max % 2 == 0) {
                if (A.at(i) - huga + 1 <= hoge) {
                    hoge = A.at(i) - huga + 1;
                    min = A.at(i);
                }
            }
            else {
                if (A.at(i) - huga <= hoge) {
                    hoge = A.at(i) - huga;
                    min = A.at(i);
                }
            }
        }
    }
    cout << max << ' ' << min << endl;
}

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

template<typename T>
struct List {
    struct Node {
        Node *prev, *next;
        T data;
        Node(Node* prev = nullptr, Node* next = nullptr, T data = T(0))
        : prev(prev), next(next), data(data) { }
    };
    Node *head, *tail;
    List() : head(new Node()), tail(new Node()) {
        head->next = tail, tail->prev = head;
    }
    Node* begin() { return head->next; }
    Node* end() { return tail; }
    Node* insert(Node* cur, T data) {
        cur = new Node(cur->prev, cur, data);
        return cur->prev->next = cur->next->prev = cur;
    }
    Node* push_front(T data) { return insert(begin(), data); }
    Node* push_back(T data) { return insert(end(), data); }
    Node* erase(Node* cur) {
        if (cur == head || cur == tail) return cur;
        cur->prev->next = cur->next, cur->next->prev = cur->prev;
        Node* tmp = cur->next;
        return free(cur), tmp;
    }
    Node* pop_front() { return erase(begin()); }
    Node* pop_back() { return erase(end()->prev); }
    Node* find(T data) {
        Node* cur = begin();
        while (cur != end() && cur->data != data) cur = cur->next;
        return cur;
    }
    friend ostream& operator<<(ostream& os, List& li) {
        Node* cur = li.begin();
        for (int cnt = 0; cur != li.end(); cur = cur->next) {
            if (cnt++) os << " "; os << cur->data;
        }
        return os;
    }
};

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int q; cin >> q;
    List<int> li;
    while (q--) {
        string op; cin >> op;
        if (op[0] == 'i') {
            int x; cin >> x;
            li.push_front(x);
        } else if (op[6] == 'F') {
            li.pop_front();
        } else if (op[6] == 'L') {
            li.pop_back();
        } else {
            int x; cin >> x;
            li.erase(li.find(x));
        }
    }
    cout << li << endl;
    return 0;
}



Measured memory_bytes: 34352
#include<iostream>
#include<map>
using namespace std;
const int maxn = 100001;
map<int,int> mp;
int count=0;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int temp;
		cin>>temp;
		if(mp.count(temp)==0){
			count++;
			mp[temp]=1;
		}else{
			if(mp[temp]==1){
				count--;
				mp[temp]=0;
			}else{
				mp[temp]=1;
				count++;
			}
		}
	}
	cout<<count;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> dp(n+1, 0);
    string s;
    cin >> s;
    for(int i = 0; i < n-1; i++) {
        if (s.substr(i, 2) == "AC") {
            dp[i+1] = dp[i];
            dp[i+2] = dp[i+1] + 1;
            i += 1;
        } else {
            dp[i+1] = dp[i];
        }
    }
    if (s.substr(n-2, 2) != "AC")
        dp[n] = dp[n-1];
    int l, r;
    for(int i = 0; i < m; i++) {
        cin >> l >> r;
        cout << dp[r] - dp[l] << endl;
    }
    return 0;
}



Measured memory_bytes: 1488
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
int main(void)
{
    int A, B;
    scanf("%d %d", &A, &B);
    int tapc = 1;
  	int count = 0;
  while(tapc<B){
  	--tapc;
    tapc += A;
    ++count;
  }
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 256
program slimes
  implicit none
  integer :: n, i = 1, j = 1, m = 0
  character(100001) :: s = ""
  read(*,*) n
  read(*,*) s
  s(n+1:n+1) = "X"
  do while (i <= n)
    do while (s(j:j) == s(i:i))
      j = j+1
    end do
    m = m+1
    i = j
  end do
  write(*,'(i0)') m
end program slimes

Measured memory_bytes: 1084
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
long long dp[2100][2100];

int main(){
	int a,b;scanf("%d%d",&a,&b);
	dp[0][a]=1;
	for(int i=1;i<=b;i++){
		long long tmp=0;
		for(int j=a-1;j>=0;j--){
			if(i<b&&j==0)continue;
			tmp=(tmp+dp[i-1][j+1])%mod;
			dp[i][j]=(dp[i][j]+tmp)%mod;
			if(j<=a-i)dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
		}
	}
	long long ret=dp[b][0];
	ret%=mod;
	ret=ret*pw(2,max(0,a-b-1))%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 34944
using System;

public class Hello
{
    public static void Main()
    {
        string[] s;

        while((s = Console.ReadLine().Split(' ')) != null)
        {
            if (s[0] == "0" && s[1] == "0") break;
            string s1 = s[0];
            string s2 = s[1];
            if(int.Parse(s1) > int.Parse(s2))
            {
                Console.WriteLine("{0} {1}", s2, s1);
            }
            else
            {
                Console.WriteLine("{0} {1}", s1, s2);
            }
        }
    }
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    pair<int, int> from, to;
    cin >> from.first >> from.second >> to.first >> to.second;
    from.first--;
    from.second--;
    to.first--;
    to.second--;
    vector<string> ike(h);
    REP(i, h)
    cin >> ike[i];
    vector<vector<int>> visited(h, vector<int>(w, 1000001));
    visited[from.first][from.second] = 0;
    queue<pair<pair<int, int>, int>> Q;
    Q.push({ from, 0 });
    int ans = -1;
    while (!Q.empty()) {
        pair<pair<int, int>, int> q = Q.front();
        Q.pop();
        if (q.first == to) {
            ans = q.second;
            break;
        }
        REP(i, 4)
        {
            FOR(j, 1, k + 1)
            {
                if (WRAP(q.first.first + dy[i] * j, q.first.second + dx[i] * j, h, w)) {
                    if (ike[q.first.first + dy[i] * j][q.first.second + dx[i] * j] != '@') {
                        if (visited[q.first.first + dy[i] * j][q.first.second + dx[i] * j] == 1000001) {
                            visited[q.first.first + dy[i] * j][q.first.second + dx[i] * j] = q.second + 1;
                            Q.push({ { q.first.first + dy[i] * j, q.first.second + dx[i] * j }, q.second + 1 });
                        } else {
                            if (visited[q.first.first + dy[i] * j][q.first.second + dx[i] * j] < q.second + 1)
                                break;
                        }
                    } else {
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

#define debug_input freopen("stdin.in", "w", stdin)
#define debug_output freopen("stdout.out", "w", stdout)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
	ll n, a, num;
	const ll comp = 1e18;

	cin >> n;
	cin >> a;

	bool flag = 1;
	for(int i = 1; i < n; i++) {
		cin >> num;
		if(num == 0) {
			flag = 1;
			a *= num;
			break;
		}
		else if(a <= (comp / num)) {
			a *= num;
		}
		else {
			flag = 0;
		}
	}	

	if(flag) {
		cout << a;
	}
	else cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 3596
n = input()
li = list(map(int,input().split()))

orl = 1000

for i in range(len(li)-1):
    if li[i] < li[i+1]:
        orl = int(orl/li[i]) * (li[i+1]) + (orl - li[i] * int(orl/li[i]))

print(orl)

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cassert>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x","<<#y":"<<x<<","<<y<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

vi num;
vi num_odd;
int N;
int N_odd;
int dp[1000001];
int dpdp[1000001];

void init(){
    int t=1;
    int i=1;
    while(t<1000000){
        num.EB(t);
        i++;
        t = i*(i+1)*(i+2)/6;
    }
    N = num.size();

    for(i=0;i<N;i++){
        if(num[i]%2==1) num_odd.emplace_back(num[i]);
    }
    N_odd = num_odd.size();
}

void solve(int n){
    for(int i=0;i<=n;i++) dp[i] = INF,dpdp[i]= INF;
    dp[0]=0;
    for(int i=0;i<N;i++){
        for(int j=num[i];j<=n;j++){
            dp[j] = min(dp[j],dp[j-num[i]]+1);
        }
    }


    dpdp[0] = 0;
    for(int i=0;i<N_odd;i++){
        for(int j=num_odd[i];j<=n;j++){
            dpdp[j] = min(dpdp[j],dpdp[j-num_odd[i]]+1);
        }
    }
}

int main(){
    init();
    int n;

    for(int i=0;i<1000001;i++) dp[i] = INF,dpdp[i]= INF;
    dp[0] = 0;
    dpdp[0] = 0;

    solve(1000000);

    while(cin>>n){
        if(n==0) break;
        cout << dp[n] << " " << dpdp[n] << endl;
    }
}

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

const ll INF = 1LL << 60;

string S, T;
int main() {
    cin >> S >> T;
    // if (S.size() < T.size()) {
    //     cout << "UNRESTORABLE" << endl;
    //     return 0;
    // }

    // ? を aで埋める
    // set<string> candi;
    vector<string> v;

    // S の先頭決め打ち
    for (int i = 0; i < S.size(); i++) {
        // T 探索
        bool judge = true;
        for (int j = 0; j < T.size(); j++) {
           if (i + j >= S.size()) {
               judge = false;
               continue;
           }
           if (S[i + j] != T[j] && S[i + j] != '?') {
               judge = false;
               break;
           }
        }
        // cout << judge << endl;
        if (judge) {
            // 先頭
            string tmp = S.substr(0, i); 
            // replace(tmp.begin(), tmp.end(), '?', 'a');

            // 残った ? を aに置き換え
            tmp += T;

            // 後半をくっつける
            string tmp2 = S.substr(tmp.size());
            // replace(tmp2.begin(), tmp2.end(), '?', 'a');
            tmp += tmp2;
            rep(k, tmp.size()) {
                if (tmp[k] == '?') {
                    tmp[k] = 'a';
                }
            }

            // candi.insert(tmp);
            v.push_back(tmp);
        }
    }

    if (v.size() == 0) {
        cout << "UNRESTORABLE" << endl;
    } else {
        sort(v.begin(), v.end());
        // cout << *candi.begin() << endl;
        cout << v[0] << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ar array
#define int long long
#define F(i,a,b) for(i=a;i<b;++i)
#define RF(i,b,a) for(i=b;i>=a;--i)
#define NL cout<<"\n";

typedef long long ll;
typedef long double ld;
const ll mod=1e9+7;
bool comp(ll a,ll b)
{
	return a<b;
}
ll fpow(ll a, ll b) {

	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a);
		a=(a*a);
		b>>=1;
	}
	return res;
}

ll minm(ll a,ll b){
	if(a<b) return a;
	return b;
}

ll maxm(ll a,ll b){
	if(a>b){ return a;}
	else return b;
}

int PHI(int k){
	// This is Euler's Totient Function.
	//This function returns no. of coprime numbers to N in range [1,2,....,N]

	  int ans=k;
	  for(int i=2;i*i<=k;++i){
	  	if(k%i==0){
	  		ans-=ans/i;
	  		while(k%i==0){
	  			k/=i;
	  		}
	  	}
	  }
     if(k>1) ans-=ans/k;
     return ans;


}

const int N=1e5+5;
int dp[N][3];
int a[N],b[N],c[N];
int n;
/*
a->0
b->1
c->2
*/


int rec(int p,int i){

    if(i>=n) return 0;
    if(dp[i][p]!=-1) return dp[i][p];

    if(p==0){
        dp[i][p]=max({dp[i][p], b[i]+rec(1,i+1), c[i]+rec(2,i+1)});

    }

    else if(p==1){
        dp[i][p]=max({dp[i][p],a[i]+rec(0,i+1),c[i]+rec(2,i+1)});

    }
    else
    dp[i][p]=max({dp[i][p] , a[i]+rec(0,i+1) , b[i]+rec(1,i+1) });

    return dp[i][p];



}


void solve(){
  int i;
  cin>>n;
  F(i,0,n){
      cin>>a[i]>>b[i]>>c[i];
      dp[i][0]=dp[i][1]=dp[i][2]=-1;
  }

  int ans=max({ a[0]+ rec(0,1),b[0]+rec(1,1),c[0]+rec(2,1) });
  cout<<ans<<"\n";

}


signed main(void)
{

	fast;

   //#ifndef ONLINE_JUDGE
	//  freopen("input.txt","r",stdin);
	//  freopen("output.txt","w",stdout);
   // #endif

	int test_cases=1;
	//cin>>test_cases;

   while(test_cases--){
   	solve();
   }

}



Measured memory_bytes: 12996
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const ll mod=1000000007;
const ll inf=1e18;
int main(){
  string s,t;
  cin >> s >> t;
  ll k=0;
  map<char,vector<ll>> v;
  for(int i=0;i<s.size();i++){
    v[s[i]].push_back(i);      
  }
  for(int i=0;i<t.size();i++){
    if(v[t[i]].size())k++;
  }
 
  ll l;
 
  if(k!=t.size())cout << -1 << endl;
  else{
    k=-1;
    ll p=0;
    for(int i=0;i<t.size();i++){
      l=lower_bound(v[t[i]].begin(),v[t[i]].end(),k+1)-v[t[i]].begin();
      if(l==v[t[i]].end()-v[t[i]].begin()){
        p++;
        k=v[t[i]][0];
      }
      else{
        k=v[t[i]][l];
      }
    }
 
    cout << p*s.size()+k+1 << endl;
 
  }
 
}

Measured memory_bytes: 4612
def to_bin(n)
  ans = ""
  divisor = 2
  while n != 0 do
    r = n%divisor
    if r == 0
      ans = "0#{ans}"
    else
      ans = "1#{ans}"
      n -= r
    end
    divisor *= -2
  end
  ans.to_i
end

n = gets.to_i
puts to_bin(n)

Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int M = scan.nextInt();

			int[]x = new int[M];
			int[]y = new int[M];

			int[]hako = new int[N];
			Arrays.fill(hako, 1);
			boolean[]red = new boolean[N];
			red[0] = true;

			for(int i = 0;i<M;i++) {
				x[i] = scan.nextInt()-1;
				y[i] = scan.nextInt()-1;

				hako[x[i]]--;
				hako[y[i]]++;

				if(red[x[i]]==true&& red[y[i]]==false) {
					red[y[i]] = true;
				}

				if(hako[x[i]]==0)red[x[i]]=false;


			}

			int count = 0;
			for(int i = 0;i<N;i++) {
				if(red[i])count++;
			}

			System.out.println(count);










		}


	}


}


Measured memory_bytes: 60928
#include <stdio.h>

int main(void){
	int i,n;
	int money = 100000;

	scanf("%d",&n);
	for(i = 0;i < n;i++){
		money += money / 100 * 5;
		if(money % 1000 != 0){
			money = money - money %1000;
			money += 1000;
		}
	}
	printf("%d\n",money);

	return 0;
}

Measured memory_bytes: 1020