akhauriyash/Code-Regression huggingface dataset:
import numpy as np
from sys import stdin


def main():
    w = next_int()
    h = next_int()
    n = next_int()
    arr = np.ones((h, w), dtype=np.int)

    for i in range(n):
        xi, yi, a = map(int, input().split())

        for y in range(h):
            for x in range(w):
                if a == 1:
                    if x < xi:
                        arr[y][x] = 0
                if a == 2:
                    if x >= xi:
                        arr[y][x] = 0
                if a == 3:
                    if y < yi:
                        arr[y][x] = 0
                if a == 4:
                    if y >= yi:
                        arr[y][x] = 0

    ans = arr.sum()
    print(ans)


def next_int():
    return int(next_str())


def next_str():
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 12516
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>

using namespace std;

void solve()
{
    long long n, k;
    cin >> n >> k;
    long long gcd = 0;
    long long mv = 0;
    for(int i = 0; i < n; ++ i) {
        int x;
        scanf("%d", &x);
        mv = max(mv, (long long)x);
        if (gcd == 0) gcd = x;
        else gcd = __gcd(gcd, (long long)x);
    }
    if (n == 1) {
        cout << ((k == mv) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
        return;
    }
    if (k > mv) {
        cout << "IMPOSSIBLE" << endl;
        return;
    }
    if ((mv - k) % gcd == 0) {
        cout << "POSSIBLE" << endl;
    } else cout << "IMPOSSIBLE" << endl;
}

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


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A+B > C+D)
    cout << "Left" << endl;
  
  if (A+B == C+D)
    cout << "Balanced" << endl;
  
  if (A+B < C+D)
    cout << "Right" << endl;
  
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.buffer.readline()[:-1]

MOD = 10**9 + 7
list_size = 200001

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

n = int(input())
adj = [[] for _ in range(n)]
for _ in range(n-1):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)


dp_pat = [0 for _ in range(n)]
dp_num = [0 for _ in range(n)]


def dfs1(x, p):
	num = 0
	res = 1
	for v in adj[x]:
		if v == p:
			continue
		dfs1(v, x)
		num += dp_num[v]
		res *= comb(num, dp_num[v]) * dp_pat[v]
		res %= MOD
	dp_num[x] = num+1
	dp_pat[x] = res
	return

dfs1(0, -1)
ans = [0 for _ in range(n)]
ans[0] = dp_pat[0]

def dfs2(x, p):
	for v in adj[x]:
		if v == p:
			continue
		pres = [dp_pat[x], dp_num[x], dp_pat[v], dp_num[v]]
		dp_pat[x] *= pow(comb(dp_num[x]-1, dp_num[v]) * dp_pat[v], MOD-2, MOD)
		dp_pat[x] %= MOD
		dp_num[x] -= dp_num[v]

		dp_pat[v] *= comb(dp_num[x] + dp_num[v] - 1, dp_num[x]) * dp_pat[x]
		dp_pat[v] %= MOD
		dp_num[v] += dp_num[x]
		ans[v] = dp_pat[v]
		dfs2(v, x)
		dp_pat[x], dp_num[x], dp_pat[v], dp_num[v] = pres
	return

dfs2(0, -1)
print(*ans, sep="\n")

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

