akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	
	static int c[][];

	public static boolean judge(int tmpa, int tmpb) {
		int b[] = new int[3];
		int a[] = new int[3];
		a[0] = tmpa;
		b[0] = tmpb;
		for(int i = 1; i < 3; ++i) 
			b[i] = c[0][i] - a[0];
		for(int i = 1; i < 3; ++i) 
			a[i] = c[i][0] - b[0];
		for(int i = 1; i  < 3; ++i) {
			for(int j = 1; j < 3; ++j) {
				int tmp = a[i] + b[j];
				if(c[i][j] != tmp)return false;
			}
		}
		return true;
	}
	
	public static boolean solve() {
		for(int i = 0; i <= c[0][0]; ++i) {
			if(judge(i, c[0][0] - i))return true;
		}
		return false;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		c = new int[3][3];
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) 
				c[i][j] = sc.nextInt();
		}
		sc.close();
		int a = 1;
		String ans[] = { "Yes", "No" };
		if(solve())a = 0;
		System.out.println(ans[a]);
	}

}


Measured memory_bytes: 22612
#include "bits/stdc++.h"

using namespace std;

typedef long long LL;
typedef long double LD;





int main()
{
  LL N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  LL range_max = 0;
  //! 1の左側を起点とすればOKだが、S[0]が0ときだけ異なる
  if (S[0] == '0') {
    LL C = 1;
    LL i = 0;
    LL j;
    for (j = i; j < S.length(); ++j) {
      if (S[j] == '1' && S[j + 1] == '0' && C >= K) {
        break;
      }
      else if (S[j] == '1' && S[j + 1] == '0' && C < K) {
        C++;
      }
    }
    //! 右端のとき
    if (j >= N) {
      j--;
    }
    LL range = j - i + 1;
    // cout << i << " : " << j << " : " << j - i + 1 << endl;
    range_max = max(range_max, range);
  }

  LL index = S.find("1");
  string U = "";
  for (LL i = S.find("1"); i < S.length(); ++i) {
    U += S[i];
  }
 // cerr << S << endl;
  S = U;
  //cerr << S << endl;

  LL C = 0;
  LL j = 0;
  for (LL i = 0; i < S.length(); ++i) {
    if (S[i] == '0') {
      continue;
    }
    //! 一つ前のもとの同じ場合はスキップ（先頭を除く）
    if (i != 0) {
      if (S[i - 1] == '1' &&
        S[i] == '1') {
        continue;
      }
    }

    for (; j < S.length(); ++j) {
      if (S[j] == '1' && S[j + 1] == '0' && C >= K) {
        C--;
        break;
      }
      else if (S[j] == '1' && S[j + 1] == '0' && C < K) {
        C++;
      }
    }
    //! 右端のとき
    if (j >= S.length()) {
      j--;
    }
    LL range = j - i + 1;
    //cout << i << " : " << j << " : " << j - i + 1 << endl;
    range_max = max(range_max, range);

  }
  cout << range_max;


  return 0;
}



Measured memory_bytes: 512
#include<stdio.h>

int main(void){
	int n, div = 5, div_plus = 2;

	scanf("%d", &n);

	printf("%d:", n);
	while(n % 2 == 0){
		printf(" 2");
		n /= 2;
	}
	while(n % 3 == 0){
		printf(" 3");
		n /= 3;
	}
	while(n != 1){
		if(n % div == 0){
			printf(" %d", div);
			n /= div;
		}else{
			div += div_plus;
			div_plus = 6 - div_plus;
		}
	}
	printf("\n");

	return 0;
}

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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    long long n;
    long long k;
    cin >> n;
    long long count,countmin = 1000000000000;

    if(n<=20) {
        for(int i = 1;i<=n;i++) {
            for(int j = 1;j<=n;j++) {
                if(i*j==n) {
                    count = i+j-2;
                    countmin = min(count,countmin);
                }
            }
        }
    }
    if(n<=20) {
        cout << countmin;
        return 0;
    }

    for(long long i = 1;i<=sqrt(n);i++) {
        if(n%i == 0) {
            k = n/i;
            count = i+k-2;
            countmin = min(countmin,count);
        }
    }
    cout << countmin;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  map<string,ll> point;
  
  ll n; cin >> n;
  
  rep(i,n){
    string s; cin >> s;
    if(point.count(s)){
      point[s]++;
    }
    else{
      point[s] = 1;
    }
  }
  
  ll m; cin >> m;
  
  rep(i,m){
    string s; cin >> s;
    if(point.count(s)){
      point[s]--;
    }
  }
  
  ll maxpoint = 0;
  
  for(auto p : point){
    ll pnt = p.second;
    maxpoint = max(maxpoint,pnt);
  }
  
  cout << maxpoint << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  string s,t;
  cin>>n>>s>>t;
  rep(i,n){
    cout<<s.at(i)<<t.at(i);
  }
}


