akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,m;
	cin>>n;
	m=n/10;
	n=n-m*10;
	if(n==9 || m==9){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> p(N);
  for(int i = 0;i<N;i++){
    cin >> p[i];
  }
  long long cm = 0;
  long long ca = 0;
  long long cr = 0;
  long long cc = 0;
  long long ch = 0;
  vector<pair<char,long long>> l;
  
  for(int i = 0;i<N;i++){
    if(p[i][0] == 'M') cm++;
  }
  if(cm >0) l.push_back(make_pair('M',cm));
  
   for(int i = 0;i<N;i++){
    if(p[i][0] == 'R') cr++;
  }
  if(cr >0) l.push_back(make_pair('R',cr));
  
  for(int i = 0;i<N;i++){
    if(p[i][0] == 'A') ca++;
  }
  if(ca >0) l.push_back(make_pair('A',ca));
  
   for(int i = 0;i<N;i++){
    if(p[i][0] == 'C') cc++;
  }
  if(cc >0) l.push_back(make_pair('C',cc));
  
   for(int i = 0;i<N;i++){
    if(p[i][0] == 'H') ch++;
  }
  if(ch >0) l.push_back(make_pair('H',ch));
  
  long long c = 0;
 if(l.size() >= 3){
  for(int i  =0;i<l.size();i++){
    for(int j = i+1;j<l.size();j++){
      for(int k = j+1;k<l.size();k++){
        c += l[i].second * l[j].second * l[k].second;
      }
    }
  }
  cout << c << endl;
 }
   else cout << 0 << endl;
}

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

struct edge{
    int to,cap,rev;
};
const int INF = (1<<29);

vector<edge> g[110];
bool used[110];

