akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    string S;
    cin >> S;
    int K = S.size();
    int D;
    cin >> D;
    ll mod = 1e9+7;
    
    vector<vector<vector<ll>>> dp(K+1, vector<vector<ll>>(D, vector<ll>(2, 0)));
    dp[0][0][1] = 1;
    
    for (int i = 1; i <= K; i++) {
        int d = (int)(S[i-1]-'0');
        for (int j = 0; j < D; j++) {
            dp[i-1][j][1] %= mod;
            dp[i-1][j][0] %= mod;
            dp[i][(j+d)%D][1] = dp[i-1][j][1];
            for (int k = 0; k <= 9; k++) {
                if (k < d) dp[i][(j+k)%D][0] += dp[i-1][j][1];
                dp[i][(j+k)%D][0] += dp[i-1][j][0];
            }
        }
    }
    
    ll ans = (dp[K][0][0] + dp[K][0][1] - 1) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 58472
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String [] letters = new String[3];

        for (int i = 0; i < 3; i++) {
            letters[i] = input.readLine();
        }
        int current = 0;
        int [] positions = new int[3];
        while (true){
            if (positions[current] == letters[current].length()){
                System.out.println((char)(current + 'A'));
                break;
            }
            current = letters[current].charAt(positions[current]++) - 'a';

        }
    }
}



Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

ll x;
ll n = 18;
ll now;
vector<ll> vs, ve, vl;
ll base;

int main()
{
    scanf("%lld", &x);
    x--;
    for(base = 0; ; base++)
    {
        if((1 << (base + 1)) - 1 > x)
        {
            break;
        }
    }
    now = (1 << (base)) - 1;
    for(ll i = 1; i <= base; i++)
    {
        vs.push_back(i), ve.push_back(i + 1), vl.push_back(0);
        vs.push_back(i), ve.push_back(i + 1), vl.push_back((1 << (i - 1)));
    }
    for(ll i = base; i >= 1; i--)
    {
        if(x - now >= (1 << (i - 1)))
        {
            vs.push_back(i);
            ve.push_back(base + 1);
            vl.push_back(now + 1);
            now += (1 << (i - 1));
        }
    }
    printf("%lld %lld\n", base + 1, (ll)vs.size());
    for(ll i = 0; i < vs.size(); i++)
    {
        printf("%lld %lld %lld\n", vs[i], ve[i], vl[i]);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		long[] list = new long[n];
		long sum = 0;
		for (int i=0; i<n; ++i) {
			long a = s.nextLong();
			list[i] = a;
			sum += a;
		}
		long snuke_ = sum;
		long raccoon = 0;
		long min = Long.MAX_VALUE;
		for (int i=n-1; i>0; --i) {
			long a = list[i];
			snuke_ -= a;
			raccoon += a;
			min = Math.min(min, Math.abs(snuke_-raccoon));
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 65504
input_= list(map(int, input().split()))
timeofholiday=input_[0]
sum=0
homework_num=input_[1]
que=list(map(int, input().split()))
for i in que:
  sum+=i
  
if sum > timeofholiday:
  print("-1")
else:
  print(timeofholiday-sum)

Measured memory_bytes: 9992
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}

int solve(){
    double l; cin >> l;
    double ans = 0;
    for(double x = 10e-6; x <= l/3; x += 10e-6){
        chmax(ans,x*x*(l-x*2));
    }
    cout << ans << endl;

    return 0;
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int z = sc.nextInt();
        int w = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
        }
        if (n == 1) {
            System.out.println(Math.abs(w - a.get(0)));
            return;
        }
        int ans1 = Math.abs(a.get(n - 2) - a.get(n - 1));
        int ans2 = Math.abs(w - a.get(n - 1));
        System.out.println(Math.max(ans1, ans2));
    }
}


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

using namespace std;

int minn[100000];

int recurse(int h[], int i, int n, int K){
    if(minn[i]!=-1){
        return minn[i];
    }
    int limit = i+K>=n-1?n-1:i+K;
    int mina = INT32_MAX;
    for(int j=i+1; j<=limit; j++){
    	mina = min(mina, (abs(h[j]-h[i])+recurse(h, j, n, K)));
    }
    minn[i] = mina;
    return minn[i];
}

int main(void){
    int n, K;
    cin >> n >> K;
    int h[n];
    for(int i=0; i<n; i++){
        int hi;
        cin >> hi;
        h[i] = hi;
        minn[i]=-1;
    }
    minn[n-1] = 0;
    cout << recurse(h, 0, n, K);
    return 0;
}