Measured memory_bytes: 256
n, u, v = map(int, input().split())
u, v = u-1, v-1
reach = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(lambda x: int(x)-1, input().split())
    reach[a].append(b)
    reach[b].append(a)

def dfs_deep_measure(st, n, reach):
    deep = [-1] * n
    check = [0] * n
    stack = [st]
    check[st] = 1
    deep[st] = 0
    while len(stack) > 0:
        tmp = stack.pop(-1)
        tmp_list = reach[tmp]
        for i in tmp_list:
            if check[i] != 1:
                stack.append(i)
                check[i] = 1
                deep[i] = deep[tmp]+1
    return deep

a_route = dfs_deep_measure(v, n, reach)
t_route = dfs_deep_measure(u, n, reach)
ans = 0
for i in range(len(a_route)):
    if t_route[i] < a_route[i]:
        ans = max(ans, a_route[i]-1)

print(ans)


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

int main(){
    int t, n;
    cin >> t;
    for(int j=1; j<=t; j++){
        vector<int> blocks;
        cin >> n;
        for(int i=1; i<=n; i++){
            int tmp;
            cin >> tmp;
            blocks.push_back(tmp);
        }
        int max_up = 0;
        int max_down = 0;

        for(int i=0; i<n-1; i++){
            if(blocks.at(i) < blocks.at(i+1)){
                if(max_up < (blocks.at(i+1) - blocks.at(i))){
                    max_up = blocks.at(i+1) - blocks.at(i);
                }
            }
            if(blocks.at(i) > blocks.at(i+1)){
                if(max_down < (blocks.at(i) - blocks.at(i+1))){
                    max_down = blocks.at(i) - blocks.at(i+1);
                }
            }
        }
        printf("%d %d\n", max_up, max_down);
    }
    return 0;
}

Measured memory_bytes: 0
S = list(input())
areas = 0
cnt = 0
stack_1 = []
stack_2 = []

for i in range(len(S)):
    if S[i] == '\\':
        stack_1.append(i)
    elif S[i] == '/' and len(stack_1) > 0:
        j = stack_1.pop()
        area = i - j
        areas += area
        while len(stack_2) > 0 and stack_2[-1][0] > j:
            area += stack_2.pop()[1]
        stack_2.append([j, area])

print(areas)
if stack_2:
    print(len(stack_2), *list(zip(*stack_2))[1])
else:
    print(0)
    


Measured memory_bytes: 6640
#include <bits/stdc++.h>
#define left(x) (x << 1)
#define right(x) (left(x) + 1)
#define mid(x, y) ((x + y) >> 1)
#define MX 0x7fffffff
using namespace std;
void build(int *st, int r, int l = 0, int p = 1)
{
    if (l == r)
    {
        st[p] = MX;
        return;
    }
    build (st, mid(l, r), l, left(p));
    build (st, r, mid(l, r) + 1, right(p));
    st[p] = min(st[left(p)], st[right(p)]);
}
void update(int *st, int i, int val, int r, int l = 0, int p = 1)
{
    if ( i > r || i < l) return ;
    if (l == r)
    {
        st[p] = val;
        return;
    }
    update(st, i, val, mid(l, r), l, left(p));
    update(st, i, val, r, mid(l, r) + 1, right(p));
    st[p] = min(st[left(p)], st[right(p)]);
}

int query(int *st, int i, int j, int r, int l = 0, int pos = 1)
{
    if (i > r || j < l) return MX;
    if (l >= i && r <= j) return st[pos];
    return min(query(st, i, j, mid(l, r), l, left(pos)), query(st, i, j, r, mid(l, r) + 1, right(pos)));
}
int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    int A[n << 2];
    build(A, n - 1);
    int c, x, y;
    for (int i = 0; i < q; i++)
    {
        scanf("%d %d %d", &c, &x, &y);
        switch(c)
        {
        case 0 :
            update(A, x, y, n - 1);
            break;
        case 1 :
            printf("%d\n", query(A, x, y, n - 1));
        }
    }
    return 0;
}



Measured memory_bytes: 4228
#include <iostream>

using namespace std;

