akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//def   puts(a) printf("%s\n", a) 文字はこっち
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
//your code here!


int main(void){
    ll N ,M, x[55], y[55], checkx[55], checky[55];
    in2(N, M);
    rep(i,N) in2(x[i], y[i]);
    rep(i,M) in2(checkx[i], checky[i]);
    rep(i,N){
        ll MIN=MOD, mincheck=-1;
        rep(j,M){
            ll d = abs(x[i]-checkx[j]) + abs(y[i]-checky[j]);
            if(d<MIN){
                MIN = d;
                mincheck = j+1;
            }
        }
        put(mincheck);
    }
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))

X = input_one_number()

m = 100

cnt = 0
while True:
	if X <= m:
		print(cnt)
		exit(0)

	m = (m * 1.01)//1
	cnt +=1


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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PRINTIA(a,n) REP(i,n){printf("%d ", *((a)+i));}putchar('\n');
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
void PI() {putchar('\n');}
template<typename... T>
void PI(const int head, T... tail ) {
    printf("%d ", head);
    PI(tail...);
}

#define MAX_N 100005

unordered_set<int> G[MAX_N];
unordered_set<int> leaf;

void delete_node(int v) {
    REPIT(ii, G[v]) {
        G[*ii].erase(v);
    }
    leaf.erase(v);
}

int main()
{
    int N;
    RI(N);
    REP(i, N-1) {
        int a, b;
        RI(a, b);
        G[a].insert(b);
        G[b].insert(a);
    }
    //PN();

    REP(i, 1, N+1) {
        if(G[i].size() == 1) {
            leaf.insert(i);
        }
    }

    while(!leaf.empty()) {
        int v = *(leaf.cbegin());
        leaf.erase(v);

        if(G[v].size() == 0) {
            //PI(11111, v);
            printf("First\n");
            return 0;
        }
        int p = *(G[v].cbegin());
        delete_node(v);

        //PI(p, v);

        REPIT(ii, G[p]) {
            if(leaf.find(*ii) != leaf.end()) {
                //PI(22222, p, v, *ii);
                printf("First\n");
                return 0;
            }
        }
        REPIT(ii, G[p]) {
            if(G[*ii].size() == 2) {
                leaf.insert(*ii);
            }
        }
        delete_node(p);
    }
    printf("Second\n");
    return 0;
}


Measured memory_bytes: 18188
N, K = map(int, input().split())

ans = 0
if K == 0:
    ans = N * N
else:
    for b in range(1, N + 1):
        div, mod = divmod(N, b)
        ans += max(0, b - K) * div
        ans += max(0, mod - K + 1)

print(ans)


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

using namespace std;

using vi = vector<int>;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  IN(N);

  int sum = 0;
  vi S;
  REP(i, N) {
    IN(s);
    S.push_back(s);
    sum += s;
  }
  SORT(S);
  if (sum % 10 != 0)
    OUT(sum);
  else {
    for (const auto& s : S) {
      if (s % 10 != 0) {
        OUT(sum - s);
        return 0;
      }
    }
    OUT(0);
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define INF 1e+9
#define PI acos((long double)(-1))
#define TAU PI * 2
#define EPS 0.00000001
const ll MOD = 998244353;

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    
    // 時針の角度を求める
    ld alpha = ((ld)h * 60.0 + (ld)m) / 720.0;
    
    // 短針の角度を求める
    ld beta = ((ld)m / 60.0);
    
    // 時針と短針の角度を求める
    ld theta = alpha - beta;
    
    ld angle = theta * 2 * PI;
    ld ans = sqrt((a * a + b * b) - (2 * a * b * cos(angle)));
    printf("%.12Lf\n", ans);
}


Measured memory_bytes: 4100
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)


int main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif // LOCAL
	string s, t;
	cin >> s >> t;
	int len = s.size();
	for (int i = 0; i < len; ++i) {
		string n = s.substr(len - i) + s.substr(0, len - i);
		if (n == t) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
    int i,n,m[100000];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    	scanf("%d",&m[i]);
    for(i=n-1;i>=0;i--){
    	if(i!=n-1)printf(" ");
    	printf("%d",m[i]);
	}
    printf("\n");	
	return 0;
}


Measured memory_bytes: 2104
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, k, x, y ] :: [Int] <- map read . lines <$> getContents
	let
		a = min k n
		b = max 0 $ n - k
	print $ a * x + b * y


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

