akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main()
{
  int H,W;
  int i,j;
    
  int plus = 0;

  while(1){
    scanf("%d %d", &H, &W);

    if(W%2 == 1){
      plus = 1;
    }
	
    if(H == 0&& W ==0){
      break;
    }
    for(i =0;i<H;i++){
      if(W == 1){
	if(i%2 == 0){
	  printf("#");
	}else{
	  printf(".");
	}
      }
      for(j=0;j<W/2;j++){
	if(i%2 == 1 && j == 0){
	  printf(".");
	}
	      
	printf("#");
	if(j != W/2 - 1){
	  printf(".");
	}
	if(plus == 1){
	  if(j == W/2-1){
	    printf(".");
	  }
	}
	if(i%2 == 0 && j == W/2 -1){
	  if(W%2 == 0){
	    printf(".");
	  }else{
	    printf("#");
	  }
	}
      }
      printf("\n");
    }
    printf("\n");
    plus = 0;
  }
  return 0;
}



Measured memory_bytes: 2064
def main():
    R, C, K = map(int, input().split())
    V = {}
    for _ in range(K):
        r, c, v = map(int, input().split())
        V[(r - 1, c - 1)] = v
    dp = [(0, 0, 0, 0) for _ in range(C)]
    for r in range(R):
        p0, p1, p2, p3 = 0, 0, 0, 0
        for c in range(C):
            m = max(dp[c])
            if (r, c) in V:
                v = V[(r, c)]
                n0, n1, n2, n3 = max(m, p0), max(p1, max(p0, m) + v), max(p2, p1 + v), max(p3, p2 + v)
            else:
                n0, n1, n2, n3 = max(m, p0), p1, p2, p3
            dp[c] = (n0, n1, n2, n3)
            p0, p1, p2, p3 = n0, n1, n2, n3

    return max(dp[-1])

print(main())


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

using namespace std;

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

    int n;
    cin >> n;

    vector<int> a(n+1);

    int64_t res = 1, node = 1, sum = 0;

    for(auto&& e : a){
        cin >> e;
        sum += e;
    }

    if(n == 0){
        if(a[0] != 1){
            cout << -1 << '\n';
        }else{
            cout << 1 << '\n';
        }
        return 0;
    }else if(a[0] != 0){
        cout << -1 << '\n';
        return 0;
    }

    for(int i = 1; i <= n; ++i){
        node = min(node * 2, sum);
        res += node;
        node -= a[i];
        sum -= a[i];
        if(node < 0){
            cout << -1 << '\n';
            return 0;
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3744
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    
    int array[n];
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        array[i]=x;
    }
    
    for(int i=n-1;i>=0;i--){
        cout << array[i];
        if(i>0)
            cout << " " ;
    }
    cout << endl;

}

