akhauriyash/Code-Regression huggingface dataset:
def resolve():
    N,M,K = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))

    Asum, Bsum = [0], [0]
    for i in range(N):
        Asum.append(A[i] + Asum[i])
    for i in range(M):
        Bsum.append(B[i] + Bsum[i])   

    ans = 0
    j = M
    for i in range(N+1):
        if Asum[i] > K:
            break
        while Bsum[j] > K - Asum[i]:
            j-=1         
        ans = max(ans,i+j)
    print(ans)
resolve()

Measured memory_bytes: 47604
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	pair<double, int> result[3][8];
	rep(i, 3){
		rep(j, 8)
			scanf("%d%lf", &result[i][j].second, &result[i][j].first);
		sort(result[i], result[i]+8);
		rep(j, 2){
			printf("%d %.2f\n", result[i][j].second, result[i][j].first);
			result[i][j].first = 1000000.0;
		}
	}
	
	sort(&result[0][0], &result[0][0]+24);
	rep(i, 2)
		printf("%d %.2f\n", result[0][i].second, result[0][i].first);
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
 long long int t, sum=1;
 scanf("%lld", &t);
 
 long long int n[t];
 for(int i=0; i<t; i++){
 	scanf("%lld", &n[i]);
 }
 for(int i=0; i<t; i++){
 	if(n[i]==0){
 		puts("0");
 		return 0;
 	} 
	 }
	 for(int i=0; i<t; i++){
	 	if(n[i]<=1000000000000000000 / sum){
	 	sum*=n[i];
	 }
	 else{
	 	puts("-1");
	 	return 0;
	 }
    }
    printf("%lld", sum);
 return 0;
}

Measured memory_bytes: 2484
import sys
import copy
from collections import deque

def main():
    s = []
    for _ in range(3):
        s+=list(map(int,input().split()))
    g = [1,2,3,4,5,6,7,8,0]
    st = set()
    inf = 1000000007
    move = [[1,3],
            [0,2,4],
            [1,5],
            [0,4,6],
            [1,3,5,7],
            [2,4,8],
            [3,7],
            [4,6,8],
            [5,7]]

    def bfs():
        k = 0
        for i in range(9):
            if s[i]==0:k = i
        dq = deque()
        dq.append([s,k,0])
        st.add(''.join(map(str,s)))
        while dq:
            state = dq.popleft()
            t,i,steps = state[0],state[1],state[2]
            if t==g:return steps
            for j in move[i]:
                u = copy.copy(t)
                u[i],u[j] = u[j],u[i]
                if ''.join(map(str,u)) in st:continue
                dq.append([u,j,steps+1])
                st.add( ''.join(map(str,u)))

    print (bfs())

if __name__ == '__main__':
    main()




Measured memory_bytes: 33172
#include<iostream>
#include<fstream>
using namespace std;
int n, k, stones[100020], vect[100020];
void prelucreaza();
void read()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> vect[i];
    prelucreaza();
}
void show();
void prelucreaza()
{
    for(int i = 0; i <= k; i++)
    {
        int ok = stones[i];
        int verif = 0;
        for(int j = 0; j < n  && verif == 0; j++)
        {
            if(i + vect[j] - k > 0)
                verif = 0;
            else if(stones[vect[j] + i] == 0)
            {
                if(stones[i] == 0)
                    stones[i + vect[j]] = 1;
                else stones[i + vect[j]] = 0;
            }
        }
    }
    show();
}
void show()
{
    if(stones[k] == 1)
        cout << "First";
    else cout << "Second";
}
int main()
{
    read();
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}
      
void run(){
    int a,b;
    cin>>a>>b;
    cout<<abs(a-b)<<endl;
}