Measured memory_bytes: 10368
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        w: u32,
        p: [(u32, usize); n],
    }
    let m = 1000 * n;
    let mut dp = vec![w + 1; m + 1];
    dp[0] = 0;
    for &(w, v) in &p {
        for j in (v..(m + 1)).rev() {
            dp[j] = std::cmp::min (dp[j], dp[j - v] + w);
        }
    }
    let mut ans = m;
    while dp[ans] > w {
        ans -= 1;
    }
    println! ("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int a[100010];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    std::priority_queue<int> que;
    for (int i = 0; i < n; i++)
    {
        que.push(a[i]);
    }
    for (int i = 0; i < m; i++)
    {
        int tmp;
        tmp = que.top();
        que.pop();
        tmp = tmp / 2;
        que.push(tmp);
    }
    ll res = 0;
    while (!que.empty())
    {
        res += (ll)que.top();
        que.pop();
    }
    cout << res << "\n";
    
    


}

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

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] line = Console.ReadLine().Split(' ');
		int N = int.Parse(line[0]);
		int M = int.Parse(line[1]);

		long[] Hn = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

		//バケツ（良い展望台として初期化）
		bool[] notGood = new bool[N];

		//消去法
		for(int i=0; i<M; i++){
				string[] line1 = Console.ReadLine().Split(' ');
				int Ai = int.Parse(line1[0]);
				int Bi = int.Parse(line1[1]);

				//より高くない方をtrueにする
				if(Hn[Ai-1] < Hn[Bi-1]){
						notGood[Ai-1] = true;
				}
				else if(Hn[Ai-1] > Hn[Bi-1]){
						notGood[Bi-1] = true;
				}
				//同じ高さの場合は、どちらもnotGood
				else{
						notGood[Ai-1] = true;
						notGood[Bi-1] = true;
				}
		}

		//カウント
		int cnt = 0;
		foreach(bool NG in notGood){
				if(!NG){
						cnt ++;
				}
		}

		Console.WriteLine(cnt);

	}
}



Measured memory_bytes: 33648
#include<bits/stdc++.h>
#define eps (1e-10)
using namespace std;
class Point
{
	public:
	double x,y;
	Point(double _x=0,double _y=0):x(_x),y(_y){}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
};
bool solve1(Point a,Point b)
{
	double f=a.x*b.x+a.y*b.y; 
	if(fabs(f-0.0)<eps) return true;
	else return false;
}
bool solve2(Point a,Point b)
{
	double f=a.x*b.y-a.y*b.x;
	if(fabs(f-0.0)<eps) return true;
	else return false;
}
int main()
{
	int T;scanf("%d",&T);
	while(T--){
		double p1_x,p1_y,p2_x,p2_y,p3_x,p3_y,p4_x,p4_y;
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&p1_x,&p1_y,&p2_x,&p2_y,&p3_x,&p3_y,&p4_x,&p4_y);
		Point a1(p1_x,p1_y),a2(p2_x,p2_y),b1(p3_x,p3_y),b2(p4_x,p4_y);
		if(solve1(a1-a2,b1-b2)) printf("1\n");
		else if(solve2(a1-a2,b1-b2)) printf("2\n");
		else printf("0\n");
		
	}
	return 0;
}


Measured memory_bytes: 3236
#include<stdio.h>

int main(void)
{
    int x,i,k,s;

    scanf("%d",&x);
    for(k=1;k<=x;k++){
        printf("Case %d:\n",k);
        scanf("%d",&s);
        for(i=0;i<10;i++){
            s*=s;
            s/=100;
            s%=10000;
            printf("%d\n",s);
        }
    }
    return 0;
}

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