int main () {

    int N;
    scanf("%d", &N);

    double A[N];
    double ans = 0.0;
    for (int i = 0; i < N; i++) {
        scanf("%lf", &A[i]);
        ans += 1/A[i];
    }
    printf("%.8lf\n", 1.0/ans);

    return 0;
}


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

int n, a[100010], dep[100010];
vector<int> child[100010];

int f(int x){
	vector<int> v;
	for(auto &i : child[x]){
		v.push_back(f(i));
	}
	sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int ret = 0, cnt = 1;
    for(auto &i : v){
		ret = max(ret, cnt + i);
		cnt++;
    }
    return ret;
}

int main(){
	scanf("%d", &n);
	for(int i = 2; i <= n; i++) scanf("%d", a + i);
	for(int i = 2; i <= n; i++) child[a[i]].push_back(i);
	printf("%d\n", f(1));
	return 0;
}


Measured memory_bytes: 13952
#include<iostream>
using namespace std;
long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long C(int N,int K)
{
	long x=1,y=1;
	for(int i=1;i<=K;i++)
	{
		x=x*(N-i+1)%mod;
		y=y*i%mod;
	}
	return x*power(y,mod-2)%mod;
}
main()
{
	long N,A,B;
	cin>>N>>A>>B;
	long ans=power(2,N);
	ans-=C(N,A);
	ans-=C(N,B);
	ans--;
	cout<<(ans%mod+mod)%mod<<endl;
}


Measured memory_bytes: 256
S = input()

if S == 'SAT':
    print(1)
elif S == 'FRI':
    print(2)
elif S == 'THU':
    print(3)
elif S == 'WED':
    print(4)
elif S == 'TUE':
    print(5)
elif S == 'MON':
    print(6)
else:
    print(7)


Measured memory_bytes: 2940
n=int(input())
a,b=map(int,input().split())
q1,q2,q3=0,0,0
for p in map(int,input().split()):
    if p<=a:
        q1+=1
    elif p>b:
        q3+=1
    else:
        q2+=1
print(min(q1,q2,q3))

Measured memory_bytes: 3060
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#define ll long long
#define ull unsigned long long
#define FOR(m,s,n,u) for(int m=s; m<n; m+=u)
#define ROF(m,s,n,u) for(int m=n; m>=s; m-=u)
#define FORb(m,s,n,u,k) for(int m=s; m<n&&k; m+=u)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define PI 3.1415926535897932384626433832795028841971
#define INF 0x3f3f3f3f
#define EPS 1e-9
#define MOD(x) ((x%mod)+mod)%mod
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define vi vector<int>
#define pii pair<int,int>

using namespace std;

int main(){
sync;
int n; cin>>n; 
int pasos; cin>>pasos;
int arr[n+1];
FOR(i,1,n+1,1)cin>>arr[i];

int DP[n+1];
FOR(i,0,n+1,1)DP[i]=INF;
DP[1] = 0;

FOR(i,2,n+1,1)ROF(j,max(1,i-pasos),i-1,1)DP[i] = min(DP[i] , DP[j] + abs(arr[i]-arr[j]));

cout<<DP[n]<<endl;

return 0;
}

Measured memory_bytes: 4388
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>


using namespace std;

int main()
{
	long long n;
	string str;
	char input[100001];
	long long cnt[26] = { 0, };
	long long i, j;
	long long prod = 1;

	scanf("%lld %s", &n, input);

	str = input;

	for (i = 0; i < n; i++)
	{
		cnt[str[i] - 'a']++;
	}

	for (i = 0; i < 26; i++)
	{
		prod = (prod*(cnt[i] + 1)) % 1000000007;
	}

	printf("%lld\n", prod - 1);

	return 0;
}

Measured memory_bytes: 384
def lower_bound(arr, v)
  l = -1
  r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    if arr[m][0] < v then l = m
    else r = m
    end
  end
  r
end

loop do
  n, q = gets.split.map(&:to_i)
  break if n == 0
  era = {}
  n.times do
    name, ey, wy = gets.split
    era[wy.to_i] = [name, ey.to_i]
  end
  era = era.sort
  q.times do
    y = gets.to_i
    x = lower_bound(era, y)
    if x != n && era[x][0] - y < era[x][1][1]
        puts "#{era[x][1][0]} #{era[x][1][1] - (era[x][0] - y)}"
    else puts "Unknown"
    end
  end
end

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

