akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int x[200],y[200],z[200],m,n;
  int sm;
  char s[3];
  map<pair<pair<int,int>,int>,int> a;
  while(cin>>n>>m&&n+m){
    sm=n*n*n-n*m;
    for(i=0;i<m;i++){
      cin>>s;
      if(0){
      }else if(strcmp(s,"xy")==0){
	cin>>x[i]>>y[i];
	z[i]=0;
      }else if(strcmp(s,"xz")==0){
	cin>>x[i]>>z[i];
	y[i]=0;
      }else if(strcmp(s,"yz")==0){
	cin>>y[i]>>z[i];
	x[i]=0;
      }
      a.clear();
      for(j=0;j<i;j++){
	if(0){
	}else if(!x[i]&&!y[j]){
	  if(z[i]==z[j])
	    a[make_pair(make_pair(x[j],y[i]),z[i])]=1;
	}else if(!x[i]&&!z[j]){
	  if(y[i]==y[j])
	    a[make_pair(make_pair(x[j],y[i]),z[i])]=1;
	}else if(!y[i]&&!z[j]){
	  if(x[i]==x[j])
	    a[make_pair(make_pair(x[i],y[j]),z[i])]=1;
	}else if(!x[j]&&!y[i]){
	  if(z[i]==z[j])
	    a[make_pair(make_pair(x[i],y[j]),z[i])]=1;
	}else if(!x[j]&&!z[i]){
	  if(y[i]==y[j])
	    a[make_pair(make_pair(x[i],y[i]),z[j])]=1;
	}else if(!y[j]&&!z[i]){
	  if(x[i]==x[j])
	    a[make_pair(make_pair(x[i],y[i]),z[j])]=1;
	}
      }
      sm+=a.size();
    }
    cout<<sm<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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 all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
	set<ld>st;
	rep(i,200)st.insert(i-10);
	ld x;cin>>x;
	int n;cin>>n;
	rep(i,n){
		ld a;cin>>a;st.erase(a);
	}
	ld num=0;
	for(auto&& q:st){
		if(abs(q-x)<abs(num-x))num=q;
	}
	cout<<(ll)num<<endl;
  	return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(15);
  solve();
}


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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX


struct misegment_tree {
    int seguki[530000],p=262143;
    void update(int x, int diff) {
        x += p;
        seguki[x] = diff;
        while(x) {
            int tmp = min(seguki[x], seguki[(x+1)/2*2-(x+1)%2]);
            x = (x-1) / 2;
            seguki[x] = tmp;
        }
    }
    int find(int l, int r) {
        int diff = r-l+1,now=l+p,size=1;
        while(true) {
            if (now%2 && size*2 <= diff) {
                now = (now-1) / 2;
                size *= 2;
            } else {
                int ans = seguki[now];
                l += size;
                if (l==r+1) return ans;
                else return min(ans,find(l,r));
            }
        }
    }
};

struct masegment_tree {
    int seguki[530000],p=262143;
    void update(int x, int diff) {
        x += p;
        seguki[x] = diff;
        while(x) {
            int tmp = max(seguki[x], seguki[(x+1)/2*2-(x+1)%2]);
            x = (x-1) / 2;
            seguki[x] = tmp;
        }
    }
    int find(int l, int r) {
        int diff = r-l+1,now=l+p,size=1;
        while(true) {
            if (now%2 && size*2 <= diff) {
                now = (now-1) / 2;
                size *= 2;
            } else {
                int ans = seguki[now];
                l += size;
                if (l==r+1) return ans;
                else return max(ans,find(l,r));
            }
        }
    }
};


int n,k,p[200001],memo[200000],ans;
bool f=false;
masegment_tree st;
misegment_tree mst;

signed main() {
    cin >> n >> k;
    rep(i,n) {
        cin >> p[i];
        st.update(i,p[i]);
        mst.update(i,p[i]);
    }
    memo[0] = 1;
    rep11(i,n) {
        if (p[i-1] < p[i]) memo[i] = memo[i-1]+1;
        else memo[i] = 1;
    }
    repo(i,k-1,n) {
        if (i == k-1) {
            if (memo[i] > k) continue;
            if (memo[i] == k) {
                f=true;
                continue;
            }
            ans++;
            continue;
        }
        if (memo[i] > k || (st.find(i-k+1,i-1) < p[i] && p[i-k] < mst.find(i-k+1,i-1))) continue;
        if (memo[i] == k) {
            f = true;
            continue;
        }
        ans++;
    }
    cout << ans+f << endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)    //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