int main(){
  int N,S1=0,S2=0,ans=100000000;
  cin>>N;
  vector<int> W(N);
  
  for(int i=0;i<N;i++){
    cin>>W.at(i);
    S1+=W.at(i);
  }
  
  for(int i=0;i<N;i++){
    S1-=W.at(i);
    S2+=W.at(i);
    ans=min(ans,abs(S1-S2));
    if(S1<S2){break;}
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    int n = s.size();
    rep(i, n) cin >> s[i];

    rep(i, n) {
        cout << s[i] << endl;
        cout << s[i] << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

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

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

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << (a - c) * (b - d) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct bian
{
	int nxt,to;
}bi[200020];
int n,head[100010],num,d[100010],ans[100010],cur[100010],p;
bool leaf[100010];
inline void add(int from,int to){bi[++num]=bian{head[from],to};head[from]=num;}
void dfs(int v,int fa)
{
	int cnt=0,s=0;
	for(int i=head[v],u;i;i=bi[i].nxt)
	{
		u=bi[i].to;
		if(u==fa)continue;
		if(leaf[u])++cnt;
		else s=u;
	}
	if(!s)
	{
		for(int i=1;i<=cnt-1;++i)cur[p+i]=p+i+1;
		cur[p+cnt]=p+1;
		cur[p+cnt+1]=p+cnt+1;
	}
	else
	{
		for(int i=1;i<=cnt;++i)cur[p+i]=p+i+1;
		cur[p+cnt+1]=p+1;
		p+=cnt+1;
		dfs(s,v);
	}
}
void check(int v)
{
//	printf("%d\n",v);
	p=0;dfs(v,0);
//	for(int i=1;i<=n;++i)printf("%d ",cur[i]);printf("\n");
	bool ok;
	if(!ans[1])ok=1;
	else
	{
		for(int i=1;i<=n;++i)
			if(cur[i]!=ans[i])
			{
				ok=cur[i]<ans[i];
				break;
			}
	}
	if(ok)memcpy(ans,cur,sizeof(cur));
}
int main()
{
	scanf("%d",&n);
	if(n==2)return printf("1 2"),0;
	int x,y;
	for(int i=1;i<n;++i)
	{
		scanf("%d %d",&x,&y);
		add(x,y),add(y,x);++d[x],++d[y];
	}
	for(int i=1;i<=n;++i)if(d[i]==1)leaf[i]=1;
	for(int i=1;i<=n;++i)if(leaf[i])--d[bi[head[i]].to];
	for(int i=1;i<=n;++i)
		if(!leaf[i]&&d[i]>2)return printf("-1"),0;
	for(int i=1;i<=n;++i)
		if(!leaf[i]&&d[i]<=1)
		{
			check(i);
			for(int j=head[i];j;j=bi[j].nxt)
				if(leaf[bi[j].to]){check(bi[j].to);break;}
		}
	for(int i=1;i<=n;++i)printf("%d ",ans[i]);
	return 0;
}


Measured memory_bytes: 3968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.HCPC2019_30
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] abc = ReadInts();
            int a = abc[0];
            int b = abc[1];
            int c = abc[2];
            var hashSet = new HashSet<int>();
            int start = 0;
            int rot = 0;
            while (!hashSet.Contains(start))
            {
                if (start <= c && c <= start + a)
                {
                    WriteLine(c + rot * 60);
                    return;
                }
                hashSet.Add(start);
                start += a + b;
                if (start >= 60)
                {
                    start %= 60;
                    rot++;
                }
            }
            WriteLine(-1);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 20404
n=int(input())
l=list(map(int,input().split()))

s=0
c=0
for (i,j) in enumerate(l):
  if i%2: #plus
    if s+j<=0:
      c+=(abs(s+j)+1)
      s=1
    else:
      s+=j
  else: #minus
    if s+j>=0:
      c+=(abs(s+j)+1)
      s=-1
    else:
      s+=j
a=c

s=0
c=0
for (i,j) in enumerate(l):
  if i%2==0: #plus
    if s+j<=0:
      c+=(abs(s+j)+1)
      s=1
    else:
      s+=j
  else: #minus
    if s+j>=0:
      c+=(abs(s+j)+1)
      s=-1
    else:
      s+=j
b=c
print(min(a,b))

Measured memory_bytes: 14468
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;


int main(){
    string s;
    int cnt0 = 0, cnt1 = 0;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if(s[i] == '0') cnt0++;
        else cnt1++;
    }
    cout << s.size() - abs(cnt0 - cnt1) << endl;
    return 0;
}


Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

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

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 main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), 1e6)
	n := readInt()
	s := []byte(readString())

	count := 1
	for i := 0; i < n-1; i++ {
		if s[i] != s[i+1] {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
	int n, m, l;
	cin >> n >> m >> l;
	long A[1001][1001], B[1001][1001], C[1001][1001];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> A[i][j];

	for (int i = 0; i < m; i++)
		for (int j = 0; j < l; j++)
			cin >> B[i][j];

	for (int i = 0; i < n; i++)
		for (int j = 0; j < l; j++)
			for (int k = 0; k < m; k++)
				C[i][j] += A[i][k] * B[k][j];

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			if (j > 0)
				cout << " ";
			cout << C[i][j];
		}
		cout << "\n";
	}
}




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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int x,y;
	cin>>x>>y;
	vector<int>v={0,1,3,1,2,1,2,1,1,2,1,2,1};
	cout<<(v.at(x)==v.at(y)?"Yes"s:"No"s)<<"\n"s;
}

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

