akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
        MyDebugger.Test(process, "../TextFile1.txt");
        MyDebugger.Test(process, "../TextFile2.txt");
#else
        checked {
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
        }
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        //var ab = new int[n][];
        //for(int i=0; i<n; i++) {
        //    ab[i] = ToIntArray(input.ReadLine(), 2);
        //}
        var aa = new int[n];
        var bb = new int[n];
        for (int i = 0; i < n; i++) {
            var spl = input.ReadLine().Split(' ');
            aa[i] = int.Parse(spl[0]);
            bb[i] = int.Parse(spl[1]);
        }

        Array.Sort(aa);
        Array.Sort(bb);

        var mins = aa; //new int[n];
        var maxs = bb; //new int[n];

        //for(int i=0; i<n; i++) {
        //    mins[i] = aa[i];
        //    maxs[i] = bb[i];
        //}

        if(n % 2 == 1) {
            var ce = (n+1)/2 -1;
            return maxs[ce] - mins[ce] + 1;
        } else {
            var ce1 = n/2-1;
            var ce2 = n/2+1-1;

            //long co1 = Math.Min(maxs[ce1], mins[ce2]) - mins[ce1];
            //long co2 = maxs[ce1] - mins[ce2] + 1;
            //if(co2 < 0) co2 = 0;
            //long co3 = maxs[ce2] - Math.Max(maxs[ce1], mins[ce2]);

            //long sum = 0;
            //sum += co1 * (co2 + co3);
            //sum += co2 * co3;
            //sum += co2 * (co2 -1) / 2 + co2;
            //return sum;

            //var hash = new HashSet<RationalNumber>();

            //for (int i = mins[ce1]; i <= maxs[ce1]; i++) {
            //    for (int j = Math.Max(mins[ce2], i); j <= maxs[ce2]; j++) {
            //        var y = new RationalNumber(j + i, 2);

            //        if (!hash.Contains(y)) hash.Add(y);
            //        Debug.WriteLine(y);
            //    }
            //}

            //return hash.Count();

            long min = mins[ce1] + mins[ce2];
            long max = maxs[ce1] + maxs[ce2];
            return max - min + 1;
        }
    }
}

Measured memory_bytes: 42104
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m, c, count=0, ans=0;
    cin >> n >> m >> c;
    vector<int> B(m);
    for(int i = 0; i < m; i++){
        cin >> B[i];
    }
    vector<int> A(m);
    for(int j = 0; j < n; j++){
        for(int i = 0; i < m; i++){
            cin >> A[i];
        }
        for(int i = 0; i < m; i++){
            ans += A[i] * B[i];
        }
        ans += c;
        if(ans > 0)
            count++;
        ans = 0;         
    }
    cout << count;
    return 0; 
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()

const int mod = 1000000007;
int binpow(int a, int b, int mod)
{
    int ans = 1;
    a = a % mod;
    b = b % mod;
    if (b == 0)
        return 1;
    while (b)
    {
        if (b & 1)
            ans = ((ans % mod) * (a % mod)) % mod;
        a = ((a % mod) * (a % mod)) % mod;
        b >>= 1;
    }
    return ans % mod;
}

//read question carefully!

/*
p p
p n
n p
n n

*/

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d; //fine
        cout << max({a * d, a * c, b * c, b * d}) << "\n";
        //p p
        // if (b > 0 && d > 0)
        // {
        //     cout << max(a * c, b * d) << "\n";
        //     return 0;
        // }

        // if (b <= 0 && d <= 0)
        // {
        //     cout << max(a * c, b * d) << "\n";
        //     return 0;
        // }
        // if (b > 0 && d == 0)
        // {
        //     cout << max(a * c, (int)0) << "\n";
        //     return 0;
        // }
        // if (b == 0 && d > 0)
        // {
        //     cout << max(a * c, (int)0) << "\n";
        //     return 0;
        // }

        // if (b < 0 && d >= 0)
        // {
        //     cout << max(b * c, a * d) << "\n";
        //     return 0;
        // }

        // if (b >= 0 && d < 0)
        // {
        //     cout << max(b * c, a * d) << "\n";
        //     return 0;
        // }
    }
}


Measured memory_bytes: 3548
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 100010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}