int main(){
	int H, W;
	while (true){
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 1; i <= H; i++){
			for (int j = 1; j <= W; j++){
				if ((i-j) % 2 == 0)cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007
#define INT_BITS 16
#define inf 1000000099
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n" 
//__builtin_popcount()


int32_t main()
{
  
   
        string s1;
        cin>>s1;
        string s2;
        cin>>s2;
        s1+=(s2[s2.length()-1]);
        if(s1==s2)
          cout<<"Yes"<<endl;
        else
          cout<<"No"<<endl;
   

   return 0;
}


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

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

    int sw=0;
    for(int i=0; i<n-1; i++){
        int mini=i;
        for(int j=i; j<n; j++){
            if(a[mini]>a[j])mini=j;
        }
        int t=a[i];
        a[i]=a[mini];
        a[mini]=t;
        if(mini != i)sw++;
    }
    
    for(int i=0; i<n; i++){
        if(i>0)cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << sw << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

int main(void)
{
	ll n; cin >> n;

	vector<ll> stick(n);
	each(e, stick)
		cin >> e;

	ll ans = 0;
	sort(all(stick));
	rep(b, 0, n - 1)
	{
		rep(c, b + 1, n)
		{
			auto it_a = lower_bound(all(stick), stick[b] + stick[c]);
			ll end_a = it_a - stick.begin();
			it_a = upper_bound(all(stick), abs(stick[b] - stick[c]));
			ll begin_a = it_a - stick.begin();

			ans += (end_a - begin_a);
			if (begin_a <= b && b < end_a)
				ans--;
			if (begin_a <= c && c < end_a)
				ans--;
		}
	}

	cout << ans / 3;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

vector<ll> inv, fact, invfact;
void Mod_build(int n = 101010) {
    fact.resize(n + 1);
    inv.resize(n + 1);
    invfact.resize(n + 1);
    fact[0] = inv[0] = invfact[0] = 1;
    inv[1] = 1;
    for (ll i = 0; i < n; i++) {
        fact[i + 1] = fact[i] * (i + 1) % mod;
        if (i > 0) inv[i + 1] = mod - inv[mod % (i + 1)] * (mod / (i + 1)) % mod;
        invfact[i + 1] = invfact[i] * inv[i + 1] % mod;
    }
}
ll perm(int n, int k) {
    if (n < 0 || k < 0 || k > n) return 0;
    return fact[n] * invfact[n - k] % mod;
}
ll comb(int n, int k) {
    if (n < 0 || k < 0 || k > n) return 0;
    return (fact[n] * invfact[n - k] % mod) * invfact[k] % mod;
}
ll powmod(ll n, ll k) {
    k %= mod - 1;
    if (k < 0) k += mod - 1;
    ll ret = 1;
    while (k) {
        if (k & 1) ret = ret * n % mod;
        n = n * n % mod;
        k >>= 1;
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    Mod_build();
    int n;
    cin >> n;
    int m = n + 1;
    VI a(m);
    VI v(m, 0);
    int k;
    for (i = 0; i < m; i++) {
        cin >> a[i];
        v[a[i]]++;
        if (v[a[i]] == 2) k = a[i];
    }
    VI w;
    for (i = 0; i < m; i++) {
        if (a[i] == k) w.pb(i);
    }
    for (i = 1; i <= m; i++) {
        ll ans = comb(m, i);
        ans += (mod - comb(m - w[1] + w[0] - 1, i - 1));
        cout << ans % mod << endl;
    }
}

Measured memory_bytes: 7136
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		X = max(X, tmp);
	}

	for (int i = 0; i < M; i++)
	{
		int tmp;
		cin >> tmp;
		Y = min(Y, tmp);
	}

	if (X < Y)
	{
		cout << "No War" << endl;
	}
	else
	{
		cout << "War" << endl;
	}
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
from pprint import pprint

INF = 1000000
dx = [1, -1, 0,  0]
dy = [0,  0, 1, -1]

# 入力
h, w = map(int, input().split())
maze = []
for i in range(h):
    maze.append(list(input()))

# ワーシャルフロイド用に枠を作る。
# 2次元マップしてもいいが面倒なので、１次元にする。[0 - x][0 - y]を[0- x * y]にflattenする
wsmap = lambda a, b: (a * w + b)
dp = []
# 辺がない時はINFを入れのでデフォルト値とする
for i in range(h * w):
    dp.append([INF] * (h * w))

# 迷路ををグラフにする。
for y in range(h):
    for x in range(w):
        if maze[y][x] == "#": # そのマスが壁なら何もしない(他のマストの連結はないので)
            continue
        # ワーシャルフロイドでは自分自身へのコストは0にしておく。
        dp[wsmap(y, x)][wsmap(y, x)] = 0
        # ４方向に移動できるかの判定
        for dir in range(len(dx)):
            nx, ny = x + dx[dir], y + dy[dir]
            if -1 < nx and nx < w and -1 < ny and ny < h: # 枠をはみ出ないかチェック
                if maze[ny][nx] != "#": # そのマスが壁でないなら
                    dp[wsmap(y, x)][wsmap(ny, nx)] = 1 # コストを1にする

# ワーシャルフロイドする
for kk in range(h * w):
    for ii in range(h * w):
        for jj in range(h * w):
            dp[ii][jj] = min(dp[ii][jj], dp[ii][kk] + dp[kk][jj])

# これで結果が出たので
import itertools
res = itertools.chain(*dp)  # 二次元配列を一次元にして
res = filter(lambda x: x != INF, res)  # INFを取り除き
res = max(res)  # 最大値を得る
print(res)


Measured memory_bytes: 44252
/*5_3 hightierra*/
#include <stdio.h>
#define LIMIT 100

int main(void){
    int row,col,i,j,rowjudge[LIMIT]={0},coljudge[LIMIT]={0};
    char matrix[LIMIT][LIMIT];
    scanf("%d %d",&row,&col);

    // 初期化
    for(i=0; i<LIMIT; i++){
        for(j=0; j<LIMIT; j++){
            matrix[i][j]='\0';
        }
    }

    // 入力
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            scanf(" %c",&matrix[i][j]);
        }
    }

    // 各行、各列に黒が１つでもあるかを判別
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            if(matrix[i][j]=='#'){
                rowjudge[i]=1;
            }
        }
    }
    for(j=0; j<col; j++){
        for(i=0; i<row; i++){
            if(matrix[i][j]=='#'){
                coljudge[j]=1;
            }
        }
    }

    // 黒が１つでもある行と列の重なる要素のみを出力
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            if(rowjudge[i]==1 && coljudge[j]==1){
                printf("%c",matrix[i][j]);
            }
        }
        if(rowjudge[i]==1){
            printf("\n");
        }
    }
    return 0;
}


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

#define ll long long int
#define rep(i,a,n) for(ll i=(a); i<(n); i++)
#define chmin(x,y) {x = min(x,y); }
#define chmax(x,y) {x = max(x,y); }

using namespace std;
double INF = 1e10;

// 各方向で、速度ごとに端っこだけわかればよい
vector<double> l(3, INF);  // l[k]: 速度k(0,1,2)で左方向への移動する点
vector<double> r(3, -INF); // r[k]: 速度k(0,1,2)で右方向への移動する点
vector<double> d(3, INF);  // d[k]: 速度k(0,1,2)で下方向への移動する点
vector<double> u(3, -INF); // u[k]: 速度k(0,1,2)で上方向への移動する点