int main() {
int k,s;
cin>>k>>s;
int ans=0;
for(int x=0;x<=k;x++){
  for(int y=0;y<=k;y++){
    int z = s-x-y;
    if(z>=0 && z<=k) ans++;
  }
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#include "string"
#define int long long
#define pi pair <int, int>
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl '\n'
 
const int N = 5e5 + 5;
const int M = 1e9 + 7;
 
int mod( int m ,int mod = M) {
   m %= mod;
   return (m + mod) % mod;
}
 
int power(int x,int y) {
   int res = 1;
   x = mod(x);
   while (y > 0) {
      if (y & 1)
         res =mod(res * x);
      y = y / 2;
      x = mod(x * x);
   }
   return mod(res);
}
 
int32_t main() {
	IOS;
	int n;
	cin >> n;
	int ans = power(10, n);
	ans = mod(ans - 2 * power(9, n));
	ans = mod(ans + power(8, n));
	cout << ans << endl;	
}

Measured memory_bytes: 3684
import java.util.*;

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

        if (N == 1) {
            System.out.println("Hello World");
            return;
        } else {
            int A = Integer.parseInt(sc.next());
            int B = Integer.parseInt(sc.next());
            System.out.println(A + B);
        }
    }

}


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

int dp[2][1000001];

int f(int n)
{
    return n * (n + 1) * (n + 2) / 6;
}

int main()
{
    int n;
    for(int k = 0; k < 2; k++)
        fill(dp[k], dp[k] + 1000001, 1000000);
    
    dp[0][0] = dp[1][0] = 0;
    for(int i = 1; i <= 1000000; i++) {
        for(int k = 1; ; k++) {
            int num = f(k);
            if(i - num >= 0) {
                dp[0][i] = min(dp[0][i], dp[0][i - num] + 1);
                if((num % 2) == 1) {
                    dp[1][i] = min(dp[1][i], dp[1][i - num] + 1);
                }
            } else {
                break;
            }
        }
    }
    
    while(cin >> n && n) {
        cout << dp[0][n] << " " << dp[1][n] << endl;
    }
}

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

vector<int> calc_cut_left(vector<long long> pref, int n) {
  vector<int> ans(n);
  int cur = 0;
  ans[1] = 0;
  for (int i = 2; i + 2 < n; i++) {
    long long s1 = abs(pref[cur + 1] - (pref[i] - pref[cur + 1]));
    long long s2 = abs(pref[cur] - (pref[i] - pref[cur]));
    while (abs(pref[cur + 1] - (pref[i] - pref[cur + 1])) <= abs(pref[cur] - (pref[i] - pref[cur])))
      cur++;
    ans[i] = cur;
  }
  return ans;
}