Measured memory_bytes: 3220
import java.util.*;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] A = new String[H];
        String[][] a = new String[H][W];
        int[] w = new int[W];
        int[] h = new int[H];
        int x = 0;

        for(int i=0; i<H; i++){
            A[i] = sc.next();
            for(int j=0; j<W; j++){
                a[i][j] = String.valueOf(A[i].charAt(j));
            }
        }
        for(int i=0; i<H; i++){
            h[i] = H;
            for(int j=0; j<W; j++){
                if(a[i][j].equals(".")){
                    x += 1;
                }
                else{
                    break;
                }
                if(j==W-1 && x==W){
                    h[i] = i;
                }
            }
            x = 0;
        }
        for(int i=0; i<W; i++){
            w[i] = W;
            for(int j=0; j<H; j++){
                if(a[j][i].equals(".")){
                    x += 1;
                }
                if(j==H-1 && x==H){
                    w[i] = i;
                }
            }
            x = 0;
        }
        for(int i=0; i<H; i++){
            if(i!=h[i]){
                for(int j=0; j<W; j++){
                    if(j!=w[j]){
                        System.out.print(a[i][j]);
                    }
                    if(j==W-1){
                        System.out.print("\n");
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 23992
import numpy as np

n, w = map(int, input().split())
dp = np.full(w + 1, 0, dtype=int)

# dp[w] : wまでitemを取捨選択した際の最大価値

for _ in range(n):
    wi, vi = map(int, input().split())
    dp[wi:] = np.maximum(dp[:-wi] + vi, dp[wi:])
print(dp[-1])

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

int WaterTrans(int A, int B, int C){
    int CapaWater = A-B;
    if(CapaWater>=C){
        return 0;
    }
    else{
        return C-CapaWater;
    }

    //return max(0,C-CapaWater)でも多分いけるはず
}

int main(){
    int A,B,C; cin >> A >> B >> C;
    cout << WaterTrans(A,B,C) << endl;
}

Measured memory_bytes: 256
n = int(input())

digit = {}
for i in range(10):
    for j in range(10):
        digit[i,j]=0
for i in range(1,n+1):
    top = int(str(i)[0])
    last = int(str(i)[-1])
    digit[top, last]+=1
ans = 0
for i in range(10):
    for j in range(10):
        ans += digit[i,j]*digit[j,i]
print(ans)



Measured memory_bytes: 40428
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>

#define ll long long
#define uint unsigned int
#define ull unsigned ll


using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 2e5+10;


int main(){
	double n; cin >> n;
	double cnt = 0;
	for(int i = 1; i <= n; i++){
		if(i%2 == 1)
		cnt++;
	}
	cout << fixed << setprecision(10) << cnt/n << endl;
	return 0;
}
// 1 | 2 3 | 4
// 1 2 | 3 4 | 5 6
// 1 2 3 | 4 5 6 7 | 8 9 10
// A B C   D E F G   H J K

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IREP(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IMAX INT_MAX
#define IMIN INT_MIN
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
template<typename T> inline void chmin(T &a, T b){ if(a > b) a = b; }
template<typename T> inline void chmax(T &a, T b){ if(a < b) a = b; }
template<typename T> inline void xch(T &a, T &b){ T w = a; a = b; b = w; }


int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int cnt = 0;
    cnt += (A == B) ? 1 : 0;
    cnt += (B == C) ? 1 : 0;
    cnt += (C == A) ? 1 : 0;
    cout << ((cnt == 1) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
temp=sum(a)
temp1=a[0]
ans=abs(temp-temp1*2)
for i in range(1,n-1):
  temp1=temp1+a[i]
  ans=min(ans,abs(temp-temp1*2))
print(ans)

Measured memory_bytes: 24832
# -*- coding: utf-8 -*-
import sys
import math

tmp = input().split()
n,m = list(map(lambda a: int(a), tmp))

#s = int(input())
#tmp = input().split()
#n,m,k = list(map(lambda a: int(a), tmp))

ans=[]
for i in range(n):
	ans.append(0)

tmp = input().split()
h = list(map(lambda a: int(a), tmp))

for i in range(m):
	tmp = input().split()
	a,b = list(map(lambda a: int(a), tmp))
	if(h[a-1]>h[b-1]):
		ans[b-1]+=1
	elif(h[b-1]>h[a-1]):
		ans[a-1]+=1
	else:
		ans[a-1]+=1
		ans[b-1]+=1
num=0
for i in range(n):
	if(ans[i]==0):
		num+=1
print(num)



Measured memory_bytes: 21168
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n: usize = sc.read();
    let mut a = vec![];
    let mut b = vec![];
    for _ in 0..n {
        a.push(sc.read::<usize>());
        b.push(sc.read::<usize>());
    }
    let sum = a.iter().sum::<usize>();
    let mut min = sum;
    for i in 0..n {
        if a[i] > b[i] {
            min = cmp::min(min, b[i]);
        }
    }
    if min == sum {
        println!("0");
    } else {
        println!("{}", sum - min);
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

const ll INF = pow(10, 9) + 7;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>=22) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def solve():
    lo = 1
    hi = 11
    while lo + 1 < hi:
        mid = (lo + hi) // 2
        x = 10 ** (mid - 1)
        print('?', x)
        r = input()
        if r == 'Y':
            lo = mid
        else:
            hi = mid

    k = lo

    if hi == 11:
        lo = 0
        hi = 10
        while lo + 1 < hi:
            mid = (lo + hi) // 2
            x = 2 * 10 ** (mid - 1)
            print('?', x)
            r = input()
            if r == 'Y':
                hi = mid
            else:
                lo = mid
        k = hi

    lo = 10 ** (k - 1) - 1
    hi = 10 ** k - 1
    while lo + 1 < hi:
        mid = (lo + hi) // 2
        x = 10 * mid
        print('?', x)
        r = input()
        if r == 'Y':
            hi = mid
        else:
            lo = mid

    return hi


def main():

    print('!', solve())

if __name__ == '__main__':
    main()



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

const int N = 100005;

typedef pair<int, int> ii;

int n, m, cnt[2];
bool f[N][2];
vector<int> G[N];

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int u, v; cin >> u >> v;
		G[u].push_back(v), G[v].push_back(u);
	}
	queue<ii> qu;
	f[1][0] = 1, qu.push(ii(1, 0));
	while (qu.size()) {
		ii u = qu.front(); qu.pop();
		for (auto v : G[u.first]) {
			if (f[v][u.second ^ 1]) continue;
			f[v][u.second ^ 1] = 1, qu.push(ii(v, u.second ^ 1));
		}
	}
	long long res = 1LL * n * (n - 1) / 2 - m;
	for (int i = 1; i <= n; ++i) {
		if (f[i][0] && !f[i][1]) cnt[0]++;
		if (f[i][1] && !f[i][0]) cnt[1]++;
	}
	res -= 1LL * cnt[0] * (cnt[0] - 1) / 2;
	res -= 1LL * cnt[1] * (cnt[1] - 1) / 2;
	cout << res;
}

Measured memory_bytes: 6400
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

N, M = map(int, input().split())
A = list(map(int, input().split()))
border = sum(A) / (4 * M)
cnt = 0
for a in A:
    if a >= border:
        cnt += 1

if cnt >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 66028
def main():
    n = int(input())
    s = [int(input()) for i in range(n)]

    sum_max = sum(s)

    if sum_max % 10 == 0:
        min_p = 101
        for i in s:
            if i % 10 != 0 and i < min_p:
                min_p = i

        if min_p == 101:
            sum_max = 0
        else:
            sum_max -= min_p

    print(sum_max)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここに追記
  int n, k, r=0;
  cin >> n >> k;
  
  while(n >= k){
    n = n / k;
    r++;
  }
  
  if(n != 0)r++;
  
  cout << r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <utility>
using namespace std;

int sub2ind(int X,int Y,int Z,int *sub){
    return sub[0]*Y*Z+sub[1]*Z+sub[2];
}

void ind2sub(int X,int Y,int Z,int ind,int *sub){
    sub[2]=ind%Z;
    sub[1]=((ind-sub[2])/Z)%Y;
    sub[0]=(ind-sub[2]-Z*sub[1])/(Y*Z);
}

int main(){
int X,Y,Z,K;
cin>>X>>Y>>Z>>K;
vector<long long>A,B,C;
long long nya;
for(int i=0;i<X;i++){
    cin>>nya;
    A.push_back(nya);
}
for(int i=0;i<Y;i++){
    cin>>nya;
    B.push_back(nya);
}
for(int i=0;i<Z;i++){
    cin>>nya;
    C.push_back(nya);
}
sort(A.begin(),A.end(),greater<long long>());
sort(B.begin(),B.end(),greater<long long>());
sort(C.begin(),C.end(),greater<long long>());

bool *index=new bool[X*Y*Z];
priority_queue<pair<long long,int>> que;

int sub[3];
int ind;
long long val;
cout<<A[0]+B[0]+C[0]<<endl;
index[0]=true;
que.push(make_pair(A[1]+B[0]+C[0],Y*Z));
que.push(make_pair(A[0]+B[1]+C[0],Z));
que.push(make_pair(A[0]+B[0]+C[1],1));
index[Y*Z]=true;
index[Z]=true;
index[1]=true;
for(int i=0;i<K-1;i++){
    cout<<que.top().first<<endl;
    ind2sub(X,Y,Z,que.top().second,sub);
    que.pop();
    if(sub[0]<X-1){
        ind=(sub[0]+1)*Y*Z+sub[1]*Z+sub[2];
        if(!index[ind]) {
            que.push(make_pair(A[sub[0]+1]+B[sub[1]]+C[sub[2]],ind));
            index[ind]=true;
        }
    }
    if(sub[1]<Y-1){
        ind=sub[0]*Y*Z+(sub[1]+1)*Z+sub[2];
        if(!index[ind]) {
            que.push(make_pair(A[sub[0]]+B[sub[1]+1]+C[sub[2]],ind));
            index[ind]=true;
        }
    }
    if(sub[2]<Z-1){
        ind=sub[0]*Y*Z+sub[1]*Z+sub[2]+1;
        if(!index[ind]) {
            que.push(make_pair(A[sub[0]]+B[sub[1]]+C[sub[2]+1],ind));
            index[ind]=true;
        }
    }
}
return 0;
}

Measured memory_bytes: 975232
#include<bits/stdc++.h>
#define ll long long
#define UP(a,b,i) for(int i=(a);i<=(b);i++)
#define DOWN(a,b,i) for(int i=(a);i>=(b);i--)
#define rep(a,b,i) UP(a,b-1,i)
#define Enter() printf("\n");
using namespace std;
int ma=0x80000000;
int mi=0x7fffffff;
const ll zfc=0xffffffff;
const ll mod=1e9+7;
ll a,b;
int main()
{
	cin>>a>>b;
	if(a==1)a+=13;
	if(b==1)b+=13;
	if(a>b)cout<<"Alice";else
	if(a==b)cout<<"Draw";else
	if(a<b)cout<<"Bob";
	Enter();
	return 0;
}


Measured memory_bytes: 256
def is_stable(output_str, same_num_str):
    if len(same_num_str)>0:
        for i in range(len(same_num_str)):
            if output_str.find(same_num_str[i]) == -1:
                return "Not stable"
    return "Stable"
    
data_num = int(input())
cards = input().split(" ")
cards2 = cards[:]
cnt = 0
num_1 = 0
num_2 = 0
same_num_str = []
output_str = ""
judge_stbl = ""
for i in range(data_num):
    
    for j in range(data_num-1, i,-1):
        if int(cards[j][1:]) < int(cards[j-1][1:]):
            cards[j], cards[j-1] = cards[j-1], cards[j]
        elif int(cards[j][1:]) == int(cards[j-1][1:]):
            same_num_str.append(cards[j-1]+" "+cards[j])    
            
output_str = " ".join(cards) 
judge_stbl = is_stable(output_str, same_num_str)

print(output_str + "\n" + judge_stbl)

same_num_str = []
output_str = ""
judge_stbl = ""

for i in range(data_num):
    min_idx = i
    for j in range(i, data_num):
        if int(cards2[j][1:]) < int(cards2[min_idx][1:]):
            min_idx = j
        elif int(cards2[j][1:]) == int(cards2[min_idx][1:]) and j != min_idx:
            same_num_str.append(cards2[min_idx]+" "+cards2[j])    

    if i != min_idx:
        cards2[i], cards2[min_idx] = cards2[min_idx], cards2[i]

output_str = " ".join(cards2) 
judge_stbl = is_stable(output_str, same_num_str)

print(output_str + "\n" + judge_stbl)

Measured memory_bytes: 7764
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

void dump(vector<ll> v) {
    rep(i, v.size()) cout << v[i] << " ";
    cout << endl;
}



int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];

    int stop = n - 1;
    rep(i, n) if (x[i] >= 0) {
        stop = i;
        break;
    }

    ll mi = 1e10;
    rep(i, stop + 1) {
        int end = i + k;
        if (end <= n) {
            mi = min(mi, 2 * abs(min(0LL, x[i])) + max(0LL, x[end-1]));
            mi = min(mi, abs(min(0LL, x[i])) + 2 * max(0LL, x[end-1]));
        }
    }
    
    put(mi);

    return 0;
}

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

using namespace std;




int main(){
    int a;
    cin >> a;
    map<string, int> mm;
    for(int i = 0;i < a; ++i){
        string s;
        cin >> s;
        mm[s]++;
    }
    cin >> a;
    for(int i = 0;i < a;++i){
        string s;
        cin >> s;
        mm[s]--;
    }
    int y = -1000000000;
    for(auto x : mm){
        y = max(y, x.second);
    }
    cout << max(0, y);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

ll solve() {
    int n, k; cin >> n >> k;
    vi nums;
    int a;
    for (int i = 0 ; i < n; ++i) {
        cin >> a;
        nums.push_back(a);
    }
    sort(nums.begin(), nums.end());

    ll res = 0;
    for (int i = 0; i < k; ++i) {
        res += nums[i];
    }

    return res;
}

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

	cout << solve() << endl;
}


Measured memory_bytes: 3640
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                   0.000000000000001
#define endl                        '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[100010],vis(100010,0),dis(100010,0),par(100010,0);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
}


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

typedef uint64_t u64;

int main() {

  u64 n;
  std::cin >> n;

  u64 res = 1;
  for(u64 i = 1; i <= n; ++i) {
    res *= i;
  }

  std::cout << res << std::endl;
  
  return 0;
}

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

#define sz(a) (int)a.size()

using namespace std;

typedef long long ll;

const int N = (int)2e5 + 123;

string s;

int main() {
	cin >> s;
	int cur = 0;
	ll res = 0;
	for(int i = sz(s) - 1; i >= 0; i --) {
		if(s[i] == 'B') {
			if(i + 1 < sz(s) && s[i + 1] == 'C')
				cur ++;
			else 
				cur = 0;
		}
		if(s[i] == 'C') {
			if(i + 1 < sz(s) && s[i + 1] == 'C')
				cur = 0;
		}
		if(s[i] == 'A') {
			if(i + 1 < sz(s) && s[i + 1] == 'C')
				cur = 0;
			res += cur;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();

    long x = 800 * N;
    long y = 200 * (N / 15);
    System.out.println(x -y);
    }










    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }
}


Measured memory_bytes: 23124
from bisect import*
s=input()
t=input()
if set(t)<=set(s):
    d={}
    for k,j in enumerate(s*2):
        if j in d:
            d[j].append(k)
        else:
            d[j]=[k]
    #print(d)
    now=-1
    ans=0
    for _,i in enumerate(t):
        nex=d[i][bisect_right(d[i],now)]
        ans+=nex-now

        #print(i,_,now,nex,ans)
        
        if nex>=len(s):
            now=nex-len(s)
        else:
            now=nex
    print(ans)

else:
    print(-1)

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

int main(){
  int a, b, j;
  cin >> a >> b;
  for(int c = 1;c < 4;c++){
    j = a*b*c;
    if(j % 2 == 1){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())

A=[2,1]
ans=0
if N==1:
    ans=1
else: 
    for _ in range(N-1):
        a=A.pop(0)
        b=A.pop(0)
        c=a+b
        A.append(b)
        A.append(c)
    ans=A[1]

print(ans)


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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

lint mi(lint a, lint b, lint c) {
	return min(a, min(b, c));
}

lint ma(lint a, lint b, lint c) {
	return max(a, max(b, c));
}

lint solve(lint h, lint w) {
	lint ret = inf;

	for (int i = 1; i < h; ++i) {
		lint a = i * w;
		lint b = (h - i) * (w / 2);
		lint c = (h - i) * (w - (w / 2));

		chmin(ret, ma(a, b, c) - mi(a, b, c));

		lint d = (h - i) / 2;
		b = d * w;
		c = (h - i - d) * w;

		chmin(ret, ma(a, b, c) - mi(a, b, c));
	}

	return ret;
}

int main() {
	int h = in(), w = in();

	cout << min(solve(h, w), solve(w, h)) << endl;
}



Measured memory_bytes: 256
import sys
n, m,*l = map(int, sys.stdin.read().split())
#print(n,m,l)
a = 0
for p, q in sorted(zip(l[::2],l[1::2])):
  a += p*min(q,m)
  m -= q
  if m <= 0:
    print(a)
    break

Measured memory_bytes: 25828
#include <cstdint>
#include <iostream>
#include <boost/lexical_cast.hpp>

using namespace std;


int main ( int argc, char** argv){
    string S;
    uint64_t N;
    cin >> N;
    cin >> S;
    for( size_t i = 0; i < S.length(); i++){
        char c = S[i];
        c += N;
        if( c > 'Z' ){
            c -= 26;
        }
        cout << c;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    ll cnt = 0;
    ll bcnt = 0;
    rep(i, N) {
        if (S[i] == 'a') {
            if (cnt < A+B) {
                cnt++;
                yes;
                continue;
            }
        } else if (S[i] == 'b') {
            if (cnt < A+B & bcnt < B) {
                yes;
                cnt++;
                bcnt++;
                continue;
            }
        }
        no;
    }
    return 0;
}


Measured memory_bytes: 896
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map read . words <$> getLine :: IO [Int]
cond t f c = if c then t else f
-- end of templete

f :: [Int] -> [Int] -> IO ()
f _ [] = return ()
f (t:s) (0:c) = print t >> f s c
f s (x:c) = f (x:s) c

main = do
    map readInt . lines <$> getContents >>= f []

Measured memory_bytes: 3764
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[114514];
void f_init(int n) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int ans[514][514];
int d[514];
int n;
int a = 2;
signed main() {
	cin >> n;
	rep(i, n - 1) {
		if (!(i & 1)) d[i] = 1;
		else {
			if (i % 4 == 1) d[i] = 2;
			else {
				int j = i + 1;
				int k = 4;
				while (j % k == 0) {
					a++;
					k *= 2;
				}
				d[i] = a;
				a = 2;
			}
		}
	}
	rep(i, n - 1) {
		rep(j, n - i - 2) {
			printf("%lld ", d[j]);
		}
		printf("%lld\n", d[n - i - 2]);
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin>>N;
    vector<int>P(N);
    vector<int>Q(N);
    for(int i=0;i<N;i++){
        cin>>P[i];
    }
    for(int i=0;i<N;i++){
        cin>>Q[i];
    }
    int a=0,b=0;
    while(next_permutation(P.begin(),P.end())){
        a++;
    }
    while(next_permutation(Q.begin(),Q.end())){
        b++;
    }
    int ans=abs(a-b);
    cout<<ans;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 41, maxhash = 2e6 + 4e5;
const ll inf = 2e18, mod = 1e9 + 7, base = 1380;

int n, X, Y, Z, HAIKU[3], dp[maxn][maxhash][2], ind;
vector<int> vec[maxhash], arr;
ll powbase[maxn], powerOfTen[maxn];
unordered_map<int, int> hashToInd;
bool good[maxhash];

inline void prep(int sum = 0)
{
	vec[ind] = arr;
	int val = 0, pos = 0;
	ll HASH = 0;
	for (int i : arr)
	{
		val += i;
		if (val == HAIKU[pos])
			val = 0, pos++;
		HASH = (HASH * base % mod + i) % mod;
	}
	hashToInd[HASH] = ind;
	good[ind++] = (pos == 3);

	for (int i = 1; i <= min(X + Y + Z - sum, 10); i++)
	{
		arr.pb(i);
		prep(sum + i);
		arr.popb();
	}
}

inline void addmod(int& a, int& b)
{
	a += b;
	if (a >= mod)
		a -= mod;
}

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

	powbase[0] = powerOfTen[0] = 1;
	for (int i = 1; i < maxn; i++)
		powbase[i] = powbase[i - 1] * base % mod, powerOfTen[i] = powerOfTen[i - 1] * 10 % mod;;

	scanf("%d %d %d %d", &n, &X, &Y, &Z);
	HAIKU[0] = X, HAIKU[1] = Y, HAIKU[2] = Z;

	prep();

	dp[0][0][0] = 1;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int HASH = 0; HASH < maxhash; HASH++)
		{
			for (int b = 0; b < 2; b++)
			{
				if (!dp[i][HASH][b])
					continue;

				if (dp[i][HASH][1])
				{
					ans += powerOfTen[n - i] * dp[i][HASH][1] % mod;
					if (ans >= mod)
						ans -= mod;
					continue;
				}
				int l = 0, r = 0, sum = 0;
				ll nowhash = 0;
				for (int j = 0; j < vec[HASH].size(); j++)
					sum += vec[HASH][j], nowhash = (nowhash * base + vec[HASH][j]) % mod, r++;
				nowhash = nowhash * base % mod;
				for (int nxt = 1; nxt <= 10; nxt++)
				{
					sum++;
					nowhash++;
					if (nowhash == mod)
						nowhash = 0;
					if (sum > X + Y + Z && l < r)
					{
						sum -= vec[HASH][l];
						nowhash = (nowhash - powbase[r - l] * vec[HASH][l] % mod + mod) % mod;
						l++;
					}
					if (sum <= X + Y + Z)
					{
						int tmp = hashToInd[nowhash];
						addmod(dp[i + 1][tmp][b | good[tmp]], dp[i][HASH][b]);
					}
					else
					{
						addmod(dp[i + 1][0][b], dp[i][HASH][b]);
					}
				}
			}
		}
	}
	for (int HASH = 0; HASH < maxhash; HASH++)
		addmod(ans, dp[n][HASH][1]);
	printf("%d\n", ans);
}



Measured memory_bytes: 192840
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

//繰り返し二乗法
ll ex(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==1)return ex(x,n-1)*x%mod;
    else return ex(x*x%mod,n/2)%mod;
};

//二項係数
ll nikou(ll n,ll k){
    ll dived=1,div=1;
    for(int i=0; i<k; i++){
        dived*=(n-i)%mod;dived%=mod;
        div*=(i+1)%mod;div%=mod;
    }
    div=ex(div,mod-2);
    return dived*div%mod;
};

int main(){
    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    cout << (ex(2,n)-1-(nikou(n,a)+nikou(n,b))%mod+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while( ch < '0' || ch > '9' ) { if( ch == '-' ) f = -1; ch = getchar(); }
	while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	int n = read(), a = read(), b = read();
	if( n == 1 || a > b ) return printf( "%d\n", a == b ), 0;
	n -= 2;
	printf( "%lld\n", 1LL * n * b -1LL * n * a + 1 );
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
	while(1){
		int r0, w, c, r; cin >> r0 >> w >> c >> r;
		if(!r0 && !w && !c && !r) break;
		int n = w*c;
		int ans = max(0, (n-r0 + r -1) / r);
		cout << ans << endl;
	}
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int H,W;

bool inBoard(int y,int x){
    if(y>=0 && y<H && x >=0 && x <W ){
        return true;
    }
    return false;
}


int main(){
    cin >> H >>W;
    vector<string> S;
    S.resize(H);
    for(int i=0;i<H;i++){
        cin >> S[i];
    }
    int dx[4] = {1,0,-1,0};
    int dy[4] = {0,1,0,-1};
    ll ans =0;
    for(int sy =0;sy<H;sy++){
        for(int sx =0;sx<W;sx++){
            if(S[sy][sx] == '#'){
                continue;
            }
            ll d[H][W];
            memset(d,-1,sizeof(d));
            d[sy][sx] =0;
            queue<pair<int,int>> q;
            q.emplace(sy,sx);
            ll maxD =0;
            while(!q.empty()){
                int y= q.front().first;
                int x = q.front().second;
                maxD = max(maxD,d[y][x]);
                q.pop();
                for(int i=0;i<4;i++){
                    int ny = y + dy[i];
                    int nx = x + dx[i];
                    // cerr << "ny=" << ny <<"nx=" << nx << endl;
                    if(inBoard(ny,nx) && S[ny][nx] == '.' && d[ny][nx] == -1){
                        d[ny][nx]  = d[y][x] +1;
                        q.emplace(ny,nx);
                    }
                }
            }
            ans = max(ans,maxD);
            
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int k[10005];
  int count=0,count2=0;
  cin>>n;
  while(n!=0){
    for(int i=0;i<n;i++){
      cin>>k[i];
      if(k[i]<1)count++;
      if(k[i]<2)count2++;
    }
    if(count2==n){
      cout<<"NA"<<"\n";
    }else{
      cout<<n+1-count<<"\n";
    }
    cin>>n;
    count=0;
    count2=0;
  }
  return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, c, k;
  cin >> n >> c >> k;
  vl t(n);
  rep(i, n) cin >> t[i];
  sort(all(t));
  ll ans = 1, num = 0;
  rep(i, n) {
  	if(i>=num+c || t[i]>t[num]+k) {ans++; num=i;}
  }
  cout << ans << newl;
  return 0;
}

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


int main(){
    
    
    char x;
    cin>>x;
    
    if(x>='A' && x<='Z')
        cout<<'A'<<endl;
    
    else if(x>='a' && x<='z')
        cout<<'a'<<endl;


    return 0;
}


Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>

char s[100010];
bool ans[100010];

int main()
{
	scanf("%s", s);
	int l = strlen(s);
	ans[0] = true;
	for (int i = 0; i < l; ++i)
	{
		if (!ans[i])
			continue;
		if (strncmp(s + i, "dream", 5) == 0)
			ans[i + 5] = true;
		if (strncmp(s + i, "dreamer", 7) == 0)
			ans[i + 7] = true;
		if (strncmp(s + i, "erase", 5) == 0)
			ans[i + 5] = true;
		if (strncmp(s + i, "eraser", 6) == 0)
			ans[i + 6] = true;
	}
	puts(ans[l] ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int n, s[100000], cand;
    long long score_max = 0, score_tmp;
    set<int> used;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    for(int i=1;i<n;i++){
        score_tmp = 0;
        used.clear();
        for(int j=1; i*j<n-1-i; j++){
            cand = i*j;
            if(used.find(cand) != used.end())break;
            used.insert(cand);
            score_tmp += s[cand];

            cand = n-1-i*j;
            if(used.find(cand) != used.end())break;
            used.insert(cand);
            score_tmp += s[cand];

            score_max = max(score_max, score_tmp);
        }
    }
    cout << score_max << endl;
}


Measured memory_bytes: 5376
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll a[100002];
    ll sum = 0;
    a[0] = a[n + 1] = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum += abs(a[i] - a[i - 1]);
    }
    sum += abs(a[n]);
    for(int i = 1; i <= n; i++){
        cout << sum + abs(a[i + 1] - a[i - 1]) - abs(a[i + 1] - a[i]) - abs(a[i] - a[i - 1]) << endl;
    }
}

Measured memory_bytes: 2048
n=int(input())
a,b=list(map(int,input().split())),[]
for i in range(n):
    c=0
    while True:
        if a[i]//2==a[i]/2:
            a[i]//=2
            c+=1
        else:
            b.append(c)
            break
print(min(b))

Measured memory_bytes: 3060
# AGC023A - Zero-Sum Ranges
from collections import Counter
from itertools import accumulate


def main():
    n = int(input())
    A = [0] + list(map(int, input().split()))
    C = Counter(accumulate(A)).values()
    ans = sum(i * (i - 1) // 2 for i in C if i >= 2)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 39424
#include <stdio.h>

int intsec_line( double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double *x, double *y ) {
	double a, b, c, d;

	if ( x0 != x1 ) {
		a = ( y0 - y1 ) / ( x0 - x1 );
		b = ( x0 * y1 - x1 * y0 ) / ( x0 - x1 );
	}

	if ( x2 != x3 ) {
		c = ( y2 - y3 ) / ( x2 - x3 );
		d = ( x2 * y3 - x3 * y2 ) / ( x2 - x3 );
	}

	if ( x0 == x1 ) {
		*x = x0;
		if ( x2 == x3 )
			*y = y0 == y2 || y0 == y3 ? y0 : y1;
		else
			*y = c * *x + d;
	} else {
		if ( x2 == x3 )
			*x = x2;
		else if ( a == c )
			*x = x0 == x2 || x0 == x3 ? x0 : x1;
		else
			*x = ( -b + d ) / ( a - c );
		*y = a * *x + b;
	}

	return 0;
}


int main( void ) {
	int q;

	scanf( "%d", &q );

	while ( q-- ) {
		double x0, y0, x1, y1, x2, y2, x3, y3, x, y;

		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3 );
		intsec_line( x0, y0, x1, y1, x2, y2, x3, y3, &x, &y );

		printf( "%.8f %.8f\n", x, y );
	}

	return 0;
}

Measured memory_bytes: 668
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
// set<int>st{ 3,1,4,1,5,9,2,6,5,3,5 };
//     for (auto itr = st.begin(); itr != st.end(); ++itr) {
//         cout << *itr;
//     }
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
 string s;
 cin>>s;
 char c;
 int sum=0;
 rep(i,s.size()){
   c=s.at(i);
   //cout<<(int)c-48<<endl;
   sum+=(int)c-48;
 }
 //cout<<sum<<endl;
 if(sum%9==0){
   cout<<"Yes"<<endl;
 }else{
   cout<<"No"<<endl;}

}


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

const int MAX_N = 2e5+5;

int n;
int cnt[MAX_N];

int main() {
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        int x; cin >> x;
        cnt[x]++;
    }

    for (int i = 1; i <= n; i++) {
        cout << cnt[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 4372
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f

using namespace std;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n; cin>>n;
	vector<lint> v(n);
	for(auto &x:v)cin>>x;
	lint ans = 0;
	for(int i=1;i<n;i++){
		if(v[i] < v[i-1]){
			lint d = v[i-1] - v[i];
			ans += d;
			v[i] += d;
		}
	}
	cout<<ans<<"\n";

	return 0;	
}


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

int main()
{
	string s;
	cin>>s;
	int l = s.length();
	int a = -1;
	int b = -1;
	for(int i=0;i<=l-1;i++)
	{
		if(s[i] == s[i+1])
		{
			a = i + 1;
			b = i + 2; 
		}
	}
	for(int i=0;i<=l-2;i++)
	{
		if(s[i] == s[i+2])
		{
			a = i + 1;
			b = i + 3; 
		}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
class Program
{

    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int count = 0;
        bool ok= false;

        for(int i=0;i<N;i++)
        {
            string[] D = Console.ReadLine().Split(' ');
            int a = int.Parse(D[0]);
            int b = int.Parse(D[1]);

            if(a==b)
            {
                count += 1;
            }
            else
            {
                count = 0;
            }

            if(count>=3)
            {
                ok = true;
            }

        }

        if (ok==true)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

}



Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if (a<=c&&b>=c)
{
    cout<<"Yes"<<endl;

}
else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
    };

    // 2次元用の標準入出力
    template<typename T>
    struct inpn {
        std::size_t szi, szj;
        inpn(std::size_t _szi, std::size_t _szj) : szi(_szi), szj(_szj) {}
        operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i)
                for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
            return a;
        }
    };

    inp inp1; // input one
}


int main() {

    int n = inp1;
    vector<ll> h = inp(n);

    // dp[i] := 足場iにいるときのコストの総和の最小値
    vector<ll> dp(n , infll);
    dp[0] = 0LL;

    rep(i, n) {
        Rep(j, 1, 3) { // j歩進む
            if (i - j < 0) continue;
            chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    Cout(dp[n - 1]);

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=2e5+5;
int a[M],b[M],cs[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int iter=0;
	for(int i=1;i<=k;i++)
	{
		bool f=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]!=n)
				f=1;
		}
		if(f==0)
			break;
		memset(cs,0,sizeof(cs));
		for(int i=1;i<=n;i++)
		{
			int l=i-a[i];
			l=max(l,1);
			cs[l]++;
			int r=i+a[i];
			r++;
			r=min(r,n+1);
			cs[r]--;
		}
		int cr=0;
		for(int i=1;i<=n;i++)
		{
			cr+=cs[i];
			a[i]=cr;
		}
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<" ";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 5180