Measured memory_bytes: 1160
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a < b && b < c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 26112
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,j,m,ans=0,x,c,y;
	cin>>n>>m;
	int k[m],s[n][m],p[m];
	for(i=0;i<m;i++)
	{
		cin>>k[i];
		for(j=0;j<k[i];j++)
		{
			cin>>s[i][j];
		}
	}
	for(i=0;i<m;i++)cin>>p[i];
	for(i=0;i<=n;i++)
	{
		string st;
		
		for(j=i;j<n;j++)st.push_back('0');
		for(j=0;j<i;j++)st.push_back('1');
		do
		{
			int bulb_on=0;
			for(x=0;x<m;x++)
			{
				c=0;
				for(y=0;y<k[x];y++)
				if(st[s[x][y]-1]=='1')c++;
				c=c%2;
				if(c== p[x])bulb_on++;
			}
			if(bulb_on==m)ans++;
			
		}while(next_permutation(st.begin(),st.end()));
	}
	cout<<ans;
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main() {
int N;
cin>>N;
int A[2][N];
int dp[2][N];
rep(i,2){
  rep(j,N){
    cin>>A[i][j];
    dp[i][j]=0;
  }

}
dp[0][0]=A[0][0];
dp[1][0]=dp[0][0]+A[1][0];
rep2(i,1,N){
  dp[0][i]=dp[0][i-1]+A[0][i];
}
rep2(i,1,N){
  dp[1][i]=max(dp[0][i],dp[1][i-1])+A[1][i];
}
cout<<dp[1][N-1]<<endl;
return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
void push(int);
int pop(void);
int s[100];
int top=0;
int main(){
  int ch,x,y;
  char c[100];
  while(scanf("%s",c)!=EOF){
    if('0'<=c[0] && c[0]<='9'){
      ch=atoi(c);
      push(ch);
      continue;
    }
    y=pop();
    x=pop();
    if(c[0]=='+')push(x+y);
    else if(c[0]=='-')push(x-y);
    else if(c[0]=='*')push(x*y);
  }
  printf("%d\n",pop());
  return 0;
}

void push(int x){
  s[top++]=x;
}

int pop(){
  return s[--top];
}



Measured memory_bytes: 2076
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static long sum;
	static int dp[];

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		dp = new int[31];
		Arrays.fill(dp, -1);
		dp[0] = 1;
		solve(30);
		// System.out.println(Arrays.toString(dp));
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			System.out.println((dp[n] / 10 + 1) / 365 + 1);
		}
	}

	public static int solve(int n) {
		int res = 0;
		if (dp[n] != -1) {
			res = dp[n];
		} else {
			for (int i = 1; i <= 3; i++) {
				if (n - i >= 0)
					res += solve(n - i);
			}
		}
		return dp[n] = res;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    FOR(i, A, B+1) {
        string str = to_string(i);
        reverse(str.begin(), str.end());
        if(str == to_string(i)) ans++;
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;

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

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll a, b, c;

    cin >> a >> b >> c;

    cout << (a + b == c || b + c == a || c + a == b ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = n.times.map do
  gets.split.map(&:to_i)
end
b = m.times.map do
  gets.to_i
end
a.each do |r|
  puts r.zip(b).map {|x, y| x * y }.inject(0, :+)
end

Measured memory_bytes: 9024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const ll MX = 1000000000000000005ll;
string s;
int S;
ll dp[100][4][2][2];
int table[10];
ll rec(int pos,int T,int tight,int lz){
	if(pos==s.size()){
		if(T==3)return 1ll;
		else return 0ll;
	}
	if(dp[pos][T][tight][lz]!=-1ll)return dp[pos][T][tight][lz];
	ll res = 0ll;
	if(!tight){
		if(lz){
			res = min(MX,res+rec(pos+1,T,0,1)); // use 0
			for(int i=1;i<10;i++){
				if((S&(1<<i))==0)continue;
				res = min(MX,res+rec(pos+1,T|(1<<table[i]),0,0));
			}
		}else{
			for(int i=0;i<10;i++){
				if((S&(1<<i))==0)continue;
				res = min(MX,res+rec(pos+1,T|(1<<table[i]),0,0));
			}
		}
	}else{
		int a = (s[pos]-'0');
		if(lz){
			res = min(MX,res+rec(pos+1,T,0,1));  // use 0
			for(int i=1;i<=a;i++){
				if((S&(1<<i))==0)continue;
				if(i==a)res = min(MX,res+rec(pos+1,T|(1<<table[i]),1,0));
				else res = min(MX,res+rec(pos+1,T|(1<<table[i]),0,0));
			}
		}else{
			for(int i=0;i<=a;i++){
				if((S&(1<<i))==0)continue;
				if(i==a)res = min(MX,res+rec(pos+1,T|(1<<table[i]),1,0));
				else res = min(MX,res+rec(pos+1,T|(1<<table[i]),0,0));
			}
		}
	}
	//cout << pos << ' ' << tight<< ' ' <<  lz << ' ' << res << endl;
	return dp[pos][T][tight][lz]=res;
}
ll f(string str){
	s = str;
	ll ret = 0ll;
	for(int i=0;i<(1<<10);i++){
		int cnt = 0;
		memset(table,0,sizeof(table));
		for(int j=0;j<10;j++){
			if((i>>j)&1){
				table[j]=cnt;
				cnt++;
			}
		}
		if(cnt!=2)continue;
		for(int a=0;a<100;a++){
			for(int b=0;b<4;b++){
				for(int c=0;c<2;c++){
					for(int d=0;d<2;d++){
						dp[a][b][c][d]=-1ll;
					}
				}
			}
		}
		S = i;
		//if(i==3)cout << rec(0,i,1,1) << endl;
		ret = min(MX,ret+rec(0,0,1,1));
	}
	return ret;
}
ll N;
string zero[105];
string plus1(string s){
	int carry = 1;
	for(int i=s.size()-1;i>=0;i--){
		if(!carry)break;
		if(s[i]=='9'){
			s[i]='0';
		}else{
			s[i]+=1;
			carry=0;
		}
	}
	if(carry)return "1"+s;
	else return s;
}
bool solve(){
	cin >> N;
	if(N==0)return false;
	//cout << f("57577") << endl;
	string cur="";
	for(int i=61;i>=0;i--){
		int l = -1,r = 10;
		while(r-l>1){
			int mid = (l+r)/2;
			string t = cur+((char)('0'+mid))+zero[i];
			//cout << t << ' ' << f(t) << endl;
			if(f(cur+((char)('0'+mid))+zero[i])<=N-1)l=mid;
			else r = mid;
		}
		if(!(cur==""&&r==0))cur+=(char)('0'+l);
	}
	cout << plus1(cur) << endl;
	return true;
}
int main(){
	zero[0]="";
	for(int i=1;i<70;i++)zero[i]=zero[i-1]+"0";
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i,n){
        cin >> a[i];
    }
    auto isOK = [&](ll m){
        for(ll i = max(0LL, m - n); i <= m; i++){
            ll t[n];
            rep(j,n){
                t[j] = a[j] + i;
            }
            ll cnt = 0;
            rep(j,n){
                cnt += (t[j] - (n - 1) + n) / (n + 1);
            }
            if(cnt <= i) return true;
        }
        return false;
    };
    ll ng = -1, ok = LINF;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(isOK(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <stdint.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

typedef int64_t ll;

int main(int argc, char **argv)
{
    int N; // 2 1e5
    scanf("%d", &N);
    vector<int> A(N); // Ai -1e9 1e9
    int odd_cnt = 0;
    int min_abs = 1000 * 1000 * 1000 + 1;
    ll s = 0; // abs <= 1e5 * 1e9 = 1e14
    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
        if(A[i] < 0){
            odd_cnt ++;
        }
        min_abs = min(min_abs, abs(A[i]));
        s += abs(A[i]);
    }
    if(odd_cnt % 2){ // swap left to positive if negative until -1 to the rightmost non-zero elements
        // then we can move "-1" to any positions. just move it to the one with mininum abs value.
        s -= 2 * min_abs;
    }
    printf("%" PRId64 "\n", s);

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,b;
  cin>>a>>b;
  if(b%a==0){
    cout<<-1<<endl;
    return 0;
  }
  Int ans=a*b+1;
  for(Int y=0;y<=a;y++){
    // Ax = By + k
    {
      Int k=(a-(b*y)%a)%a;
      Int x=(b*y+k)/a;
      if(x<y+k) chmin(ans,a*x);
    }
    // Ax + k = By
    if(y){
      Int k=(b*y)%a;
      Int x=(b*y-k)/a;
      if(x+k<y) chmin(ans,a*x);
    }
  }
  if(ans>a*b) ans=-1;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3108
n,c,k=map(int, input().split())
a=[int(input()) for i in range(n)]
a.sort()
ans,d,t=0,0,0
for i in a:
    if d==0:
        ans+=1
        t=i
        d+=1
    else:
        if i>t+k:
            ans+=1
            d=1
            t=i
        else:
            d+=1
    if d==c:d=0
print(ans)

Measured memory_bytes: 7384
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();

    let mut edges = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let (u, v, w) = i.read3::<usize, usize, usize>();
        let (u, v, w) = (u - 1, v - 1, (w % 2) as u8);

        edges[u].push((v as u32, w));
        edges[v].push((u as u32, w));
    }
    let mut ds = vec![0; n];
    let mut q = vec![(0, 0, 0)];

    while let Some((p, u, d)) = q.pop() {
        for &(v, w) in &edges[u] {
            let v = v as usize;
            if v != p {
                let d = d ^ w;
                ds[v] = d;
                q.push((u, v, d));
            }
        }
    }
    for d in ds {
        writeln!(o, "{}", d).unwrap();
    }
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 10492
#include <stdio.h>
#include <math.h>
#define pi 3.141592653589793238462
int main()
{
    int a, b, h, m;
    double hour_angle, minite_angle, angle, degree, result;
    scanf("%d %d %d %d", &a, &b, &h, &m);
    hour_angle = h * 30 + m * 0.5;
    minite_angle = m * 6.0;
    if (hour_angle >= minite_angle)
    {
        angle = hour_angle - minite_angle;
    }
    else
    {
        angle = minite_angle - hour_angle;
    }
    degree = (pi / 180) * angle;
    result = sqrt(a * a + b * b - 2 * a * b * cos(degree));
    printf("%.20lf", result);

    return 0;
}

Measured memory_bytes: 2588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int n, k; cin >> n >> k;
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		double b = 1. / n;
		int cur = i;
		while (cur < k) {
			b *= .5;
			cur *= 2;
		}
		ans += b;
	}
	printf("%.15f\n", ans);
	return 0;
} 

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

int main(){
    string s, t;
    cin>>s;
    cin>>t;
    if (s.size() + 1 == t.size() && t.substr(0, s.size()) == s){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    a, b, c = list(map(int, input().split()))

    # See:
    # https://www.youtube.com/watch?v=HDRfgn_UXLE
    # https://img.atcoder.jp/arc094/editorial.pdf
    count_min = max(a, b, c)

    if ((count_min % 2) != ((a + b + c) % 2)):
        count_min += 1

    print((3 * count_min - (a + b + c)) // 2)


Measured memory_bytes: 2940
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int a = in.nextInt();
        int e = a / 2;
        int o = a % 2 == 0 ? e : e + 1;

        out.println(e*o);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
int cnt_R,cnt_G,cnt_B,n;
string s;
ll res;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> s;
	for(int i = 0;i < n;i++){
		if(s[i] == 'R'){
			cnt_R++;
		}else if(s[i] == 'G'){
			cnt_G++;
		}else{
			cnt_B++;
		}
	}
	res = cnt_R * cnt_G * cnt_B;
	for(int i = 0;i < n;i++){
		for(int j = 1;i + 2 * j < n;j++){
			if(s[i] == 'R' && s[i + j] == 'G' && s[i + 2 * j] == 'B'){
				res--;
			}else if(s[i] == 'R' && s[i + j] == 'B' && s[i + 2 * j] == 'G'){
				res--;
			}else if(s[i] == 'B' && s[i + j] == 'G' && s[i + 2 * j] == 'R'){
				res--;
			}else if(s[i] == 'B' && s[i + j] == 'R' && s[i + 2 * j] == 'G'){
				res--;
			}else if(s[i] == 'G' && s[i + j] == 'R' && s[i + 2 * j] == 'B'){
				res--; 
			}else if(s[i] == 'G' && s[i + j] == 'B' && s[i + 2 * j] == 'R'){
				res--;
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N,A,B;
    scanf("%d %d %d", &N, &A, &B);
    int num[3] = {0,0,0};
    for(int i = 0; i < N; ++i) {
        int p;
        scanf("%d", &p);
        if(p <= A) ++num[0];
        else if(p <= B) ++num[1];
        else ++num[2];
    }

    int res = min(num[0], min(num[1], num[2]));
    printf("%d\n", res);
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	string s;
	cin >> n >> s;
	int ans=0;
	for(int i=0; i<1000; i++){
		int a[3];
		a[0]=i/100, a[1]=(i-a[0]*100)/10, a[2]=i%10;
		int k=0;
		for(int j=0; j<n; j++){
			if(s[j]-'0'==a[k]) k++;
			if(k==3){
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

const int MAX_N = 1e5 + 5, MOD = 1e9 + 7;
int n;
int cnt[MAX_N];

int _mul (int a, int b) {
	int c = 1LL * a * b % MOD;
	return c;
}

int _pow (int a, int b) {
	int res = 1;
	int tmp = a;
	while (b) {
		if (b & 1)
			res = _mul(res, tmp);
		tmp = _mul(tmp, tmp);
		b >>= 1;
	}

	return res;
}

int main() {
    bool ok = true;
    cin >> n;
    for (int i = 0; i < n; i++) {
    	int tmp;
    	cin >> tmp;

    	if ((tmp & 1) == (n & 1))
    		ok = false;
    	cnt[tmp]++;
    	if (cnt[tmp] == 3)
    		ok = false;
    	if ((n & 1) && tmp == 0 && cnt[tmp] == 2)
    		ok = false;
    }

    if (!ok) {
    	cout << "0\n";
    	return 0;
    }

    cout << _pow(2, n / 2) << "\n";
    return 0;
}

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

int main()
{
  ll N;
  scanf("%lld",&N);
  ll x;
  scanf("%lld",&x);
  vector<ll> a(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&a[i]);
  }

  ll ans = 0;
  if (a[0]>x) {
    ans += a[0]-x;
    a[0] = x;
  }
  for (int i=1; i<N; i++) {
    if (a[i-1] + a[i] > x) {
      ans += a[i-1] + a[i] - x;
      a[i] = x - a[i-1];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = S()
    l = len(a)
    t = {}
    for c in string.ascii_lowercase:
        t[c] = l
    b = [(1,0,0) for _ in range(l)]
    b.append((1,'a',l))
    b.append((0,'',l+1))

    for c,i in reversed(list(zip(a,range(l)))):
        t[c] = i
        b[i] = min([(b[t[d]+1][0] + 1,d,t[d]+1) for d in string.ascii_lowercase])

    r = ''
    i = 0
    while i < l:
        r += b[i][1]
        i = b[i][2]
    return r

print(main())





Measured memory_bytes: 54864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, n;
  cin >> h >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll sum = accumulate(all(a), 0);
  cout << (h <= sum ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1024
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Duplex Printing
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  printf("%d\n", (n + 1) / 2);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define sd(x) scanf("%d", &(x))
inline int mex(set<int> & s){
	for(int i = 0; ;i++) if(!s.count(i)) return i;
}
const int N = 2e5 + 10;
int deg[N], p[N], bad[N];
vector< set<int> > adj, adj2;
vector<pair<int, int> > edges;
int vis[N];
vector<int> cycle;
int color[N];
bool error = 0;
void toposort(int n){
	queue<int> q;
	for(int i = 1; i <= n; i++) if(deg[i] == 0 && !bad[i]) q.push(i);
	while(!q.empty()){
		int u = q.front(); q.pop();
		set<int> s;
		for(int v : adj[u]){
			s.insert(color[v]);
		}
		color[u] = mex(s);
		if(!bad[p[u]]){
			deg[p[u]]--;
			if(deg[p[u]] == 0) q.push(p[u]);
		}
	}
}
#define print(s) cerr<<#s<<" : ";for(auto i:(s))cerr<<i<<" ";cerr<<"\n";

int main(){
	memset(color, -1, sizeof color);
	int n;
	sd(n);
	adj.resize(n + 1);
	for(int i = 1; i <= n; i++) sd(p[i]), adj[p[i]].insert(i), deg[p[i]]++, edges.pb({p[i], i});
	adj2 = adj;
	// find a cycle
	bool found;
	for(int i = 1; i <= n; i++){
		if(vis[i]) continue;
		set<int> vec = {i};
		vis[i] = 1;
		int v = p[i];
		while(!vis[v]){
			vec.insert(v);
			vis[v] = 1;
			v = p[v];
		}
		if(vec.count(v)){
			found = 1;
			cycle.push_back(v); bad[v] = 1;
			int u = p[v];
			while(u != v){
				cycle.push_back(u);
				bad[u] = 1;
				u = p[u];
			}
			break;
		}
	}
	// print(cycle);
	if(cycle.empty()){
		printf("POSSIBLE"); return 0;
	}
	// Remove cycle and color
	for(auto it : edges){
		if(bad[it.S]){
			adj[it.F].erase(it.S);
			deg[it.F]--;
		}
	}
	toposort(n);
	int ind = 0, mn = 1e9;
	for(int c : cycle) if(adj[c].size() < mn){mn = adj[c].size(); ind = c;}
	for(int i = 0; i <= mn + 2; i++){
		for(int j : cycle) color[j] = -1;
		color[ind] = i;
		int v = p[ind];
		error = 0;
		while(v != ind){
			set<int> s;
			for(int x : adj2[v]) s.insert(color[x]);
			color[v] = mex(s);
			v = p[v];
		}
		for(int j : cycle) if(color[j] == color[p[j]]) error = 1;
		set<int> s;
		for(int x : adj2[ind]) s.insert(color[x]);
		if(mex(s) != i) error = 1;
		if(!error){
			/*for(int j = 1; j <= n; j++) cerr << color[j] << " ";
			cerr << endl;*/
			printf("POSSIBLE");
			return 0;
		}
	}
	printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 51824
#include<iostream>
#include<queue>
#include<algorithm>
#define LL long long
#define Max 107
#define pb push_back
using namespace std;
int n,k;
LL a[Max];
priority_queue<LL,vector<LL>,greater<LL>>p;
LL fun(int l,int r){
for(int i=1;i<=l;i++)
p.push(a[i]);
for(int j=1,t=n;j<=r;j++,t--)
p.push(a[t]);
int opt=k-l-r;
while(p.size() && p.top()<0 && opt)
p.pop(),opt--;
LL sum=0;
while(p.size())
sum+=p.top(),p.pop();
return sum;
}
int main()
{
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++){
cin>>a[i];
}
LL sum=0;
for(int i=0;i<=k;i++){
for(int j=0;(i+j)<=min(n,k);j++){
sum=max(fun(i,j),sum);
}
}
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int N, M;
    cin >> N >> M;

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

    if (N >= M)
    {
        printf("0\n");
        return (0);
    }

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

    vector<ll> diff;
    for (int i = 0; i < X.size() - 1; i++)
    {
        diff.push_back(X[i + 1] - X[i]);
        // printf("%d - %d\n", X[i + 1], X[i]);
    }
    sort(diff.begin(), diff.end(), greater<int>());
    // for (int i = 0; i < diff.size(); i++)
    // {
    //     printf("%d ", diff[i]);
    // }
    ll ans = X.back() - X[0];
    for (int i = 0; i < min((int)diff.size(), N - 1); i++)
    {
        ans -= diff[i];
    }
    cout << ans << endl;
    return (0);
}

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

using namespace std;

int main(void){
    int n,i=0,count=0,end=0,cur=0 ;
    string s;

    cin >> s;
    n = s.length();

    if(n>1){
        do{
            if( s[i] != s[i+1] ){
                    count++;
                    s.erase( s.begin() +i , s.begin() +(i+2) );
                    if(i>0) i--;
                    n = n-2;             
            }else{
                i++;
            }
        }while(n>1 && i<n-1);
    }

    cout << 2*count << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int maxn=3e3+20;
const int mod=1e9+7;

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

int n,m,dp[maxn][maxn][2];

inline void init()
{
	n=read();m=read();
}

inline void doing()
{
	REP(i,0,n)dp[0][i][i==0]=1;
	REP(i,1,m)REP(j,0,n)REP(op,0,1)if(dp[i-1][j][op])
	{
		int t=dp[i-1][j][op];
		if(j)pls(dp[i][j-1][op|(j-1==0)],t),pls(dp[i][j][op|(j-1==0)],t);
		if(n-j)pls(dp[i][j][op],t),pls(dp[i][j+1][op],t);
	}
	int ans=0;
	REP(j,0,n)ans=(ans+dp[m][j][1])%mod;
	printf("%d\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "/Users/swad/Desktop/CP/debug.h"
#endif

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

template <typename T>
class segmentTree {
	int n;
	vector<T> a;
	vector<T> st;
	T st_default;
	T (*merge)(T, T);
	void build(int stI, int L, int R) {
		if (L == R) {
			st[stI] = a[L - 1];
			return;
		}

		int mid = (L + R) >> 1;
		build(stI << 1, L, mid);
		build(stI << 1 | 1, mid + 1, R);

		st[stI] = merge(st[stI << 1], st[stI << 1 | 1]);
	}
	void update(int stI, int L, int R, int at, T val) {
		if (L == R) {
			st[stI] = val;
			return;
		}

		int mid = (L + R) >> 1;
		if (at <= mid) update(stI << 1, L, mid, at, val);
		else update(stI << 1 | 1, mid + 1, R, at, val);

		st[stI] = merge(st[(stI << 1)], st[(stI << 1) + 1]);
	}
	T query(int stI, int L, int R, int l, int r) {
		if (l <= L && R <= r) return st[stI];

		int mid = (L + R) >> 1;
		if (r <= mid) return query(stI << 1, L, mid, l, r);
		else if (mid + 1 <= l) return query(stI << 1 | 1, mid + 1, R, l, r);
		else return merge(
				query(stI << 1, L, mid, l, mid),
				query(stI << 1 | 1, mid + 1, R, mid + 1, r)
			);
	}
public:
	segmentTree(vector<T> _a, T (*_merge)(T, T), T st_default, bool build_init) {
		n = _a.size();
		a = _a;
		st.resize(4 * n + 1, st_default);
		this->st_default = st_default;
		merge = _merge;
		if (build_init) build(1, 1, n);
	}
	T query(int l, int r) { // range [l, r], 1-based index
		if (r < 1 || n < l || r < l) return st_default;
		l = max(l, 1); r = min(r, n);
		return query(1, 1, n, l, r);
	}
	void update(int at, T val) { // at is 1-based index
		if (at < 1 || n < at) return;
		update(1, 1, n, at, val);
	}
};

int n;
vector<int> h, a;

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	scanf("%d", &n);
	h.resize(n + 1);
	for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
	a.resize(n + 1);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

	segmentTree<ll> st = segmentTree<ll>(
			vector<ll>(n, 0LL),
			[](ll i, ll j) {return max(i, j);},
			0,
			false);

	for (int i = 1; i <= n; i++) {
		st.update(h[i], st.query(1, h[i] - 1) + a[i]);
	}

	cout << st.query(1, n) << endl;

	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
//#define random_shuffle(r...) random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}
ll prime[1000000];bool visprime[10000000];
void sieve(){ll k=0;for(ll i=2;i*i<=1000000;i++){for(ll j=i*i;j<=1000000;j+=i){visprime[j]=true;}}for(ll i=2;i<=1000000;i++){if(visprime[i]==false) prime[k++]=i;}}
int myrandom (int i) { return std::rand()%i;}

bool checkbit(int mask,int bit) {return (mask & (1<<bit));}

ll fact(ll n)
{
    if(n==0) return 1;
    if(n==1) return 1;
    ll ret=((n%mod)*(fact(n-1)%mod))%mod;
    return ret;

}

int main()
{

   int n;
   cin>>n;
   int arr[n];
   for(int i=0;i<n;i++) cin>>arr[i];
   ll temp=0;

   for(int i=0;i<n;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           temp+=(arr[i]*arr[j]);
       }
   }
   cout<<temp<<endl;


}

















Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 13
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
using namespace std;
int n,m,x;
int ar[N][N];
int tmp[N];
int c[N];
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   cin>>n>>m>>x;
   for(int i=0;i<n;i++){
       cin>>c[i];
       for(int j=0;j<m;j++){
           cin>>ar[i][j];
       }
   }
   int ans = 1e18;
   int on = 1;
   for(int i=0;i<(1<<n);i++){
       int co = 0;
       memset(tmp,0,sizeof(tmp));
       for(int j=0;j<n;j++){
           if(i&(on<<j)){
               co += c[j];
               for(int k=0;k<m;k++){
                   tmp[k] += ar[j][k];
               }
           }
       }
       int fl = 0;
       for(int j=0;j<m;j++){
           if(tmp[j]<x)fl = 1;
       }
       if(fl==0)ans = min(ans, co);
   }
   if(ans==1e18)ans=-1;
   cout<<ans;
        return 0;
}


Measured memory_bytes: 3668
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.array;
import core.bitop;

int[] read_numbers() {
  return readln.strip.chomp.split(" ").map!(to!(int)).array;
}

void main() {
  int col, row;
  for(;scanf("%d%d ", &col, &row), col;) {
    auto table = new int[][](col, row);
    foreach(ref line; table) {
      line = read_numbers;
    }
    auto rows = new int[](row);
    foreach(c; 0..col) {
      foreach(r; 0..row) {
        rows[r] |= (table[c][r] << c);
      }
    }
    int ans = 0;
    foreach(bit; 0..(1 << col)) {
      auto value =
        reduce!((accum, x) {
            return accum + max(popcnt(x ^ bit), col - popcnt(x ^ bit));
          })(0, rows);
      ans = max(value, ans);
    }
    writeln(ans);
  }
}

Measured memory_bytes: 3864
N = int(input())
A,B = map(int, input().split())
P_str = input().split()

P = [int(s) for s in P_str]
P_Aless = len([i for i in P if i <= A])
P_ABmiddle = len([i for i in P if (i > A and i <= B)])
P_Blarger = len([i for i in P if i > B])
min = min([P_Aless,P_ABmiddle,P_Blarger])
print(min)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

bool check(const string& T){
  bool flg = true;
  rep(i,T.size()){
    if(T[i] != T[T.size()-1-i]) flg = false;
  }

  if(T[0] != '1') flg = false;

  return flg;
}

void solve(int N, const vector<int>& v){
  int sum = 1;
  int prev = 1;
  int now = 2;
  REP(i,1,v.size()){
    cout << prev << " " << now << endl;
    sum++;
    prev = now;
    now++;
    while(sum < v[i]){
      cout << prev << " " << now << endl;
      now++;
      sum++;
    }
  }
  while(now <= N){
    cout << prev << " " << now << endl;
    now++;
  }
}

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

  N = S.size();
  
  if(S[S.size()-1] != '0'){
    cout << -1 << endl;
  }else{
    string T = S.substr(0,S.size()-1);
    if(check(T)){
      vector<int> v;
      rep(i,N){
        if(T[i]=='1') v.push_back(i+1);
      }

      solve(N, v);
    }else{
      cout << -1 << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;  //偶数
    cin >> n;
    int m = n/2;
    int d[n];
    rep(i, n) {
        cin >> d[i];
    }

    sort(d, d+n);

    int ans = d[m] - d[m-1];

    cout << ans;
    
    cout << endl;
    return 0;
}

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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int ans=0;
  
    for(int i=0;i<A;i++){
      ans ++;
      K --;
      if(K<=0)break;
    }
    if(K>0){
      for(int i=0;i<B;i++){
       K--;
       if(K<=0)break;
      }
    }
    if(K>0){
      for(int i=0;i<C;i++){
        ans --;
        K --;
        if(K<=0)break;
      }
    }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut h: [i64; n]
    }
    let mut ans = true;
    for i in 1..n {
        let j = n - 1 - i;
        if h[j] - h[j + 1] == 1 {
            h[j] -= 1;
        } else if h[j] - h[j + 1] > 1 {
            ans = false;
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(){

	string n;
	int k, ans;

	cin >> n;
	cin >> k;

	if (k == 1) {
		ans = (n.size() - 1) * 9 + (int)(n[0] - '0');
		cout << ans << endl;
		return 0;
	}
	else if (k == 2) {
		if (n.size()<2) {
			cout << "0" << endl;
			return 0;
		}

		ans = (n.size() - 1)*(n.size() - 2) / 2 * 81;
		ans += ((int)(n[0] - '0') - 1)*((n.size() - 1) * 9);
		for (int i = 1;i < n.size();i++) {
			if (n[i] != '0') {
				ans += (n.size() - i - 1) * 9;
				ans += (int)(n[i]-'0');
				i=1000;
			}
		}
		cout << ans << endl;
		return 0;
	}
	else {
		if (n.size() < 3) {
			cout << "0" << endl;
			return 0;
		}

		ans= (n.size() - 1)*(n.size() - 2)*(n.size() - 3) / 6 * 81*9;
		ans += ((int)(n[0] - '0') - 1)*(n.size() - 1)*(n.size() - 2) / 2 * 81;
		for (int i = 1;i < n.size();i++) {
			if (n[i] != '0') {
				ans += (n.size() - i - 1)*(n.size() - i - 2) / 2 * 81;
				ans += ((int)(n[i] - '0') - 1)*(n.size() - i - 1) * 9;
				for (int j = i + 1;j < n.size();j++) {
					if (n[j] != '0') {
						ans += (n.size() - j - 1) * 9;
						ans += (int)(n[j]-'0');
						j=1000;
					}
				}
				i=1000;
			}
		}
		cout << ans << endl;
		return 0;
	}

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  ll x; cin >> x;
  ll ans = 0;
  if ( x <= 6 ) ans = 1;
  else if ( x <= 11 ) ans = 2;
  else {
  ll tmp = x /11;
  x -= tmp*11;
  ans += tmp*2;
  if ( x >= 7 ) ans += 2;
  else if ( 1 <= x && x <= 6 ) ans++;
  }
  cout << ans  << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,i,j;
    cin>>n;
    for(i=1; i<=9; i++){
        for(j=1; j<=9; j++){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();

        int[] b = new int[m];
        //        int[][] a = new int[n][m];

        for (int i = 0; i < m; i++) {
            b[i] = sc.nextInt();
        }

        int sum = 0;
        int cnt = 0;

        for (int i = 0; i < n; i++) {
            sum = 0;
            for (int j = 0; j < m; j++) {
                int num = sc.nextInt();
                sum += num * b[j];
            }
            sum += c;
            if (sum > 0) {
                cnt++;
            }
        }

        sc.close();

        System.out.println(cnt);
    }

}

Measured memory_bytes: 24020
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <utility>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[200005],a(300005),b(300005,0),f(500005,0);
lli vis[200005];
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
void fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        f[k]=(f[k-1]*k)%mod;
    }
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
lli comb(lli n,lli i)
{
    lli g=f[n]*(bpow(f[i],mod-2))*bpow(f[n-i],mod-2);
    return g%mod;
}
lli permute(lli n, lli i)
{
    lli h=f[n-i];
    lli g=f[n]*(bpow(h,mod-2));
    return g%mod;
}
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
lli ans=0;
void dfs(lli i,lli pr)
{
    if(b[i])return;
    b[i]=1;
    ans++;
    for(auto u:p[i])
    {
        if(u!=pr)
        {
            dfs(u,i);
        }
    }
}
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli n,m;cin>>n>>m;
    lli x,y;
    for(lli i=0;i<m;i++)
    {
        cin>>x>>y;
        p[x].pb(y);
        p[y].pb(x);
    }
    lli mx=0;
    for(lli i=1;i<=n;i++)
    {
        if(!b[i])
        {
            ans=0;
            dfs(i,0);
            mx=max(mx,ans);
        }
    }
    cout<<mx<<endl;
    
}



Measured memory_bytes: 32224
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

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


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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	ll ans = 0;
	string s;
	cin >> n >> s;
	s = '#'+s;
	vector <int> pref[100];
	char sym[3] = {'B', 'G', 'R'};
	for (int j=0; j<3; j++) {
		pref[sym[j]].resize(n+1);
	}
	for (int i=1; i<=n; i++) {
		for (int j=0; j<3; j++) {
			pref[sym[j]][i] = pref[sym[j]][i-1];
		}
		pref[s[i]][i] ++;
	}
	for (int i=2; i<=n; i++) {
		for (int j=i+1; j<=n; j++) {
			if (s[i] == s[j]) continue;
			char mn = min(s[i], s[j]);
			char mx = max(s[i], s[j]);
			char need;
			//cout << mn << " " << mx << "\n";
			if (mn == 'G') {
				need = 'B';
			} else {
				if (mx == 'G') {
					need = 'R';
				} else {
					need = 'G';
				}
			}
			ans += pref[need][i-1];
			if (i-(j-i) >= 1) {
				ans -= bool(s[i-(j-i)] == need);
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define int       long long
#define w(x)      int x;cin >> x;while (x--)
#define rep(d,a,n)  for(int d=a;d<=n;d++) 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define oj  freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int inf=1e18;
int gcd(int a,int b,int temp){
    if(temp==1){
        return 1;
    }else if(a%temp==0 && b%temp==0){
        return temp;
    }
    temp-=max(a%temp,b%temp);
    return gcd(a,b,temp);
}

void fun(){
    char a;
    cin>>a;
    if(a>='A' && a<='Z'){
        cout<<"A";
    }else{
        cout<<"a";
    }
}
int32_t main()
{
  
    fast_io;
    fun();

    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
	int n;
	cin>>n;
	vector < int > dp(n,INF),h(n);
	for(int i = 0; i < n ; i++) {
		cin>>h[i];	
	}
	dp[0] = 0;
	for(int i = 0 ; i < n ; i++) {
		for(int j : {i+1, i+2}) {
			if(j<n) {
				dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}
	cout<<dp[n-1];
	
	return 0;
}
//Errichto's code


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _for(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FOR(...)   _for (__VA_ARGS__)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
template <typename T>
using PQR = priority_queue <T, vector <T>, greater <T>>;

template <typename T, typename ... Us>
auto sum (priority_queue <T, Us ...> & p)
{
  T res = 0;
  while (not p.empty ())
  {
    auto t = p.top (); p.pop ();
    res += t;
    cerr << "debug: " << t << endl;
  }
  return res;
}

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;

  vector <ll> p_ (a), q_ (b);
  priority_queue <ll> r;
  rep (i, a) cin >> p_ [i];
  rep (i, b) cin >> q_ [i];
  rep (i, c)
  {
    ll r_;
    cin >> r_;
    r.push (r_);
  }
  sort (ALL (p_), greater <void> ());
  sort (ALL (q_), greater <void> ());

  PQR <ll> p, q;
  rep (i, x) p.push (p_ [i]);
  rep (i, y) q.push (q_ [i]);

  while (not r.empty ())
  {
    auto pt = p.top ();
    auto qt = q.top ();
    auto rt = r.top (); r.pop ();
    if (pt < qt)
    {
      if (pt < rt) {
        p.pop ();
        p.push (rt);
      }
      else break;
    }
    else
    {
      if (qt < rt)
      {
        q.pop ();
        q.push (rt);
      }
      else break;
    }
  }

  auto ans = sum (p) + sum (q);
  cout << ans << endl;
}


Measured memory_bytes: 4852
#include<bits/stdc++.h>
            using namespace std;
        #define int long long
            signed main() {
              int n;
              cin>>n;
              int k=sqrt(n);
              for(int i=k ; i>=1 ; i--) {
              	if(n%i==0) {
              		cout<<i+n/i-2;
              		return 0;
              	}
              }
            }

Measured memory_bytes: 256