akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    vector<bool> f(10);
    rep(i,0,4){
        i64 N;
        cin >> N;

        if(N<10) f[N]=true;
    }

    if(f[1] and f[9] and f[7] and f[4]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  cin>>n;
  int cnt[100010]={};
  for(int i=0;i<n;i++){
    int a;cin>>a;
    cnt[a]++;cnt[a+1]++;cnt[a+2]++;
  }
  sort(cnt,cnt+100010,greater<int>());
  cout<<cnt[0]<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
#define MOD LL(1e9 + 7)
#define INF 1000000
using namespace std;
using LL = long long;

LL a[101][101], b[101][101], c[101][101];

int main() {
	int n, m, l;
	cin >> n >> m >> l;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			cin >> b[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			cout << c[i][j];
			if (j != l - 1) cout << " ";
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3320
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
//#define P pair<int, int>

using namespace std;
using ll = __int64_t;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve(){
  ll a, b, c, x, y;
  ll res = 0;
  cin >> a >> b >> c >> x >> y;

  if(a+b > c*2){
    res += (c*2) * min(x, y);
    if(x != y){
      if(x > y){
        if(a > c*2){
          res += (c*2) * (x-y);
        }else{
          res += a * (x-y);
        }
      }else{
        if(b > c*2){
          res += (c*2) * (y-x);
        }else{
          res += b * (y-x);
        }
      }
    }
  }else{
    res += (a*x)+(b*y);
  }

  cout << res << endl;
}

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


Measured memory_bytes: 256
/*input
10 10
2 5 6 5 2 1 7 9 7 2
5 5
2 4
6 7
2 2
7 8
7 9
1 8
6 9
8 10
6 8
*/
#include<bits/stdc++.h>
#define REP(i,n) for (int i = 1; i <= n; i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define INF 1000000000
#define endl '\n'

const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
 
using namespace std;
struct query{
    int l;
    int r;
    int i;
};
query Q[500005];
int ar[500005] , ans[500005];
int fre[500006];
int cnt = 0;
 int  BLOCK =555;
bool comp(query a , query b)
{
    if(a.l / BLOCK != b.l/BLOCK)
    return a.l/BLOCK < b.l/BLOCK;
 
    return a.r < b.r;
}
 
void add(int pos)
{
    fre[ar[pos]]++;
    if(fre[ar[pos]] == 1)
    cnt++;
}
 
void remove(int pos)
{
    fre[ar[pos]]--;
    if(fre[ar[pos]] == 0)
    cnt--;
}
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 

    int n , q;
    cin>>n>>q;
   BLOCK=sqrt(n);
    for(int i=0;i<n;i++)
    {cin>>ar[i];
   
    }
   int  i=1;

 
    
    for(int i=0;i<q;i++){
        cin>>Q[i].l>>Q[i].r;
        Q[i].i = i , Q[i].l-- , Q[i].r--;
    }
 
    sort(Q , Q+q , comp);
 
    //why ML = 0 , and MR = -1?
    int ML = 0 , MR = -1;
    for(int i=0;i<q;i++)
    {
        int L = Q[i].l;
        int R = Q[i].r;
 
        while(ML > L)
        ML-- , add(ML);
 
        while(MR < R)
        MR++ , add(MR);
 
        while(ML < L)
        remove(ML) , ML++;
 
        while(MR > R)
        remove(MR) , MR--;
 
        ans[Q[i].i] = cnt;
    }
 
    for(int i=0;i<q;i++)
    cout<<ans[i]<<'\n';
}

Measured memory_bytes: 15436
def main():
    s = input()
    MOD = 2019
    r = [0]*MOD
    r[0] = 1
    z = 0
    t = 1
    for i in reversed(s):
        z = int(i) * t + z
        z %= MOD
        t *= 10
        t %= MOD
        r[z] += 1
    print(sum(i*(i-1)//2 for i in r))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9260
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
// #include <boost/intrusive/rbtree.hpp>
// #include <boost/geometry.hpp>
// #include <boost/geometry/geometries/linestring.hpp>
// #include <boost/geometry/geometries/polygon.hpp>
// #include <boost/geometry/geometries/point_xy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"");if(i>INF/2)cout<<"INF";else cout<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define LINF 9223372036854775807
#define MOD 1000000007
#define endl "\n"
struct any{
    string s;
    any(string s):s(s){}
    operator lint()const{return stoll(s);}
    operator double()const{return stod(s);}
    operator string()const{return s;}
};
any in(void){
    return any(*istream_iterator<string>(cin));
}
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
inline lint mex(vector<lint> s){
    lint res=0;
    sort(all(s));
    while(binary_search(all(s),res))res++;
    return res;
}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

int main(){
    cout<<(lint)pow<lint>((lint)in(),3);
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;

	//a500 b100 c50

	int ans = 0;
	int i = 0, j = 0;

	while (i <= x / 500 && i<=a) {
		j = 0;
		while (j <= (x - 500 * i) / 100 && j<=b) {
			int nokori = x - 500 * i - 100 * j;
			if (nokori % 50 == 0 && nokori/ 50<=c) {
				ans++;
				//cout << i << " " << j << " " << nokori / 50 << endl;
			}
			j++;
		}
		++i;
	}

	ANS(ans)

	return 0;
}



Measured memory_bytes: 256
#[allow(unused_macros)]
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 ( 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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: u64, b: u64
    }
    println!("{}", if a+b>=10 {"error".to_owned()} else {format!("{}", a+b)});
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

template <typename T>
inline bool chmin(T& a, T b){
    if(b < a){ a = b; return true;}
    return false;
}

template <typename T>
inline bool chmax(T& a, T b){
    if(a < b){ a = b; return true;}
    return false;
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





int main(void){
    lli n, a, b; scanf("%lld%lld%lld", &n, &a, &b);
    if((b - a) % 2 == 0){
        printf("%lld\n", (b - a) / 2);
    }
    else{
        lli res = 0;
        lli p = a + (b - a - 1) / 2;
        lli q = (n - b + 1) + (b - a - 1) / 2;
        res = (p > q) ? q : p;
        printf("%lld\n", res);
    }


    





    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'
 
 
int main() {
  string s;
  cin >> s;
  bool flag = true;
  for (int i = 0; i < s.size(); i += 2) {
    if (s[i] == 'L') {
      flag = false;
    }
  }

  for (int i = 1; i < s.size(); i += 2) {
    if (s[i] == 'R') {
      flag = false;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
    return 0;
  }
  else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
    public static void Main()
    {
        string[] hw = Console.ReadLine().Split(' ');
        int h, w;
        h = int.Parse(hw[0]);
        w = int.Parse(hw[1]);
        char[][] s = new char[h][];
        for (int i = 0; i < h; i++)
            s[i] = Console.ReadLine().ToCharArray();

        int[][] min = new int[h][];
        int countw = 0;
        for (int i = 0; i < h; i++)
        {
            min[i] = new int[w];
            for (int j = 0; j < w; j++)
            {
                if (s[i][j] == '#')
                {
                    min[i][j] = -1;
                    countw++;
                }
                else
                    min[i][j] = -2;
            }
        }
        min[0][0] = 1;
        countw = h * w - countw;
        //Console.WriteLine(countw);

        int[,] temp = new int[h, w];

        for (; ; )
        {
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                    temp[i, j] = min[i][j];
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if (min[i][j] == -2)
                    {
                        int m = int.MaxValue;
                        try { if (min[i - 1][j] > 0 && m > min[i - 1][j] + 1) m = min[i - 1][j] + 1; } catch { }
                        try { if (min[i][j - 1] > 0 && m > min[i][j - 1] + 1) m = min[i][j - 1] + 1; } catch { }
                        try { if (min[i][j + 1] > 0 && m > min[i][j + 1] + 1) m = min[i][j + 1] + 1; } catch { }
                        try { if (min[i + 1][j] > 0 && m > min[i + 1][j] + 1) m = min[i + 1][j] + 1; } catch { }
                        if (m != int.MaxValue)
                            min[i][j] = m;
                    }
                }
            }
            bool f = true;
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                    f = f && temp[i, j] == min[i][j];
            if (f)
                break;
        }
        //for (int i = 0; i < h; i++)
        //{
        //  for (int j = 0; j < w; j++)
        //    Console.Write(min[i][j]);
        //  Console.WriteLine();
        //}
        if (min[h - 1][w - 1] > 0)
            Console.WriteLine(countw - min[h - 1][w - 1]);
        else
            Console.WriteLine(-1);
    }
}

Measured memory_bytes: 11328
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

ll a,b,c,aa,bb,cc,r=0;

int main(){
    scanf("%lld %lld %lld",&a,&b,&c);
    if(a==b and b==c){
        if(a%2==0 and b%2==0 and c%2==0)printf("%d\n",-1);
        else printf("%d\n",0);
    }
    else{
        while(a%2==0 and b%2==0 and c%2==0){
            aa=a/2;bb=b/2;cc=c/2;
            a=bb+cc;b=cc+aa;c=aa+bb;
            r++;
        }
        printf("%lld\n",r);
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    int M = sc.nextInt();
	    
	    if (N==M)
	    	System.out.println(N+M);
	    
	    else if (N-1>=M)
	    	System.out.println(2*N-1);
	    
	    
	    else 
	    	System.out.println(2*M-1);
	    
	    sc.close();

	}

}

Measured memory_bytes: 22100
import java.util.*;

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

        int numOfItems = sc.nextInt();
        int numOfPopItemsLowerLimit = sc.nextInt();
        int cnt = 0;
        int sumOfVotes = 0;

        int[] numOfVotes = new int[numOfItems];

        for (int i = 0; i < numOfItems; i++) {
            numOfVotes[i] = sc.nextInt();
            sumOfVotes += numOfVotes[i];
        }

        for (int i = 0; i < numOfItems; i++) {
            if ((double) numOfVotes[i] >= (double) sumOfVotes / 4 / numOfPopItemsLowerLimit) {
                cnt++;
            }
        }

        if (cnt >= numOfPopItemsLowerLimit) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
int n, k, s, ans;
void solve(int deep = 0, int sum = 0, int back = 0) {
	if (deep == k) {
		if (sum == s)ans++;
		return;
	}
	for (int i = back + 1; i <= n; i++) {
		solve(deep + 1, sum + i, i);
	}
	return;
}
signed main() {
	while (cin >> n >> k >> s, n || k || s) {
		ans = 0;
		solve();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2980
#include <stdio.h>
#include <string.h>

/*
   const char s[][10] = 
   {
   "dream",
   "dreamer",
   "erase",
   "eraser"
   };
   */
const char s[][10] =
{
	"maerd",
	"remaerd",
	"esare",
	"resare"
};
const int s_len[] = {5, 7, 5, 6};

char str[100005];

int main()
{
	scanf("%s", str);

	int len = strlen(str);
	int remove_len = 0;
	
	for (int i = 0; i < len / 2; i++) {
		char tmp = str[i];
		str[i] = str[len - i - 1];
		str[len - i - 1] = tmp;
	}

	for (int i = 0; i < len; i++) {

		for (int j = 0; j < 4; j++) {
			if (strncmp(str + i, s[j], s_len[j]) == 0) {

				remove_len += s_len[j];
				i += s_len[j] - 1;

				break;
			}
		}
	}


	if (remove_len == len) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x,y,z;
    cin >> x >> y >>z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " "<< z << "\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
struct SCC{
    int n;
    vector<vector<int>> g,rg;
    vector<int> vs,cmp;
    vector<bool> used;
    SCC(int _n){
        n=_n;
        g=vector<vector<int>>(n);rg=g;
        cmp=vector<int>(n);used=vector<bool>(n);
    }
    void add_edge(int f, int t){
        g[f].push_back(t);
        rg[t].push_back(f);
    }
    int init(){
        rep(i,n)if(!used[i])dfs(i);
        int k=0;
        used=vector<bool>(n,false);
        per(i,n){
            if(!used[vs[i]]){
                rdfs(vs[i],k);
                k++;
            }
        }
        return k;
    }
    private:
    void dfs(int v){
        used[v]=true;
        rep(i,g[v].size()){
            if(!used[g[v][i]])dfs(g[v][i]);
        }
        vs.push_back(v);
    }
    void rdfs(int v, int k){
        used[v]=true;cmp[v]=k;
        rep(i,rg[v].size()){
            if(!used[rg[v][i]]){
                rdfs(rg[v][i],k);
            }
        }
    }
};

int main(){
    ll n,m;cin >> n >>m;
    SCC g(n);
    rep(i,m){
        ll a,b;cin >> a >> b;
        g.add_edge(a,b);
    }
    int k=g.init();
    vvl ans(k);
    rep(i,n){
        ans[g.cmp[i]].pb(i);
    }
    cout << k <<endl;
    for(auto p:ans){
        cout << p.size() <<" ";
        for(auto e:p)cout << e <<" ";
        cout << endl;
    }
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

int main(){
  ll X;
  cin>>X;
  ll tmp(100);
  int cnt(0);
  while(tmp < X){
    cnt++;
    tmp *= 1.01;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {

int M,K;
cin>>M>>K;
	ll m=1<<M;
if(K==0){
	fx(m){
		cout<<x<<' ';
		if(x+1==m){
			cout<<x<<endl;
		}else{
			cout<<x<<' ';
		}
	}
}else{
	ll XOR=0;
	fx(m){
		if(x==K){continue;}
		XOR^=x;
	}
	if(XOR==K){
	fx(m){
		if(x==K){continue;}
		cout<<x<<' ';
	}
	cout<<K<<' ';
	for(int x=m-1;x>=0;x--){
		if(x==K){continue;}
		cout<<x<<' ';
	}
	cout<<K<<endl;
	}else{
		ce(-1)
	}
}

}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>

using namespace std;

int gcd(int n, int m) {
    if (n == 0) return m;
    return gcd(m % n, n);
}

int bit_count(int i) {
    i = i - ((i>>1) & 0x55555555);
    i = (i & 0x33333333) + ((i>>2) & 0x33333333);
    i = (i + (i>>4)) & 0x0f0f0f0f;
    i = i + (i>>8);
    i = i + (i>>16);
    return i & 0x3f;
}

int sum(vector<int> &v) {
    int ret = 0;
    for (int i: v) ret += i;
    return ret;
}

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

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

    int ans = 0;
    for (int i = 0; i <= min(n, k); ++i) {
        for (int j = 0; i+j <= min(n, k); ++j) {
            vector<int> mine(i+j);
            for (int l = 0; l < i; ++l) mine.emplace_back(values[l]);
            for (int l = 0; l < j; ++l) mine.emplace_back(values[values.size() - 1 - l]);
            sort(mine.rbegin(), mine.rend());
            for (int l = 0; l < k-i-j && !mine.empty() && mine.back() < 0; ++l) {
                mine.pop_back();
            }
            ans = max(ans, sum(mine));
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
const int MAXN = 1e5 + 5, MAXM = 30;
long long a[MAXN], k;
int d[MAXN], index[MAXN], T[MAXN], n, m;
int new_pos[MAXN][MAXM];
bool vis[MAXN];
int dfs(int i, int cnt_edge) {
	if(vis[i]) return cnt_edge;
	vis[i] = true;
	return T[i] = dfs(new_pos[i][0], cnt_edge + 1);
}
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i]), index[i] = i;
	scanf("%d%lld", &m, &k);
	for(int i = 0; i < m; i++) {
		int x; scanf("%d", &x);
		std::swap(index[x], index[x - 1]);
	}
	for(int i = 1; i <= n - 1; i++) new_pos[index[i]][0] = i;
	for(int i = 1; i <= n - 1; i++) if(!vis[i]) dfs(i, 0);
	for(int j = 1; j < MAXM; j++) {
		for(int i = 1; i <= n - 1; i++) new_pos[i][j] = new_pos[new_pos[i][j - 1]][j - 1];
	}
	for(int i = 1; i <= n - 1; i++) {
		int cur = k % T[i], pos = i;
		for(int j = 0; cur != 0; cur >>= 1, j++) {
			if(cur & 1) pos = new_pos[pos][j];
		}
		index[pos] = i;
	}
	double cur = a[1];
	for(int i = 1; i <= n; i++) {
		printf("%.1f\n", cur);
		cur += a[index[i] + 1] - a[index[i]];
	}
	return 0;
}


Measured memory_bytes: 16256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := -int(1e+18)
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := int(1e+18)
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp1 int = 1000000007
var lp2 int = 998244353

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp1)
	sc.Split(bufio.ScanWords)
	n := iScan() * 2
	ans := int(1e+18)
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			a, b := i, n/i
			g := gcd(a, b)
			if g == 1 {
				x, y := 0, 0
				extGCD(a, b, &x, &y)
				if x < 0 {
					z := (-x) % b
					if z == 0 {
						z += b
					}
					ans = smaller(ans, a*z)
				} else {
					z := x - x/b*b - b
					ans = smaller(ans, -a*z)
				}
			}
			a, b = b, a
			if g == 1 {
				x, y := 0, 0
				extGCD(a, b, &x, &y)
				if x < 0 {
					z := (-x) % b
					if z == 0 {
						z += b
					}
					ans = smaller(ans, a*z)
				} else {
					z := x - x/b*b - b
					ans = smaller(ans, -a*z)
				}
			}
		}
	}
	fmt.Println(ans)
}
func extGCD(a int, b int, x *int, y *int) int {
	if b == 0 {
		*x = 1
		*y = 0
		return a
	}
	d := extGCD(b, a%b, y, x)
	*y -= a / b * *x
	return d
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func gcd(a, b int64) int64 {
	if b > a {
		a, b = b, a
	}
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func solve(k int64) int64 {
	ret := int64(0)
	for i0 := int64(1); i0 <= k ; i0 ++ {
		for i1 := int64(1); i1 <= k ; i1 ++ {
			g1 := gcd(i0, i1)
			for i2 := int64(1); i2 <= k ; i2 ++ {
				g2 := gcd(i2, g1)
				ret += g2
			}
		}
	}
	return ret
}

func main() {
	defer out.Flush()

	k := nextInt()
	res := solve(k)
	fmt.Fprintln(out, res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

//------------------------------------------------------

int main() {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    bool can = false;

    repll(m, n) {
        ll p = n - 1 - m;
        if (a - d * m + c * p <= b && b <= a - c * m + d * p) {
            can = true;
        }
    }

    YES(can);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N,K;
    cin >> N >> K;
    vector<P> vec(N);
    for(int i = 0;i < N;i++) {
        ll A,B;
        cin >> A >> B;
        vec.at(i) = P(A,B);
    }
    vector<int> x(N);
    vector<int> y(N);
    for(int i = 0;i < N;i++) {
        x.at(i) = vec[i].first;
        y.at(i) = vec[i].second;
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    ll ret = INF;
    for(int i = 0;i < N - 1;i++) {
        for(int j = i + 1;j < N;j++) {
            for(int k = 0;k < N - 1;k++) {
                for(int l = k + 1;l < N;l++) {
                    ll x1 = x.at(i);
                    ll x2 = x.at(j);
                    ll y1 = y.at(k);
                    ll y2 = y.at(l);
                    int cnt = 0;
                    for(int m = 0;m < N;m++) {
                        if(x1 <= vec[m].first && vec[m].first <= x2 && y1 <= vec[m].second && vec[m].second <= y2) {
                            cnt++;
                        }
                    }
                    if(cnt >= K) {
                        ll cnt2 = (x2 - x1) * (y2 - y1);
                        ret = min(ret,cnt2);
                    }
                }
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (isok).erase(unique(ALL((isok))),(isok).end())
# define LOWER(s)    transform(ALL((maze)),(maze).begin(),TL<char>)
# define UPPER(s)    transform(ALL((maze)),(maze).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)


bool iswall[70][70][70][70];
int h, w;
int sx, sy, gx, gy;

int d[70][70];
int bfs() {
	queue<pair<int, int>> que;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			d[i][j] = HINF;
		}
	}
	que.push(pair<int, int>(sx, sy));
	d[sy][sx] = 0;
	while (que.size()) {
		pair<int, int> p = que.front();
		que.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (iswall[p.second][p.first][ny][nx] == 1)continue;
			if (0 <= nx&&nx < w && 0 <= ny&&ny < h && d[ny][nx] == HINF) {
				que.push(pair<int, int>(nx, ny));
				d[ny][nx] = d[p.second][p.first] + 1;
				//cout << p.second << " " << p.first << endl;
				//cout <<" "<< ny << " " << nx << endl;
				//system("pause");
			}
		}
	}
	return d[gy][gx];
}

int num;
int main() {
	while (cin >> w >> h&&w&&h) {
		REP(i, 70)REP(j, 70)d[i][j] = 0;
		REP(i, 70)REP(j, 70)REP(k, 70)REP(l, 70)iswall[i][j][k][l] = 0;

		REP(i, 2 * h - 1) {
			if (i % 2 == 0) {
				REP(j, w - 1) {
					cin >> num;
					iswall[i/2][j][i/2][j + 1] = iswall[i/2][j + 1][i/2][j] = num;
				}
			}
			else {
				REP(j, w) {
					cin >> num;
					iswall[(i) / 2][j][(i) / 2 + 1][j] = iswall[(i) / 2 + 1][j][(i)/2][j] = num;
				}
			}
		}
		sy = 0, sx = 0;
		gy = h - 1, gx = w - 1;
		LL ret = bfs();
		cout << (ret == HINF ? 0 : ret + 1) << endl;
	}
}


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

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define _shv(v) for (auto _t1 : v) cerr << _t1 << " "; cerr << endl;
#define dg(x) cerr << #x << ": " << (x) << endl;
#define dgv(v) cerr << #v << ": "; _shv(v);
#define dgm(m) cerr << #m << ":" << endl; for (auto _t2 : m) { _shv(_t2); }

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

template<typename T> inline void pt(T x) { cout << x << endl; }
template<typename T> inline void inv(T& v) { for (auto& t : v) cin >> t; }
template<typename T> inline int siz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T, typename U>
inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


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

    vi a(n);
    inv(a);

    vi dp(n, -1);
    rep(i, n)
        *(lower_bound(rng(dp), a[i]) - 1) = a[i];
    pt(dp.end() - upper_bound(rng(dp), -1));

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  char S[N];
  cin >> S;

  int ans = 0;
  for (int i = 0; S[i] != '\0'; i++) {
    if(S[i] == 'A') {
      if (S[i+1] != '\0' and S[i+1] == 'B') {
	if (S[i+2] != '\0' and S[i+2] == 'C') {
	  ans++;
	}
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cctype>
#include <cstring>
#include <cstdio>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
int a, b;
int main()
{
    a = read(), b = read(); if(a > b) swap(a, b);
    if(a <= 0&&b >= 0) puts("Zero");
    else if(a > 0) puts("Positive");
    else if((b-a+1)&1) puts("Negative");
    else puts("Positive");
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
INF = 99999#1001001001
from collections import deque

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def pad(mxy, wall="#"):
	w = len(mxy[0])
	gp = wall*(w+2)
	re = [gp,]
	re_app = re.append
	for vx in mxy:
		re_app(wall+vx+wall)
	re_app(gp)
	return re

vD = [(0,1),(1,0)]
vQ = deque([])
vQ_app, vQ_popl = vQ.append, vQ.popleft

def main():
	H,W = linput()
	mM = [input().rstrip() for _ in [0,]*H]
	mM = pad(mM, "$")
	
	res = 0
	cnt = 0
	
	for sr in range(1,1+1):
		for sc in range(1,1+1):
			if mM[sr][sc]=="#":
				res += 1
			mV = [[INF,]*(W+2) for _ in [INF,]*(H+2)]
			mV[sr][sc] = res
			vQ_app((sr,sc))
			while vQ:
				r,c = vQ_popl()
				now_cost = mV[r][c]
				now_s = mM[r][c]
				for dr,dc in vD:
					nr,nc = r+dr, c+dc
					if mM[nr][nc]=="$":
						continue
					next = now_s=="."!=mM[nr][nc]
					new_cost = now_cost + next
					if new_cost < mV[nr][nc]:
						vQ_app((nr,nc))
						mV[nr][nc] = new_cost
		
				cnt += 1
				#print(res,cnt,X,Y,H)
				if cnt>999999: break
	
	#print(*mV,sep="\n")###
	res = mV[H][W]
	print(res)

if __name__ == "__main__":
	main()


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

signed main(){
    ios_base::sync_with_stdio(0);
    char a;
    cin >> a;
    if(a >= 'a') a = 'a';
    else a = 'A';
    cout << a << endl ;
    return 0;
}



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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    if(N%2==0) {
        cout << N*(N-1)/2-N/2 << endl;
        for(int i=1;i<=N-1;i++) {
            for(int j=i+1;j<=N;j++) {
                if(i+j!=N+1) cout << i << " " << j << endl;
            }
        }
    }
    if(N%2==1) {
        cout << N*(N-1)/2-(N-1)/2 << endl;
        for(int i=1;i<=N-1;i++) {
            for(int j=i+1;j<=N;j++) {
                if(i+j!=N) cout << i << " " << j << endl;
            }
        }
    }
    return 0;
}

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

int main() {
  int H1, M1, H2, M2, K, X1, X2;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  X1 = H1 * 60 + M1;
  X2 = H2 * 60 + M2;
  cout << X2 - X1 - K << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;

 
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,m,k;
    cin>>n>>m>>k;
    vector<string> a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll ans=0;
    for(ll mi=0;mi<(1<<n);mi++){
        for(ll mj=0;mj<(1<<m);mj++){
            ll r=0;
            for(ll i=0;i<n;i++){
                for(ll j=0;j<m;j++){
                    if((1<<i)&mi) continue;
                    if((1<<j)&mj) continue;
                    if(a[i][j]=='#')
                        r++;
                }
            }
            if(r==k)
                ans++;
        }
    }
    cout<<ans;





    return 0;
}

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

public class Main {

    public static void main(String[] args) {

        FastReader fastReader = new FastReader();
        find( fastReader.nextInt() );

    }

    public static void find( int num ){

        int lastDigit = num % 10;

        if( lastDigit == 2 || lastDigit == 4 || lastDigit == 5 || lastDigit == 7 || lastDigit == 9 ){
            System.out.println("hon");
        }
        else if( lastDigit == 0 || lastDigit == 1 || lastDigit == 6 || lastDigit == 8 ){
            System.out.println("pon");
        }else{
            System.out.println("bon");
        }
    }
}

class FastReader
{
    BufferedReader br;
    StringTokenizer st;

    public FastReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

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

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

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}



Measured memory_bytes: 32656
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	double r,s,j;
	cin>>r;
	s=r*r*3.141592653589;
	j=2*r*3.141592653589;
	printf("%.6lf",s);
	cout<<" ";
	printf("%.6lf\n",j);
}

Measured memory_bytes: 3240