int dfs(int v,int t,int f){
    if(v == t) return f;
    used[v] = true;
    for(int i=0;i<g[v].size();i++){
        edge &e = g[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to,t,min(f,e.cap));
            if(d > 0){
                e.cap -= d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s,int t){
    int flow = 0;
    while(1){
        memset(used,0,sizeof(used));
        int f = dfs(s,t,INF);
        if(f == 0) return flow;
        flow += f;
    }
}

int main()
{
    int v,e,s,t,c;
    cin >> v >> e;
    for(int i=0;i<e;i++){
        cin >> s >> t >> c;
        g[s].push_back( (edge){t,c,g[t].size()} );
        g[t].push_back( (edge){s,0,g[s].size()-1} );
    }
    
    cout << max_flow(0,v-1) << endl;
    
    return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

struct q
{

    int a, b, c, d;
    q(int _a, int _b, int _c, int _d)
    {
        a = _a;
        b = _b;
        c = _c;
        d = _d;
    }
};

int N, M, Q;
vector<q> r;

int dfs(vector<int> vec)
{
    int size = vec.size();
    int res = 0;

    if (size == N)
    {

        for (q elem : r)
        {
            if (vec[elem.b - 1] - vec[elem.a - 1] == elem.c)
            {
                res += elem.d;
            }
        }

        return res;
    }

    else
    {
        int last;
        if (size == 0)
        {
            last = 1;
        }
        else
        {
            last = vec[size - 1];
        }

        for (int i = last; i <= M; i++)
        {
            vector<int> vec2 = vec;
            vec2.push_back(i);
            int res2 = dfs(vec2);
            if (res2 > res)
            {
                res = res2;
            }
        }

        return res;
    }
}

int main()
{

    cin >> N >> M >> Q;

    rep(i, Q)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        r.push_back(q(a, b, c, d));
    }

    vector<int> vec;
    cout << dfs(vec) << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

void rec(int i, int j) 
{
  if (j == 10) return;

  printf("%dx%d=%d\n", i, j, i * j);
  rec(i, j + 1);
}

int main(void)
{
  int n;

  for (n = 1; n < 10; n++) {
    rec(n, 1);
  }

  return (0);
}

Measured memory_bytes: 2588
def calRate(n,num)
    (1/n.to_f) * (0.5)**num
end
rate = 0
N,K = gets.split.map(&:to_i)
[*1..N].each do |n|
    point = n
    num = 0
    loop do
        break if K <= point
        num += 1
        point *= 2
    end
    rate += calRate(N,num)
end
puts rate

Measured memory_bytes: 3452
N, M, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

ans = 0
minutes = 0
last = nil
N.times do |i|
  break if minutes + A[i] > K

  minutes += A[i]
  ans += 1
  last = i
end

b_idx = 0
tmp_ans = ans
while b_idx < M
  break if minutes + B[b_idx] > K

  minutes += B[b_idx]
  tmp_ans += 1
  b_idx += 1
end
ans = [tmp_ans, ans].max

last&.downto(0) do |a_idx|
  minutes -= A[a_idx]
  tmp_ans -= 1
  while b_idx < M
    break if minutes + B[b_idx] > K

    minutes += B[b_idx]
    tmp_ans += 1
    b_idx += 1
  end
  ans = [tmp_ans, ans].max
end

puts(ans)


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

bool isPrime(ll X){
    for(ll i=2;i*i<=X;i++){
        if(X%i==0)return false;
    }
    return true;
}

int main()
{
    ll X;
    cin >> X;
    ll res=0;
    while(true){
        bool prime = isPrime(X);
        if(prime){
            cout<<X;return 0;
        }
        ++X;
    }
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int n; cin >> n;
  cout << (n-2)*180 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

int main(){
   
    int N,P; cin >> N>> P;
    int a = 0, b = 0;
    rep(i,N){
        int c; cin >> c;
        if(c%2 == 0) a++;
        else b++;
    }
    ll sum=1;
    if(b == 0){
        if(P == 1) cout << 0 << endl;
        else{
            rep(i,N){
                sum*=2;
            }
            cout << sum << endl;
        }
    }
    else{
        rep(i,N-1) {
            sum*=2;
    }
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 2019;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll L, R;

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

  cin >> L >> R;

  int ln = L/MOD;
  int rn = R/MOD;
  if (ln != rn) {
    cout << 0 << endl;
    return 0;
  }

  int lr = L%MOD;
  int rr = R%MOD;
  ll ans = MOD-1;
  for (ll i = lr; i <= rr; ++i) {
    for (ll j = i+1; j <= rr; ++j) {
      ans = min(ans, mod(i*j, MOD));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='7'){
            cout<<"Yes"<<endl;
             return 0;
        }
    }
    cout << "No"<<endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,X=0;
    cin >> N >> X;
    vector<int> bound(N);
    for (int i = 0; i < N; ++i) {
       cin >> bound.at(i);
    }
    int d = 0;
    for (int i = 0; i < N; ++i) {
       d += bound.at(i);
    }
    int count = 0;
    count = d - X;
    int d2 = 0;
    int count2 = 1;
    for (int i = 0; i < N; ++i) {
       d2 += bound.at(i);
       if(d2 <= X){
          count2++;
       }else{
           break;
       }
    }
    cout << count2;
    return 0;
}

Measured memory_bytes: 256
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    For(i,n) for(int i=0;i<n;i++)
#define    rFor(i,n) for(int i=n-1;i>=0;i--)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    all(v) v.begin(),v.end()
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    test   int t;cin>>t;for(int l=0;l<t;l++)
#define    min3(a,b,c)     min(a,min(b,c))
#define    max3(a,b,c)     max(a,max(b,c))
#define    min4(a,b,c,d)   min(min(a,b),min(c,d))
#define    max4(a,b,c,d)   max(max(a,b),max(c,d))
#define    Max(a)  *max_element(a,a+sizeof(a)/sizeof(a[0]))
#define    Min(a)  *min_element(a,a+sizeof(a)/sizeof(a[0]))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long 
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    //test
    {
        string s;
        cin>>s;
        int x=s.size();
        if(s[x-1]=='s')cout<<s+"es";
        else cout<<s+'s';
    }
    
End;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
 
int C[102][102];
 
void meiro(int W,int H,int c){
  if(C[W][H]!=c){
    return;
  }
 
  C[W][H] = -1;
 
  meiro(W+1,H  ,c);
  meiro(W-1  ,H,c);
  meiro(W,H+1 ,c);
  meiro(W  ,H-1,c);
}
 
int main(){
  while(1){
    int w,h;
    cin >> w >> h;
    if(w==0 && h==0){
      break;
    }
 
    for(int i=0;i<102;i++){
      for(int j=0;j<102;j++){
        C[i][j] = 10;
      }
    }
 
    int xs,ys,xg,yg;
    cin >> xs >> ys >> xg >> yg;
 
    int n;
    cin >> n;
 
    int c,d,x,y;
    for(int i=0;i<n;i++){
      cin >> c >> d >> x >> y;
 
      if(d==0){
        for(int j=x;j<x+4;j++){
          for(int k=y;k<y+2;k++){
            C[j][k]=c;
          }
        }
      }else{
        for(int j=x;j<x+2;j++){
          for(int k=y;k<y+4;k++){
            C[j][k]=c;
          }
        }
      }
    }
 
    meiro(xs,ys,C[xs][ys]);
 
    if(C[xg][yg] == -1){
      cout << "OK" << endl;
    }else{
      cout << "NG" << endl;
    }
  }
 
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <functional>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-10;

bool dfs(int* a, vector<int> &b, vector<int> &c, int n) {
    if(n == 10) return true;

    bool ok = false;
    if(b.empty() || b.back() < a[n]) {
        b.push_back(a[n]);
        ok |= dfs(a, b, c, n+1);
        b.pop_back();
    }
    if(c.empty() || c.back() < a[n]) {
        c.push_back(a[n]);
        ok |= dfs(a, b, c, n+1);
        c.pop_back();
    }
    return ok;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    int a[10];
    REP(i,N) {
        REP(j,10) cin >> a[j];
        vector<int> b, c;
        if(dfs(a, b, c, 0)) cout << "YES";
        else cout << "NO";
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 3112
import math
n = int(input())
sn = int(math.sqrt(n)) + 1

seki = []
for i in range(1, sn):
    if n%i == 0:
        seki.append([i, n//i])
totalseki = [sum(li) for li in seki]
min_ = min(totalseki)

print(min_ - 2)

Measured memory_bytes: 3600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            int[] a = in.nextIntArray(n);
            Arrays.sort(a);

            int min = Integer.MAX_VALUE;
            for (int i = 0; i + k - 1 < n; i++) {
                min = Math.min(min, a[i + k - 1] - a[i]);
            }

            out.println(min);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 36076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int x=scan.nextInt();
		int y=scan.nextInt();
		int z=scan.nextInt();
		if(x<y && y<z)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 17204
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int a, b, k;
    cin >> a >> b >> k;

    int diff = (b - a + 1) / 2;
    if (diff < k) {
        for (int i = a; i <= b; i++) cout << i << endl;
    } else {
        for (int i = a; i < a + k; i++) cout << i << endl;
        for (int i = b - k + 1; i <= b; i++) cout << i << endl;
    }
}


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

using namespace std;
const int N=2e5+10;

const int MAX=1e9+10;
vector <int> g[N];
int vis[N];
int ans;
typedef long long ll;
map<ll,ll>mp;
map<ll,ll>a;
ll cal(int a){
    ll sum=1;
    for(int i=1;i<=5;i++) sum*=a;
    return sum;
}
int main()
{
   ll x;
    cin>>x;

    for(int i=-1000;i<=1000;i++){
        for(int j=-1000;j<=1000;j++){
            if(cal(i)-cal(j)==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }

        }
    }
}


Measured memory_bytes: 8348
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

/*
  Node treeMinimum(Node x){
  }
*/

Node treeSearch(Node u, int k){
  while (u != NIL) {
    if (u->key == k) break;

    if (u->key > k) {
      u = u->left;
    } else {
      u = u->right;
    }
  }
  return u;
}

/*
  Node treeSuccessor(Node x){
  }

  void treeDelete(Node z){
    Node y; // node to be deleted
    Node x; // child of y
  }
*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if (y == NIL) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}

void inorder(Node u){
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node u){
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(void) {
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s", com);
    if (com[0] == 'f') {
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if (t != NIL) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    } else if (com[0] == 'i') {
      scanf("%d", &x);
      insert(x);
    } else if (com[0] == 'p') {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if (com[0] == 'd') {
      /*
        scanf("%d", &x);
        treeDelete(treeSearch(root, x));
      */
    }
  }

  return 0;
}

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

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w) << endl;
  return 0;
}

Measured memory_bytes: 256
// Custom define
#ifdef __McDic__ // Local testing
#define debugprintf(f_, ...) printf(f_, ##__VA_ARGS__), fflush(stdout)
#else // Submission version
#define debugprintf(f_, ...) -1
#endif
#define raise(f_, ...) {debugprintf(f_, ##__VA_ARGS__); exit(1000);}
#define raiseif(condition, f_, ...) if(condition) raise(f_, ##__VA_ARGS__)

// Standard libraries
#include <stdio.h>
#include <iostream>
#include <vector>

// Random stuff
#include <random>
#include <chrono>

int min2(int a, int b){
    return a>b ? b:a;
}

// Main
int main(int argc, char **argv){
#ifdef __McDic__ // Local testing
    freopen("IO/input.txt", "r", stdin);
    printf("------------------------------------------------\n");
    printf(" McDic's C++17 file execution for CP\n");
    printf("------------------------------------------------\n");
    freopen("IO/output.txt", "w", stdout);
    std::clock_t c_start = std::clock();
#endif

    int a, b, m; scanf("%d %d %d", &a, &b, &m);
    std::vector<int> avec(a), bvec(b);
    for(int i=0; i<a; i++) scanf("%d", &avec[i]);
    for(int i=0; i<b; i++) scanf("%d", &bvec[i]);
    std::vector<int> xvec(m), yvec(m), discounts(m);
    for(int i=0; i<m; i++){
        scanf("%d %d %d", &xvec[i], &yvec[i], &discounts[i]);
        xvec[i]--;
        yvec[i]--;
    }

    // Case 1. Minimum buy
    int answer = 1<<29;
    int mina = 1<<29, minb = 1<<29;
    for(int i=0; i<a; i++) mina = min2(mina, avec[i]);
    for(int i=0; i<b; i++) minb = min2(minb, bvec[i]);
    answer = min2(answer, mina+minb);

    // Case 2. Discounts
    for(int i=0; i<m; i++){
        answer = min2(answer, avec[xvec[i]] + bvec[yvec[i]] - discounts[i]);
    }
    printf("%d\n", answer);

#ifdef __McDic__ // Local testing
    std::clock_t c_end = std::clock();
    debugprintf("Total %.4lf ms used.\n", 1e3 * (c_end - c_start) / CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 2176
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split()))
    ans = 1
    if 0 in A:
        print(0)
        sys.exit()
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

if __name__=='__main__':
    main()

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

int main()
{
	int m1, d1, m2, d2;
	scanf("%d%d%d%d", &m1, &d1, &m2, &d2);
	if(m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11)
	{
		if(d1 == 30)
			printf("1\n");
		else
			printf("0\n");
	}
	else if(m1 == 1 || m1 == 3 || m1 == 5 || m1 == 7 || m1 == 8 || m1 == 10 || m1 == 12)
	{
		if(d1 == 31)
			printf("1\n");
		else 
			printf("0\n");
	}
	else
	{
		if(d1 == 28)
			printf("1\n");
		else 
			printf("0\n");
	}
	return 0;
}

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

inline char get(void) {
  static char buf[100000], *S = buf, *T = buf;
  if (S == T) {
    T = (S = buf) + fread(buf, 1, 100000, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
inline void read(int &x) {
  static char c; x = 0; int sgn = 0;
  for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
  for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
  if (sgn) x = -x;
}

const int N = 110;
const int INF = 1 << 30;
typedef long long ll;

int n, m, ans, mx, mn, md, p1, p2, p3, p4;
struct cpp {
  int w, v;
  inline friend bool operator <(const cpp &a, const cpp &b) {
    return a.w == b.w ? a.v > b.v : a.w < b.w;
  }
};
cpp a[N];

inline int Min(int a, int b) {
  return a < b ? a : b;
}
inline int Max(int a, int b) {
  return a > b ? a : b;
}

int main(void) {
  read(n); read(m); mn = INF;
  for (int i = 1; i <= n; i++) {
    read(a[i].w); read(a[i].v);
  }
  sort(a + 1, a + n + 1);
  p1 = 1;
  while (a[p1 + 1].w == a[p1].w && p1 < n) p1++;
  p2 = p1 + 1; while (p2 > n) p2--;
  while (a[p2 + 1].w == a[p2].w && p2 < n) p2++;
  p3 = p2 + 1; while (p3 > n) p3--;
  while (a[p3 + 1].w == a[p3].w && p3 < n) p3++;
  p4 = p3 + 1; while (p4 > n) p4--;
  while (a[p4 + 1].w == a[p4].w && p4 < n) p4++;
  for (ll i = 0, v1 = 0, w1 = 0; i <= p1; i++, v1 += a[i].v, w1 += a[i].w)
    for (ll j = p1, v2 = 0, w2 = 0; j <= p2; j++, v2 += a[j].v, w2 += a[j].w)
      for (ll k = p2, v3 = 0, w3 = 0; k <= p3; k++, v3 += a[k].v, w3 += a[k].w)
        for (ll x = p3, v4 = 0, w4 = 0; x <= p4; x++, v4 += a[x].v, w4 += a[x].w)
          if (w1 + w2 + w3 + w4 <= m) ans = Max(ans, v1 + v2 + v3 + v4);
          
  cout << ans << endl;
  return 0;
}


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

int n, p[MAXN];

int main () {
    ios::sync_with_stdio (0);

    cin >> n;

    for (int i = 1; i <= n; ++i)
        cin >> p[i];

    int sol = 0;
    for (int i = 1; i < n; ++i) {
        if (i == p[i] && i + 1 == p[i + 1]) {
            swap (p[i], p[i + 1]);
            ++sol;
            ++i;
        }
    }

    for (int i = 1; i <= n; ++i)
        sol += (i == p[i]);

    cout << sol << "\n";

    return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (int)(n); ++i)
#define fj(st,n) for (int j = (st); j <= (int)(n); ++j)
#define fk(st,n) for (int k = (st); k <= (int)(n); ++k)
#define fq(st,n) for (int q = (st); q <= (int)(n); ++q)
#define fw(st,n) for (int w = (st); w <= (int)(n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (int)(n); ++(i))
#define ei(st,n) for (int i = (st); i >= (int)(n); --i)
#define ej(st,n) for (int j = (st); j >= (int)(n); --j)
#define ek(st,n) for (int k = (st); k >= (int)(n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (int)(n); --(i))
#define ri(st,n) for (int i = (st); i < (int)(n); ++i)
#define rj(st,n) for (int j = (st); j < (int)(n); ++j)
#define rk(st,n) for (int k = (st); k < (int)(n); ++k)
#define rq(st,n) for (int q = (st); q < (int)(n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (int)(n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));


ll n, p, a[111];
ll d[111][2];

int main()
{
//    fin("t.in");
    sync;
    cin >> n >> p;
    d[0][1] = 0;
    d[0][0] = 1;
    fi(1, n)
    {
    	cin >> a[i];
    }
    fi(0, n - 1)
    {
    	d[i + 1][0] = d[i][0] + d[i][a[i + 1] % 2];
    	d[i + 1][1] = d[i][1] + d[i][(a[i + 1] + 1) % 2];
    }
    cout << d[n][p] << endl;
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = 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; }

int main() {
  string S;
  cin >> S;
  vector<char> alp(26);
  alp = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  int num[100010] = {0};
  int N = S.size();
  rep(i, N) {
    rep(j, 26) {
      if (S[i] == alp[j]) {
        num[j]++;
      }
    }
  }
  string ans = "None";
  rep(i, 26) {
    if (num[i] == 0) {
      ans = alp[i];
      break;
    }
  }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b;

int main() {
    cin >> a >> b;
    int c = a * b;
    if (c & 1)
        cout << "Odd" << endl;
    else
        cout << "Even" << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

int GCD(int x, int y)
{
    return y ? GCD(y, x % y) : x;
}

int GCD(int x, int y, int z)
{
    return GCD(GCD(x, y), z);
}

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

    int Ans = 0;

    for(int x = 1; x <= n; x++)
        for(int y = 1; y <= n; y++)
            for(int z = 1; z <= n; z++)
                Ans += GCD(x, y, z);

    cout << Ans << endl;
}


Measured memory_bytes: 3640
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut split = buf.trim().split_whitespace();
    let a = &split.next().unwrap().parse::<u8>().unwrap();
    let b = &split.next().unwrap().parse::<u8>().unwrap();
    let c = &split.next().unwrap().parse::<u8>().unwrap();
    let d = &split.next().unwrap().parse::<u8>().unwrap();
    let ab = *a + *b; 
    let cd = *c + *d; 

    if ab == cd {
        println!("Balanced");
    } else if ab > cd {
        println!("Left");
    } else if ab < cd {
        println!("Right");
    }   
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int n,m,v,p,x,y,z;
 cin>>n>>m>>v>>p;
 long long int a[n];
 long long int s[n];
 int i;
 for(i=0;i<n;i++)
 {
 	cin>>a[i];
 }
 sort(a,a+n,greater<long long int> ());
 int ans=p;
 s[p-1]=0;
 for(i=p;i<n;i++)
 {
 	s[i]=s[i-1]+a[p-1]-a[i];
 	//cout<<s[i]<<endl;
 }
 for(i=p;i<n;i++)
 {
 	x=m*v-m*(p+n-i-1);
 	if(x>0)
 	{
 	 	x=x-s[i-1];
 	 	if(x>0)
 	 	{
 	 	 if(x%(i-p+1)==0)
		   {
		   	y=a[p-1]+x/(i-p+1);
		   	if(y>(a[i]+m))
		   	break;
		   	else
		   	ans++;
		   }
		  else
		  {
		  	y=a[p-1]+x/(i-p+1)+1;
		   	if(y>(a[i]+m))
		   	break;
		   	else
		   	ans++;
		  }	
		}
		else
		{
			if(a[i]+m>=a[p-1])
			ans++;
			else
			break;
		}
	}
	else
	{
		if((a[i]+m)>=a[p-1])
		ans++;
		else
		break;
	}
 }
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 1792
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b[li],a[li],k,flag,t,at=1,kat=9;;
lo cev;
string s;
vector<int> v;

int main(void){
	scanf("%lld",&n);
	while(kat<=n){
		cev+=kat-at+1;
		at*=10;
		kat+=9*at;
		at*=10;
		kat+=9*at;
		//~ cout<<kat<<endl;
	}
	//~ at*=100;
	if(at<=n)cev+=n-at+1;
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 2e18
#define pi acos(-1)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
bool prime[100005];
const int mx=100009;
void seive()
{
    for(ll i=2;i*i<=mx;i++){
        if(prime[i]==false){
            for(ll j=i*i;j<mx;j+=i){
                prime[j]=true;
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    seive();
    ll n;cin>>n;
    for(ll i=2;i<mx;i++){
        if(prime[i]==false){
            if(i>=n){
                cout<<i<<endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 384
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 8000000000000000000
int main() {
	int a, b;
	cin >> a >> b;
	REP(i, a) {
		REP(q, b) {
			string s;
			cin >> s;
			if (s == "snuke") {
				cout <<char('A' + q)<< i + 1 << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int x;
    cin>>x;
    cout<<(x^1)<<endl;
    return 0;
}


Measured memory_bytes: 3628
import sys

R, C, K = map(int, sys.stdin.readline().split())

grid = [[0 for _ in range(C+1)] for _ in range(R+1)]
for _ in range(K):
    r, c, v = map(int, sys.stdin.readline().split())
    grid[r][c] = v

# r行目、c列目にいるときに、その行でアイテムをi個取得している場合の最大価値
dp0 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp1 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp2 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp3 = [[0 for _ in range(C+1)] for _ in range(R+1)]
# print(dp)
for r in range(1, R+1):
    for c in range(1, C+1):
        # 取らない
        dp0[r][c] = max((dp0[r][c-1], dp0[r-1][c], dp1[r-1][c], dp2[r-1][c], dp3[r-1][c]))
        dp1[r][c] = max(dp1[r][c-1], dp1[r][c])
        dp2[r][c] = max(dp2[r][c-1], dp2[r][c])
        dp3[r][c] = max(dp3[r][c-1], dp3[r][c])

        # 取る
        dp1[r][c] = max(dp0[r-1][c] + grid[r][c], dp1[r][c])
        dp1[r][c] = max(dp1[r-1][c] + grid[r][c], dp1[r][c])
        dp1[r][c] = max(dp2[r-1][c] + grid[r][c], dp1[r][c])
        dp1[r][c] = max(dp3[r-1][c] + grid[r][c], dp1[r][c])

        dp1[r][c] = max(dp0[r][c-1] + grid[r][c], dp1[r][c])
        dp2[r][c] = max(dp1[r][c-1] + grid[r][c], dp2[r][c])
        dp3[r][c] = max(dp2[r][c-1] + grid[r][c], dp3[r][c])


# print(dp0)
# print(dp1)
# print(dp2)
# print(dp3)
print(max((dp0[R][C], dp1[R][C], dp2[R][C], dp3[R][C])))

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

#define MOD (int)(1e9+7)

int main()
{
	int n, m; cin >> n >> m;
	vector<int>x(n), y(m);
	vector<long long>xsums(n-1), ysums(m-1);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		if (i)xsums[i-1] = x[i] - x[i - 1];
	}
	for (int i = 0; i < m; i++) {
		cin >> y[i];
		if (i)ysums[i-1] = y[i] - y[i - 1];
	}

	long long area;
	long long xsum = 0, ysum = 0;
	for (int i = 0; i < n-1; i++) {
		xsum += xsums[i] * (i + 1) * (n - 1 - i);
	}
	for (int i = 0; i < m - 1; i++) {
		ysum += ysums[i] * (i + 1) * (m - 1 - i);
	}

	area = (xsum%MOD)*(ysum%MOD);

	cout << area%MOD << endl;

    return 0;
}



Measured memory_bytes: 2560
S = input().strip()
f = True
if S.count("N")*S.count("S") == 0 and S.count("N")+S.count("S") != 0:
    f = False
if S.count("E")*S.count("W") == 0 and S.count("E")+S.count("W") != 0:
    f = False
print("Yes" if f else "No")


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

int main() {
  int N,Y,i,j;
  cin >> N >> Y;
  
  for(i=N; i>=0; i--)
    for(j=N-i; j>=0; j--)
      if(Y-10000*i-5000*j-1000*(N-i-j) == 0) {
        cout << i << " " << j << " " << N-i-j << endl;
        return 0;
      }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int is_smaller(char);
char to_bigger(char);

int main(){
        char c;

        while(scanf("%c", &c) != EOF) {
                printf("%c", to_bigger(c));
        }

        return 0;
}

int is_smaller(char c){
        return 'a' <= c && c <= 'z';
}

char to_bigger(char c){
        if(is_smaller(c)) {
                return c - 32;
        } else{
                return c;
        }
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	string s;
	ll k;
	cin >> s >> k;

	for (int i = 0; i < k; i++) {
		if (s[i] - '0' >= 2) {
			cout << s[i] << endl;
			return 0;
		}
	}

	cout << 1 << endl;

	return 0;
}


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

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
char arr[1001][1001];
int dp[1001][1001];
int n, m;
int dfs(int x, int y)
{
    if (x > n || y > m || arr[x][y] == '#')
        return 0;
    if (x == n && y == m)
        return 1;
    if (dp[x][y] != -1)
        return dp[x][y];
    int sum = 0;
    sum += dfs(x + 1, y) % mod;
    sum += dfs(x, y + 1) % mod;
    return dp[x][y] = sum % mod;
}
void mysol()
{
    cin >> n >> m;

    memset(arr, '#', sizeof(arr));
    memset(dp, -1, sizeof(dp));

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> arr[i][j];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++)
            clog << arr[i][j];
        clog << endl;
    }
    cout << dfs(1, 1);

    return;
}

int32_t main()
{
    //fast();
    // w(t)
    {
        mysol();
    }
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int a[26];
	for (int i = 0; i < 26; i++) {
		a[i] = 0;
	}
	for (int i = 0; i < s.size(); i++) {
		a[s[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (a[i] > 1) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
array_1 = list(map(int, input().split()))
array_2 = list(map(int, input().split()))
# 全探索する
# N回移動できる
# どのタイミングで下に移動するかがキーポイント
# 下に移動するタイミングはN通りある
max_candy = 0
for n in range(N):
    # n列目で下に移動したときのキャンディの個数をチェック
    total = sum(array_1[: n + 1] + array_2[n:])
    # 記録更新なら上書き
    if max_candy < total:
        max_candy = total
print(max_candy)


Measured memory_bytes: 2940
#include<stdio.h>
#include<algorithm>
#include<vector>

int main()
{
	int n;
	scanf("%d", &n);
	n--;
	n /= 111;
	if (n < 9)
		printf("%d\n", (n + 1) * 111);
	else
		printf("1111\n");

	return 0;
}

Measured memory_bytes: 128
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        a-=k;
        k=0;
    }
    else{
        k-=a;
        a=0;
    }
    if(b>=k){
        b-=k;
        k=0;
    }
    else{
        k-=b;
        b=0;
    }
    cout<<a<<" "<<b;
	exit(0);
}


Measured memory_bytes: 256
from collections import defaultdict

s = int(input())

A = defaultdict(int)

n = 1
while True:
  if A[s]:
    print(n)
    exit()
  A[s] = n
  if s % 2:
    s = 3 * s + 1
  else:
    s //= 2
  n += 1
  

Measured memory_bytes: 3316
def main():
    N = int(input())
    l = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                a = l[i]
                b = l[j]
                c = l[k]
                if a == b or b == c or c == a:
                    continue
                if a + b > c and b + c > a and c + a > b:
                    ans += 1
    print(ans)
main()


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, Z, W;
  cin >> N >> Z >> W;
  vector<int> a(N);
  rep(i, N)
  {
    cin >> a[i];
  }

  int ans;
  if (N == 1)
    ans = abs(a[0] - W);
  else
    ans = max(abs(a[N - 1] - W), abs(a[N - 2] - a[N - 1]));
  cout << ans << endl;
  return 0;
}

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

int main(){

  int a,b,c,d;

  cin>>a>>b>>c>>d;

  int p,q,r;

  p=fabs(a-b);
  q=fabs(b-c);
  r=fabs(a-c);

  if(r<=d){
      cout<<"Yes"<<endl;
    }
    else{

      if(p<=d && q<=d){
        cout<<"Yes"<<endl;
      }
      else{
        cout<<"No"<<endl;
      }
    }

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int x, y, h, w, n, sum, z;
int a[7] = { 60,80,100,120,140,160,1000000000 };
int b[7] = { 2,5,10,15,20,25,1000000000 };
int c[7] = { 600,800,1000,1200,1400,1600,0 };
int main() {
	while (true) {
		cin >> n;
		if (n == 0) { break; }
		sum = 0;
		for (int i = 0; i < n; i++){
			cin >> x >> y >> h >> w;
			z = x + y + h;
			for (int j = 0; j < 7; j++) {
				if (z <= a[j] && w <= b[j]) { sum += c[j]; break; }
			}
		}
		cout << sum << endl;
	}
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;

	ll res = 0;
	ll a = 0, b = 0;
	bool acyc = false;

	while (n--) {
		string s; cin >> s;
		if (s.back() == 'A') a++;
		if (s.front() == 'B') b++;
		if ((s.back() == 'A') != (s.front() == 'B')) acyc = true;
		FOR(i,0,sz(s)-1) if (s[i] == 'A' && s[i+1] == 'B') res++;
	}
	
	if (min(a,b) > 0) res += min(a,b) - 1 + acyc;
	cout << res << endl;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		List<Integer> p = new ArrayList<>();
		List<Integer> q = new ArrayList<>();
		List<Integer> r = new ArrayList<>();
		int[] s = new int[x + y + c];

		for (int i = 0; i < a; i++) {
			p.add(sc.nextInt());
		}
		for (int i = 0; i < b; i++) {
			q.add(sc.nextInt());
		}
		for (int i = 0; i < c; i++) {
			r.add(sc.nextInt());
		}

		p.sort(Collections.reverseOrder());
		p = p.subList(0, Math.min(x,a) );
		q.sort(Collections.reverseOrder());
		q = q.subList(0, Math.min(y,b) );

		r.addAll(p);
		r.addAll(q);
		r.sort(Collections.reverseOrder());

		long sum = 0;
		for (int i = 0; i < x+y; i++) {
			sum += r.get(i);
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 99944