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

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

  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int s = 0;
  for (int i = 0; i + 1 < N; i++) {
    s += vec.at(i + 1);
  }
  if (vec.at(0) < s) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

using namespace std;

#define ll long long
#define ar array



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

    int x;
    cin >> x;
    if(x>=400 && x<=599){
        cout << 8;
        return 0;
    }    
    if(x>=600 && x<=799){
        cout << 7;
        return 0;
    }   
    if(x>=800 && x<=999){
        cout << 6;
        return 0;
    }   
    if(x>=1000 && x<=1199){
        cout << 5;
        return 0;
    }   
    if(x>=1200 && x<=1399){
        cout << 4;
        return 0;
    }   
    if(x>=1400 && x<=1599){
        cout << 3;
        return 0;
    }   
    if(x>=1600 && x<=1799){
        cout << 2;
        return 0;
    }   
    if(x>=1800 && x<=1999){
        cout << 1;
        return 0;
    }   
    return 0;
}


Measured memory_bytes: 3648
D = int(input())

def table(i, k):
    if i == k:
        return list(range(9, -1, -1)) + [0]*9
    else:
        return list(range(10, 0, -1)) + list(range(1, 10))

def nine(i):
    return 10**i - 1

def rec(d, i, k):
    res = 0
    num  = table(i, k)
    if i == 1:
        for j in range(-9, 10):
            if 9*j == d:
                return num[j]
        return 0
    if i == 2:
        for j in range(-9, 10):
            if d == 99*j:
                return 10*num[j]
    if not -10*nine(i) <= d <= 10*nine(i):
        return 0
    for j in range(-9, 10):
        if d%10 == j*nine(i)%10:
            res += num[j] * rec((d-j*nine(i))//10, i-2, k)
    return res

l = 0
while D % 10 == 0:
    D//= 10
    l += 1

if l == 0:
    a = 1
else:
    a = 9*10**(l-1)

ans = 0
for i in range(1, 20):
    if not l:
        ans += rec(D, i, i)
    else:
        ans += rec(D, i, 100)
print(a * ans)


Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};

static MOD: i64 = 1e9 as i64 + 7;

fn modpow(a: i64, n: usize) -> i64{
    if n == 0{
        return 1i64
    }
    let mut res = modpow((a * a) % MOD, n / 2);
    if n % 2 == 1{
        res *= a;
        res %= MOD;
    }
    res
}