int main(){
    //srand(time(NULL)+clock());
    int T,ca=0,k,i,j,m=0,n,K;
    //double start=clock();
    scanf("%d",&n);
    vector<pii>ans;
    if(n&1){
        rep(i,1,n)ans.pb({i,n});
        int r=n-1;
        rep(i,1,n){
            rep(j,i+1,n)if(j!=r)ans.pb({i,j});
            r--;
        }
    }
    else{
        rep(i,2,n)ans.pb({1,i}),ans.pb({i,n});
        int r=n-1;
        rep(i,2,n){
            rep(j,i+1,n)if(j!=r)ans.pb({i,j});
            r--;
        }
    }
    printf("%d\n",SZ(ans));
    for(auto &o:ans)printf("%d %d\n",o.x,o.y);
    //cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n,k;
  while(scanf("%d%d",&n,&k), n+k){
    vector<int> c(k+1);
    REP(i,k) scanf("%d",&c[i]);
    c[k] = n+3;
    sort(c.begin(), c.end());

    if(n == k){
      printf("%d\n",n);
      continue;
    }

    bool white = (c[0] == 0);
    int prevlen = 0;
    int nowlen  = 0;
    int prev = -2;
    int ans = 0;
    bool canCont = false;

    REP(i,k+1){
      //printf("%d(ans=%d)\n",c[i],ans);
      if(c[i] == 0) continue;
      nowlen++;
      if(c[i] == prev + 1){
      }else{
        if(canCont)
          ans = max(ans, nowlen + 1 + prevlen);
        else
          ans = max(ans, nowlen + (white?1:0));

        if(white && c[i] == prev + 2){
          canCont = true;
        }

        prevlen = nowlen;
        nowlen  = 0;
      }
      prev = c[i];
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let B = {
        let mut B = vec![0; N + 1];
        for &a in &A { B[a] += 1; }
        B.sort_by_key(|b| N - b);
        B
    };
    struct SegmentTree<T: Clone + Copy>{
        n: usize,
        f: fn(T, T) -> T,
        e: T,
        x: Vec<T>
    }

    impl<T: Clone + Copy> SegmentTree<T> {
        fn new(n: usize, f: fn(T, T) -> T, e: T) -> SegmentTree<T> {
            let m = 1 << format!("{:b}", n).len();
            SegmentTree { n: m, f: f, e: e, x: vec![e; 2 * m - 1] }
        }
        fn update(&mut self, i: usize, y: T) {
            let mut j = i + self.n - 1;
            self.x[j] = y;
            while j > 0 {
                j = (j - 1) / 2;
                self.x[j] = (self.f)(self.x[2 * j + 1], self.x[2 * j + 2]);
            }
        }
        fn find(&self, s: usize, t: usize) -> T { self.q(0, 0, self.n, s, t) }
        fn q(&self, i: usize, l: usize, r: usize, s: usize, t: usize) -> T {
            if l >= t || r <= s { self.e }
            else if s <= l && r <= t { self.x[i] }
            else {
                (self.f)(
                    self.q(2 * i + 1, l, (l + r) / 2, s, t),
                    self.q(2 * i + 2, (l + r) / 2, r, s, t)
                )
            }
        }
    }
    fn bis<P>(ok: usize, ng: usize, p: P) -> usize
        where P: Fn(usize) -> bool {
        let mid = (ok + ng) / 2;
        if ok - ng == 1 {
            ok
        } else if p(mid) {
            bis(mid, ng, p)
        } else {
            bis(ok, mid, p)
        }
    }
    let mut dp = SegmentTree::new(N + 1, std::cmp::max, 0);
    let mut acc = vec![0; N + 1];
    acc[0] = N;
    for k in 0..N {
        acc[k + 1] = acc[k] - B[k];
        let i = bis(N, k, |i| {
            let j = dp.find(0, i + 1);
            acc[k + 1] * (i - j + 1) <= acc[j] * (i - k)
        });
        dp.update(i, k + 1);
    }
    let ans = (0..N).map(|k| {
        let i = dp.find(0, k + 1);
        (acc[i] / (k - i + 1)).to_string()
    })
    .collect::<Vec<_>>()
    .join("\n");

    println!("{}", ans);
}

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

signed main() {
	ll a, b, c;
	cin >> a >> b;
	for(int i = 1; i <= b; i++){
		c = a * i;
		if(c % b == 0){
			cout << c << endl;
			break;
		}
	}
}


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

a=list(map(int,input().split()))

tmp=[]

for i in range(n):
    if i%2==1:
        continue
    x=a[i]^a[i+1]
    tmp.append(x)

S=0
for j in range(len(tmp)):
    S = S^tmp[j]

ans=[]

for k in range(n):
    p = a[k]^S
    ans.append(p)

print(*ans)

Measured memory_bytes: 31416
#include <iostream>

using namespace std;

bool ok(int P);

int main(){

  int start,end,mid,n;
  cin >> n;
  long long int a[n];
  int ans=1;
  long long int lis[100000];
  cin >> lis[0];
  for(int i=1;i<n;i++){
    cin >> a[i];
    if(lis[ans-1]<a[i]){
      lis[ans]=a[i];
      ans++;
    }else if(lis[ans-1]>a[i]){
      start=0;
      end=ans-1;
      mid=end/2;

      while(end-start!=0){
	if(lis[mid]>a[i]){
	  end=mid;
	}else if(lis[mid]<a[i]){
	  start=mid+1;
	}else{
	  end=-1;
	  break;
	}
	mid=(start+end)/2;
      }
      if(end!=-1){
	lis[end]=a[i];	  
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 2728
#include <stdio.h>
  
int main(void){
  
  int x,y;
  int change;
  
  while(1){
    scanf("%d %d",&x,&y);
    if((x == 0) & (y == 0)){
      break;
    }
    if(x > y){
      change = x;
      x = y;
      y = change;
    }
    printf("%d %d\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 600
from itertools import accumulate

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_cumsum = [0] + list(accumulate(a))
b_cumsum = [0] + list(accumulate(b))
j = m
res = 0
for i in range(n+1):
    if a_cumsum[i] > k:
        break
    while a_cumsum[i] + b_cumsum[j] > k:
        j -= 1
    if (v := i + j) > res:
        res = v
print(res)


Measured memory_bytes: 50656
n = int(input())
deliciousness = list(map(int, input().split()))
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += deliciousness[i] * deliciousness[k]
  i += 1
  
print(sum)



Measured memory_bytes: 2940
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

def popcnt(x):
    c = 0
    while x>0:
        c += x%2
        x >>= 1
    return c

def dfs(u,v,p):
    global d
    d[u][v] = p
    for x in dst[v]:
        if u!=x and d[u][x]==0:
            p |= 1<<dst[v][x]
            dfs(u,x,p)
            p ^= 1<<dst[v][x]

n = inn()
dst = [{} for i in range(n+1)]
for i in range(n-1):
    a,b = inm()
    dst[a][b] = dst[b][a] = i

m = inn()
u = []
v = []
for i in range(m):
    uu,vv = inm()
    u.append(uu)
    v.append(vv)

if False and n==2 and m==1:
    print(0)
    exit()

d = [[0]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
    dfs(i,i,0)
dd = []
for i in range(m):
    dd.append(d[u[i]][v[i]])
ddprint(dst)
ddprint(d)
ddprint(u)
ddprint(v)
ddprint(dd)

y = 0
for i in range(1,2**m):
    nbits = x = 0
    for j in range(m):
        if (i>>j)%2>0:
            x |= dd[j]
            nbits += 1
    nsegs = popcnt(x)
    s = 2*(nbits%2)-1
    y += s*2**(n-1-nsegs)
print(2**(n-1)-y)


Measured memory_bytes: 91172
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


N = int(sys.stdin.readline())
A, B = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

print(min(B)+max(A))


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 100010;

int N;
int A[MN], B[MN];
int cnt[MN];

int main() {
	cin >> N;
	vector<pii> vec;

	ll s1 = 0, s2 = 0;

	rep(i, N) {
		cin >> A[i] >> B[i];
		s1 += A[i];
		s2 += B[i];
		vec.eb(A[i], i);
		vec.eb(B[i], i);
	}

	ll ret = min(s1, s2);

	sort(ALL(vec));

	ll s = 0;
	ll d2 = 0;

	rep(i, N) {
		++cnt[vec[i].se];
		s += vec[i].fi;
		if (i < N-2) {
			d2 += vec[i].fi;
		}
	}

	rep(i, N) {
		ll t;
		if (cnt[i] == 2) {
			t = s;
		} else if (cnt[i] == 1) {
			t = s - min(A[i], B[i]);
			int p = N;
			while (true) {
				if (vec[p].se != i) {
					t += vec[p].fi;
					break;
				} else {
					p++;
				}
			}
		} else {
			t = d2 + A[i] + B[i];
		}
		ret = min(ret, t);
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <unordered_map>
#include <numeric>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
#define int long long
signed main(){
    int n,m;
    cin >> n >> m;
    vector<int>a;
    for(int i = 1; i*i<=m; i++){
        if(m%i==0){
            a.push_back(i);
            if(i*i!=m)a.push_back(m/i);
        }
    }
    sort(a.rbegin(),a.rend());
    for(int x:a){
        if(x*n<=m){
            cout << x << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

int gcd(int x, int y) {
  int a = std::max(x,y), b = std::min(x,y);
  int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main(void) {
  int N, X;
  scanf("%d %d", &N, &X);
  std::array<int, 100000> x;
  for (int i = 0; i < N; i++){
    scanf("%d", &x[i]);
    x[i] = std::abs(x[i] - X);
  }
  int D = x.at(0);
  for (int i = 1; i < N; i++) {
    D = gcd(D, x.at(i));
  }
  printf("%d\n", D);
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  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;
  }
};
mint dp[10010][100][2];
int main()
{
  string k;
  int d;
  cin >> k >> d;


  
  dp[0][0][0].x = 1;

  int n = k.size();
  
  rep(i,n) rep(j,d) rep(f,2){
    int x = k[i] - '0';
    int lim = (f ? 10 : x+1);
    rep(dj, lim){
      int nj = (j + dj) % d;
      int nf = f || dj < x;
      dp[i+1][nj][nf] += dp[i][j][f];
    }
  }

  mint res = dp[n][0][0] + dp[n][0][1] - 1;

  cout << res.x << "\n";
  
  return 0;
}


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

#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> ws, rs;
  char c;
  rep(i, n) {
    cin >> c;
    if (c == 'W')
      ws.push_back(i);
    else
      rs.push_back(i);
  }

  if ((ws.size() == 0) || (rs.size() == 0)) {
    cout << '0' << endl;
    return 0;
  }

  int w_i = 0, r_i = rs.size() - 1;
  int max_i_ws = ws.size() - 1;

  int cnt = 0;
  while (ws[w_i] < rs[r_i]) {
    cnt++;
    w_i++;
    r_i--;

    if ((w_i > max_i_ws) || (r_i < 0)) {
      break;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4652
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 2e3 + 10;
char s[N][N];
int L[N][N], R[N][N], U[N][N], D[N][N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  for (int i = 0; i < n; ++i) {
    L[i][0] = s[i][0] == '#' ? 0 : -1;
    for (int j = 1; j < m; ++j) {
      L[i][j] = s[i][j] == '#' ? j : L[i][j - 1];
    }
    R[i][m - 1] = s[i][m - 1] == '#' ? m - 1 : m;
    for (int j = m - 2; j >= 0; --j) {
      R[i][j] = s[i][j] == '#' ? j : R[i][j + 1];
    }
  }
  for (int j = 0; j < m; ++j) {
    U[0][j] = s[0][j] == '#' ? 0 : -1;
    for (int i = 1; i < n; ++i) {
      U[i][j] = s[i][j] == '#' ? i : U[i - 1][j];
    }
    D[n - 1][j] = s[n - 1][j] == '#' ? n - 1 : n;
    for (int i = n - 2; i >= 0; --i) {
      D[i][j] = s[i][j] == '#' ? i : D[i + 1][j];
    }
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '#') continue;
      int cur = R[i][j] - L[i][j] - 1;
      cur += D[i][j] - U[i][j] - 1;
      cur -= 1;
      // trace(i, j, L[i][j], R[i][j], U[i][j], D[i][j]);
      ret = max(ret, cur);
    }
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 67328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x, a=100, count = 0;
    cin >> x;
    while(a < x) {
        a = (a + a/100);
        count++;
    }
    cout << count << "\n";
    return 0; 
}

Measured memory_bytes: 3608
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;

function main() {
    let S = cin.shift();
    let T = cin.shift();
    if (S.length + 1 == T.length && S ==T.substr(0, S.length)) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}
main();


Measured memory_bytes: 30252
// IOI 2021
 
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

const int N = 3e5 + 5, LOG = 6e1 + 1;

int A[LOG];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		ll x; cin >> x;
		for (int j = 0; j < LOG; j++) A[j] += (x >> j) & 1;
	}
	int ans = 0;
	for (int i = 0; i < LOG; i++)
		ans = (ans + (1LL * A[i] * (n - A[i]) % MOD) * ((1LL << i) % MOD) % MOD) % MOD;
	cout << ans << endl;


	return 0;
}


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

int main(){
	string str;
	cin >> str;
	int ans = 0;
	for(int i = 0;i < str.size();i++){
		if(str[i] == '9')ans = 1;
	}
	if(ans)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define push push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
int main(){
    int n;
    ll ans=1LL;
    ll MOD = 1000000000+7;
    cin >>n;
    ll a=n;
    ll bef=n;
    bool f=false;
    for(int i=2;i<=n;i++){
        a=1;
        bef=n;
        f=true;
        
        for(int j=2;j*j<=i;j++){
            if(i%j==0){
                f=false;
            }
        }
        if(f){
            while(bef!=0){
               
                bef/=i;
                a += bef;
            }
            
            a%=MOD;
            ans*=a;
            ans%=MOD;
           // cout<<i<<" "<<a<<endl;
        }

    }
    cout<<ans<<endl;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> answer(N, -1);
    bool is_exist = true;
    for (int i = 0; i < M; i++ ) {
        int s, c;
        cin >> s >> c;
        if (N < s) {
            is_exist = false;
        }
        if (0 <= answer[s - 1] and answer[s - 1] != c) {
            is_exist = false;
        } else {
            answer[s - 1] = c;
        }
    }
    if (1 < N and answer[0] == 0) is_exist = false;
    if (is_exist) {
        for (int i = 0; i < N; i++) {
            if (answer[i] == -1) {
                if (N == 1) answer[i] = 0;
                else if (i == 0) answer[i] = 1;
                else answer[i] = 0;
            }
            cout << answer[i];
        }
        cout << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p (n);
  for(int i=0; i<n; i++){
    cin >> p.at(i);
  }
  int ans = 0;
  for(int i=0; i<n-2; i++){
    if(p.at(i+1) > p.at(i) && p.at(i+1) < p.at(i+2)){
      ans++;
    }
    else if(p.at(i+1) < p.at(i) && p.at(i+1) > p.at(i+2)){
      ans++;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 764
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
void DimensionalWorldTale() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int ax[101];
	int ay[101];
	for (size_t i = 0; i < n; i++)
	{
		cin >> ax[i];
	}
	for (size_t i = 0; i < m; i++)
	{
		cin >> ay[i];
	}

	for (int z = x + 1; z <= y; z++)
	{
		bool c = true;
		for (size_t i = 0; i < n; i++)
		{
			if (z <= ax[i]) {
				c = false;
				break;
			}
		}
		if (!c) continue;
		for (size_t i = 0; i < m; i++)
		{
			if (z > ay[i]) {
				c = false;
				break;
			}

		}
		if (!c) continue;
		cout << "No War" << "\n";
		return;
	}
	cout << "War" << "\n";
}
int main() {
	DimensionalWorldTale();
		return 0;
}

Measured memory_bytes: 256
//<editor-fold desc="I/O Templates">
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readLong() = readLn().toLong()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map(String::toInt)
private fun readLongs() = readStrings().map(String::toLong)
//</editor-fold>

fun main() {
    val n = readInt()
    val a = readInts()
    var money : Long = 1000
    var stock : Long = 0
    for (i in 0 until n) {
        if (i + 1 < n && a[i] < a[i + 1]) {
            // buy la
            stock += money / a[i]
            money %= a[i]
        } else {
            // sell la
            money += a[i] * stock
            stock = 0
        }
    }
    println(money)
}

Measured memory_bytes: 36548
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	
      	String S = sc.next();
      	sc.close();
      
      	String year = S.substring(0, 4);
      	String month = S.substring(5, 7);
      	String day = S.substring(8, 10);
      
      	if (Integer.parseInt(year) >= 2019 && Integer.parseInt(month) >= 5) {
        	System.out.println("TBD");
        } else {
        	System.out.println("Heisei");	
        }
	}
}

Measured memory_bytes: 23124
import java.util.Scanner;

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

		if(n < k) {
			if(n > k - n) {
				n = k - n;
			}
		}else {
			n %= k;
		}

		n = (n > Math.abs(n - k))? Math.abs(n - k) : n;

		System.out.println(n);

		sc.close();
	}
}


Measured memory_bytes: 21844
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム 
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
using namespace std; // std 名前空間を使用する

int main(void){
    int n,a,b,cal;
    scanf("%d",&n);
    int d[n];
    scanf("%d %d",&a,&b);
    scanf("%d",&cal);
    for(int i=0;i<n;i++){
        scanf("%d",&d[i]);
    }
    sort(d,d+n);
    reverse(d,d+n);
    for(int i=0;i<n;i++){
        if((cal+d[i])/(a+b)>=cal/a){
            cal += d[i];
            a += b;
        }
    }
    printf("%d\n",cal/a);
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001

using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
const int INF=1e9;
const ll LINF=1e18;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


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


int main(){
    int n;
    cin>>n;
    vi a(n+1);
    rep(i,n+1)cin>>a[i];
    
    vl b(n+1);
    
    rep(i,n+1){
        if(i==0){
           b[i]=1-a[i];
        }
        else{
            b[i]=2*b[i-1]-a[i];
            chmin(b[i],LINF);
            
        }
        if(b[i]<0){
                cout<<-1<<endl;
                return 0;
        }
    }
    vl d(n+1);
    d[n]=a[n];
    
    for(int i=n-1;i>=0;i--){
        d[i]=min(b[i]+a[i],d[i+1]+a[i]);
    }
    ll ans=0;
    rep(i,n+1)ans+=d[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 5384
#include <iostream>
#include <vector>

using namespace std;

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) res.push_back(n / i);
        }
    }
    return res;
}

int main() {
	long long n; cin >> n;
    int cnt = divisor(n - 1).size() - 1;
    auto tmp = divisor(n);
    for (auto a : tmp) {
        if (a == 1) continue;
        long long t = n;
        while (t % a == 0) t /= a;
        if (t % a == 1) ++cnt;
    }
    cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 384
n = gets.chomp
a = n.to_i
if a >= 2000
    puts "1"
elsif a < 100
    puts "0"
end

aa = n.size
if aa >= 3 && aa < 4
    an = n[0].to_i
    hani = an * 100
    iti = an * 5
    all = hani + iti
    if a > all
        puts "0"
    else
        puts "1"
    end
elsif aa >= 4 && aa < 5 && a < 2000
    an = n[1].to_i
    hani = (an +10) * 100
    iti = (an+10) * 5
    all = hani + iti
    if a > all
        puts "0"
    else
        puts "1"
    end
end


Measured memory_bytes: 1788
#include <iostream>
#include <vector>

using namespace std;

typedef struct st_crossBar{
	int left;
	int right;
} CrossBar;

int main(void)
{
	int w = 0, n = 0;
	cin >> w >> n;
	
	vector<CrossBar> crossBarVec;
	for(int i = 0; i < n; i++){
		CrossBar crossBar = {0};
		
		char c;
		cin >> crossBar.left >> c >> crossBar.right;
		crossBarVec.push_back(crossBar);
	}
	
	vector<int> underNumVec;
	underNumVec.resize(w);
	
	for(int i = 1; i <= w; i++){
		int num = i;
		for(int j = 0; j < n; j++){
			if(num == crossBarVec[j].left){
				num = crossBarVec[j].right;
			}
			else if(num == crossBarVec[j].right){
				num = crossBarVec[j].left;
			}
			else{
				;
			}
		}
		
		underNumVec[num - 1] = i;
	}
	
	for(int i = 0; i < w; i++){
		cout << underNumVec[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, ll> MAP;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111

ll p[MAX];
struct UnionFind {
  vll rank, par;

  void set(ll n) {
	rank.resize(n, 0);
	par.resize(n, 0);
	FOR(i, 0, n) {
	  par[i] = i;
	  rank[i] = 0;
	}
  }

  ll find(ll x) {
	if (x != par[x]) par[x] = find(par[x]);
	return par[x];
  }

  void unite(ll a, ll b) {
	ll x = find(a);
	ll y = find(b);
	if (rank[x] > rank[y]) {
	  par[y] = x;
	}
	else {
	  par[x] = y;
	  if (rank[x] == rank[y]) {
		rank[y]++;
	  }
	}
  }

  bool same(ll a, ll b) {
	return find(a) == find(b);
  }
};

int main(void) {
  UnionFind u;
  ll x, y;
  cin >> n >> m;
  u.set(n + 1);

  FOR(i, 1, n + 1) cin >> p[i];

  FOR(i, 0, m) {
	cin >> x >> y;
	u.unite(x, y);
  }

  FOR(i, 1, n + 1) {
	if (p[i] == i) {
	  ans++;
	  continue;
	}
	if (u.same(i, p[i])) ans++;
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 2560
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;

ll n,a[200010],mem,ans;
set<ll>st;

int main(){
	cin>>n;
	lp(n){
		cin>>mem;
		a[mem-1]=i;
	}
	ans=(a[0]+1)*(n-a[0]);
	st.insert(a[0]);
	lp(n-1){
		auto it=st.end();
		it--;
		if(a[i+1]<*st.begin()){
			ans+=(a[i+1]+1)*(*st.begin()-a[i+1])*(i+2);
		}
		else if(*it<a[i+1]){
			ans+=(a[i+1]-*it)*(n-a[i+1])*(i+2);
		}
		else {
			auto it2=st.lower_bound(a[i+1]);
			auto it3=it2;
			it2--;
			ans+=(a[i+1]-*it2)*(*it3-a[i+1])*(i+2);
		}
		st.insert(a[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}
int a[300000];
signed main(){
    int k,n;
    cin >> k >> n;
    REP(i,n){
        cin >> a[i];
    }
    int ans = -10;
    REP(i,n-1){
        ans = max(ans,a[i+1]-a[i]);
    }
    ans = max(ans,k+a[0]-a[n-1]);
    cout << k-ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

#define EPS (1e-10)
class P{                    //テァツつケ
public:
	double x,y;
	
	P(double _x=0,double _y=0):x(_x),y(_y){};
	P operator + (const P &p     )const{ return P( x+p.x , y+p.y ); }  //テ・ツ環?ァツョツ?
	P operator - (const P &p     )const{ return P( x-p.x , y-p.y ); }  //テヲツクツ崚ァツョツ?
	P operator * (const double k )const{ return P( x*k   , y*k    ); } //テ、ツケツ療ァツョツ?
	P operator / (const double k )const{ return P( x/k   , y/k    ); } //テゥツ卍、テァツョツ?
	
	bool operator == (const P &p){ return ( fabs(x-p.x)<EPS && fabs(y-p.y)<EPS ); }
	bool operator < (const P &p) const{ return ( x!=p.x ? x<p.x:y<p.y ); }
	
	double norm(){ return x*x+y*y; }        //テ」ツδ偲」ツδォテ」ツδ?
	double abs() { return sqrt(norm()); }   //テ・ツ、ツァテ」ツ?催」ツ??
	void normalize() {double d = sqrt(x*x+y*y); x /= d; y /= d;}	//テヲツュツ」ティツヲツ湘・ツ個?
};
struct C{P p;double r;};    //テ・ツ??
struct S{P p1,p2;};         //テァツキツ堙・ツ按?
typedef vector<P> Polygon;  //テ・ツ、ツ堙ィツァツ津・ツスツ「
typedef P Vector;           //テ」ツδ凖」ツつッテ」ツδ暗」ツδォ
typedef S L;                //テァツ崢エテァツキツ?

double dot  (Vector a,Vector b) { return a.x*b.x+a.y*b.y; }
double cross(Vector a,Vector b) { return a.x*b.y-a.y*b.x; }
double sqDist(P a, P b)         {return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}
double dist (P a, P b)          {return sqrt(sqDist(a,b));}
Vector vec(S a)                 {return P(a.p2.x-a.p1.x,a.p2.y-a.p1.y);}


//テァツキツ堙・ツ按?」ツ?ョテ・ツ楪づァツ崢エテ、ツコツ古ァツュツ嘉・ツ按?ァツ崢エテァツキツ堙」ツつ津ヲツアツづ」ツつ?」ツつ?
S getBisector(P a, P b){
	Vector vect = vec(S{a,b});
	P n = P(vect.y, -vect.x);
	n.normalize();
	P cent = (a+b)/2.0;
	return S{cent,cent+n};
}


// テァツ崢エテァツキツ堙」ツ?ィテァツ崢エテァツキツ堙」ツ?ョテ、ツコツ、テァツつケ vefiried AOJ CGL_2
P getCrossPointSS(S l1, S l2){
	double A = cross(vec(l1), vec(l2));
	double B = cross(vec(l1), l1.p2 - l2.p1);
	if(abs(A)<EPS && abs(B)<EPS) return l2.p1; // テ、ツコツ古ァツ崢エテァツキツ堙」ツ?古ゥツ?催」ツ?ェテ」ツ?」テ」ツ?ヲテ」ツ??」ツつ?
	if(abs(A)<EPS) assert(false); // テァツ崢エテァツキツ堙」ツ?古、ツコツ、テ」ツつ湘」ツつ嘉」ツ?ェテ」ツ??
	return l2.p1 + vec(l2) * B / A;
}


int main(){
	int n;
	cin>>n;
	rep(hoge,n){
		vector<P> points(3);
		rep(i,3)cin>>points[i].x>>points[i].y;
		
		vector<S> bisectors(2);
		rep(i,2) bisectors[i] = getBisector(points[i], points[i+1]);
		
		P cent = getCrossPointSS(bisectors[0], bisectors[1]);
		
		
		printf("%.3lf %.3lf %.3lf\n",cent.x,cent.y,dist(cent,points[1]));
	}
}

Measured memory_bytes: 3180
#include <stdio.h>
#include <string.h>
//#define DEBUG
#define MAX 20

#ifdef DEBUG
#define DBGPRINTF(...) printf(__VA_ARGS__)
#else
#define DBGPRINTF(...)
#endif

int main( int argc, char *argv[] )
{
    int i, j, tmp, m[2], loopcount = 0, tencount;
    char s[MAX];

    {
        while( ( fgets( s, MAX, stdin ) != NULL ) && ( loopcount < 200 ) )
        {
            DBGPRINTF( "%s", s );

            if ( sscanf( s, "%d %d", &m[0], &m[1] ) == 2 )
            {

                DBGPRINTF( "m[0]: %d, m[1]: %d, m[0]+m[1]: %d\n", m[0], m[1], m[0]+m[1] );

                tmp = m[0] + m[1];
                tencount = 0;
                for ( ; ; )
                {
                    tmp /= 10;
                    if ( tmp == 0 )
                    {
                        break;
                    }
                    else
                    {
                        tencount++;
                    }
                }
                printf( "%d\n", tencount + 1 );
                loopcount++;
                memset( s, 0, sizeof(s) );
            }
        }

    }

    return 0;

}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<llint> a(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
    }

    llint sgn, sum, ans1, ans2;

    sgn = 1;
    sum = 0;
    ans1 = 0;
    for(int in=0;in<n;in++) {
        sum += a.at(in);
        if(sum*sgn>0) {
            ;
        }
        else {
            ans1 += abs(sum-sgn);
            sum += sgn*abs(sum-sgn);
        }
        sgn *= -1;  
    }

    sgn = -1;
    sum = 0;
    ans2 = 0;
    for(int in=0;in<n;in++) {
        sum += a.at(in);
        if(sum*sgn>0) {
            ;
        }
        else {
            ans2 += abs(sum-sgn);
            sum += sgn*abs(sum-sgn);
        }
        sgn *= -1;  
    }

    llint ans;
    ans = ans1;
    chmin(ans, ans2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3932
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i] = a[i] - (i + 1);
    sort(a.begin(), a.end());
    
    ll x = a[n / 2];
    ll ans = 0;
    rep(i, n) ans += abs(x - a[i]);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  int n, k;
  int cnt = 0;
  
  scanf("%d %d\n", &n, &k);
  for (int i = 0; i < n; i++)
  {
    int h;
    scanf("%d", &h);
    if (h >= k)
      cnt++;
  }
  printf("%d\n", cnt);
  
  return 0;
}

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

using namespace std;
int a[200005],b[200005];
vector<int>edge[200005];
int vis[200005];
int cnt;
void dfs(int x){
	cnt++;
	vis[x]=1;
	for(int i=0;i<edge[x].size();i++){
		if(!vis[edge[x][i]]){
			dfs(edge[x][i]);
		}
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		edge[a[i]].push_back(b[i]);
		edge[b[i]].push_back(a[i]);
	}
	int ans=0;
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			cnt=0;
			dfs(i);
			ans=max(ans,cnt);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,m;
	cin >> n >> m;
	bool foods[n][m];
	for(int j = 0; j < n; j++){
		for(int i = 0; i < m; i++){
			foods[j][i] = false;
		}
	}
	for(int i = 0; i < n; i++){
		int k;
		cin >> k;
		for(int j = 0; j < k; j++){
			int a;
			cin >> a;
			foods[i][a-1] = true;
		}
	}
	int ans = 0;
	FOR(i, 0, m){
		bool minnnasuki = true;
		FOR(j, 0, n){
			if(!foods[j][i]){
				minnnasuki = false;
				break;
			}
		}
		if(minnnasuki)ans++;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge {ll to, label;};
const ll INF = 1000000;
vector<edge> G[100000];
ll C[100000];
ll visit[100000];
ll K;

void dfs(ll v) {
  visit[v] = 0;
  ll colored = INF;
  for (ll i = 0; i < G[v].size(); i++) {
    edge e = G[v][i];
    if (C[e.label] != INF) {colored = C[e.label];}
  }
  
  vector<ll> vec;
  for (ll i = 0; i < G[v].size(); i++) {
    if (i != colored) {vec.push_back(i);}
  }
  
  ll p = 0;
  
  for (ll i = 0; i < G[v].size(); i++) {
    edge e = G[v][i];

    if (visit[e.to] != 0) {
      C[e.label] = vec.at(p); p++;
      dfs(e.to);
    }
    else {continue;}
  }
}
  

int main() {
  ll N;
  cin >> N;
  
  for (ll i = 0; i < N; i++) {
    visit[i] = INF;
    C[i] = INF;
  }
  
  for (ll i = 0; i < N-1; i++) {
    ll a, b; cin >> a >> b; a--; b--;
    G[a].push_back({b, i}); G[b].push_back({a, i});
  }
  
  K = 0;
  ll root;
  for (ll i = 0; i < N; i++) {
    if (G[i].size() > K) {
      root = i; K = G[i].size();
    }
  }
  
  dfs(0);
  
  cout << K << endl;
  for (ll i = 0; i < N-1; i++) {
    cout << C[i]+1 << endl;
  }
}

Measured memory_bytes: 13824
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 1e5+5;

template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int ac[N], wa[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, k;
	long long a, b;
	string s;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> k >> s;
		if (s[0] == 'W' && ac[k] == 0) {
			wa[k]++;
		} else {
			ac[k]++;
		}
	}

	a = b = 0;
	for (int i = 0; i <= n; ++i) {
		if (ac[i]) {
			++a;
			if (wa[i]) b += wa[i];
		}
	}

	cout << a << ' ' << b << '\n';
}
		

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

const int N=3e3+5;
const int mod=1e9+7;
const int inv2=500000004;
int n,x,y,q,ans,tmp=1,a[N],f[N][N];

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

int main() {
	IN(n),IN(q);
	for(int i=1;i<=n;++i) IN(a[i]);
	for(int i=1;i<=n;++i) for(int j=1;j<=n;++j) f[i][j]=(bool)(a[i]>a[j]);
	for(int t=1;t<=q;++t) {
		IN(x),IN(y),
		f[x][y]=f[y][x]=1ll*(f[x][y]+f[y][x])*inv2%mod;
		for(int i=1;i<=n;++i) if(i!=x&&i!=y)
			f[i][x]=f[i][y]=1ll*(f[i][x]+f[i][y])*inv2%mod,
			f[x][i]=f[y][i]=1ll*(f[x][i]+f[y][i])*inv2%mod;
		tmp=2ll*tmp%mod;
	}
	for(int i=1;i<=n;++i) for(int j=i+1;j<=n;++j) ans=(ans+f[i][j])%mod;
	printf("%d\n",1ll*ans*tmp%mod);
	return 0;
}

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

A=list(map(int,input().split()))

cnt_4=0

cnt_2=0

for i in A:
    if i%4==0:
        cnt_4+=1
    elif i%2==0:
        cnt_2+=1


if cnt_4>=(n//2):
    print('Yes')
else:
    if 2*cnt_4+cnt_2>=n:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 15020