typedef long long LL;
typedef unsigned int UINT;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector< Vi > VVi;
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(UINT *a){scanf("%u",a);}                            //scan for type unsigned int
void SCAN(UINT *a,int n){int i;REP(i,n){scanf("%u",&a[i]);}}  //scan for type unsigned int array
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){int i;REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int MOD = 1000000007;
const int INF = 1999999999;
const LL INFLL = 999999999999999;
 
const int DX4[4]= {-1,0,1,0};
const int DY4[4]= {0,-1,0,1};
 
//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
	fill((T*)array,(T*)(array+N),val);
}
 
long double pascalTri(int n,int r){
	long double tri[n+1][n+1];
	int i,j;
	REP(i,n+1){REP(j,n+1){tri[i][j]=0;}}
	REP(i,n+1){
		REP(j,n+1){
			if(j>i){break;}
			if(j==0||j==i){tri[i][j]=1;}else{tri[i][j]=(tri[i-1][j-1]+tri[i-1][j]);}
		}
	}
	return tri[n][r];
}
 
 
int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	int n,a,b,c,ans;
	int i,j,k;
 
	cin>>n;

	a=0;
	b=n%10;
	REP(i,4){
		if(n%10==b){
			a++;
			if(a>=3){
				break;
			}
		}else{
			a=1;
			b=n%10;
		}
		n/=10;
	}

	if(a>=3){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}	
	

	return 0;
}


Measured memory_bytes: 256
# define F first
# define S second
# define L long long
# define P push_back
# define Z(x) (x).size()
# define I 1000000007
# include <bits/stdc++.h>
using namespace std;
void solve();
int T=1;int main(){if(!T)cin>>T;while(T--)solve();}
// ---
L an;
string s,t;
void solve(){
	cin>>s>>t;
	for(int i=0;i<3;i++)
	if(s[i]==t[i])an++;
	cout<<an;
}

Measured memory_bytes: 256
eval'*A=#'+`tr ' ' ,`;f=->a{l=[[0,i=-1]];a.map{|x|l.pop while(t=l[-1])[0]>x;l<<[x,i+=1];i-t[1]}}
r=0;A.zip(f[A],f[A.reverse].reverse){|a,b,c|r+=a*b*c};p r

Measured memory_bytes: 48616
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, M;
	long long COUNT = 0;
	cin >> N >> M;
	vector<long long> A(M);
	for (int i = 0; i < M; i++) cin >> A[i], COUNT += A[i];
	if (COUNT <= N) cout << N - COUNT << endl;
	else cout << -1 << endl;
}


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