fn main() {
    input! {
        n: usize,
    }
    let mut ans = modpow(10, n) - modpow(9, n) - modpow(9, n) + modpow(8, n);
    ans %= MOD;
    ans = (ans + MOD) % MOD;
    println!("{}", ans);
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define mo 998244353
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define ms 16
#define endl '\n'

 
using namespace std ;
 
#define N 400005

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;


int main()
{
    
///////////////////////////////////////////
    fastio;

    lli n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;

    string s;
    cin>>s;

    lli f1=1;
    
    loopl(i,a-1,c-1)
    {
        if(s[i]=='#' && s[i+1]=='#')
        {
            f1=0;
            break;
        }
    }

    if(!f1)
    {
        cout<<"No";
        return 0;
    }

    f1=1;
    loopl(i,b-1,d-1)
    {
        if(s[i]=='#' && s[i+1]=='#')
        {
            f1=0;
            break;
        }
    }

    if(!f1)
    {
        cout<<"No";
        return 0;
    }

    if(c<b)
    {
        cout<<"Yes";
        return 0;
    }

    if(d>c)
    {
        cout<<"Yes";
        return 0;
    }

    f1=0;
    for(lli i=b-1;i<=d-1;i++)
    {
        if(s[i] == '#')
            continue;

        if(s[i-1]!='#' && s[i+1]!='#')
        {
            f1=1;
           // cout<<i<<endl;
            break;
        }

    }


    if(f1)
    {
        cout<<"Yes";
        return 0;
    }

    cout<<"No";






}

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



int main() {
   int n,y;
  cin >> n >> y;
  
  int res10000=-1;
  int res5000=-1;
  int res1000=-1;
  
  for(int i=0;i<=n;++i){
    for(int j=0;j+i<=n;j++){
      int k = n-i-j;
      int total = 10000*i+5000*j+1000*k;
      if(total==y){
        res10000 = i;
        res5000 =j;
        res1000 = k;
      }
    }
  }
  
  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

    
 





Measured memory_bytes: 256
H, W = map(int, input().split())
A = [list(map(int, input().split())) for h in range(H)]


ans = []
for h in range(H):
    for w in range(W - 1):
        # 偶数なら何もしない
        if A[h][w] % 2 == 0:
            continue

        # 右隣に移動
        A[h][w] -= 1
        A[h][w + 1] += 1

        ans.append([h, w, h, w + 1])


for h in range(H - 1):
    # 偶数なら何もしない
    if A[h][W - 1] % 2 == 0:
        continue

    # 下に移動
    A[h][W - 1] -= 1
    A[h + 1][W - 1] += 1

    ans.append([h, W - 1, h + 1, W - 1])


print(len(ans))
for ph, pw, nh, nw in ans:
    print(ph + 1, pw + 1, nh + 1, nw + 1)


Measured memory_bytes: 26392
(defun main ()
  (declare (optimize (speed 3) (safety 0)))
  (let* ((unit-r (read))
         (unit-g (read))
         (unit-b (read))
         (n (read))
         (res 0))
    (declare ((integer 0 3000) unit-r unit-g unit-b n)
             ((unsigned-byte 32) res))
    (loop for r to n by unit-r
          do (loop for g to (- n r) by unit-g
                   for rest = (- n r g)
                   when (zerop (mod rest unit-b))
                   do (incf res)))
    (format t "~D~%" res)))
 
#-swank(main)


Measured memory_bytes: 13668
#python3
from collections import Counter
def main():
    n,k,q = map(int, input().split())
    a = Counter([int(input())-1 for _ in range(q)])
    p = [k-q for _ in range(n)]

    for i,j in a.items():
        p[i] += j

    for i in range(n):
        if p[i] > 0:
            print('Yes')
        else:
            print('No')
main()


Measured memory_bytes: 13172
S = input()

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

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

int main(void){
    // Your code here!
    long long N;cin>>N;
    vector<long long>D(N);
    for(long long i=0;i<N;i++){
        cin>>D[i];
    }
    sort(D.begin(),D.end());
    long long M;cin>>M;
    if(N<M){
        cout<<"NO"<<endl;
        return 0;
    }
    vector<long long>T(M);
    for(long long i=0;i<M;i++){
        cin>>T[i];
    }
    sort(T.begin(),T.end());
    long long tmp=0,count=0;
    for(long long i=0;i<N;i++){
        if(D[i]!=T[count]){
            continue;
        }
        count++;
        tmp++;
    }
    if(tmp==M){
        cout<<"YES"<<endl;
        return 0;
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 6344
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))

int H[100000];
//int A[100000];
//int B[100000];
int X[100000];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &H[i]);
    X[i] = 1;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    //scanf("%d%d", &A[i], &B[i]);
    scanf("%d%d", &a, &b);
    a -= 1;
    b -= 1;
    if (H[a] <= H[b]) {
      X[a] = 0;
    }
    if (H[b] <= H[a]) {
      X[b] = 0;
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (X[i]) {
      sum++;
    }
  }
  printf("%d", sum);

  return 0;
}

Measured memory_bytes: 2928
#include <stdio.h>

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

    int H[N], i, j,  ans = 0, lf;

    for (i=0; i<N; i++){
        scanf("%d", &H[i]);
    }

    for (i=0; i<N; i++){
        lf =1;
        for (j=0; j<N; j++){
            if (j >= i) break;
            if (H[j] > H[i]){
                lf = 0;
                break;
            }
        }
        if (lf == 1) ans++;
    }

    printf("%d",  ans);

    return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), m = sc.nextInt();
        int[] cnt = new int[n];
        Arrays.fill(cnt, 1);
        Set<Integer> s = new HashSet<>();
        s.add(0);
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt() - 1, y = sc.nextInt() - 1;
            cnt[x]--;
            cnt[y]++;
            if (s.contains(x)) {
                s.add(y);
            }
            if (cnt[x] == 0) {
                s.remove(x);
            }
        }
        debug(s);
        System.out.println(s.size());
    }

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


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


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

using namespace std;

int flip[2];
vector<int> nums[2];
void ng(){
	cout<< "No" << endl;
	exit(0);
}

void ok(){
	cout << "Yes" << endl;
	exit(0);
}

int bit[108000];

void add(int x, int val){
	x++;
	while(x < 108000){
		bit[x] += val;
		x += x & -x;
	}
}