vector<int> calc_cut_right(vector<long long> pref, int n) {
  vector<int> ans(n);
  int cur = n - 2;
  ans[n - 3] = cur;
  for (int i = n - 4; i >= 1; i--) {
    long long s1 = abs((pref[n - 1] - pref[cur - 1]) - (pref[cur - 1] - pref[i]));
    long long s2 = abs((pref[n - 1] - pref[cur]) - (pref[cur] - pref[i]));
    while (abs((pref[n - 1] - pref[cur - 1]) - (pref[cur - 1] - pref[i])) <= abs((pref[n - 1] - pref[cur]) - (pref[cur] - pref[i])))
      cur--;
    ans[i] = cur;
  }
  return ans;
}

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  vector<long long> pref(n, a[0]);
  for (int i = 1; i < n; i++)
    pref[i] = pref[i - 1] + a[i];
  vector<int> pos_left = calc_cut_left(pref, n);
  vector<int> pos_right = calc_cut_right(pref, n);
  long long ans = -1;
  for (int i = 1; i + 2 < n; i++) {
    int l = pos_left[i];
    int r = pos_right[i];
    long long s1 = pref[l];
    long long s2 = pref[i] - pref[l];
    long long s3 = pref[r] - pref[i];
    long long s4 = pref[n - 1] - pref[r];
    long long cur = max({s1, s2, s3, s4}) - min({s1, s2, s3, s4});
    if (ans == -1 || cur < ans)
      ans = cur;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 5732
import math

N = int(input())
A = [0] * N
B = [0] * N

for i in range(N):
    A[i], B[i] = map(int, input().split())

A.sort()
B.sort()

mid_a = A[(N + 1) // 2 - 1] if N % 2 == 1 else (A[N // 2 - 1] + A[N // 2]) / 2
mid_b = B[(N + 1) // 2 - 1] if N % 2 == 1 else (B[N // 2 - 1] + B[N // 2]) / 2

# ans = 0
# if isinstance(mid_a, float):
#     if not mid_a.is_integer():
#         ans += 1
#         mid_a = math.ceil(mid_a)
# if isinstance(mid_b, float):
#     if not mid_b.is_integer():
#         ans += 1
#         mid_b = math.floor(mid_b)

ans = (mid_b - mid_a + 1) if N % 2 == 1 else int((mid_b - mid_a) * 2) + 1
print(ans)


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

using namespace std;

void solve(void)
{
	int n, ps[4], ts[4];
	cin >> n;
	for (int i = 0; i < 4; i++) cin >> ps[i];
	for (int i = 0; i < 4; i++) cin >> ts[i];
	int ans = 10000;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++)
			for (int k = 0; k <= n; k++)
			{
				int l = n - i*ts[0] - j*ts[1] - k*ts[2];
				ans = min(ans, i * ps[0] + j * ps[1] + k * ps[2] + max(0, (l+ts[3]-1) / ts[3]) * ps[3]);
			}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3112
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
///////////////////////////

int main(){fastio
    ll n,a,b;cin>>n>>a>>b;
    ll c=a+b;
    ll ans=n/c*a;
    ll t=n/c*c;
    n-=t;
    if(n<=a)ans+=n;
    else ans+=a;
    cout<<ans<<endl;
    
    return 0;
}


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

void MakeMap(string str, map<string, int> &outMap)
{
    auto iter = outMap.find(str);
    if(iter == outMap.end())
    {
      outMap.insert(make_pair(str, 1));
    }
    else
    {
      iter->second++;
    }
}
 
int main(){
  int N, M;
  cin >> N;
  map<string, int> plusMap;
  for(int i=0; i < N; i++)
  {
    string temp;
    cin >> temp;
    MakeMap(temp, plusMap);
  }
  cin >> M;
  map<string, int> minusMap;
  for(int i=0; i < M; i++)
  {
    string temp;
    cin >> temp;
    MakeMap(temp, minusMap);
  }
  
  int answer = 0;
  for(auto iterPlus = begin(plusMap); iterPlus != end(plusMap); ++iterPlus)
  {
    int tempAnswer = iterPlus->second; //plusMap（プラスになる枚数）
    auto iter = minusMap.find(iterPlus->first);
    if(iter != minusMap.end())
    {
      tempAnswer -= iter->second;		//マイナス計算
    }
    answer = max(answer, tempAnswer);
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, count = 0;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, n)
    {
        int a;
        cin >> a;
        mp[a]++;
    }
    for (auto e : mp)
        count++;
    if (count % 2 == 0)
        cout << count - 1 << endl;
    else
        cout << count << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;
constexpr int64_t mod = 10000000000;
int64_t a[100010];
int main(){
    int n;
    cin >> n;

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

    sort(a, a + n);
    int64_t dis = a[n-1];
    int64_t ans2 = a[0];
    for(int i = 0; i < n-1; ++i){
        if(dis > abs(a[n-1] - a[i] * 2)){
            dis = abs(a[n-1] - a[i] * 2);
            ans2 = a[i];
        }
    }
    cout << a[n - 1] << " " << ans2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
    int n;
    cin >> n;
    int keta = log10(n)+1;
    int c = n;
    int ma = 0;
    while(c>0) {
        ma+=(c%10);
        c/=10;
    }
    cout << max(ma,(keta-1)*9+(int)(n/pow(10,keta-1))-1) << endl;
}



Measured memory_bytes: 3912
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    // chrono::steady_clock clk;
    // auto start = clk.now();
    int n, k;
    cin >> n >> k;
    string s; cin >> s;
    vector<int> ss(n);
    for(int i=0;i<n;i++){
        ss[i] = s[i] == 'A';
    }
    bool flip = false, fflip = false;;
    int idx = 0;
    for(int i=0;i<k;i++){
        if(flip ^ ss[idx]){
            // ss[idx] = !ss[idx];
            ss[idx] ^= 1;
        }else{
            // flip = !flip;
            flip ^= 1;
            idx++;
            if(idx == n){ idx = 0; }
        }
        // if(i % 1000000 == 0 && clk.now() - start > 1900ms){
        //     if(n % 2 && (k - i - 1) % 2){
        //         fflip = true;
        //     }
        //     break;
        // }
    }
    string buf;
    buf.resize(n);
    buf[0] = fflip ^ flip ^ ss[idx] ? 'A' : 'B';
    for(int i=0;i<n;i++){
        buf[i] = flip ^ ss[(idx + i) % n] ? 'A' : 'B';
    }
    cout << buf << '\n';
    // cout << (fflip ^ flip ^ ss[idx] ? 'A' : 'B');
    // for(int i=1;i<n;i++){
    //     cout << (flip ^ ss[(idx + i) % n] ? 'A' : 'B');
    // }
    // cout << '\n';
    return 0;
}


Measured memory_bytes: 1660
using System;

namespace A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] date = s.Split('/');
            System.Collections.Generic.List<int> d
                = new System.Collections.Generic.List<int>();
            foreach(var str in date) d.Add(int.Parse(str));
            DateTime dateTime = new DateTime(d[0], d[1], d[2]);
            DateTime TBD = new DateTime(2019, 4, 30);
            if (dateTime <= TBD) Console.WriteLine("Heisei");
            else Console.WriteLine("TBD");
        }
    }
}


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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll whole = 0;
    rep(i, 0, n){
        cin >> a[i];
    }
    whole = abs(a[0] - 0);
    rep(i, 1, n){
        whole += abs(a[i] - a[i-1]);
    }
    whole += abs(0 - a[n-1]);
    cerr << "whole: " << whole << endl;
    cout << whole - abs(a[0] - 0) - abs(a[1] - a[0]) + abs(a[1] - 0) << endl;
    rep(i, 1, n-1){
        cout << whole - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1]) << endl;
    }
    cout << whole - abs(0 - a[n-1]) - abs(a[n-1] - a[n-2]) + abs(0 - a[n-2]) << endl;
    return 0;
}