int main() {
    int n;
    while (cin >> n && n != 0) {
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            int temp = i;
            while (temp % 5 == 0) {
                temp /= 5;
                ans++;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
// --------------------------------------------------------
template<class T> bool chmax(T& a, const T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T b) { if (b < a) { a = b; return 1; } return 0; }
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


// segtree
using S = int;
S op(S a, S b) { return max(a, b); }
S e() { return 0; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int N, K; cin >> N >> K;
    VI A(N); REP(i,N) cin >> A[i];

    int MAX_A = MAX(A);
    segtree<S, op, e> dp(MAX_A + 1);
    for (int a : A) {
        int l = max(0, a - K);
        int r = min(MAX_A, a + K);
        dp.set(a, dp.prod(l, r + 1) + 1);
    }
    int ans = dp.all_prod();
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9764
import Data.List
import Data.Char
main :: IO ()
main = do
    [a,b] <- map read . words <$> getLine :: IO [Int]
    s <- getLine :: IO String
    let (t1,t2) = break (=='-') s
        (s1,s2) = (t1, if null t2 then "" else drop 1 t2)
    putStrLn $ if length s1 == a && length s2 == b
                  && all isDigit (s1 ++ s2)
               then "Yes" else "No"


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

const int N = 3e5+5;

int n, qs[N];
char A[N];

int main() {
    scanf("%d", &n);
    scanf("%s", A+1);
    for(int i = 1; i <= n; ++i) qs[i] = qs[i-1] + (A[i] == 'E');
    int mx = N;
    for(int i = 1; i <= n; ++i) 
        mx = min(mx, i-1-qs[i-1] + qs[n]-qs[i]);
    printf("%d\n", mx);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h> 
using namespace std; 
  
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i)
#define ll long long 
// int check()
#include <string.h>


int main()
{
    ll s,w;
    cin>>s>>w;
    if(s>w)
    cout<<"safe";
    else 
    cout<<"unsafe";
    return 0;
}

 

Measured memory_bytes: 3632
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define LL long long
const int N=100005;
LL a[N],b[N];
int main()
{
  //  freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,n;LL ans=0;
    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%lld%lld",&a[i],&b[i]);
    for (i=n;i>=1;i--)
    {
        a[i]+=ans;
        ans+=(b[i]-a[i]%b[i])%b[i];
    }
    printf("%lld\n",ans);
    
    return 0;
}


Measured memory_bytes: 1920
N, K = list(map(int, input().split()))
mod = 10**9 + 7

# i=1
n = N-K+1
print(n)

# i>1
for i in range(2, K+1):
  n = n * (N-K+2-i)//i * (K-(i-1))//(i-1)
  print(n % mod)

Measured memory_bytes: 3316
#include<stdio.h>
#define MAX 36
   
typedef struct {
  char op;
  int value;
}c;
   
int N;
int isStable(c *,c *);
void bubble(c *);
void selection(c *);
   
c A[MAX],C[MAX],D[MAX];
   
int main(){
  int i,j;
  char dummy;
  c D[MAX];
  scanf("%d%c",&N,&dummy);
  for(i=0;i<N;i++){
    scanf("%c%d%c",&C[i].op,&C[i].value,&dummy);
    A[i]=C[i];
    D[i]=C[i];
  }
   
  bubble(C);
  selection(D);
  return 0;
}
     
void bubble(c *C){
  int i,j,nstac;
  char opstac;
  for(i=0;i<=N-1;i++){
    for(j=N-1;j>=i+1;j--){
      if(C[j].value<C[j-1].value){
	nstac=C[j].value;
	opstac=C[j].op;
	C[j].value=C[j-1].value;
	C[j].op=C[j-1].op;
	C[j-1].value=nstac;
	C[j-1].op=opstac;
      }
    }
  }
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%c%d",C[i].op,C[i].value);
  }
  printf("\n");
  printf("Stable\n");
}
    
void selection(c *D){
  c x[MAX];
  int i,j,minj;
  for(i=0;i<=N-1;i++){
    minj=i;
    for(j=i;j<=N-1;j++){
      if(D[j].value<D[minj].value)
	minj=j;
    }
    x[i]=D[minj];
    D[minj]=D[i];
    D[i]=x[i];
  }
       
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%c%d",D[i].op,D[i].value);
  }
  printf("\n");
  if(isStable(D,A)==0)
    printf("Not stable\n");
  if(isStable(D,A)==1)
    printf("Stable\n");
}
              
int isStable(c *in,c *out){
  int i,j,a,b;
  for(i=0;i<=N-1;i++){
    for(j=i+1;j<=N-1;j++){
      for(a=0;a<=N-1;a++){
	for(b=a+1;b<=N-1;b++){
	  if(in[i].value==in[j].value && in[i].op==out[b].op && in[j].op==out[a].op) return 0;
	}}}}
  return 1;
}

Measured memory_bytes: 612
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

char data[8][8]={};

int d[]={-3,-2,-1,1,2,3};
void dfs(int x,int y){
    data[y][x]='0';
    rep(i,6){
        if(x+d[i]<8 && 0<=x+d[i] && data[y][x+d[i]]=='1')dfs(x+d[i],y);
    }
    rep(i,6){
        if(y+d[i]<8 && 0<=y+d[i] && data[y+d[i]][x]=='1')dfs(x,y+d[i]);
    }
}

int main() {
    int n;
    cin>>n;
    rep(i,n){
        rep(i,8) rep(j,8) cin>>data[i][j];
        
        int x,y;
        cin>>x>>y;
        x--,y--;
        
        dfs(x,y);
        
        cout<<"Data "<<i+1<<":"<<endl;
        rep(i,8){
            rep(j,8){
                cout<<data[i][j];
            }
            cout<<endl;
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 1160
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        temperature: i32
    }

    if temperature >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2144
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    cin >>a>>b>>c>>d;
    
    if(a==b && c==d) cout << "yes" <<endl;
    else if(a==c && b==d) cout << "yes" <<endl;
    else if(a==d&& c==b) cout << "yes" <<endl;
    else cout<<"no"<<endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const int MAX_W=400,MAX_H=400;
int H,W;
string S[MAX_H];	
bool flg[MAX_H][MAX_W];
typedef pair<int,int> P;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
	cin>>H>>W;
	REP(i,H)cin>>S[i];
	ll ans=0;
	REP(h,H){
		REP(w,W){
			if (!flg[h][w] && S[h][w]=='#'){
				queue<P> que;
				que.push(P(h,w));
				flg[h][w]=true;
				ll bc=0,wc=0;
				while(!que.empty()){
					P p=que.front();
					que.pop();
					if (S[p.first][p.second]=='#'){
						bc++;
					}else{
						wc++;
					}
					REP(t,4){
						int h2=p.first+dy[t],w2=p.second+dx[t];
						if (0<=h2 && h2<H && 0<=w2 && w2<W && S[h2][w2]!=S[p.first][p.second] && !flg[h2][w2]){
							que.push(P(h2,w2));
							flg[h2][w2]=true;
						}
					}
				}
				ans+=wc*bc;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
using AtCoderBeginnerContest120.Questions;
using AtCoderBeginnerContest120.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest120.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var abc = inputStream.ReadIntArray();
            yield return Math.Min(abc[1] / abc[0], abc[2]);
        }
    }
}


namespace AtCoderBeginnerContest120
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest120.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest120.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  if(n==1){
    cin>>a;
    cout<<abs(a-b);
    return 0;
  }
  int c[n];
  for(int i=0;i<n;i++) cin>>c[i];
  cout<<max(abs(c[n-1]-b),abs(c[n-1]-c[n-2]));
}

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

#define MOD 1046527

vector<string> D(MOD);

int getChar(char c){
    if(c=='A') return 1;
    else if(c=='C') return 2;
    else if(c=='G') return 3;
    else if(c=='T') return 4;
    else return 0;
}

long long getKey(string s){
    long long sum=0,p=1;
    for(int i=0;i<s.size();i++){
        sum+=p*getChar(s.at(i));
        p*=5;
    }
    return sum;
}

int h1(int key){
    return key%MOD;
}
int h2(int key){
    return 1+(key%(MOD-1));
}

int find(string s){
    long long key,h,i=0;
    key=getKey(s);
    while(i<MOD){
        h=(h1(key)+i*h2(key))%MOD;
        if(D.at(h)==s) return 1;
        else if(D.at(h).size()==0) return 0;
        i++;
    }
    return 0;
}

int insert(string s){
    long long key,h,i=0;
    key=getKey(s);
    while(i<MOD){
        h=(h1(key)+i*h2(key))%MOD;
        if(D.at(h).size()==0){
            D.at(h)=s;
            return 0;
        }
        i++;
    }
    return 0;
}

int main() {
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
	    string com,s;
	    cin >> com >> s;
	    if(com.at(0)=='i'){
	        insert(s);
	    }
	    else if(com.at(0)=='f'){
	        if(find(s)){
	            printf("yes\n");
	        }
	        else{
	            printf("no\n");
	        }
	    }
	}
}



Measured memory_bytes: 41436
#include<bits/stdc++.h>
#define int   long long 
#define endl "\n"
#define max -1e18
using namespace std;

signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int a,b,c,d,p,q;cin>>a>>b>>c>>d;
   int ar[16];
   for(int i=0;i<16;i++) ar[i] = max;
   ar[0] = a*c;
  if( c != d) ar[1] = a*(c+1);
   //cout<<ar[0]<<endl;
   ar[2] = a*d;
   if( c != d)ar[3] = a*(d-1);

  if(a != b) ar[4] = (a+1)*c;
  if(a != b && c != d) ar[5] = (a+1)*(c+1);
   
 if(a != b)  ar[6] = (a+1)*d;
 if(a != b && c != d)  ar[7] = (a+1)*(d-1);
   //////////////////////////
   ar[8] = b*c;
  if(c != d) ar[9] = b*(c+1);  
   ar[10] = b*d;
 if(c != d)  ar[11] = b*(d-1);

  if(a != b) ar[12] = (b-1)*c;
  if(a != b && c != d) ar[13] = (b-1)*(c+1);
   
 if(a != b)  ar[14] = (b-1)*d;
 if(a != b && c != d)  ar[15] = (b-1)*(d-1);

//for(int i=0;i<16;i++) cout<<ar[i]<<endl;
   sort(ar,ar+16);
  cout<<ar[15]<<endl; 
}


/*
 ==========================
    Author-Shivmangal
 ==========================
 */




Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
    int n,m;
    cin>>n>>m;
    int ans=0;
    for(int i=10;i<=min(99LL,m);i++)
    {
        string s=to_string(i);
        if(s[0]-'0'>=2&&s[1]-'0'>=2)
        {
            if((s[0]-'0')*(s[1]-'0')<=n)
            {
                ans++;
                
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = list(map(int,input().split()))
dis_x = abs(n[2]-n[0])
dis_y = abs(n[3]-n[1])
if n[0]<=n[2]:
    if n[1]<=n[3]:
        print(n[2]-dis_y,n[3]+dis_x,n[0]-dis_y,n[1]+dis_x)
    else:
        print(n[2]+dis_y,n[3]+dis_x,n[0]+dis_y,n[1]+dis_x)
elif n[0]>n[2]:
    if n[1]<=n[3]:
        print(n[2]-dis_y,n[3]-dis_x,n[0]-dis_y,n[1]-dis_x)
    else:
        print(n[2]+dis_y,n[3]-dis_x,n[0]+dis_y,n[1]-dis_x)


Measured memory_bytes: 3064
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n+1-i):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            # Show a canditate of bill combination.
            print(i, j, n - i - j)
            exit()

# If there are no canditate, show -1 combination.
print(-1, -1, -1)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector< int > A;
bool rec(int now,int sum){
  if(!sum) return true;
  else if(now == A.size() || sum < 0) return false;
  return rec( now + 1, sum - A[now]) || rec( now + 1, sum);
}
int main(){
  int n;
  cin >> n;
  A.resize(n);
  for(int i = 0 ; i < n ; i++ ) cin >> A[i];
  int q;
  cin >> q;
  for(int i = 0 ; i < q ; i++ ){
    int M;
    cin >> M;
    cout << ( rec(0,M) ? "yes" : "no" ) << endl;
  }
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
char a[1001][1001];
int wi[8]={1,1,0,-1,-1,-1,0,1};
int wj[8]={0,-1,-1,-1,0,1,1,1},n=0,m=0;
int main(){
    read(n),read(m);
    for(int i=1;i<=n;i++)
    	for(int j=1;j<=m;j++)
        	cin>>a[i][j];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='#') cout<<'#';
            else{
                int num=0;
                for(int m=0;m<8;m++)
                {
                    if(a[i][j]!='.') continue;
                    if(a[i+wi[m]][j+wj[m]]=='#') num++;
                }
                cout<<num;
            }
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


#include <bits/stdc++.h>
using namespace std;

typedef  long long ll;
class BMultiplication2 {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        ll limit = (ll)1e18;
        cin >> n;
        ll res = 1;
        vector<ll> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            if (a[i] == 0) {
                cout << 0 << endl;
                return;
            }
        }
        for (int i = 0; i < n; ++i) {
            if (a[i] <= limit / res){
                res = res * a[i];
            }else {
                cout << -1 << endl;
                return;
            }
        }
        cout << res << endl;
	}
};


int main() {
	BMultiplication2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3992
N ,x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if a[i] + a[i+1] > x:
        tmp =  (a[i]+a[i+1]) - x
        a[i+1] = max(0, a[i+1] - tmp)
        ans += tmp
print(ans)

Measured memory_bytes: 14252
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	char c;

	cin >> c;

	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;

}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=0

for i in range(n):
    k=b[i]-a[i]
    if k>0:
        s+=a[i]
        a[i]=0
        if a[i+1]<k:
            s+=a[i+1]
            a[i+1]=0
        else:
            s+=k
            a[i+1]-=k
    else:
        s+=b[i]
        a[i]=-k

print(s)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,p[300005];
int f[3][300005];
ll ans[3];

int read(){
	int x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

int query(int id,int x){
	int res=0;
	while(x) res+=f[id][x],x-=x&-x;
	return res;
}

void add(int id,int x){
	while(x<=n) f[id][x]++,x+=x&-x;
}

int main(){
	n=read();
	for(int i=1;i<=n;i++) p[i]=read();
	for(int i=1;i<=n;i++){
		ans[0]+=query(0,n)-query(0,p[i]),add(0,p[i]);
		if(i&1) ans[1]+=query(1,n)-query(1,p[i]),add(1,p[i]);
		else ans[2]+=query(2,n)-query(2,p[i]),add(2,p[i]);
	}
	if(ans[0]%3==0&&ans[0]/3==ans[1]+ans[2]) puts("Yes");
	else puts("No");
	
	return 0;
}

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

using namespace std;

int X[200010]={};
int org[200010]={};

void swap(int *x, int *y);
void quicksort(int X[], int low, int high);

int main(void)
{
	int N,tmp;

	cin >> N;
	for(int i =0; i<N; i++){
	 cin >> tmp;
	 X[i] = tmp;
	 org[i] = tmp;
	}
	quicksort(X,0,N-1);

/*
	for(int i=0;i<N; i++){
		cout << i << "=" << X[i] << endl;
	}
	*/
	int mid1 = N/2 -1 ; int mid2 = N/2; 
	for(int i = 0; i < N; i++){
		if(org[i] <= X[mid1]){
			cout << X[mid2] << endl;
		}else{
			cout << X[mid1] << endl;
		}
	}
	
	return 0;
}

void quicksort(int X[], int low, int high){
	if(low < high){
		int mid = (low + high) /2;
		int x= X[mid];
		int i = low; int j = high;
		while(i <= j){
			while(X[i] < x) i = i+1;
			while(X[j] > x) j = j-1;
			if(i<=j) swap(&X[i++], &X[j--]);
		}
		quicksort(X,low,j);
		quicksort(X,i,high);
	}
}

void swap(int *x, int *y){
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  int zero = 0, one = 0;
  for (char c : s) {
    if (c == '0') ++zero;
    else ++one;
  }
  cout << min(zero, one) * 2 << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************


int a,b,c,d; 

int main(void)
{
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    
    if(a==1 || b==1 || c==1 || d==1)
    {
        if(a==9 || b==9 || c==9 || d==9)
        {
            if(a==7 || b==7 || c==7 || d==7)
            {
                if(a==4 || b==4 || c==4 || d==4)
                {
                    cout << "YES";
                }
                else
                {
                    cout << "NO";
                }

            }
            else
            {
                cout << "NO";
            }
               

        }
        else
        {
            cout << "NO";
        }

    }
    else
    {
        cout << "NO";
    }





    return 0;
}





Measured memory_bytes: 256
use std::cmp;

fn solve(xs: &Vec<i32>, k: i32) -> i32 {
    xs.iter().map(|x| 2 * cmp::min(*x, k - *x)).sum()
}

#[test]
fn test_solve() {
    assert_eq!(solve(&vec![2], 10), 4);
    assert_eq!(solve(&vec![3, 6], 9), 12);
    assert_eq!(solve(&vec![11, 12, 9, 17, 12], 20), 74);
}

pub mod contest_input {
    use std::io;
    use std::str::FromStr;
    use std::fmt::Debug;

    pub fn read_line<F>() -> F
    where F: FromStr, <F as FromStr>::Err: Debug {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        input.trim().parse().unwrap()
    }

    pub fn read_words<F>() -> Vec<F>
    where F: FromStr, <F as FromStr>::Err: Debug {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        input
            .split_whitespace()
            .map(|i| i.parse().unwrap())
            .collect()
    }

    pub fn read_matrix<F>(num_lines: usize) -> Vec<Vec<F>>
    where F: FromStr, <F as FromStr>::Err: Debug {
        (0..num_lines).map(|_| read_words()).collect()
    }
}

fn main() {
    contest_input::read_line::<usize>(); // N
    let k: i32 = contest_input::read_line();
    let xs: Vec<i32> = contest_input::read_words();
    println!("{}", solve(&xs, k));
}


Measured memory_bytes: 4352
N=int(input())
S=input()
R=""
L=[]
obj={}
for s in S:
    if s not in L:
        R+=s
        L.append(s)
        obj[s]=1
    else:
        obj[s]+=1

out=1
for a in obj.keys():
    out*=(obj[a]+1)
    if out>10**9+7:
        out=out%(10**9+7)
print(out-1)


Measured memory_bytes: 3188
let combine =
  fun n ->
    let rec _combine = fun list ->
      match list with
      | [] -> []
      | [a] -> [[a]]
      | [a; b] -> [[a; b]; [b; a]]
      | _ ->
        list                                    // [1; 2; 3]
        |> List.collect (fun x ->               // 1
            list
            |> List.filter (fun x2 -> x <> x2)  // [2; 3]
            |> _combine                         // [[2; 3]; [3; 2]]
            |> List.map  (fun ts -> x::ts)      // [[1; 2; 3]; [1; 3; 2]]
        )
    [1..n]
    |> _combine
    |> List.mapi (
      fun i order ->
        (
          i,
          order
          |> List.map string
          |> List.reduce (fun a b -> a + " " + b)
        )
    )

(
  stdin.ReadLine() |> int,
  stdin.ReadLine(),
  stdin.ReadLine()
)
|> fun (n, ps, qs) -> (n |> combine, ps, qs)
|> fun (dict, ps, qs) ->
  (
    (dict |> List.find (fun (_, v) -> v = ps) |> fun (i, _) -> i),
    (dict |> List.find (fun (_, v) -> v = qs) |> fun (i, _) -> i)
  )
|> fun (a, b) -> (a - b) |> abs
|> printfn "%d"


Measured memory_bytes: 36720
n1, n2 = [int(i) for i in input().split()]

t1 = []
r1 = 1001

for i1 in range(n1):
    t1 = [int(j) for j in input().split()]
    if t1[1] <= n2:
        if t1[0] < r1:
            r1 = t1[0]

if r1 == 1001:
    r1 = "TLE"
print(r1)

Measured memory_bytes: 3060
def main():
    N, M = map(int, input().split())
    
    total = 0
    for i in range(1, 10 ** 5):
        # x = ((i + 1) * 1900) * ((1/2) ** (i + 1))

        # x = (1900 + 1900 + 800) * i
        # y = x * ( ( (3/4) ** (i-1) ) * (1/4) )
        # total += y
        # print(x, y)

        x = (1900 * M + 100 * (N - M)) * i
        prob = (1/2) ** M
        y = x * ( ( (1-prob) ** (i-1) ) * prob )
        total += y
        # print(':', prob, x, y, total)

    print(round(total))

if __name__ == "__main__":
    main()

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

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
const int mod = 1e9 + 7;

int main() {
    FASTIO;

    int n,m;
    cin>>n>>m;

    vector<vector<char>> grid(n,vector<char>(m));
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<m;j++) cin>>grid[i][j];
    }

    // vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
    // dp[n-1][m-1] = 1;

    vector<ll> dp(m+1,0);
    dp[m-1] = 1;

    for(int i = n-1;i>=0;i--)
    {
        for(int j = m-1;j>=0;j--)
        {
            if(grid[i][j]=='.')
            {
                dp[j] += dp[j+1];
                dp[j] %= mod;
            }
            else dp[j] = 0;
        }
    }

    cout<<dp[0];
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000



int main(){
	
	int N;
	cin>>N;
	
	vector<long long> A(N+1,0);
	for(int i=0;i<N;i++){
		cin>>A[i+1];
		A[i+1]+=A[i];
	}
	
	long long ans = Inf;
	
	for(int i=2;i<=N-2;i++){
		int ok = 1;
		int ng = i;
		while(ng-ok>1){
			int mid = (ok+ng)/2;
			long long a = A[mid];
			long long b = A[i]-a;
			if(a>b)ng=mid;
			else ok=mid;
		}
		int ok2 = 1;
		int ng2 = N-i;
		while(ng2-ok2>1){
			int mid = (ok2+ng2)/2;
			long long a = A[mid+i]-A[i];
			long long b = A[N]-A[i]-a;
			if(a>b)ng2=mid;
			else ok2=mid;
		}
		for(int j=0;j<4;j++){
			int a = ok;
			int b = ok2;
			if(j%2==1)a++;
			if(j/2==1)b++;
			long long maxi = 0;
			long long mini = Inf;
			vector<long long> X = {A[a],A[i]-A[a],A[b+i]-A[i],A[N]-A[b+i]};
			for(int k=0;k<4;k++){
				maxi = max(maxi,X[k]);
				mini = min(mini,X[k]);
			}
			ans = min(ans,maxi-mini);
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <list>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;
 
int main(void) {
  int n;
  list<int> ls;
  list<int>::iterator it;
  scanf("%d", &n);
  rep(i, n) {
    char s[20];
    scanf("%s", s);
    if(strlen(s) == 6) {
      int x;
      scanf("%d", &x);
      if(s[0] == 'i') {
        ls.push_front(x);
      } else {
        for(it = ls.begin(); it != ls.end(); ++it) {
          if(*it == x) {
            ls.erase(it);
            break;
          }
        }
      }
    } else {
       if(s[6] == 'F') ls.pop_front();
       else ls.pop_back();
    }
  }
  list<int>::iterator itt = ls.end();
  itt--;
  for(it = ls.begin(); it != itt; ++it) {
    printf("%d ", *it);
  }
  printf("%d\n", *it);
  return 0;
}


Measured memory_bytes: 33996
N = int(input())
inX = input().split()
X = []
a = 0
for x in inX:
	X.append(int(x))
	a += int(x)
P = round(a / N)

# 算出
sum = 0
for x in X:
	sum += (x - P) * (x - P)

print(sum)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;
using ll = long long;

ll a(ll x) {

    ll count = 0;

    while(x > 0) {
        count++;
        x /= 10;
    }

    return count;
}

int main() {

    ll n;

    cin >> n;

    ll ans = LLONG_MAX;

    for(ll i = 1; i * i <= n; ++i) {

        if(n % i)
            continue;

        ans = min(ans, max(a(i), a(n / i)));

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// #define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int mod = (int)1e9 + 7;
const int inf = mod;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }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...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = (int)1e4 + 10;
// make sure N size is correctttt!!!!!!!!!


int n, a[N], m;
vector<int> f;
int dp[15][N];

int solve(int idx, int coins, int type){
   if(coins < 0)
      return -inf;

   if(idx == m){
      return dp[idx][coins] = ((coins == 0) ? 0 : -inf);
   }

   int &ans = dp[idx][coins];
   if(~ans)
      return ans;

   if(type == 1){
      //bhai tu calculate hoke aya haiiiki
      assert(0);
   }

   ans = -inf;
   if(f[a[idx]] <= coins){
      smax(ans, 1 + solve(idx, coins-f[a[idx]], type));
   }

   smax(ans, solve(idx+1, coins, type));
   return ans;
}

void trace(int idx, int coins){
   if(idx == m){
      // assert(coins == 0);
      exit(0);
   }

   if(f[a[idx]] <= coins){
      if(solve(idx, coins, 1) == 1 + solve(idx, coins - f[a[idx]], 1)){
         cout << a[idx];
         return trace(idx, coins-f[a[idx]]);
      }
   }

   return trace(idx+1, coins);
}


int32_t main(){_

   cin>>n>>m;
   f = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

   memset(dp, -1, sizeof dp);
   for (int i = 0; i < m; ++i)
      cin>>a[i];

   sort(a, a+m);
   reverse(a, a+m);
   int faltu = solve(0, n, 0);
   trace(0, n);

   //make sure N size is correct!!!!!!!!!
   return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String s, out = "";
		Scanner input = new Scanner(System.in);
		s = input.next();
		for (int j = 0; j <= s.length() - 1; j++) {
			if (Character.valueOf(s.charAt(j)).toString().equals("0")) {
				out += "0";
			} else if (Character.valueOf(s.charAt(j)).toString().equals("1")) {
				out += "1";
			} else if (Character.valueOf(s.charAt(j)).toString().equals("B")) {
				if (!out.equals("")) {
					out = out.substring(0, out.length() - 1);
				}
			}
		}
		System.out.println(out);

	}

}

Measured memory_bytes: 26972
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 1;

int main() {
  string str; cin >> str;
  bool flag = true;
  if (str[0] != 'A') flag = false;
  int cnt = 0, c_idx = 0;
  for (int i = 2; i < str.length()-1; i++) {
    if (str[i] == 'C') {
      c_idx = i;
      cnt++;
    }
  }
  if (cnt != 1) flag = false;
  for (int i = 1; i < str.length(); i++) {
    if (i!=c_idx && str[i]<='Z') flag = false;
  }
  cout << (flag?"AC":"WA") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 
#define nint int
using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> pii;
typedef pair<double,double> dop;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;



signed main()
{
int n;
std::cin >> n;
std::vector<int> a(n);
rep(i,n){
    int temp;
    std::cin >> temp;
    a[i] = temp;
}
int out = gcd(a[0],a[1]);
for(int i = 2; i < n; i++){
    out = gcd(out,a[i]);
}
std::cout << out << std::endl;
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
bool checkValidity(ll a, ll b, ll c) 
{ 
    if (a + b <= c || a + c <= b || b + c <= a) {
        return false; 
    }
    return true; 
} 

int main()
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    ll a[n];
    map<ll, ll> m1;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        m1[a[i]]++;
    }

    if(m1.size()<3){
        cout<<0;
        return 0;
    }

    ll ans=0;
    for (auto i = m1.begin(); i != m1.end(); ++i)
    {
        auto it=i;
        it++;
        for (auto j = it; j != m1.end(); ++j)
        {
            auto it1=j;
            it1++;
            for (auto k = it1; k != m1.end(); ++k)
            {
                if(checkValidity(i->F, j->F, k->F)){
                    ans = ans + (i->S*j->S*k->S);
                }
            }
        }
    }

    cout<<ans;

    return 0;
}

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

count = [0] * 10001

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            temp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if(1 <= temp and temp <= 10000):
                count[temp] += 1

for i in range(1,n+1):
    print(count[i])

Measured memory_bytes: 69460