int sum(int x){
	x++;
	int res = 0;
	while(x){
		res += bit[x];
		x -= x & -x;
	}
	return res;
}

int bubble(vector<int> x){
	fill(bit, bit + 108000, 0);
	int n = x.size();
	int res = 0;
	for(int i = n-1;i >= 0;i--){
		int a = x[i];
		res += sum(a);res %= 2;
		add(a, 1);	
	}
	return res;
}

int n;
int a[3][108000];
int val[108000];

int main(){
	cin >> n;
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < n;j++){
			cin >> a[i][j];
		}
	}
	for(int i = 0;i < n;i++){	
		int x = a[0][i];
		int y = a[1][i];
		int z = a[2][i];
		if(!((x+1 == y && y+1 == z) || (x-1==y && y-1==z)))ng();
		
		val[i] = y / 3;
		flip[i%2] += !(x % 3);
	}
	
	for(int i = 0;i < n;i++){
		if((val[i] - i) % 2)ng();
	}

	for(int i = 0;i < n;i++){
		nums[i%2].push_back(val[i]/2);
	}
	
	int even = bubble(nums[0]) % 2;
	int odd = bubble(nums[1]) % 2;
	flip[0] %= 2;
	flip[1] %= 2;
	if(even != flip[1])ng();
	if(odd != flip[0])ng();
	ok();
	return 0;		
}

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll n, k;

const int MAX = 303030;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> n >> k;
	combinit();
	ll ans = 0;
	for (int i = 0; i <= min(k,n-1); i++) {
		ans += (comb(n-1,i)*comb(n,i))%MOD;
		ans %= MOD;
	}
	puts(ans);
	


	return 0;
}

Measured memory_bytes: 7424
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int A = sc.nextInt();
			if (A == 0) break;
			int B = sc.nextInt();
			int D = sc.nextInt();
			int ax = 100000;
			int ay = 100000;
			for (int x = 0; x < ax + ay; ++x) {
				if (x * A >= D) {
					if ((x * A - D) % B == 0) {
						int y = (x * A - D) / B;
						if (x + y < ax + ay || x + y == ax + ay && x * A + y * B < ax * A + ay * B) {
							ax = x;
							ay = y;
						}
					}
				} else {
					if ((D - x * A) % B == 0) {
						int y = (D - x * A) / B;
						if (x + y < ax + ay || x + y == ax + ay && x * A + y * B < ax * A + ay * B) {
							ax = x;
							ay = y;
						}
					}
				}
				if ((x * A + D) % B == 0) {
					int y = (x * A + D) / B;
					if (x + y < ax + ay || x + y == ax + ay && x * A + y * B < ax * A + ay * B) {
						ax = x;
						ay = y;
					}
				}
			}
			System.out.println(ax + " " + ay);
		}
	}
}

Measured memory_bytes: 20768
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e18+1e18;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

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

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

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

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

	ll g = gcd(A, B);

	if (C % g == 0) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define lli long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fi(a,n) for(lli i=a; i<=n; i++)
const int M=1000000007;
using namespace std;
const int mxn=2e5;
int n,m,p[mxn];
vector<int> adj[mxn],ans;
int dp[mxn];
int vis[mxn],act[mxn];

// int pro(int a[],int n){
// 	int mxp=1;
// 	int mip=1;
// 	int mxf=1;
// 	int f=0;
// 	int mini=INT_MAX;
// 	int maxa=INT_MIN;
// 	for(int i=0;i<n;i++){
// 		mini=min(mini,arr[i]);
// 		maxa=max(maxa,a[i]);
// 		if(a[i]>0){
// 			mxp=mxh*a[i];
// 			mip=min(mip*a[i],1);
// 			flag=1;
// 		}
// 		else if(a[i]==0){
// 			mxp=1;mip=1;
// 		}
// 		else {
// 			int temp=
// 		}
// 	}
// }
int main() {
	
fast
lli a,b,c,d;
cin>>a>>b>>c>>d;
lli t=max(a*c,max(a*d,max(b*c,b*d)));
cout<<t<<endl;
}


Measured memory_bytes: 8336
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 read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let nk: Vec<usize> = read_vec();
    let n = nk[0];
    let k = nk[1];

    let mut a_vec: Vec<usize> = Vec::new();

    for _ in 0..k {
        let _: usize = read();
        a_vec.append(&mut read_vec());
    }

    a_vec.sort();
    a_vec.dedup();
    println!("{}", n - a_vec.len());
}


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