Measured memory_bytes: 2048
N= int(input())
S = [input() for _ in range(N)]

cnt = {}

for s in S:
  cnt[s[0]] = cnt.get(s[0], 0) +1

n = [cnt.get(x,0) for x in ['M','A','R','C','H']]

a = sum(n) **3 - 3*sum([v**2 for v in n])*sum(n) + 2*sum([v**3 for v in n])
print(a//6)
  

Measured memory_bytes: 9752
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define int long long
const int N=1e5+10;


int32_t main() 
{
   string s; cin>>s; int n=s.size();
   int cnt=0; int ans=0;
   for(int i=0;i<n;i++)
   {
      if( !(i%2) and s[i]!='0') cnt++; 
      if((i%2) and s[i]!='1') cnt++;
   }
   ans=max(ans,cnt); cnt=0; 
   for(int i=0;i<n;i++)
   {
      if( !(i%2) and s[i]!='1') cnt++; 
      if((i%2) and s[i]!='0') cnt++;
   }
   cout<<min(ans,cnt);  return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;

ll k=1;
int n;
int main() {
	string s="Christmas";
	int a;
	cin>>a;
	for(int i=a;i<25;++i){
		s+=" Eve";
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    int su=0;
    for(int i=0; i<n; i++){
        cin>>a.at(i);
        su += a.at(i);
    }
    int can =0;
    for(int i=0; i<n; i++){
        if(a.at(i) * 4 * m >= su){
            can ++;
        }
    }
    cout<<(can>=m ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int mat[3][3];
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      scanf("%d", &mat[i][j]);
    }
  }
  for(int i=0; i<2; i++){
    int diff0=mat[i][0]-mat[i+1][0];
    int diff1=mat[i][1]-mat[i+1][1];
    int diff2=mat[i][2]-mat[i+1][2];

    if( diff0 != diff1 ){
      printf("No\n");
      return 0;
    }
    if( diff2 != diff1 ){
      printf("No\n");
      return 0;
    }
  }
  for(int i=0; i<2; i++){
    int diff0=mat[0][i]-mat[0][i+1];
    int diff1=mat[1][i]-mat[1][i+1];
    int diff2=mat[2][i]-mat[2][i+1];

    if( diff0 != diff1 ){
      printf("No\n");
      return 0;
    }
    if( diff2 != diff1 ){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K,*V = map(int,read().split())

vals = []
for L in range(N+1):
    for R in range(N+1):
        if L+R > N:
            break
        get = V[:L] + V[N-R:]
        rest = K - (L+R)
        if rest < 0:
            break
        get.sort(reverse=True)
        for _ in range(min(len(get),rest)):
            if get[-1] < 0:
                get.pop()
            else:
                break
        vals.append(sum(get))

answer = max(vals)
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	int x;
	int now = 100;
	
	cin >> x;
	
	int i;
	for (i = 1; ; i++) {
		now = now + now / 100;
		if (now >= x) { cout << i << endl; return 0; }
	}
	return 0;
}

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

if K==0:
    if S==1:
        ans=[2]*N
        print(*ans)
        exit()
    else:
        ans=[S-1]*N
        print(*ans)
        exit()

if S==1:
    ans=[]
    for i in range(K):
        ans.append(1)
    for i in range(N-K):
        ans.append(2)
    print(*ans)
    exit()

if N-K<S:
    ans=[]
    for i in range(K):
        ans.append(S)
    for i in range(N-K):
        ans.append(S-1)
    print(*ans)
elif N-K>=S:
    ans=[]
    n=(N-K)//K
    Pt=[S]
    for i in range(n):
        Pt.append(S-1)
    for i in range(K):
        ans.extend(Pt)
    for i in range(N-(n+1)*K):
        ans.append(S-1)
    print(*ans)



Measured memory_bytes: 9652
#include <iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a=0,w=0,t=0,r=0;
    for (int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if (s=="AC")
        {
            a=a+1;
        }
        else if (s=="WA")
        {
            w=w+1;
        }
        else if (s=="TLE")
        {
            t=t+1;
        }
        else if (s=="RE")
        {
            r=r+1;
        }
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define PI 		    acos(-1)
#define pb          push_back
#define ins         insert
#define INF        	1000000000000000007 //1e18+7
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define ld     		long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007		//1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, mp) for(ll i = (a); i<=(mp); ++i)
#define trav(a, x) 	  for(auto &a : x)
#define re(i,n)       for(ll i = 0; i < n; ++i) 
const int N = 5e5 + 7;
const ld eps=1e-7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int dx[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int dy[8]={+1, 0, -1, +1, -1, +1, 0, -1};
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template <typename T> T gcd(T a,T mp){ if(a==0) return mp; return gcd(mp%a,a); }
template <typename T> T powm(T a,T mp, ll m){T cnt=1; while(mp>0){ if(mp%2==1) cnt=(cnt*a)%m; mp/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;} 
void prec(){

}
int sum=0,dp[102][N],now[N];
void run(){
	int n,k;cin>>n>>k;
	int a[n+1];
	a[0]=0;
	rep(i,1,n) cin>>a[i];
	fill(dp,0);
	dp[0][0]=1;
	for(int j=0;j<=k;j++){
			now[j]+=(dp[0][j]+(j==0?0:now[j-1]))%MOD;
	}
	for(int i=1; i<=n; ++i){
		for(int j=0; j<=k; ++j){
			dp[i][j]=now[j]-(j-a[i]-1<0?0:(now[j-a[i]-1]));            //now[i-1][j-a[i]-1];
			if(dp[i][j]<0) dp[i][j]+=MOD;
			dp[i][j]%=MOD;
			// for(int c=j-a[i]; c<=j; ++c){
			// 	dp[i][j]+=dp[i-1][c];
			// }
		}
		fill(now,0);
		for(int j=0;j<=k;j++){
			now[j]+=(dp[i][j]+(j==0?0:now[j-1]))%MOD;
		}
	}
	cout<<dp[n][k]<<endl;
}
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int tc=1;
    //cin>>tc;
    prec();
    re(i,tc)
    	run();
    return 0; 
}

Measured memory_bytes: 201472
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int n = 100, m = 100;
    a--, b--;
    vvi table(n, vi(m));
    for (int i = 0; i < n; ++i) {
    	table[i][0] = 1;
    	table[i][m-1] = 0;
    }
    int ind = 0;
    for (int i = 0; i < n; i += 3) {
    	if (i+2 >= n) break;
    	for (int j = 1; j < m-1; ++j) {
    		table[i][j] = ind;
    		table[i+1][j] = ind;
    		table[i+2][j] = ind;
    	}
    	for (int j = 2; j < m-2; j += 2) {
    		if (ind && a != 0) {
    			table[i+1][j] = !ind;
    			a--;
    		} else if (!ind && b != 0) {
    			table[i+1][j] = !ind;
    			b--;
    		}
    	}
    	ind = !ind;
    }
    cout << "100 100\n";	
    for (int i = 0; i < n; ++i) {
    	for (int j = 0; j < m; ++j) {
    		if (table[i][j]) cout << "#";
    		else cout << ".";
    	}
    	cout << "\n";
    }
    return 0;
}

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

using namespace std;

void solve(void)
{
	int l, r;
	cin >> l >> r;
	if (l+2019<=r)
	{
		cout << 0 << endl;
		return;
	}
	int ans = 2018;
	for (int i = l; i < r; i++)
		for (int j = i+1; j <= r; j++)
		{
			if (1L*i*j%2019L < ans) ans = 1L*i*j%2019L;
		}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	int [] ans_ar; 
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 32 * 1024 * 1024).start(); //
	}
	public void run() {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int ans = 0;
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next())-1;
		}
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(sc.next());
		}
		int[] c = new int[n];
		for (int i = 0; i < n-1; i++) {
			c[i] = Integer.parseInt(sc.next());
		}
		ans += b[a[0]];
		for (int i = 1; i < n; i++) {
			ans += b[a[i]];
			if(a[i-1]==a[i]-1)
			{
				ans += c[a[i]-1];
			}
			
		}
		out.println(ans);
		out.flush();
	}


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}