signed main() {
	ll N;
	cin>>N;
	rep(i,0,N) {
		double x,y; char D;
		cin>>x>>y>>D;
		switch(D) {
			case 'L': chmin(l[2], x); chmax(r[0], x); chmin(d[1], y); chmax(u[1], y); break;
			case 'R': chmin(l[0], x); chmax(r[2], x); chmin(d[1], y); chmax(u[1], y); break;
			case 'U': chmin(l[1], x); chmax(r[1], x); chmin(d[0], y); chmax(u[2], y); break;
			case 'D': chmin(l[1], x); chmax(r[1], x); chmin(d[2], y); chmax(u[0], y); break;
		}
	}

	// xとyどちらも減少するときは単調減少。0より小さくはならないため。なので右側が最小値。
	// xとyどちらも増加するときは単調増加。なので左側が最小値。
	// xが増加、yが減少するときは上に凸な二次関数。なので、両側が最小値

	vector<double> ts; // 傾きの変わる時刻（つまり面積のかわるポイント）
	ts.push_back(0);
	ts.push_back(INF);
	rep(i, 0, 3) rep(j, 0, i) { double dx = l[i] - l[j]; if (dx > 0.0) ts.push_back(dx/(i-j)); }
	rep(i, 0, 3) rep(j, 0, i) { double dx = r[j] - r[i]; if (dx > 0.0) ts.push_back(dx/(i-j)); }
	rep(i, 0, 3) rep(j, 0, i) { double dx = d[i] - d[j]; if (dx > 0.0) ts.push_back(dx/(i-j)); }
	rep(i, 0, 3) rep(j, 0, i) { double dx = u[j] - u[i]; if (dx > 0.0) ts.push_back(dx/(i-j)); }
	sort(begin(ts),end(ts));

	double ans = 1e18;
	for (auto t : ts) {
		double lp = min(min(t+l[0], 1.0*l[1]), -t+l[2]);
		double rp = max(max(-t+r[0], 1.0*r[1]), t+r[2]);
		double dp = min(min(t+d[0], 1.0*d[1]), -t+d[2]);
		double up = max(max(-t+u[0], 1.0*u[1]), t+u[2]);
		chmin(ans, (rp-lp)*(up-dp));
	}
	printf("%.10f\n", ans);
	return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
w,h=map(int,input().split())
P=[float('inf')]+[int(input()) for _ in range(w)]
Q=[float('inf')]+[int(input()) for _ in range(h)]
P.sort(reverse=True); Q.sort(reverse=True)
ans=0
while w or h:
    if P[-1]<Q[-1] or (P[-1]==Q[-1] and w>=h):
        c=P.pop()
        ans+=c*(h+1)
        w-=1
    else:
        c=Q.pop()
        ans+=c*(w+1)
        h-=1
print(ans)

Measured memory_bytes: 54364
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char op;
    cin >> a >> op >> b;
    while(op!='?'){
switch (op){
    case'+':
    cout << a+b << endl;
    break;
    case'-':
    cout << a-b << endl;
    break;
    case'*':
    cout << a*b << endl;
    break;
    case'/' :
    cout << a/b << endl;
    break;
} 
cin >> a >> op >> b;}
   
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
int read(){
    char ch=getchar(); int w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
const int M=5e6+10;
int t[M][3],n,pw[M];
int val[M],rt,tot,ans[M];
bool tg[M];
char ch[M];
void rev(int x){
	tg[x]^=1;
	swap(t[x][1],t[x][2]);
}
void pd(int x){
	if (tg[x]) {
		F(i,0,2)
		rev(t[x][i]);
		tg[x]=0;
	}
}
void build(int &x,int dep,int o){
	x=++tot; val[x]=o;
	if (dep==n) return ;
	F(i,0,2) build(t[x][i],dep+1,o+pw[dep]*i);
}
void add(int x,int dep){
	if (dep==n) return ;
	pd(x);
	int t0=t[x][0],t1=t[x][1],t2=t[x][2];
	t[x][0]=t2; t[x][1]=t0; t[x][2]=t1; 
	add(t[x][0],dep+1);
}
void calc(int x,int dep,int o){
	if (dep==n){
		ans[val[x]]=o; 
		return ;
	}
	pd(x);
	F(i,0,2) calc(t[x][i],dep+1,o+pw[dep]*i);
}
int main(){
	n=read(); scanf("%s",ch+1); int m=strlen(ch+1);
	pw[0]=1; F(i,1,20) pw[i]=pw[i-1]*3;
	build(rt,0,0);
	F(i,1,m){
		if (ch[i]=='S') rev(rt);
		else add(rt,0);
	}
	calc(1,0,0);
	
	F(i,0,pw[n]-1){
		cout<<ans[i]<<" ";
	}
	cout<<"\n";
    return 0;
}

Measured memory_bytes: 19488
package main

import (
        "fmt"
)

func main() {
        var a, b int
        fmt.Scanf("%d %d", &a, &b)

        if a >= 1 && a <= 9 && b >= 1 && b <= 9 {
                fmt.Println(a * b)
        } else {
                fmt.Println(-1)
        }
}


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

int main() {
    int N, Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a = 0; a <= N; ++a) {  // 10000円の枚数を 0 〜 N で調べる
        for (int b = 0; b + a <= N; ++b) {  // 5000円の枚数を 0 〜 N-a で調べる
            int c = N - a - b;  // 1000円の枚数は決まる
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y) {  // 答えが見つかったら
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }

    // 答えを出力 (見つかっていなくても -1 -1 -1 になるので OK です)
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
   let mut s = String::new();
   std::io::stdin().read_line(&mut s).ok();
   s.trim().parse().ok().unwrap()
}

fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
   let s = read::<String>();
   s.split(delimiter)
      .map(|e| e.parse().ok().unwrap())
      .collect::<Vec<T>>()
}

fn main() {
   let nm = readn::<i32>(" ");
   let n = nm[0];
   let m = nm[1];
   let a = readn::<i32>(" ");
   let q: i32 = 1 + (a.iter().fold(0, |sum, a| sum + a) - 1) / 4 / m;
   let mut count = 0;
   for i in a {
      if i >= q {
         count += 1;
      }
   }
   if count >= m {
      println!("Yes");
   } else {
      println!("No");
   }
}


Measured memory_bytes: 4352
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, m, k := intScanner(), intScanner(), intScanner()
	a := make([]int, n+1)
	b := make([]int, m+1)
	for i := 1; i < n+1; i++ {
		a[i] = a[i-1] + intScanner()
	}
	for i := 1; i < m+1; i++ {
		b[i] = b[i-1] + intScanner()
	}
	ans := 0
	for i := 0; i < n+1; i++ {
		if k-a[i] >= 0 {
			idx := sort.Search(len(b), func(j int) bool { return b[j] > k-a[i] })
			ans = larger(ans, i+idx-1)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8268
import sys

n = int(input())

dice = []

for i in range(n):
    dice.append(list(map(int,input().split())))

c = 0

for i in range(n):
    if dice[i][0] == dice[i][1]:
        c += 1
    else:
        c = 0
    if c == 3:
        print('Yes')
        sys.exit()

print('No')


Measured memory_bytes: 9200
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        index=bisect.bisect_left(l,l[i]+l[j])
        if j<index:
            ans+=index-j-1
print(ans)

Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}
int main() {
	ll a;
	cin >> a;
	cout << (a + a*a + a*a*a) << endl;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力
		int K = sc.nextInt();
		int N = sc.nextInt();
		int A[] = new int[N];
		int sum = 0;
		int max = 0;
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			if (i != 0) {
				int distance = A[i] - A[i-1];
				sum = sum + distance;
				if (max <= distance) {
					max = distance;
				}
			}
			if (i == N-1) {
				int distance = K - A[i] + A[0];
				sum = sum + distance;
				if (max <= distance) {
					max = distance;
				}
			}
		}
		System.out.println(sum - max);			
	}

	
	// ユークリッドの控除法(最大公約数を求める)
	private static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	// 複数の最大公約数を求める
	private static long gcdex(long param[]) {
		long g = gcd(param[0], param[1]);
		for (int i = 1; i < param.length-1; i++) {
			g = gcd(g, param[i+1]);
		}
		return g;
	}

	// 最小公倍数を求める
	private static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	//
	private static long all(long n, long count, int N) {
		if (count == N) {
			return count;
		}
		return all(1, count, N);
	}

}