const int NM=1e5;

int v[105];
bool dp[NM];

int main()
{   int n,k;
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>v[i];
    ///dp[i]=1, daca sunt i pietre si primul jucator castiga
    for(int j=0; j<=k; j++)
        for(int i=1; i<=n; i++)
            if(!dp[j] && j+v[i]<=k)
                dp[j+v[i]]=1;
    cout<<(dp[k] ? "First" : "Second");
    return 0;
}

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

int main() {
  int64_t X;
  cin >> X;
  int64_t T = 100LL;
  int year = 0;

 
  
  while (T < X) {
    T = T * 1.01;
    year++;
  }

  cout << year << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

int compare_int(const void *a, const void *b){//qsort 整数比較<
	return *(int*)a - *(int*)b;
}
int compare_int2(const void *a, const void *b){//qsort 整数比較>
	return *(int*)b - *(int*)a;
}

int main(void){
	int n;
	char c[4]={'\0'};
	int aa=0,aw=0,at=0,ar=0;
	int i;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",c);
		if(strcmp(c,"AC")==0){
			aa++;
		}else if(strcmp(c,"WA")==0){
			aw++;
		}else if(strcmp(c,"TLE")==0){
			at++;
		}else{
			ar++;
		}

	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",aa,aw,at,ar);

	return 0;
}


Measured memory_bytes: 1732
// 1_abc131_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<char> s(4);
    rep(i, 4){
        cin >> s[i];
    }
    if(s[0] != s[1] && s[1] != s[2] && s[2] != s[3]){
        cout << "Good" << endl;
    }else{
        cout << "Bad" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
     
    public class Main{
        
        static final int MOD = (int)1e9+7;
        
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int n = Integer.parseInt(sc.next());
            int k = Integer.parseInt(sc.next());
            long[] a = new long[n];
            for(int i=0; i<n; i++){
                a[i] = Long.parseLong(sc.next());
            }
            Arrays.sort(a);
            int l = 0;
            int r = n-1;
            long ans = k%2==0 ? 1 : a[r--];
            int b = ans<=0 ? -1 : 1;
            while(k>1){
                long m = a[l]*a[l+1];
                long p = a[r]*a[r-1];
                if(m*b >= p*b){
                    ans = ans*(m%MOD)%MOD;
                    l+=2;
                }else{
                    ans = ans*(p%MOD)%MOD;
                    r-=2;
                }
                k-=2;
            }
            System.out.println((ans+MOD)%MOD);
        }
    }

Measured memory_bytes: 62000
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;


void main() {
    immutable int INF = 1 << 29;

    auto N = readln.chomp.to!int + 2;
    auto S = '0' ~ readln.chomp ~ '0';
    auto dp = new int[](N);
    dp.fill(-INF);
    dp[0] = 0;

    foreach (i; 1..N-1) {
        dp[i] = max(dp[i], dp[i-1]);
        if (S[i-1..i+2] != "101") continue;
        for (int p = i - 1; p >= 0 && S[p] == '1'; --p) {
            dp[i+1] = max(dp[i+1], dp[p-1] + i - p);
        }
        for (int p = i + 1; p < N && S[p] == '1'; ++p) {
            dp[p] = max(dp[p], dp[i-2] + p - i);
        }
    }

    dp[N-2].writeln;
}


Measured memory_bytes: 4368
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
//const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int h,w,n;
		cin>>n>>w>>h;
		if(h==0) break;
		vp a;
		a.push_back({h,w});
		for(int i=0;i<n;i++){
			int id,x;
			cin>>id>>x;
			id--;
			P p=a[id];
			a.erase(a.begin()+id);
			int H=p.first,W=p.second;
			while(x>=2*H+2*W) x-=2*H+2*W;
			if(x<W){
				a.push_back({H,x});
				a.push_back({H,W-x});
			}
			else if(x<H+W){
				a.push_back({x-W,W});
				a.push_back({H+W-x,W});
			}
			else if(x<H+2*W){
				a.push_back({H,x-H-W});
				a.push_back({H,H+2*W-x});
			}
			else{
				a.push_back({x-H-2*W,W});
				a.push_back({2*H+2*W-x,W});
			}
			if(a[i].first*a[i].second>a[i+1].first*a[i+1].second) swap(a[i],a[i+1]);
/*			sort(a.begin(),a.end(),[](P p,P q){
				return p.first*p.second<q.first*q.second;
			});*/
		}
		sort(a.begin(),a.end(),[](P p,P q){
				return p.first*p.second<q.first*q.second;
		});
		for(int i=0;i<=n;i++){
			if(i) cout<<' ';
			cout<<a[i].first*a[i].second;
		}
		cout<<endl;
	}
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  vector<int> vec(3);
  for(int i = 0;i < 3; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  
  if(vec[0] == 5 && vec[1] == 5 && vec[2] == 7){
    cout << "YES" <<endl;
  }
  
  else {
    cout << "NO" << endl;
  }
  
  return 0;
}
    

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

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
	vector<double> l(10);
	vector<double> v(2);
	char c;
	
	while(cin>>l[0]){
		rep(i,9) cin >> c >> l[i+1];
		rep(i,2) cin >> c >> v[i];
		double sum = 0,sum2=0,sum3=0;
		rep(i,l.size()) sum += l[i];
		rep(i,v.size()) sum2 += v[i];
		rep(i,l.size()) {
			sum3+=l[i];
			if(sum3/sum>=v[0]/sum2){
				cout << i+1 << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1224
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(void){
  int n,count=0;
  cin>>n;
  int a[n];
  for(int i = 0 ; i< n ; i++){
    cin>>a[i];
    if(a[i]< 2) {
        count++;
    }
    else if(a[i] ==2 ){
        
    }
    else if(a[i]% 2 ==0 ){ 
         count++;
    }
   else{
      for(int j = 3 ; j<= sqrt(a[i]); j+=2){
          if(a[i] % j ==0){
              count++;
              break;
            }
        }
     }
  }
  cout<<n-count<<endl;
  return 0;
}


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

typedef long long LL;

int main(void){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " "<< x << " " << y << endl;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define INF LLONG_MAX/2
#define PI acos(-1.0)
//#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long n, long long x, long long y){
    x--; y--;
    Vi ans(n);
    REP(i,0,n){
        REP(j,i+1,n){
            if(j<=x) ans[j-i]++;
            else if(y<=i) ans[j-i]++;
            else{
                int t_ans;
                t_ans=min({j-i,abs(x-i)+1+abs(y-j)});
                ans[t_ans]++;
            }
        }
    }
    REP(i,1,n){
        cout<<ans[i]<<endl;
    }
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(N, X, Y);
    return 0;
}


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

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

using namespace std;

typedef long long ll;

#define MAX 100010
int N, A[MAX];

int main() {
  cin >> N;
  rep(i,N) cin >> A[i];
  ll answer = 0;
  rep(i,N) {
    int use = A[i]/2;
    A[i] -= use * 2;
    answer += (ll)use;
    if( A[i] && A[i+1] && i+1 < N ) {
      ++answer;
      --A[i], --A[i+1];
    }
  }
  /*
  rep(i,N-1) {
    int use = min(A[i],A[i+1]);
    A[i]   -= use;
    A[i+1] -= use;
    answer += (ll)use;
  }
  rep(i,N) {
    int use = A[i] / 2;
    A[i] -= use * 2;
    answer += (ll)use;
  }
  */
  cout << answer << endl;
  return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> V(N);
	for (int i = 0; i < N; ++i) cin >> V[i];

	long long ans = 0;
	for (int p = 0; p <= min(N, K); ++p) {
		for (int q = 0; p + q <= min(N, K); ++q) {
			vector<long long> v;
			long long cur = 0;
			for (int i = 0; i < p; ++i) v.push_back(V[i]), cur += V[i];
			for (int i = 0; i < q; ++i)
				v.push_back(V[N - 1 - i]), cur += V[N - 1 - i];
			sort(v.begin(), v.end());
			for (int i = 0; i < min((int)v.size(), K - p - q); ++i) {
				if (v[i] < 0) cur -= v[i];
			}
			ans = max(ans, cur);
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int N = 100;

int min(int x,int y){
  if(x<y)return x;
  else return y;
}

int main(){
  int n, p[N+1], m[N+1][N+1], h=1;
  scanf("%d",&n);
  for(int i=1;i<=n;i++)scanf("%d %d",&p[i-1],&p[i]);

  for(int i=1;i<=n;i++)m[i][i]=0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j = i + l -1;
      m[i][j] = (1<<21);
      for(int k=i;k<=j-1;k++){
	m[i][j]= min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}




Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
	int n, m;
	cin >> n >> m;
	int sum = 0;
	rep (i, m) {
		int a;
		cin >> a;
		sum += a;
	}
	if (sum > n) cout << -1 << endl;
	else cout << n - sum << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>

using namespace std;

int main(){

  string s;
  int appear_cnt[26][2]={0};
  int over_half;

  int char_num = 0;
  const int char_base = 'a';

  int a = 0, b = 0;

  cin >> s;

  int s_len=s.size();
  over_half = s_len / 2 + 1;

  for (int i = 0; i < s_len; i++)
  {
    char_num = (char)s[i] - char_base;
    
    if (appear_cnt[char_num][0]==0)
    {
      appear_cnt[char_num][1] = -3;
    }
    appear_cnt[char_num][0]++;

    if (i-appear_cnt[char_num][1]<=2) {
      a = i - 1;
      b = i + 1;
      appear_cnt[char_num][1] = i;      
      break;
    }
    else
    {
      appear_cnt[char_num][1] = i;
    }
  }

  if (a==0 && b!=0)
  {
    a = 1;
    b = s_len;
  }

  if (a==0 || b==0)
  {
    cout << -1 << " " << " " << -1 << endl;
  } else 
  {
    //cout << s.substr(a, b-a+1) << endl;
    cout << a << " " << " " << b << endl;
  }

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<ctime>
#include<cstdlib>
#include<vector>
using namespace std;
int vis[101];
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);vis[a]++;vis[b]++;
	vis[c]++;
	if(vis[5]==2&&vis[7]==1)cout<<"YES";
	else cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//{
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define all(v) (v).begin(),(v).end()
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)


#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
};
//{
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);
//}

vector<string> v[1234567];
set<int> memo[1234567];
set<int> memo2[1234567];
int mod = 1e9 + 9;
int mod2 = 1e9+7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
	int n;
	cin >> n;
	FOR(i,0,n) {
		string s; cin >> s;
		v[s.length()].pb(s);
	}
	vector<string> in;
	FOR(i,1,1e6) {
		if (v[i].size() != 0) {
			FOR(j,0,v[i].size()) in.pb(v[i][j]);
		} 
	}
	lint ans = 0;
	FOR(jj,0,in.size()) {	

		string s = in[jj];
		//debug() << s;
		if (s.size() == 1) {
			memo[0].insert((s[0]-'a')+100);
			memo2[0].insert((s[0]-'a')+123);
			continue;
		}
		VI ile(26,0);
		FOR(i,0,s.length()) ile[s[i]-'a']++;
		int hash = 0;
		int hash2 = 0;
		FOR(i,0,s.length()) {
			FOR(j,0,26) if (ile[j] > 0 && memo[i].find((2137LL*hash+j+100)%mod) != memo[i].end() && 
			memo2[i].find((7312LL*hash2+j+123)%mod) != memo2[i].end()) ans++;
			int ii = s.length()-i-1;
			ile[s[ii]-'a']--;
			if (ii == 0) memo[s.length()-1].insert((hash*2137LL+(s[0]-'a')+100)%mod);
			if (ii == 0) memo2[s.length()-1].insert((hash2*7312LL+(s[0]-'a')+123)%mod);
			hash = (hash *2137LL + (s[ii]-'a')+100) % mod;
			hash2 = (hash2 *7312LL + (s[ii]-'a')+123) % mod;
		}
		//debug() << ans;
	}
	printf("%lld\n", ans);
}



Measured memory_bytes: 179192
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    long h;
    cin >> h;

    long two = 1;
    long sum = 0;
    while (h > 1) {
        sum += two;
        two = two << 1;
        h = h / 2;
    }
    sum += two;

    cout << sum << endl;
    return 0;
}


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

using namespace std;

int main(){
	char S[6];
	int len;
	scanf(" %s",S);
    len = strlen(S);
    if(len == 2)
    	for(int i = 0; i< len ;i++){
    		printf("%c",S[i]);
    		}
    		if(len == 3)
    			for(int i = len - 1;i>=0; i--)
    				printf("%c",S[i]);
}


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

int main(){
  
  int X,A;
  string S;

  cin >> S;

  sort(S.begin(),S.end());

  if((S[0]==S[1])&&(S[2]==S[3])&&(S[1]!=S[2])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
 
  return(0);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int A[10000];
	int i=0;
	cin>>A[i];
    while (A[i] != 0)
	{
		i=i+1;
		cin>>A[i];
	};
	for(int j=0;j<i;j++)
	{
		cout<<"Case"<<" "<<j+1<<": "<<A[j]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3104
package main

import (
        "fmt"
)

func main() {
        var n, x, min, m int
        fmt.Scan(&n, &x)
        fmt.Scan(&min)
        x -= min
        for i := 1; i < n; i++ {
                fmt.Scan(&m)
                x -= m
                if min > m {
                        min = m
                }
        }
        fmt.Println(x/min + n)
}

Measured memory_bytes: 512
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
V ans;

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

  cin >> n >> m >> s;
  ll now = n;
  while (1) {
    if (now - m <= 0) {
      ans.p_b(abs(now));
      break;
    } else {
      int ok = 0;
      ll dis = m;
      rrep(i, now - m, now) {
        if (s[i] == '0') {
          now = i;
          ans.p_b(dis);
          ok = 1;
          break;
        } else
          dis--;
      }
      if (!ok) {
        Cout(-1);
        return 0;
      }
    }
  }
  reverse(all(ans));
  rep(i, Size(ans)) cout << ans[i] << " ";
  cout << "\n";
  return 0;
}

Measured memory_bytes: 1480
H, W = list(map(int, input().split()))
Hs = [[0] * W for i in range(H)]
Vs = [[0] * W for i in range(H)]
 
Ss = [0] * H
for i in range(H):
    Ss[i] = input()
 
for i in range(H):
    s = 0
    e = 0
    c = 0
    for k in range(W):
        if Ss[i][k] == ".":
            c += 1
        else:
            e = k
            for m in range(e - s):
                Hs[i][s + m] = c
            s = e + 1
            c = 0
    e = W
    for m in range(e - s):
        Hs[i][s + m] = c
# 縦
for i in range(W):
    s = 0
    e = 0
    c = 0
    for k in range(H):
        if Ss[k][i] == ".":
            c += 1
        else:
            e = k
            for m in range(e - s):
                Vs[s + m][i] = c
            s = e + 1
            c = 0
    e = H
    for m in range(e - s):
        Vs[s + m][i] = c
 
maxv = 0
for i in range(H):
    for k in range(W):
        t = Hs[i][k] + Vs[i][k] - 1
        if t > maxv:
            maxv = t
print(maxv)

Measured memory_bytes: 123356
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
const int INF=1000000000;
const int MAX_N=1000;
const int MAX_M=1000;
typedef pair<int,int> P;
char maze[MAX_N][MAX_N+1];
int N,M,a,b,c,e,f;
int sx,sy;
int gx,gy;
int d[MAX_N][MAX_N];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int bfs(){
 queue<P>que;
  que.push(P(sx,sy));
  d[sx][sy]=0;
  while(que.size()){
    P p=que.front();que.pop();
    if(p.first==gx&&p.second==gy)break;
    for(int i=0;i<4;i++){
      int nx=p.first+dx[i],ny=p.second+dy[i];
      if(0<=nx&&nx<N&&0<=ny&&ny<M&&maze[nx][ny]!='X'&&d[nx][ny]==INF){
        que.push(P(nx,ny));
        d[nx][ny]=d[p.first][p.second]+1;
      }
    }
  }
  return d[gx][gy];
}
int main(){
  ll a,ans=0;cin>>a;
  vector<ll>b(a);
  rep(i,a)cin>>b[i];
  sort(b.begin(),b.end());
  rep(i,a-2){
    for(ll o=i+1;o<a-1;o++){
      for(ll j=o+1;j<a;j++){
        if(b[j]<b[i]+b[o]&&b[j]!=b[i]&&b[j]!=b[o]&&b[o]!=b[i])ans++;
      }
    }
  }
  cout<<ans;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
long long a[200005],b[200005];
long long s1,s2;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<n;i++) 
	{
		s1+=a[i];
		s2+=b[i];
	}
	if(s1<s2)
	{
		cout<<"-1";
		return 0;
	}
	long long x=0,cnt=0;
	vector<long long>v;
	for(int i=0;i<n;i++)
	{
		if(a[i]<b[i])
		{
			x+=b[i]-a[i];
			cnt++;
		}
		else
			v.push_back(a[i]-b[i]);
	}
	sort(v.begin(),v.end(),greater<long long>());
	for(int i=0;i<v.size();i++)
	{
		if(x>0)
		{
			x-=v[i];
			cnt++;
		}
	}
	cout<<cnt;

	return 0;
}

Measured memory_bytes: 2936
#include<bits/stdc++.h>
// #define int long long int
#define endl "\n"
#define arrinp(v) for(auto &i:v) cin>>i;
#define arrout(v) for(auto &i:v) cout<<i<<" ";
#define newline cout<<endl;
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        string s;
        cin >> s;
        if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
        {
            cout << "3" << endl;
        }
        else if (s[0] == 'R' && s[1] == 'R' || s[1] == 'R' && s[2] == 'R')
        {
            cout << "2" << endl;
        }
        else if (s[0] == 'S' && s[1] == 'S' && s[2] == 'S')
        {
            cout << "0" << endl;
        }
        else
        {
            cout << "1" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

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


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0;
    if (N < 105) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 105; i <= N; i+=2) {
        int count = 0;
        for (int j = 1; j <= N; ++j) {
            if (i%j==0) count++;
            
        }
        if (count == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

bool isP(char str[],int l,int h) 
{ 
    h--;
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return false; 
        } 
    } 
    return true;
} 

int main()
{
    char s[100];
    cin>>s;
    int l=strlen(s);
    
    if(isP(s,0,l) && isP(s,0,(l-1)/2) && isP(s,((l+3)/2)-1,l))
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    while a:
        a, b = b % a, a
    return b
 
 
def main():
    n, y = map(int, input().split())
    xs = list(map(int, input().split()))
    res = abs(y - xs[0])
    for x in xs[1:]:
        res = gcd(res, abs(y - x))
    print(res)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back





int factorial(int n){
  if (n==0){
    return 1;
  }
  if (n==1){
    return 10;
  }
  if (n%2==0){
    return (factorial(n/2)*factorial(n/2))%2019;
  }
  if (n%2==1){
    return (factorial(n/2)*factorial(n/2)*10)%2019;
  }
}




int main(){
  
 
  string s;
  cin>>s;
  
  ll n=int(s.size());
  
  vector<ll> data(n+1);
  
  data.at(n)=0;
  data.at(n-1)=(s.at(n-1)-'0');
  
  for (int i=n-2;i>=0;i--){
    data.at(i)=(data.at(i+1)+(factorial(n-1-i)*(s.at(i)-'0')))%2019;
  }
  

  
  map<ll,ll> cnt;
  rep(i,n+1){
    if (cnt.count(data.at(i))){
      cnt.at(data.at(i))++;
    }
    else {
      cnt[data.at(i)]=1;
    }
  }
  
  ll answer=0;
  for (auto mypair:cnt){
    answer+=(mypair.second)*(mypair.second-1)/2;
  }
  
  cout<<answer<<endl;
  
  
 
  
}






















Measured memory_bytes: 5232
S = list(input())
cnt1 = 0
cnt2 = 0
if S[0] == 'A':
    for i in range(2, len(S)-1):
        if S[i] == 'C':
            cnt1 += 1
    if cnt1 == 1:
        for j in range(len(S)):
            if S[j].isupper():
                cnt2 += 1
        if cnt2 == 2:
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
    string s;
    cin >> s;
    string s1, s2;
    for (ll i = 0; i < s.size();i++){
        if(i%2==1){
            s1.push_back('0');
            s2.push_back('1');
        }
        else{
            s1.push_back('1');
            s2.push_back('0');
        }
    }
    ll cnt1 = 0;
    ll cnt2 = 0;
    for (ll i = 0; i < s.size();i++){
        if (s[i] != s1[i]) cnt1++;
        if (s[i] != s2[i]) cnt2++;
    }
    cout << min(cnt1, cnt2) << endl;
}


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

int n,start=0;
int a[200005],num[200005],ans[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		num[a[i]]++;
	}
	for (int i=1;i<=200000;i++)  start=start+(num[i]*num[i]-num[i])/2;
	for (int i=1;i<=200000;i++)  ans[i]=start-(num[i]-1);
	
	for (int i=1;i<=n;i++)  cout<<ans[a[i]]<<endl;
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <cmath>

using namespace std;
int A[100001];
int F[100001];
int n;

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>A[i];
    }
    F[1]=0;
    F[2]=abs(A[1]-A[2]);
    for(int i=3; i<=n; i++)
    {
        F[i]=min(F[i-1]+abs(A[i-1]-A[i]),F[i-2]+abs(A[i-2]-A[i]));
    }
    cout<<F[n];
    return 0;
}


Measured memory_bytes: 1024