Measured memory_bytes: 23252
h,w=gets.split.map(&:to_i)
map=[]
h.times.each do
    map<<gets.split("").map(&:to_s)
end
all_index_check=[]
for i in 0..h-1
    index_check=[]
    v=map[i]
    for j in 0..w-1
        if v[j]=="#"
            index_check<<j
        end
    end
    all_index_check<<index_check
end
    



for i in 0..all_index_check.length-2
    first=all_index_check[i]
    second=all_index_check[i+1]
    if second[0]-first[0]<0
        puts "Impossible"
        exit
    elsif second.count(first[-1])<0
    
    puts "Impossible"
    exit
    elsif second[0]!=first[-1]
    puts "Impossible"
    exit
    end
    
end
    
  for j in 0..first.length-2
      if (first[j+1]-first[j])!=1
          puts "Impossible"
          end
      
     
    
end
puts "Possible"

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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long long int> a(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<long long int> dp(n, 0);
  vector<long long int> dp_non_zero(n, 0);
  dp[0] = a[0];
  dp_non_zero[0] = max(a[0], 0ll);
  for (int i = 1; i < n; ++i) {
    dp[i] = dp[i - 1] + a[i];
    dp_non_zero[i] = dp_non_zero[i - 1] + max(a[i], 0ll);
  }
  long long int max_range = 0;
  for (int i = 0; i < n + 1 - k; ++i) {
    long long int temp1 = i != 0 ? dp_non_zero[i - 1] : 0ll;
    max_range = max(max_range,
        (dp[i + k - 1] - dp[i] + a[i]) + temp1 + (dp_non_zero[n - 1] - dp_non_zero[i + k - 1]));
    max_range = max(max_range,
        temp1 + (dp_non_zero[n - 1] - dp_non_zero[i + k - 1]));
  }
  cout << max_range << endl;
  return 0;
}