Measured memory_bytes: 72496
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef set<int>::iterator ssii;

#define Cmp(a, b) memcmp(a, b, sizeof(b))
#define Cpy(a, b) memcpy(a, b, sizeof(b))
#define Set(a, v) memset(a, v, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define _forS(i, l, r) for(set<int>::iterator i = (l); i != (r); i++)
#define _rep(i, l, r) for(int i = (l); i <= (r); i++)
#define _for(i, l, r) for(int i = (l); i < (r); i++)
#define _forDown(i, l, r) for(int i = (l); i >= r; i--)
#define debug_(ch, i) printf(#ch"[%d]: %d\n", i, ch[i])
#define debug_m(mp, p) printf(#mp"[%d]: %d\n", p->first, p->second)
#define debugS(str) cout << "dbg: " << str << endl;
#define debugArr(arr, x, y) _for(i, 0, x) { _for(j, 0, y) printf("%c", arr[i][j]); printf("\n"); }
#define _forPlus(i, l, d, r) for(int i = (l); i + d < (r); i++)
#define lowbit(i) (i & (-i))
#define MPR(a, b) make_pair(a, b)

pair<int, int> crack(int n) {
    int st = sqrt(n);
    int fac = n / st;
    while (n % st) {
        st += 1;
        fac = n / st;
    }

    return make_pair(st, fac);
}

inline ll qpow(ll a, int n) {
    ll ans = 1;
    for(; n; n >>= 1) {
        if(n & 1) ans *= 1ll * a;
        a *= a;
    }
    return ans;
}

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

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

// ============================================================== //

const int maxn = 80 + 10;
int a[maxn];
int n;

ll solve() {
    ll sum = 1000, stock;
    _rep(i, 1, n-1) {
        if(a[i] < a[i+1] && sum >= a[i]) {
            stock = sum / a[i];
            sum -= stock * a[i];
            sum += a[i+1] * stock;
        }
    }
    return sum;
}