int n,s;
int dfs(int p,int t,int r){
    if(p==10){
        if(t==0&&r==s)return 1;
        return 0;
    }
    return dfs(p+1,t,r)+dfs(p+1,t-1,r+p);
}
int main(){
    while(cin>>n>>s,n||s)cout<<dfs(0,n,0)<<endl;
    return 0;
}

Measured memory_bytes: 1160
var
s:string;
x:0..5;
begin
readln(s);
x:=0;
if s[1]='2' then inc(x);
if s[2]='2' then inc(x);
if s[3]='2' then inc(x);
if s[4]='2' then inc(x);
writeln(x);
end.

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
const int MOD = 1000000007;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  string s1, s2; cin >> s1 >> s2;
  long long ans;
  bool tate;
  int next = 0;
  if (s1[next] == s2[next]) {
    ans = 3;
    tate = true;
    ++next;
  } else {
    ans = 6;
    tate = false;
    next += 2;
  }
  while (next < n) {
    if (s1[next] == s2[next]) {
      if (tate) { // ||
        (ans *= 2) %= MOD;
      } else { // =|
        tate = true;
      }
      ++next;
    } else {
      if (tate) { // |=
        (ans *= 2) %= MOD;
        tate = false;
      } else { // ==
        (ans *= 3) %= MOD;
      }
      next += 2;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
using namespace std;

int main(){
  int n;
  cin >> n;
  int d[n];
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  sort(d,d+n);
  cout << d[n/2]-d[n/2-1] << endl;
  return 0;
}



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

bool B[1000000];

int main(){
    int n;
    cin>>n;
    vector<int> D(n);
    for(int i=0;i<n;i++) cin>>D[i];
    for(int i=0;i<n;i++){
        int num=0;
        for(int j=i;j<n;j++){
            num=num*10+D[j];
            if(num>=1000000) break;
            B[num]=true;
        }
    }
    for(int i=0;i<10000;i++){
        if(!B[i]){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3996
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
void NO() {
	puts("-1");
	exit(0);
}
int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	bool rev;
	if (rev = a < b)
		swap(a, b);
	vector<int> v;
	for (int i = n - a + 1; i <= n; ++i)
		v.push_back(i);
	if (b > 1) {
		--b;
		int rem = (n - a) / b;
		int p = (n - a) % b;
		if (!rem)
			NO();
		int l = n - a;
		while (v.size()<n) {
			int cur = rem + (p > 0);
			if (cur > a)
				NO();
			--p;
			for (int i = l - cur + 1; i <= l; ++i)
				v.push_back(i);
			l -= cur;
		}
	}
	if (v.size() != n)
		NO();
	if (rev)
		reverse(v.begin(), v.end());
	for (auto x : v)
		printf("%d ", x);
	puts("");
	return 0;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define inf (0x3f3f3f3f)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

template<class T>inline T read(T &_) {
	T __ = getchar(), ___ = 1; _ = 0;
	for (; !isdigit(__); __ = getchar()) if (__ == '-') ___ = -1;
	for (; isdigit(__); __ = getchar()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
	return _ *= ___;
}

template<class T>inline bool chkmax(T &_, T __) { return _ < __ ? _ = __, 1 : 0; }
template<class T>inline bool chkmin(T &_, T __) { return _ > __ ? _ = __, 1 : 0; }

inline void proStatus() {
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>());
}

int main() {

	int a, b, c; 

	cin >> a >> b >> c; 
	printf("%d\n", min(a + b + 1, c) + b);

	return 0;
}


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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = sc.nextInt();
	static int K = sc.nextInt();
	static int[] h = new int[N];
	static {
		Arrays.setAll(h, i->sc.nextInt());
	}
	public static void main(String[] args) {
		Arrays.sort(h);
		int ans = h[K-1] - h[0];
		for (int i = 0; i <= N - K; i++) {
			ans = Math.min(ans, h[i+K-1] - h[i]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 61704
//配るDPにしたよ
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

long long N, K;
long long h[100110];
long long dp[100110];
const long long inf = 1 << 30;

int main() {
    scanf("%Ld %Ld", &N, &K);
    for (int i = 0; i < N; i++) scanf("%Ld", & h[i]);
    for (int i = 0; i < N; i++) dp[i] = inf;
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        for(int j = 0; j < K+1; j++) {
            chmin(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
        }
    }

    printf("%Ld\n", dp[N-1]);
    return 0;
}

Measured memory_bytes: 1792
package main

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

func main() {
	n := readInt()

	if n%2 == 1 {
		fmt.Println(0)
		return
	}

	ans := 0
	t := 10
	for t <= n {
		ans += n / t
		t *= 5
	}
	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);       
		int n = sc.nextInt();
		int k = sc.nextInt();
        double ans = 0;
        for(int i=1;i<=n;i++){
          int count = n;
          int point = i;
          while(point<k){count*=2;point*=2;}
          double ans2 = 1.0/count;ans+=ans2;}        
	    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll N;
    cin >> N;

    vector<ll> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }


    ll ret = 1;
    for(int i = 0; i < N; i++) {
        ll ten18 = 1000000000000000000;//pow(10, 18);
        // cout << ret <<"," << A[i] << "," <<  (ten18/A[i] + 1) << endl;
        // cout << ret*A[i] <<  "aaa," <<  ten18 <<endl;
        if(ret > ((ten18/A[i] + 1)) || ret*A[i] > ten18 ) {
            cout << -1 << endl;
            return 0;
        }
        else ret *= A[i];
    }

    cout << ret << endl;

    
}



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

int main()
{
  string S ;
  cin>>S ;
  
  int SIZE=S.size() ;
  if(SIZE==2) cout<<S<<endl ;
  else for(int i=SIZE-1;i>=0;i--) cout<<S.at(i) ;
  
  return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
        try (final Scanner sc = new Scanner(System.in)) {
            final String s = sc.next();
            if (s.length() == 1) {
                System.out.println(0);
            } else {
                final String zeroOne = generateMask(s.length(), '0');
                final String oneZero = generateMask(s.length(), '1');
                System.out.println(Math.min(calc(s, zeroOne), calc(s, oneZero)));
            }
        }
    }

    private static int calc(final String s, final String mask) {
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != mask.charAt(i)) {
                count += 1;
            }
        }
        return count;
    }

    static String generateMask(final int size, final char first) {
        final char[] buf = new char[size];
        buf[0] = first;
        for (int i = 1; i < size; i++) {
            buf[i] = buf[i - 1] == '0' ? '1' : '0';
        }
        return new String(buf);
    }
}


Measured memory_bytes: 29464
N = int(input())
D = [int(x) for x in input().split()]
new_l = [0 for n in range(max(D)+1)]
for n in range(N):
    new_l[D[n]] += 1
if new_l[0] == 1 and D[0] == 0:
    res = 1
    for n in range(max(D)):
        res *= pow(new_l[n],new_l[n+1],998244353)
    print(res%998244353)
else:
    print(0)


Measured memory_bytes: 13908
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const int dy[] = { 1,0,-1,0 }, dx[] = { 0,1,0,-1 };
pair<int, int> p;

int main() {
	while (1) {
		int col, row, k, dir = 0;
		string str;
		cin >> col >> row;
		if (col + row == 0)break;
		p.first = 1; p.second = 1;
		for (;;) {
			cin >> str;
			char c = str[0];
			if (c == 'S')break;
			else if (c == 'F') {
				cin >> k;
				p.first += k*dx[dir];
				p.second += k*dy[dir];
				p.first = max(1, p.first);
				p.second = max(1, p.second);
				p.first = min(col, p.first);
				p.second = min(row, p.second);
			}
			else if (c == 'B') {
				cin >> k;
				p.first -= k*dx[dir];
				p.second -= k*dy[dir];
				p.first = max(1, p.first);
				p.second = max(1, p.second);
				p.first = min(col, p.first);
				p.second = min(row, p.second);
			}
			else if (c == 'R') {
				dir = (dir + 1) % 4;
			}
			else {
				dir = (dir + 3) % 4;
			}
		}
		cout << p.first << " " << p.second << endl;
	}
}

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

int A,B,C,D;

int main()
{
	cin >> A >> B >> C >> D;
	while(1)
	{
		C -= B;
		if(C <= 0)
		{
			cout << "Yes";
			return 0;
		}
		
		A -= D;
		if(A <= 0)
		{
			cout << "No";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int a[110];
int main(){
  //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    int N;
    cin>>N;
    int tot=0;
    int sol=1000000000;
    for(int i=0;i<N;i++){
      cin>>a[i];
      tot+=a[i];
    }
    int somma=0;
    for(int i=0;i<N;i++){
      somma+=a[i];
      int o=abs(somma-(tot-somma));
      if(o<sol)sol=o;

    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 256
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool cmp(int a,int b) {return a>b;}
int fast_pow(int b,int p,int m=1){
     if(p==0) return 1;
     if(p==1) return b;
    int res=fast_pow(b,p/2,m);  res=(res*res)%m;
    if(p%2==0) return res; else return  (b*res)%m;
}
int mmi(int a,int m){ return fast_pow(a,m-2,m);}

int a[200001],b[200001];

int32_t main()
{
    FIO
    int x,y,z; cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<"\n";
    return 0;
}

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

int main(){
    int n, l;
    cin >> n >> l;
    int sum, eat;
    sum = 0;
    eat = l;
    rep(i, n){
        sum += l+i;
        if (abs(eat) > abs(l+i)){
            eat = l+i;
        }
    }
    cout << sum - eat <<endl;
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
    ll bBeforeSum[1000005];
    ll bsum[1000005];
    ll csum[1000005];
    ll bBefore[1000005];

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    string s;
    cin >> s;
    s = "#" + s;
    int q;
    cin >> q;
    bsum[0] = 0;
    csum[0] = 0;
    if(s[0] == 'M') bsum[0]++;
    if(s[0] == 'C') csum[0]++;
    for(int i = 1; i <= n; i++){
        bsum[i] = bsum[i - 1];
        csum[i] = csum[i - 1];
        if(s[i] == 'M')bsum[i]++;
        if(s[i] == 'C')csum[i]++;
    }
    //cout << "a" << endl;
    int now = 0;
    bBefore[0] = 0;
    bBeforeSum[0] = 0;
    if(s[0] == 'M') now++;
    for(int i = 1; i <= n; i++){
        //cout << i << endl;
        bBefore[i] = 0;
        if(s[i] == 'M'){
            now++;
        }
        if(s[i] == 'C'){
            bBefore[i] = now;
        }
        bBeforeSum[i] = bBeforeSum[i - 1] + bBefore[i];
    }
    for(int i = 0; i <= n; i++){
        //cout << i << " BSum " << bsum[i] << " bBefore " << bBefore[i] << " " << endl;
    }
    for(int times = 0; times < q; times++){
        int k;
        cin >> k;
        ll ans = 0;
        for(int index = 0; index <= n; index++){
            if(s[index] != 'D') continue;
            int end = min(index + k - 1, n);
            ll NC = csum[end] - csum[index - 1];
            //cout << index << " " << (bBeforeSum[end] - bBeforeSum[index - 1]) - NC * bsum[index - 1] << endl;
            ans += (bBeforeSum[end] - bBeforeSum[index - 1]) - NC * bsum[index - 1];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 32560
#include <stdio.h>

int main(void)

{
	
	int w,a,b;
	
	scanf("%d%d%d",&w,&a,&b);
	
	if(b-(a+w)>0){
		printf("%d\n",b-(a+w));
	}else if(a<=b){
		printf("%d\n",0);
	}else if(a-(b+w)>0){
		printf("%d\n",a-(b+w));
	}else{
		printf("%d\n",0);
	}
	
	return 0;
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	string s;
	cin >> s;
	int count = 0;
	rep(i, s.size())
	{
		if (s[i] == '-')
			count++;
	}
	if (count == 1)
	{
		if (a + b + 1 == s.size())
		{
			if (s[a] == '-')
			{
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<algorithm>
#define NUM 100000
using namespace std;

struct discount{
  int x;
  int y;
  int c; //割り引かれる値段
};

int main(){
  int A,B,M;
  discount dis[NUM];
  int value[NUM],a[NUM],b[NUM];
  int ma,mb,mv,ans;
  /*入力*/
  cin >> A;
  cin >> B;
  cin >> M;
  for(int i = 0;i < A;i++){
    cin >> a[i];
    if(i == 0){
      ma = a[i];
    }
    else{
      ma = min(ma,a[i]);
    }
  }
  for(int i = 0;i < B;i++){
    cin >> b[i];
    if(i == 0){
      mb = b[i];
    }
    else{
      mb = min(mb,b[i]);
    }
  }

  int count = 0;

  for(int i = 0;i < M;i++){
    cin >> dis[i].x;
    cin >> dis[i].y;
    cin >> dis[i].c;   
  }

  for(int i = 0;i < M;i++){   
     value[i] = a[dis[i].x - 1] + b[dis[i].y - 1] - dis[i].c;
    if(i == 0){
      mv = value[i];
    }
    else{
      mv = min(mv,value[i]);
    }
  }

  ans = min(ma + mb,mv);

  cout << ans << endl;

  return 0;
}
  
  
  
  


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

using namespace std;

int main()
{
    char c;

    cin >> c;

    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }

    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, A, B;
  string S;
  cin >> N >> A >> B >> S;
  int cnta = 0, cntb = 0;
  REP(i,N) {
    if(S[i] == 'a') {
      if(cnta + cntb < A + B) {
        cout << "Yes" << endl;
        cnta++;
      }else{
        cout << "No" << endl;
      }
    }else if(S[i] == 'b') {
      if(cnta + cntb < A + B && cntb < B) {
        cout << "Yes" << endl;
        cntb++;
      }else{
        cout << "No" << endl;
      }
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

int N;

int main(){
    cin>>N;
    repi(i,1,10){
        if(N%i==0){
            if(N/i<10){
                out("Yes");
                return 0;
            }
        }
    }
    out("No");
    
    
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  char a, b; cin >> a >> b;
  if (a > b) {
    cout << ">" << endl;
  } else if (a < b) {
    cout << "<" << endl;
  } else {
    cout << "=" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  rep2(i, A, B + 1){
    if(i % K == 0){
      cout << "OK" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  string s, t;
  int hit, blow;

  while (true) {
    cin >> s >> t;
    if (s == "0")
      break;
    hit = blow = 0;
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (i == j && s[i] == t[j])
          hit++;
        else if (s[i] == t[j])
          blow++;
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int n;
	int[][] t;
	int[] dp;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt();
			if( n == 0 ) break;
			t = new int[n][n+1];
			for(int i=0;i<n;i++) for(int j=0;j<=n;j++) {
				t[i][j] = sc.nextInt();
			}
			
			dp = new int[1<<n];
			fill(dp, -1);
			System.out.println(solve( (1<<n)-1 ));
			
		}
	}
	
	int solve(int S) {
		if( dp[S] >= 0 ) return dp[S];
		if( S == 0 ) return dp[S] = 0;
		int min = INF;
		for(int i=0;i<n;i++) if( ((S>>i)&1) == 1 ) {
			int v = t[i][0];
			for(int j=0;j<n;j++) if( i!=j && ((S>>j)&1) == 1 ){
				v = min(v, t[i][j+1]);
			}
			
			min = min(min, v + solve(S-(1<<i)));
		}
		
		return dp[S] = min;
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 15000
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0)->ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
int fact[int(2e5+1)];
int inv[int(2e5+1)];
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA  
    int n;cin>>n;
    cout<<(n*(n+1))/2<<endl;
   
   


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 1e9+7
#define N 400001
#define MAX_V 400010
#define vec vector<int>
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<ll,int,custom_hash>
struct pair_hash
{
    template<class T1,class T2>
    size_t operator() (const pair<T1,T2> &p)const{
        return hash<T1>()(p.first)^hash<T2>()(p.second);
    }
};


main(){
    int n=in();
    int p[N];
    rep(i,n)p[i]=in();
    sort(p,p+n);
    int ans=0;
    rep(i,n-1){
        ans+=p[i];
    }
    cout<<ans+p[n-1]/2;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void){
	const char *table[] ={
		"afkpuz",
		"bglqv.",
		"chmrw?",
		"dinsx!",
		"ejoty "
	};

	while( true ){
		bool bNA = false;
		string s;

		cin >> s;

		if( cin.eof() )
			break;

		if( s.length() % 2 == 1 ){
			bNA = true;
			goto NA;
		}
		for(unsigned int l = 0; l < s.length(); l += 2){
			int i = s[l+1]-'0'-1;
			int j = s[l]-'0'-1;
			if( !(0 <= i && i <= 4) || !(0 <= j && j <= 5) ){
				bNA = true;
				goto NA;
			}
		}
NA:;
		if( bNA ){
			cout << "NA\n";
			continue;
		}

		for(unsigned int l = 0; l < s.length(); l += 2){
			int i = s[l+1]-'0'-1;
			int j = s[l]-'0'-1;
			cout << table[i][j];
		}
		cout << '\n';
	}

	return 0;
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 998244353;

lnt powmod(lnt a, lnt p, lnt m){
	lnt res = 1, tmp = a;
	while(p != 0){
		if(p % 2) res = (res*tmp) % m;
		tmp = (tmp*tmp) % m;
		p /= 2;
	}
	return res;
}

lnt dp[3010][3010];

int main(){
	summon_tourist;

	lnt N, S, A[3000]; cin >> N >> S;
	REP(i, N) cin >> A[i];
	lnt ans = 0;
	dp[0][0] = 1;
	REP(i, N){
		REP(j, S){
			if(j + A[i] <= S){
				dp[i+1][j+A[i]] += dp[i][j];
				dp[i+1][j+A[i]] %= MOD;
			}
			dp[i+1][j] += dp[i][j]*2;
			dp[i+1][j] %= MOD;
		}
		ans += dp[i+1][S] * powmod(2, N-i-1, MOD) % MOD;
		ans %= MOD;
	}
	cout << ans << ln;
}

Measured memory_bytes: 74180
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, a: "List[int]"):
    a.sort()
    ret = a[-1] - a[0]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
string s,t;
int ans = 0;

cin >> s >> t;

rep(i,3){
    if (s[i] == t[i])
    {
        ans++;
    }
    

}
cout << ans << endl;



//////////////////////////////////////////////////////
return 0;}

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

int main() 
{
    list<int> lst;

    int n=0, x=0;
    char c[100];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s %d", c, &x);
        if (c[0] == 'i') lst.push_front(x);
        else if (c[6] == 'F') lst.pop_front();
        else if (c[6] == 'L') lst.pop_back();
        else 
        {
            for (auto itr = lst.begin(); itr != lst.end(); ++itr) 
            {
                if (*itr == x) 
                {
                    lst.erase(itr);
                    break;
                }
            }
        }
    }

    for (auto itr = lst.begin(); itr != lst.end(); ++itr)
    {
        if (itr == lst.begin()) printf("%d", *itr);
        else printf(" %d", *itr);
    }
    printf("\n");
}


Measured memory_bytes: 34396
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String s = input.next();
		long[] dp = new long[2019]; //stores remainder from 0-2018
		int cur = Integer.parseInt(s.substring(s.length()-1,s.length()));
		dp[cur]++;
		dp[0]=1;
		long cnt = 0;
		long pow_10 = 10;
		long div = 2019;
		//(2019 does not share any divisors with 10 (the base), 
		//therefore storing remainder trick works.
		for (int i = s.length()-2; i >= 0; i--) {
			long digit = Long.parseLong(s.substring(i,i+1));
			cur+=digit*pow_10;
			pow_10*=10;
			pow_10%=div;
			cur%=div;
			dp[cur]++;
		}
		for (int i = 0; i < 2019; i++) {
			cnt+=(dp[i])*(dp[i]-1)/2;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 40684
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a <= c && c <= b)
    {
        Yes(true);
    }else
    {
        Yes(false);
    }
}


Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define M (int)(1e9 + 7)
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
int power(int x, int y){
    x %= M;
    int ans = 1;
    while(y){
        if(y & 1)
            ans = (ans * x) % M;
        y >>= 1LL;
        x = (x * x) % M;
    }
    return ans;
}
int add(int a, int b){
    return((a % M + b % M) % M);
}
int sub(int a, int b){
    return((a % M - b % M + M) % M);
}
int mul(int a, int b){
    return(((a % M) * (b % M)) % M);
}
int divi(int a, int b){
    return(mul(a, power(b, M - 2)) % M);
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>k;
	vector<int> v(n),inv(n),arBade(n);
	for(auto &x : v){
		cin>>x;
	}
	for(int i =0;i<n;i++){
		int cnt = 0;
		for(int j=i-1;j>=0;j--){
			if(v[i]<v[j]){
				cnt++;
			}
		}
		inv[i] = cnt;
	}
	for(int i=0;i<n;i++){
		int cnt = 0;
		for(int j=0;j<n;j++){
			if(v[j]>v[i]){
				cnt++;
			}
		}
		arBade[i] = cnt;
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		int x = add(mul(arBade[i],divi(mul((k-1),k),2)) , mul(inv[i],(k)));
		ans=add(x,ans);
	}
	cout<<ans;
    return 0;
}
//.........

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

typedef long long ll;

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

    int n, h;
    cin>>n;
    int prev; 
    cin>>prev;
    bool isTrue = true;
    
    for (int i=1;i<n;++i){
        cin>>h;
        if (h-1 >= prev) h--;
        else if (h != prev) isTrue = false;
    
        prev = h;
    }
    if (isTrue) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256