Measured memory_bytes: 2560
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 1000000007
#define M 1000000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,a,b,c;
	cin>>n>>a>>b>>c;
	int out=0;
	loop(i,n,2*n){
		int t=100*(powmod(a,n,MOD)*powmod(b,i-n,MOD)%MOD+powmod(b,n,MOD)*powmod(a,i-n,MOD)%MOD)%MOD*i%MOD;
		(out+=nCr(i-1,n-1)*t%MOD*powmod(powmod(a+b,i,MOD)*(100-c)%MOD,MOD-2,MOD)%MOD)%=MOD;
	}
	cout<<out<<endl;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N;

int main(void) {
    cin >> N;
    vector<int> s(N);
    int sum = 0;
    int m = INT32_MAX;
    rep(i, N) {
        cin >> s[i];
        sum += s[i];
        if (s[i] % 10 != 0) m = min(m, s[i]);
    }

    if (sum % 10 != 0) {
        cout << sum << endl;
    }
    else if (m == INT32_MAX) {
        cout << 0 << endl;
    }
    else {
        cout << sum - m << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
const int N=1e9+7;
#define int long long
#define double long double

int32_t main()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 IOS;
int n;
cin>>n;
int a[n];
for (int i = 0; i < n; ++i)
{
	/* code */cin>>a[i];
}
int dp[n];
dp[0]=a[0];
for (int i = 1; i < n; ++i)
{
	dp[i]=(dp[i-1]+a[i])%N;
}
int s=0;
for (int i = n-1; i>=1; i--)
{
	s+=(a[i]%N*dp[i-1]%N)%N;
}
cout<<s%N;


 	



  
 




  
return 0;
}


Measured memory_bytes: 6740