void init() {
    //
}

int main() {
    //freopen("input.txt", "r", stdin);
    init();
    cin >> n;
    _rep(i, 1, n) scanf("%d", &a[i]);

    // solve
    ll ans = solve();
    cout << ans << endl;
}

Measured memory_bytes: 3732
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int main () {
    ios_base::sync_with_stdio(0);
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);

	int n;
	cin >> n;

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

	long long res = inf64;
	for (int t = 0; t < 2; ++t) {
	    long long sum = 0;
	    long long cur = 0;
	    for (int i = 0, sign = 1; i < n; ++i, sign *= -1) {
	    	sum += a[i];
	    	if (sign * sum <= 0) {
	    		cur += 1 - sign * sum;
	    		sum += sign * (1 - sign * sum);
	    	}
        }

        res = min(res, cur);
		for (int i = 0; i < n; ++i) {
			a[i] = -a[i];
		}
	}


	cout << res << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    while(n > 0){
        vector<string> s(n);
        rep(i, n) cin >> s[i];
        int ans = 0;
        rep(i, n-1){
            if(s[i][1] == s[i+1][1]) ans++;
        }
        cout << ans << endl;
        cin >> n;
    }
}


Measured memory_bytes: 3176
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static List<Integer>[] edges;
    static int N;

    static void solve(Scanner scanner) {
        N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());
        edges = new List[N];
        for (int i = 0; i < N; i++) {
            edges[i] = new ArrayList<>();
        }
        for (int i = 0; i < M; i++) {
            int s = Integer.parseInt(scanner.next()) - 1;
            int t = Integer.parseInt(scanner.next()) - 1;
            edges[s].add(t);
        }

        List<Integer> minPath = Collections.emptyList();
        for (int i = 0; i < N; i++) {
            List<Integer> path = bfs(i);
            if (minPath.isEmpty()) {
                minPath = path;
                continue;
            }
            if (!path.isEmpty() && path.size() < minPath.size()) {
                minPath = path;
            }
        }

        if (minPath.isEmpty()) {
            System.out.println(-1);
        } else {
            System.out.println(minPath.size());
            for (int n : minPath) {
                System.out.println(n + 1);
            }
        }
    }

    static List<Integer> bfs(int s) {
        Queue<Integer> q = new LinkedList<>();
        q.add(s);

        int[] dist = new int[N];
        Arrays.fill(dist, Integer.MAX_VALUE);
        dist[s] = 0;

        int[] prev = new int[N];
        Arrays.fill(prev, -1);

        Set<Integer> visited = new HashSet<>();
        visited.add(s);

        while (!q.isEmpty()) {
            Integer top = q.poll();
            for (int next : edges[top]) {
                if (visited.add(next)) {
                    dist[next] = dist[top] + 1;
                    prev[next] = top;
                    q.add(next);
                }
            }
        }

        int mind = Integer.MAX_VALUE;
        int to = -1;
        for (int i = 0; i < N; i++) {
            if (i == s) continue;
            if (edges[i].contains(s)) {
                if (mind > dist[i]) {
                    mind = dist[i];
                    to = i;
                }
            }
        }

        if (to == -1) {
            return Collections.emptyList();
        }
        List<Integer> path = new ArrayList<>();
        int curr = to;
        while (prev[curr] != -1) {
            path.add(curr);
            curr = prev[curr];
        }
        path.add(curr);

        return path;
    }
}