using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	if(n==1){
		cout<<m;
		return 0;
	}
	n--;
	int x=m-n;
	int y=m+n;
	for(int i=x;i<=y;i++){
		printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>

struct low_link {
    int n;
    std::vector<std::vector<int>> adj;
    std::vector<int> ord, low;
    std::vector<int> articulations;
    std::vector<std::pair<int, int>> bridges;
    low_link(const std::vector<std::vector<int>> &adj) : n(adj.size()), adj(adj), ord(n), low(n) {
        std::vector<bool> visited(n);
        int k = 0;
        auto dfs = [&](auto &&self, int cur, int par) -> void {
            visited[cur] = true;
            ord[cur] = k++;
            low[cur] = ord[cur];
            int cnt = 0;
            bool is_articulation = false;
            for (int to : adj[cur]) {
                if (!visited[to]) {
                    cnt++;
                    self(self, to, cur);
                    low[cur] = std::min(low[cur], low[to]);
                    is_articulation |= ord[cur] <= low[to];
                    if (ord[cur] < low[to]) { bridges.emplace_back(std::minmax(cur, to)); }
                } else if (to != par) { low[cur] = std::min(low[cur], ord[to]); }
            }
            if (par == -1) { is_articulation = cnt >= 2; }
            if (is_articulation) { articulations.emplace_back(cur); }
        };
        dfs(dfs, 0, -1);
    }
};

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

int main() {
    int V, E;
    cin >> V >> E;
    vector<vector<int>> adj(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        adj[s].emplace_back(t);
        adj[t].emplace_back(s);
    }
    low_link ll(adj);
    sort(ll.articulations.begin(), ll.articulations.end());
    for (auto p:ll.articulations) { cout << p << endl; }
}


Measured memory_bytes: 5088
#include <stdio.h>

int height(int n);

int main(){
	int a,b;

	scanf("%d %d", &a, &b);

	int n = b - a;

	printf("%d", (height(n) - b));
}

int height(int n){
	if(n == 1)       return 1;
	return (n + height(n - 1));
}

Measured memory_bytes: 128
#line 1 "template.cpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB") {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


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

int main(){

    int x,n;
    cin >> x >>  n;

    vector<vector<int>> v(x);

    for (int i = 0; i < n; i++)
    {
        int a; scanf("%d",&a);
        if(a==0){
            int b,c;
            scanf("%d%d",&b,&c);
            v[b].push_back(c);
        }
        else if(a==1){
            int b;           
            scanf("%d",&b);
            for (size_t j = 0; j < v[b].size(); j++)
            {
                printf("%d",v[b][j]);
                if(j != v[b].size()-1)
                   printf(" ");
            }  
            printf("\n");
     
        }
        else{
             int b;   scanf("%d",&b);
             v[b].clear();
        }

    }


}


Measured memory_bytes: 5900
#include <stdio.h>
#include <math.h>

int main(){
	int A,B,C,D,E,P,X,Y,Z;
	scanf("%d %d %d %d %d",&A,&B,&C,&D,&P);
	X = A*P;
	Y = B;
	if(C < P){
		E = P - C;
		Y = B + E * D;
	}
	Z = fmin(X,Y);
	printf("%d\n",Z);
	return 0;
}

Measured memory_bytes: 2672
#include<stdio.h>
int main(){
  int n,i,j,min,max,d[100][100];
  while(scanf("%d",&n),n){
    int c[10001]={0};
    for(i=0;i<n;i++){
      min=210000000;
      for(j=0;j<n;j++){
	scanf("%d",&d[i][j]);
	if(min>d[i][j])min=d[i][j];
      }
      c[min]=1;//printf("%d ",min);
    }//printf("\n");
    for(i=0;i<n;i++){
      for(j=max=0;j<n;j++){
	if(max<d[j][i])max=d[j][i];
      }//printf("%d ",max);
      if(c[max])break;
    }//printf("\n");
    if(n-i)printf("%d\n",max);
    else   printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 660
fn main() {
    proconio::input! {
        x: i64,
        y: i64,
    }
    if x.abs() == y.abs() {
        println!("1");
        return;
    }
    let ans = if x < 0 && y == 0 {
        y - x
    } else if x > 0 && y == 0 {
        x + 1
    } else if x == 0 && y < 0 {
        -y + 1
    } else if x == 0 && y > 0 {
        y
    } else {
        match (x < y, x.abs() < y.abs(), x < 0, y < 0) {
            (true, true, true, true) => unreachable!(),
            (true, true, true, false) => 1 + y + x, // -10 20
            (true, true, false, true) => unreachable!(),
            (true, true, false, false) => y - x,      // 10 20
            (true, false, true, true) => y - x,       // -20 -10
            (true, false, true, false) => -x - y + 1, // -20 10
            (true, false, false, true) => unreachable!(),
            (true, false, false, false) => unreachable!(),
            (false, true, true, true) => 1 + x - y + 1, // -10 -20
            (false, true, true, false) => unreachable!(),
            (false, true, false, true) => -y - x + 1, // 10 -20
            (false, true, false, false) => unreachable!(),
            (false, false, true, true) => unreachable!(),
            (false, false, true, false) => unreachable!(),
            (false, false, false, true) => 1 + x + y, // 20 -10
            (false, false, false, false) => 1 + x - y + 1, // 20 10
        }
    };
    println!("{}", ans);
}


Measured memory_bytes: 2088
H = ''
W = ''
i = j = 0

while True:
  line = input()
  line = line.split()
  H = int(line[0])
  W = int(line[1])

  if H == 0 and W == 0:
    break

  while i < H:
    print('#'*W)
    i += 1
  i = 0
  print()

Measured memory_bytes: 7548
import scala.math._

object Main extends App {
  val sc = new java.util.Scanner(System.in)
//  val list = List.fill(3)(sc.nextInt)
  val x, a, b = sc.nextInt

  val ans = if (abs(x - a) < abs(x - b)) "A" else "B"

  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25416
#include <stdio.h>

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

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

int main(){
    int n,i;
    while (1) {
        scanf("%d",&n);
        if (n==0) return 0;
        int b=0,s=1000,sum=0,x;
        for (i=0; i<n; i++) {
            scanf("%d",&x);
            b=max(x,b);
            s=min(x,s);
            sum+=x;
        }
        printf("%d\n",(sum-b-s)/(n-2));
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__);
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Couty(cond) Cout((cond) ? "Yes" : "No")
#define CoutY(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(string, s);
    Cout(s[0], s.size()-2, s.back());
}


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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;


int main()
{
    int M, T, P, R;
    while (cin >> M >> T >> P >> R, M) {
        vector<vector<int>> result(T, vector<int>(3+P,0));
        loop(T,i) result[i][0] = i+1;
        loop(R,i) {
             int m, t, p, j;
             cin >> m >> t >> p >> j;
             if (j) {
                 if (result[t-1][p+2] != -1) result[t-1][p+2]++;
             } else {
                 if (result[t-1][p+2] != -1) {
                     result[t-1][1]++;
                     result[t-1][2] += result[t-1][p+2]*20 + m;
                     result[t-1][p+2] = -1;
                 }
             }
        }
        //cout << "====debug====" << endl;
        //for(auto r:result){
        //    cout << r[0] << ' ' << r[1] << ' ' << r[2] << endl;
        //}
        
        sort(all(result),
                [](vector<int> a, vector<int> b) {
                    if(a[1] != b[1]) return a[1] > b[1];
                    if(a[2] != b[2]) return a[2] < b[2];
                    return a[0] > b[0];
                });
            
        loop(T,i) {
            cout << result[i][0];
            if (i==T-1) {
                cout << endl;
            } else if (result[i][1] == result[i+1][1]
                    && result[i][2] == result[i+1][2])
                cout << '=';
            else cout << ',';
        }
    }
}

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

using namespace std;

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

    while(1){
        int x,y,s;
        cin>>x>>y>>s;

        if(x==0)break;

        int ans=0;

        for(int i=1;i<s;i++){
                for(int j=1;j<s;j++){
                int cost1=i*(100+x)/100+j*(100+x)/100;
                if(cost1==s){
                    int cost2=i*(100+y)/100+j*(100+y)/100;
                    ans=max(ans,cost2);
                }
            }
        }

        cout<<ans<<endl;

    }

}


Measured memory_bytes: 3144
while 1:
    H, W = map(int, input().split())
    if H == 0:
        break
    P = {}
    for i in range(H):
        r = input()
        for j, c in enumerate(r):
            P[c] = (i, j)
    S = input()
    ans = len(S)
    px = 0; py = 0
    for c in S:
        x, y = P[c]
        ans += abs(x - px) + abs(y - py)
        px = x; py = y
    print(ans)



Measured memory_bytes: 5616
package main

import "fmt"

func main() {
        var s string
        fmt.Scan(&s)

        var prev rune
        for _, r := range s {
                if prev == 0 {
                        prev = r
                        continue
                }
                if prev == r {
                        fmt.Println("Bad")
                        return
                }
                prev = r
        }
        fmt.Println("Good")
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const int N=100010;
int n,m,fg,d[N],t[3],S,w;long long ans;vector<pair<int,int> > e[N];
void dfs(int x){
	t[d[x]]++;S++;
	ref(i,0,((int)e[x].size())-1){
		int y=e[x][i].first;w++;
		int D=(3+d[x]+e[x][i].second)%3;
		if(d[y]==-1)d[y]=D,dfs(y);else if(d[y]!=D)fg=1;
	}
}
int main(){
	cin>>n>>m;
	ref(i,1,m){int x,y;cin>>x>>y;
		e[x].push_back(make_pair(y,1));
		e[y].push_back(make_pair(x,-1));
	}
	ref(i,1,n)d[i]=-1;
	ref(i,1,n)if(d[i]<0){
		fg=d[i]=S=w=t[0]=t[1]=t[2]=0,dfs(i);
		if(fg)ans+=1LL*S*S;else
		if(!t[0]||!t[1]||!t[2])ans+=w/2;else
		ans+=1LL*t[0]*t[1]+1LL*t[1]*t[2]+1LL*t[2]*t[0];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 10752
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int K, S;cin >> K >> S;
  int result = 0;
  rep(i, K+1) rep(j, K+1) if (S-i-j>=0 && S-i-j<=K) result++; 
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <tuple>
#include <set>
#include <algorithm>
#include <string>
#include <limits>
#include <cmath>

using namespace std;

int main()
{
  // skip the first line
  //cin.ignore(numeric_limits<streamsize>::max(), '\n');

  int n, x;
  while (cin >> n >> x, n != 0 or x != 0) {
    int count {0};
    set<tuple<int, int, int>> values;
    for (int i = 1; i<n-1; ++i)
      for (int j=i+1; j<n; ++j)
        for (int k=j+1; k<n+1; ++k)
          values.insert(make_tuple(i, j, k));
    for (auto &t : values)
      if (get<0>(t) + get<1>(t) + get<2>(t) == x) ++count;  

    cout << count << endl;
  }

}


Measured memory_bytes: 13196
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)


int fac[N],inv[N];

int me(int x, int n) 
{
  int res = 1;
  while(n) {
      if(n & 1) 
         res = (1LL * res * x) % mod;
      x = (1LL * x * x) % mod;
      n >>= 1;
  }
  return res;
}

int mi(int x, int m)
{
    return me(x, m-2);
}

void fact() 
{
  fac[0] = 1;

  rep(i, 1, N) 
     fac[i] = (1LL * fac[i - 1] * i) % mod;
   

  inv[N-1] = mi(fac[N-1], mod);

  for(int i = N - 1; i > 0; i--) 
    inv[i - 1] = (1LL * inv[i] * i) % mod;
   
}

int nCr(int n, int k) 
{
  if(k > n)
      return 0;

  int ans = (1LL * fac[n] * inv[k]) % mod;
  ans = (1LL * ans * inv[n - k]) % mod;

  return ans;
}



int main()
{
    
    fact();
   
    int n,a,b;
    scf(n),scf(a),scf(b);

    ll ans=me(2,n)-1;

    ll x=1,y=1;

    rep(i,n-a+1,n+1)
    x=x*i, x%=mod;

    rep(i,n-b+1,n+1)
    y=y*i,y%=mod;

    x*=inv[a];
    x%=mod;

    y*=inv[b];
    y%=mod;

    x+=y;

    x%=mod;

    ans=(ans-x+mod)%mod;
    ans+=mod;

    lprin((ans+mod)%mod);
}

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

using i64 = long long;

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

const int MAXN = 101000;

int n, a, b;
int arr[MAXN];

bool check(int x) {
    int s = 0;
    int y = x * b;
    for(int i = 0; i < n; ++i) {
        if(arr[i] <= y) continue;
        s += (arr[i] - y + a - 1) / a;
        if(s > x) return false;
    }
    return true;
}

int main() {
    std::scanf("%d%d%d", &n, &a, &b);
    a -= b;
    for(int i = 0; i < n; ++i)
        std::scanf("%d", &arr[i]);
    int l = 0, r = (*std::max_element(arr, arr + n) + b - 1) / b + 1;
    while(l < r) {
        int mid = (l + r) / 2;
        if(!check(mid)) l = mid + 1;
        else r = mid;
    }
    std::printf("%d\n", l);
}

Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val t = arrayOf(a, b, a - 1, b - 1).sortedArrayDescending()
    println(t[0] + t[1])
}

Measured memory_bytes: 35912
s = input()

if(s[0] == "A" and s.count("A") == 1):
    if(s[2:len(s)-1].count("C") == 1 and s.count("C") == 1):
        s = s.replace("C", "")
        s = s.replace("A", "")
        if(s.islower()):
            print("AC")
        else:
            print("WA")
    else: 
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3060
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        s: chars,
        t: chars,
    }
    let mut s_cnt = vec![0; 26];
    let mut t_cnt = vec![0; 26];

    for i in 0..s.len() {
        s_cnt[(s[i] as u8 - b'a') as usize] += 1;
        t_cnt[(t[i] as u8 - b'a') as usize] += 1;
    }
    s_cnt.sort();
    t_cnt.sort();

    for i in 0..26 {
        if s_cnt[i] != t_cnt[i] {
            return println!("No");
        }
    }
    println!("Yes");
}


Measured memory_bytes: 6396
using System;
class Program
{
    static void Main(string[] args)
    {
        //入力の受け取り
        string[] input = Console.ReadLine().Split(' ');
        string[] input2 = Console.ReadLine().Split(' ');
        int row = int.Parse(input[0]);
        int column = int.Parse(input[1]);
        int rowBlack = int.Parse(input2[0]);
        int columnBlack = int.Parse(input2[1]);

        int totalCell = row * column;
        int totalBlack = rowBlack * column + (row - rowBlack) * columnBlack;

        //提出
        Console.WriteLine(totalCell - totalBlack);

    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    while(pow((int)sqrt(n),2) != n)n--;
    cout << n<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long long A;
long long B;
long long K;
  cin >> A >> B >> K;
if (A >=K) {
  A =A-K;
  cout <<A  <<" " << B << endl;
}
  else if ((A <K) && (B >(K-A))) {
    B =B-(K-A);
   
    cout << 0  <<" "<< B << endl;
  }
      else if ((A <K) && (B <=(K-A))) {
        A=0;
        B=0;
        
  
  cout << 0 << " "<< 0 << endl;
  
  
      }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  string S;
  cin >> S;
  rep(i,S.size()) cout << 'x';
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0, q = 0;
    ll k = 0;
    cin >> n >> k >> q;
    vector<ll> cnt(n+2);
    int buf = 0;
    for (int i=0; i<q; i++) {
        cin >> buf;
        cnt.at(1)++;
        cnt.at(buf)--;
        cnt.at(buf+1)++;
        cnt.at(n+1)--;
    }
    for (int i=2; i<n+1; i++) {
        cnt.at(i) += cnt.at(i-1);
    }
    for (int i=1; i<n+1; i++) {
        if (cnt.at(i) < k) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main(){
  int n,x,t;
  cin>>n>>x>>t;
  
  cout<<(n+x-1)/x*t<<endl;
  return 0;
}


Measured memory_bytes: 3636
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

ans = INF
for i in range(-100, 101):
    val = 0
    for a in A:
        val += (a - i) ** 2
    ans = min(ans, val)
print(ans)

Measured memory_bytes: 9416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 100001
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e16;
//__gcd(a,b), __builtin_popcount(a);

vector<int> G[MAX], cost[MAX];
ll d[MAX];
int main(){
	int n, m, c, t1, t2, t3;
	ll total = 0;
	scanf("%d%d%d", &n, &m, &c);
	fill(d, d+MAX, inf);
	rep(i,m){
		scanf("%d%d%d", &t1, &t2, &t3);
		G[t1].push_back(t2);
		G[t2].push_back(t1);
		cost[t1].push_back(t3);
		cost[t2].push_back(t3);
		total += t3;
	}
	
	d[1] = 0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, 1));
	while(!q.empty()){
		P p = q.top();q.pop();
		if(d[p.se] < p.fi)continue;
		for(int i = 0;i < G[p.se].size();i++){
			int from = p.se, to = G[p.se][i];
			if(d[to] > d[from]+cost[from][i]){
				d[to] = d[from]+cost[from][i];
				q.push(P(d[to], to));
			}
		}
	}
	
	ll ans = total, dis, tmp;
	for(int i = 2;i <= n;i++){
		q.push(P(d[i], i));
	}
	
	while(!q.empty()){
		P p = q.top();q.pop();
		dis = 0;
		for(int i = 0;i < G[p.se].size();i++){
			tmp = G[p.se][i];
			if(d[tmp] < d[p.se])dis += cost[p.se][i];
			if(d[tmp] == d[p.se] && tmp < p.se)dis += cost[p.se][i];
		}
		total -= dis;
		ans = min(ans, total+(ll)p.fi*c);
	}
	
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 17684
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

int main()
{
  double D, T, S,how_long;
  cin >> D >> T >> S;
  how_long = D / S;
  if(how_long<=T)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;

}


Measured memory_bytes: 3720
from collections import OrderedDict
rate = (
  ('gray', 400),
  ('brown', 800),
  ('green', 1200),
  ('water', 1600),
  ('blue', 2000),
  ('yellow', 2400),
  ('orange', 2800),
  ('red', 3200),
  ('rainbow', 4801),
)

n = int(input())
a = []
for i in map(int, input().split()):
  for color, border in rate:
    if i < border:
      a.append(color)
      break

rainbow = 0
colors = list(set(a))
if 'rainbow' in colors:
  rainbow = a.count('rainbow')
  colors.remove('rainbow')
  if len(colors) == 0:
    colors.append('rainbow')
    print(len(colors), rainbow)
    exit(0)

print(len(colors), len(colors)+rainbow)

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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll big = 10e12 + 11 ;

int  main (  ) {

    FASTIO ;

    ll  n , m ;
    cin >> n >> m ;

    ll  ans ;

    ans = ( n * ( n - 1 )/ 2 ) ;

    ans += m * ( m - 1 ) / 2 ;

    cout <<  ans ;

    return  0 ;
}



Measured memory_bytes: 256
N = 10**6
mod = 10**9 + 7
fact = [1]
for i in range(1, N+1):
    fact.append(fact[-1]*i%mod)

n, m = map(int, input().split())

if n - m > 1 or m - n > 1:
    ans = 0
elif n - m == 0:
    ans = 2 * fact[n] * fact[m] % mod
else:
    ans = fact[n] * fact[m] % mod
    
print(ans)

Measured memory_bytes: 42644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

vector<int> divisor(int a){
    int i = 1;
    vector<int> D;
    while(i * i <= a){
        if(a % i == 0){
            D.push_back(i);
            D.push_back(a / i);
        }
        i++;
    }
    sort(D.rbegin(), D.rend());
    return D;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);

    int ans1, ans2;

    vector<int> F = divisor(A.at(0));

    for(int i : F){
        int count = 0;
        rep(j, N){
            if(A.at(j) % i != 0) count++;
        }
        if(count <= 1){
            ans1 = i;
            break;
        }
    }

    vector<int> S = divisor(A.at(1));
    for(int i : S){
        int count = 0;
        for(int j = 1; j < N; j++){
            if(A.at(j) % i != 0) count++;
        }
        if(count == 0){
            ans2 = i;
            break;
        }
    }

    cout << max(ans1, ans2) << endl;
}

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

const ll maxs = 2e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

void solve(){
    
    string s;
    cin >> s;

    if(s[1] == 'R')
        s[1] = 'B';
    else s[1] = 'R';

    cout << s;

}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		// 出力
if(a-b<0){
		System.out.println(0);
 
}
else{
		System.out.println(a-b);
}
	}
}


Measured memory_bytes: 22868
import kotlin.math.sqrt

fun main() {
    val n = nextLong()
    val s = nextLong()
    fun f(b: Long, n: Long): Long {
        if (n < b) return n
        return f(b, n / b) + n.rem(b)
    }
    if (n == s) {
        println(n + 1)
        return
    }
    (2L..sqrt(n.toDouble()).toLong()).forEach {
        if (f(it, n) == s) {
            println(it)
            return
        }
    }
    (sqrt(n.toDouble()).toLong() downTo 1L).forEach {
        val b = n.minus(s).div(it) + 1
        if (b < 2) return@forEach
        if (f(b, n) == s) {
            println(b)
            return
        }
    }
            println (-1)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 35028
#include<bits/stdc++.h>
using namespace std;
const int MAXN=10005;
int res[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    for(int x=1;x*x<=n;x++)
        for(int y=1;y*y<=n;y++)
            for(int z=1;z*z<=n;z++)
            {
                int t=x*x+y*y+z*z+x*y+y*z+z*x;
                if(t<MAXN)res[t]++;
            }
    for(int i=1;i<=n;i++)
        printf("%d\n",res[i]);
    return 0;
}


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

if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(n-90)
elif n < 10000:
    print(909)
elif n < 100000:
    print(n-9090)
elif n < 1000000:
    print(90909)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;

int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if (a == 0) {
    cout << 1;
  } else if (b == 0) {
    cout << 2;
  } else if (c == 0) {
    cout << 3;
  } else if (d == 0) {
    cout << 4;
  } else {
    cout << 5;
  }
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(){
  int r,D,x,i,ans,dp[11]={};
  scanf("%d%d%d",&r,&D,&x);
  dp[0]=x;
  for(i=1;i<11;i++){
    dp[i]=r*dp[i-1]-D;
    ans=dp[i];
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 101;
const double pi = acos(-1.0);
int n, m, ord[maxn], stk[maxn];
struct Point {
	int x, y;
	void read() {
		scanf("%d%d", &x, &y);
	}
	bool operator < (Point const &t) const {
		return x < t.x || (x == t.x && y < t.y);
	}
	Point operator - (Point const &t) const {
		return (Point){x - t.x, y - t.y};
	}
	LL det(Point const &t) const {
		return (LL)x * t.y - (LL)y * t.x;
	}
	LL dot(Point const &t) const {
		return (LL)x * t.x + (LL)y * t.y;
	}
	double len() const {
		return sqrt(dot(*this));
	}
} p[maxn];
double ans[maxn];
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		p[i].read();
		ord[i] = i;
	}
	sort(ord, ord + n, [&](int const &u, int const &v) {
		return p[u] < p[v];
	});
	for(int i = 0; i < n; ++i) {
		int o = ord[i];
		for( ; m > 1 && (p[stk[m - 1]] - p[stk[m - 2]]).det(p[o] - p[stk[m - 2]]) <= 0; --m);
		stk[m++] = o;
	}
	for(int i = n - 2, tp = m; i >= 0; --i) {
		int o = ord[i];
		for( ; m > tp && (p[stk[m - 1]] - p[stk[m - 2]]).det(p[o] - p[stk[m - 2]]) <= 0; --m);
		stk[m++] = o;
	}
	--m;
	if(m == 2) {
		ans[stk[0]] = ans[stk[1]] = 0.5;
	} else {
		for(int i = 0; i < m; ++i) {
			int lft = stk[(m + i - 1) % m], mid = stk[i], rht = stk[(i + 1) % m];
			Point pre = p[mid] - p[lft], suf = p[rht] - p[mid];
			ans[mid] = acos(pre.dot(suf) / pre.len() / suf.len()) / pi / 2;
		}
	}
	for(int i = 0; i < n; ++i)
		printf("%.20f\n", ans[i]);
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/24  Problem: ABC 119 D / Link: http://abc119.contest.atcoder.jp/tasks/abc119_d  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


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

	LL A, B, Q; cin >> A >> B >> Q;
	VL s(A), t(B);
	FOR(i, 0, A) {
		cin >> s[i];
	}
	FOR(i, 0, B) {
		cin >> t[i];
	}
	SORT(s);
	SORT(t);
	
	auto f = [](LL x, const VL&s, const VL& t) {
		LL sub = LINF;
		auto it = lower_bound(ALL(s), x) - s.begin();
		auto g = [&]() {
			LL ans = LINF;
			LL ret = abs(s[it] - x);
			auto it2 = lower_bound(ALL(t), s[it]) - t.begin();
			if (it2 != SZ(t))
				ans = min(ans, ret + abs(s[it] - t[it2]));
			if (it2 != 0) {
				it2--;
				ans = min(ans, ret + abs(s[it] - t[it2]));
			}
			return ans;
		};

		if (it != SZ(s)) {
			sub = min(sub, g());
		}
		if (it != 0) {
			it--;
			sub = min(sub, g());
		}
		return sub;
	};
	FOR(_, 0, Q) {
		LL x; cin >> x;

		LL ans = LINF;
		ans = min(f(x, s, t), f(x, t, s));
		cout << ans << "\n";
	}


	return 0;
}


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

using namespace std;

int main() {
  int n; cin >> n;
  vector <int> a(n);
  for(auto &x : a) cin >> x;
  int cur = a[0];
  int len = 0;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(a[i] > cur) {
      ans = max(ans, len);
      len = 1;
      cur = a[i];
    } else cur = a[i], len++;
  }
  ans = max(ans, len);
  cout << ans - 1 << '\n';
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#define STACK_MAX  101               /* スタックサイズ */
#define STACK_OK   0x8000           /* スタック成功を表すデータ */
#define STACK_FULL STACK_OK + 1     /* スタックサイズを超えたときのデータ */
#define STACK_END  STACK_OK + 2     /* スタックの終わりを表すデータ */
/* 関数のプロトタイプ宣言 */
int     push(int);          /* スタックにデータを積む関数 */
int     pop(void);          /* スタックからデータを取り出す関数 */
/* グローバル変数 */
int     stack[STACK_MAX];   /* スタック領域 [0] - [19] */
int     stack_pointer = 0;  /* スタックポインタ */

int main(void)
{  int x=0,y=0,n,flag=0,bai,total;
  int i=0,j;
  char data;
  while((scanf("%c",&data)!=EOF)){
      
	  if(data=='+'){
				push(pop()+pop());
	  }
	  else if(data=='-'){
			
				y = pop();
				x = pop();
				push(x-y);
	  }
	  else if(data=='*'){
				x = pop();
				y = pop();
				push(x*y);
	  }
	  else if(data==' '){
	    bai=1;
	    total=0;
	    if(flag>=2){
	      for(j=1;j<=flag;j++){
		
		total+=pop()*bai;
		  bai*=10;
	      }
	      push(total);
	    }
	    flag=0;
	  }
	  else if(data=='\n'){
	    break;
	  }
	  else {
	    n=data-'0';
	    push(n);
	    flag++;
	  }
	}
  printf("%d\n",pop());
    
	return 0;
}
int push(int d)
{
  //printf("check %d\n",d);
  if(stack_pointer >= STACK_MAX)  /* スタックポインタが最大 */
        return(STACK_FULL);         /* STACK_FULLを返す */
    stack[stack_pointer] = d;       /* スタックにデータ格納 */
    ++stack_pointer;                /* スタックポインタに1加算 */
    return(STACK_OK);               /* STACK_OKを返す */
}
int pop(void)
{
    if(stack_pointer == 0)          /* スタックポインタが0 */
        return(STACK_END);          /* STACK_ENDを返す */
    --stack_pointer;                /* スタックポインタから1減算 */
    return(stack[stack_pointer]);   /* スタックのデータを返す */
}




Measured memory_bytes: 2088
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A, B, C, X;
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		X = sc.nextInt();
		int ans = 0;
		for (int i=0; i<=A; i++) {
			for (int j=0; j<=B; j++) {
				for (int k=0; k<=C; k++) {
					if (500*i + 100*j + 50*k == X) ans++;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23892