Measured memory_bytes: 88964
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=205;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline ll read(){
	ll x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n;ll a[MAXN],b[100];char s[MAXN];
inline void clear(){memset(b,0,sizeof(b));}
inline bool Ins(ll x){
	Red(i,63,0)if(x>>i&1){
		if(!b[i]){b[i]=x;return 1;}
		x^=b[i];
	}return 0;
}
inline void Solve(){
	clear();n=read();
	Rep(i,1,n)a[i]=read();scanf("%s",s+1);
	Red(i,n,1)if(s[i]=='0')Ins(a[i]);else if(Ins(a[i])){puts("1");return;}
	puts("0");
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	for(int t=read();t--;)Solve();
	return 0;
}




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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

string L; 
ll DP1[int(1e5+5)], DP2[int(1e5+5)];
int main(){
  cin >> L;
  int N = L.length();
  DP1[0] = 1; DP2[0] = 2;

  for (int i = 1; i < N; i++){
    DP1[i] += DP1[i-1] * 3 % MOD;
    if (L[i] == '0'){
      DP2[i] += DP2[i-1];
    }else{
      DP1[i] += DP2[i-1]; DP1[i] %= MOD;
      DP2[i] += DP2[i-1] * 2 % MOD;
    }
  }
  ll ans = (DP1[N-1] + DP2[N-1]) % MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5312
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>

#define div1 1000000007

using namespace std;

int main(void)
{
    long long A, B, C, X, Y, sum1, sum2, sum3;

    cin >> A >> B >> C >> X >> Y;

    if(X > Y){
        sum1 = A*X + B*Y;

        sum2 = C*Y*2 + A*(X-Y);

        sum3 = C*X*2;
    }

    else{
        sum1 = A*X + B*Y;

        sum2 = C*X*2 + B*(Y-X);

        sum3 = C*Y*2;
    }

    if(sum1<=sum2 && sum1<=sum3) cout << sum1 << endl;
    else if(sum2<=sum1 && sum2<=sum3) cout << sum2 << endl;
    else cout << sum3 << endl;

    return 0;
}

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

int main(){
  int R;
  cin >> R;

  if(R >= 2800){
    cout << "AGC" << endl;
  }else if(R >= 1200){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }

  return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char mozi[100000];
  int i,n,count=0;
  
  scanf("%d",&n);
  scanf("%s",mozi);
  
  for(i=0;i<n;i++){
    count++;
    if(mozi[i]=='x' && mozi[i+1]=='x'){
      printf("%d\n",count);
      return 0;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1952
#include <stdio.h>
int main(){
  int n,r=0,a=0;
  char s[101];
  scanf("%d%s",&n,s);
  for(int i=0;i<n;i++){
    s[i]=='I'?r++:r--;
    if(r>a)a=r;
  }
  printf("%d",a);
  return 0;
}

Measured memory_bytes: 128
input_str = input()
new_str = ''.join(list(reversed(input_str)))
candidates = ["dream", "dreamer", "erase", "eraser"]
candidates = [''.join(list(reversed(s))) for s in candidates]

def match_candidates(s, i, candidates):
    for candidate in candidates:
        length = len(candidate)
        if s[i:i+length] == candidate: return length
    return -1

def judge_str(s, candidates):
    i = 0
    while i < len(new_str):
        jump = match_candidates(s, i, candidates)
        if jump == -1:
            return "NO"
        i += jump
    return "YES"
    
print(judge_str(new_str, candidates))



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

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

const int N = 100005;
const ll INF = INT_MAX - 1;

ll n, dp[4], a, b, c;

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

  cin >> n;
  while(n--){
    cin >> a >> b >> c;
    ll temp1 = max(dp[2], dp[3]) + a;
    ll temp2 = max(dp[1], dp[3]) + b;
    ll temp3 = max(dp[1], dp[2]) + c;
    dp[1] = temp1, dp[2] = temp2, dp[3] = temp3;
  }
  cout << max( max(dp[1], dp[2]), dp[3] ) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
using namespace std;
typedef long long ll;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
const int INF = 1e9;

int main() {
    int N,M;
    cin >> N >> M;
    if(N==M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

namespace 課題1
{
    class Program
    {
        static void Main(string[] args)
        {
            //文字列を取得する
            string str = Console.ReadLine();
            int intInput = int.Parse(str);
            int intNum = str.Length;

            //文字列を一つずる配列に格納する
            //1文字目の文字を取得する
            char c1 = str[0];
            //あ

            string[] strArray = new string[intNum];

            //forを使って1文字ずつ列挙する
            for (int i = 0; i < str.Length; i++)
            {
               strArray[i]=str[i].ToString();
            }

            //合計を格納する変数
            int intSum = 0;

            //for文で配列を回す
            for (int i = 0;i< intNum;i++)
            {
                intSum = intSum + int.Parse(strArray[i]);
                
            }

            //出力
            if(intInput% intSum==0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }


    }

    
}


Measured memory_bytes: 27436
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE ScopedTypeVariables #-}
import           Control.Monad      (foldM, replicateM)
import           Control.Monad.ST   (ST)
import           Data.Array.ST      (STUArray)
import qualified Data.Array.ST      as MA
import           Data.Array.Unboxed (UArray, (!))
import qualified Data.Array.Unboxed as A
import           Data.Set           (Set)
import qualified Data.Set           as S

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  sss <- replicateM h getLine
  print $ solve h w sss

solve :: Int -> Int -> [[Char]] -> Int
solve h w sss = if d == inf then -1 else h * w - bs - d - 1 where
  d = dss ! (h - 1, w - 1)
  dss = dijkstra h w sss' (0, 0)
  sss' = A.array ((0, 0), (h - 1, w - 1))
    [((i, j), s) | (ss, i) <- zip sss [0 .. ]
                 , (s, j) <- zip ss [0 .. ]] :: UArray (Int, Int) Char
  bs = sum $ map (length . filter (== '#')) sss

inf :: Int
inf = maxBound `div` 3

add :: Int -> Int -> Int
add x y = if x == inf || y == inf then inf else x + y

dijkstra :: Int -> Int -> UArray (Int, Int) Char -> (Int, Int) -> UArray (Int, Int) Int
dijkstra h w sss start = MA.runSTUArray $ do
  distMA <- MA.newArray ((0, 0), (h - 1, w - 1)) maxBound :: ST s (STUArray s (Int, Int) Int)
  MA.writeArray distMA start 0
  let q = S.singleton (0, start)
  dijkstraMain distMA q
    where
      dijkstraMain :: forall s. STUArray s (Int, Int) Int -> Set (Int, (Int, Int)) -> ST s (STUArray s (Int, Int) Int)
      dijkstraMain distMA q
        | S.null q = return distMA
        | otherwise = do
            let ((_, u), q') = S.deleteFindMin q
            du <- MA.readArray distMA u
            q'' <- foldM (dijkstraFor du) q' (adjacent u)
            dijkstraMain distMA q''
        where
          dijkstraFor :: Int -> Set (Int, (Int, Int)) -> (Int, Int) -> ST s (Set (Int, (Int, Int)))
          dijkstraFor du q' v = do
            dv <- MA.readArray distMA v
            let w' = weight $ sss ! v
                dv' = du `add` w'
            if dv > dv'
              then do
                MA.writeArray distMA v dv'
                return $ S.insert (dv', v) q'
              else return q'

      adjacent v = filter isValidIx [plus2 v dv | dv <- dvs] where
        dvs = [(1, 0), (0, 1), (-1, 0), (0, -1)]
        isValidIx (i, j) = 0 <= i && i < h && 0 <= j && j < w
        plus2 (i, j) (di, dj) = (i + di, j + dj)

      weight '.' = 1
      weight '#' = inf
      weight  _  = undefined


Measured memory_bytes: 1148
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int x = sc.nextInt();
        int y = sc.nextInt();
        int result = 0;
        if(x > y){
            result = gcd(x, y);
        } else {
            result = gcd(y, x);
        }
        System.out.println(result);
    }

    static int gcd(int x, int y){
        if(y == 0){
            return x;
        } else {
            return gcd(y, x % y);
        }   
    }
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

struct E{
  ll to,cost;
};

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

  ll n,m,s,t;
  cin>>n>>m>>s>>t;
  vector<ll>u(m),v(m),a(m),b(m);
  for(int i=0;i<m;i++)cin>>u[i]>>v[i]>>a[i]>>b[i];
  vector<vector<E>>e1(n+1);
  vector<vector<E>>e2(n+1);
  for(int i=0;i<m;i++){
    e1[v[i]].push_back({u[i],a[i]});
    e1[u[i]].push_back({v[i],a[i]});
    e2[v[i]].push_back({u[i],b[i]});
    e2[u[i]].push_back({v[i],b[i]});
  }
  vector<ll>v1(n+1,INF);
  priority_queue<pll,vector<pll>,greater<pll>>q1;
  q1.push({0,s});
  while(q1.size()){
    ll cost=q1.top().first;
    ll now=q1.top().second;
    q1.pop();
    if(v1[now]!=INF)continue;
    v1[now]=cost;
    for(auto it:e1[now]){
      q1.push({it.cost+cost,it.to});
    }
  }
  vector<ll>v2(n+1,INF);
  priority_queue<pll,vector<pll>,greater<pll>>q2;
  q2.push({0,t});
  while(q2.size()){
    ll cost=q2.top().first;
    ll now=q2.top().second;
    q2.pop();
    if(v2[now]!=INF)continue;
    v2[now]=cost;
    for(auto it:e2[now]){
      q2.push({it.cost+cost,it.to});
    }
  }
  //for(int i=1;i<=4;i++)cout<<v1[i]<<" ";
  //cout<<endl;
  //for(int i=1;i<=4;i++)cout<<v2[i]<<" ";
  //cout<<endl;
  vector<ll>mm(n+1);
  for(int i=1;i<=n;i++){
    mm[i]=1000000000000000-(v1[i]+v2[i]);
  }
  vector<ll>ans(n+1,0);
  ans[n]=mm[n];
  for(int i=n-1;i>=1;i--){
    ans[i]=max(ans[i+1],mm[i]);
  }
  for(int i=1;i<=n;i++){
    cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 25596
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

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

int main()
{
        string S;
        string divide[4] = {"dream", "dreamer", "erase", "eraser"};

        cin >> S;
        reverse(S.begin(), S.end());
        rep(i, 4) reverse(all(divide[i]));

        bool can = true;
        for (int i; i < S.size();)
        {
                bool can2 = false;
                rep(j, 4)
                {
                        string d = divide[j];
                        if (S.substr(i, d.size()) == d)
                        {
                                can2 = true;
                                i += d.size();
                        }
                }
                if (!can2)
                {
                        can = false;
                        break;
                }
        }
        if (can)
                cout << "YES" << endl;
        else
                cout << "NO" << endl;

        return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<complex>
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-8
using namespace std;
typedef complex<double> P;
int main(){
	int n; double x,y;
	while(scanf("%d",&n),n){
		P p[n]; rep(i,n)scanf("%lf,%lf",&x,&y),p[i]=P(x,y);
		int mx=1,m1,m2;
		rep(i,n)rep(j,i)if(norm(p[i]-p[j])<4+EPS){
			P M=(p[i]+p[j])/P(2,0),C1,C2;
			double l=sqrt(1-norm(M-p[i])),a=arg(p[j]-p[i]);
			C1=M+polar(l,a+M_PI/2),C2=M+polar(l,a-M_PI/2);
			m1=m2=0;
			rep(k,n){
				if(norm(p[k]-C1)<1+EPS)m1++; if(norm(p[k]-C2)<1+EPS)m2++;
			}
			if(m1>mx)mx=m1; if(m2>mx)mx=m2;
		}
		printf("%d\n",mx);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int n, d, x;
    cin >> n >> d >> x;
    int a[100];
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        sum += d / a[i];
        if (d % a[i] != 0) sum += 1;
    }
    sum += x;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int main() {
  ios::sync_with_stdio(false);
  LL a,b;
  cin>>a>>b;
  cout<<a*b<<'\n';
  return 0;
}

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


int main() {
    string s;cin >> s;
    string ans;
    for (int i = 0;i < 19;i++){
        char c;c = s.at(i);
        if (c == ','){
            ans+=" ";
        }else{
            ans+=c;
        }
    }
    cout << ans << endl;

}       

Measured memory_bytes: 256
let modulo = 1000000007
let ( *@ ) a b = a * b mod modulo
let ( -@ ) a b = (a - b + modulo) mod modulo
let rec mod_pow a n =
  if n <= 0 then 1
  else if n mod 2 = 1 then a *@ mod_pow a (n-1)
  else let h = mod_pow a (n/2) in h *@ h
let mod_inv a = mod_pow a (modulo-2)

let fact =
  let a = Array.make 100010 1 in
  for i = 1 to 100009 do a.(i) <- i *@ a.(i-1) done;
  a
let fact_inv = Array.map mod_inv fact

let comb n k =
  if n < 0 || k < 0 || n < k then 0
  else fact.(n) *@ fact_inv.(k) *@ fact_inv.(n-k)

let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init (n+1) (fun i -> Scanf.scanf " %d" (fun x -> i,x)) in
  let d = Array.fold_left (fun s (_,x) -> s+x) 0 a - n*(n+1)/2 in
  let [j; i] = Array.fold_left (fun s (i,e) -> if e = d then i::s else s) [] a in
  for k = 1 to n+1 do
    comb (n+1) k -@ comb (n-j+i) (k-1)
    |> Printf.printf "%d\n"
  done

Measured memory_bytes: 8960
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] c = new int[3][3];
		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++)
				c[i][j] = Integer.parseInt(sc.next());
		int a1 = 0;
		int a2 = 0;
		int a3 = 0;
		int b1 = 0;
		int b2 = 0;
		int b3 = 0;
		int a1max = Math.max(Math.max(c[0][0], c[0][1]), Math.max(c[0][1], c[0][2]));
		int a2max = Math.max(Math.max(c[1][0], c[1][1]), Math.max(c[1][1], c[1][2]));
		int a3max = Math.max(Math.max(c[2][0], c[2][1]), Math.max(c[2][1], c[2][2]));
		boolean yes = false;
		for (a1 = 0; a1 <= a1max; a1++) {
			for (a2 = 0; a2 <= a2max; a2++) {
				for (a3 = 0; a3 <= a3max; a3++) {
					b1 = c[0][0] - a1;
					b2 = c[1][1] - a2;
					b3 = c[2][2] - a3;
					if (a1 + b1 == c[0][0] &&
							a1 + b2 == c[0][1] &&
							a1 + b3 == c[0][2] &&
							a2 + b1 == c[1][0] &&
							a2 + b2 == c[1][1] &&
							a2 + b3 == c[1][2] &&
							a3 + b1 == c[2][0] &&
							a3 + b2 == c[2][1] &&
							a3 + b3 == c[2][2]) {
						yes = true;
						break;
					}
				}
				if(yes)
					break;
			}
			if(yes)
				break;
		}

		System.out.println((yes)? "Yes" : "No");
	}
}

Measured memory_bytes: 24020
#include <algorithm>
#include <cstdio>
#include <numeric>

static const int k_max = 10000;
static const size_t n_max = 2000000;
int A[n_max], B[n_max], C[k_max+1];

int main() {
  size_t n;
  scanf("%zu", &n);
  for (size_t i = 0; i < n; i++)
    scanf("%d", A + i);
  auto k = *std::max_element(A, A + n);
  for (size_t i = 0; i < n; i++)
    C[A[i]]++;
  std::partial_sum(C, C + k + 1, C);
  for (size_t i = 0; i < n; i++)
    B[--C[A[i]]] = A[i];
  for (size_t i = 0; i < n - 1; i++)
    printf("%d ", B[i]);
  printf("%d\n", B[n-1]);
  return 0;
}

Measured memory_bytes: 18312
#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 x, y;
  cin >> x >> y;
  int kame, sum_legs;
  string ans = "No";
  if (x==1){
    if(y==2 || y==4){
      ans = "Yes";
    }
  }else {
    for (int i = 0;i < (x+1); ++i){
      kame = x - i;
      sum_legs = 2 * i + 4 * kame;
      if(sum_legs == y) {
        ans = "Yes";
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

using ll = long long;

const int INF = 1001001001;

int main()
{
  int h, n;
  cin >> h >> n;
  vector<int> dp(h+1, INF);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    for (int j = 0; j < h; j++) {
      int nj = min(j+a,h);
      dp[nj] = min(dp[nj], dp[j]+b);
    }
  }
  cout << dp[h] << endl;
  return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

cs = [0] * N
cnt = 0
for i in range(1, N):
    if S[i-1:i+1] == "AC":
        cnt += 1
    cs[i] = cnt

for i in range(Q):
    l,r = map(int, input().split())
    print(cs[r-1]-cs[l-1])


Measured memory_bytes: 11524
N = int(input())
a = [int(i) for i in input().split()]

a.insert(0,0)
a.append(0)

S = 0
for i in range(N+1):
    S += abs(a[i+1] - a[i])

for i in range(1,N+1):
    output = S + abs(a[i+1] - a[i-1]) - abs(a[i]-a[i-1]) - abs(a[i+1] - a[i])
    print(output)

Measured memory_bytes: 14168