akhauriyash/Code-Regression huggingface dataset:
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint out[60];
int main()
{
	lint k,t;int n=50,x;
	cin>>k;
	t=k/n;x=(int)(k%n);
	rep(i,n) out[i]=t+n-1;
	rep(i,n){
		if(i<x) out[i]+=n-(x-1);
		else out[i]-=x;
	}
	cout<<n<<endl;
	rep(i,n){
		cout<<out[i];
		if(i<n-1) cout<<' ';else cout<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD = 1000000007;


     signed main(){
   int x;
   cin>>x;
   cout<<max(1ll,8-(x-400)/200)<<endl;
   
  
  

     }


 


 






    





      

        


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <complex>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

typedef complex<double> P;

const double EPS = 1e-10;

//二つのスカラーが等しいか
#define EQ(a, b) (abs((a) - (b)) < EPS)
//二つのベクトルが等しいか
#define EQV(a, b) (EQ((a), real(), (b).real()) && EQ((a), imag(), (b).imag()))

double dot(P a, P b)
{
    return real(a) * real(b) + imag(a) * imag(b);
}

double cross(P a, P b)
{
    return real(a) * imag(b) - imag(a) * real(b);
}

ll mod(ll x, ll n)
{
    ll res = 1;
    while (n > 0)
    {
        if ((n & 1) == 1)
        {
            res = (res * x) % MOD;
        }
        x = x * x;
        n >>= 1;
    }
    return res % MOD;
}

int main()
{
    P p1, p2;
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    p1.real(x1);
    p1.imag(y1);
    p2.real(x2);
    p2.imag(y2);
    int q;
    cin >> q;
    while (q--)
    {
        P p;
        double x, y;
        cin >> x >> y;
        p.real(x);
        p.imag(y);

        P ans = p1 + (dot(p - p1, p2 - p1) / (abs(p2 - p1) * abs(p2 - p1))) * (p2 - p1);
        ans.real(2.0 * ans.real() - p.real());
        ans.imag(2.0 * ans.imag() - p.imag());
        cout << fixed << setprecision(12) << ans.real() << " " << ans.imag() << endl;
    }
    return 0;
}


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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    int a, b; cin >> a >> b;
    cout << max({a*b, a + b, a - b}) << '\n';
    return 0;
}

Measured memory_bytes: 3604
program nanagoyon
  implicit none
  character(10) :: s
  integer :: i, x, d = 1e9
  read(*,*) s
  do i = 1, len_trim(s)-2
    read(s(i:i+2),*) x
    if (d > abs(x-753)) d = abs(x-753)
  end do
  write(*,'(i0)') d
end program nanagoyon

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
using ll = long long int;

int main()
{
    vector<ll> five(121);
    vector<ll> minusfive(121);
    for(int i=0; i<=120; i++) five[i] = i*i*i*i*i;
    for(int i=0; i<=120; i++) minusfive[i] = -i*i*i*i*i;


    ll x; cin >> x;


    ll b;
    for(int i=0; i<=120; i++){
            b = five[i] - x;
            for(int j=0; j<=120; j++){
                if(b == five[j]){
                    cout << i << ' ' << j << endl;
                    return 0;
                }
                if(b == minusfive[j]){
                    cout << i << ' ' << -j << endl;
                    return 0;
                }
            }
    }
    for(int i=0; i<=120; i++){
            b = minusfive[i] - x;
            for(int j=0; j<=120; j++){
                if(b == five[j]){
                    cout << i << ' ' << j << endl;
                    return 0;
                }
                if(b == minusfive[j]){
                    cout << i << ' ' << j << endl;
                    return 0;
                }
            }
    }
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

long long gcd(long long a, long long b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main(){
    long long A,B;
    cin >> A >> B;
    long long ans =lcm(A,B); 
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int idx;
string s;

Int getNum(){
  Int res = 0;
  while(isdigit(s[idx])) res = res * 10 + (s[idx++] - '0');
  return res;
}

Int calc(){
  assert(s[idx++] == '[');

  vector<Int> num;
  while(1){
    if(isdigit(s[idx])) num.push_back(getNum()/2+1);
    else if(s[idx] == '['){
      num.push_back(calc());
      assert(s[idx++] == ']');
      continue;
    }
    else if(s[idx] == ']') break;
    else assert(!"undefined");
  }

  sort(num.begin(), num.end());
  Int res = 0;
  for(Int i=0;i<=(Int)num.size()/2;i++) res += num[i];
  return res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int num_test;
  cin>>num_test;
  while(num_test--){
    cin>>s;
    idx = 0;

    Int ans = calc();
    cout<<ans<<endl;

  }

  return 0;
}



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

int main(){
  int N,Y,a=-1,b=-1,c=-1;
  cin >> N >> Y;
  Y /= 1000;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      if(Y==10*i+5*j+(N-i-j)&& 0<=N-i-j){
        a = i;
        b = j;
        c = N-i-j;
      }
    }
  }
    cout << a <<' '<< b <<' '<< c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int n,m,a[101],c[101],b[201],e,sum,now;
int main()
{
	scanf("%d%d",&n,&m);
	if(m==1)
	{
		printf("%d\n",n);
		if(n==1)puts("1"),puts("1");
		else puts("2"),printf("%d %d\n",n-1,1);
		return 0;
	}
	for(int i=1;i<=m;++i)
		scanf("%d",&a[i]),sum+=a[i],now+=a[i]/2;
	now+=sum/2;
	if(now<sum-1)puts("Impossible");
	else 
	{
		for(int i=1;i<=m;++i)
			if(a[i]&1)
			{
				if(c[1])c[m]=a[i];
				else c[1]=a[i];	
				a[i]=0;
			}
		for(int i=1,j=c[1]?1:0;i<=m;++i)
			if(a[i])
				c[++j]=a[i];
		for(int i=1;i<=m;++i)
			b[i]=c[i];
		++b[1];
		e=m;
		--b[m];
		if(c[m]==1)--e;
		for(int i=1;i<=m;++i)
			printf("%d ",c[i]);
		puts("");
		printf("%d\n",e);
		for(int i=1;i<=e;++i)
			printf("%d ",b[i]);
		puts("");
	}
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n, k, a[10101], b[10101];
void solve(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i]--;
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	
	i64 ans = -LINF;
	for(int i = 0; i < n; i++){
		bool used[10101] = {};
		i64 cnt = 0, cc = 0, now = i;
		while(!used[now]){
			used[now] = 1;
			cc++;
			cnt += b[now];
			now = a[now];
			chmax(ans, cnt);
			if(cc == k) break;
		}
		if(cc == k) continue;
		cnt = cnt*(k/cc - 1);
		for(i64 j = cc*(k/cc-1); j < k; j++){
			cnt += b[now];
			now = a[now];
			chmax(ans, cnt);
		}
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3748
#include<iostream>
using namespace std;
int main(){
  int count=0,n,ans=0;
  cin >> n;
  for(int i=105;i<=n;i+=2){
    count =0;
    for(int j=1;j<=n/2;j++){
      if(i%j==0){
        count ++;
      }
      if(count>=8)break;
    }
    if(count == 7)ans++;
  }
  cout << ans<<endl;
}


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

int main() {
  long long N;
  cin >> N;
  
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  vector<int> B(N);
  for (int j = 0; j < N; j++) {
    while (A.at(j) % 2 == 0){
      A.at(j) = A.at(j) / 2;
      B.at(j) = B.at(j) + 1;
    }
  }
  sort(B.begin(), B.end());
  cout << B.at(0) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=1e5+10;
    int N,C;
    int s[MAXN];
    int t[MAXN];
    int c[MAXN];
    int tmp[2*MAXN];
    int r[2*MAXN];
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>N>>C;
        for(int u=0;u<N;u++){
            cin>>s[u]>>t[u]>>c[u];
        }
        for(int ch=1;ch<=C;ch++){
            memset(tmp,0,sizeof(tmp));
            for(int u=0;u<N;u++){
                if(c[u]==ch){
                    tmp[2*s[u]-1]++;
                    tmp[2*t[u]]--;
                }
            }
            for(int t=1;t<2*MAXN;t++){
                tmp[t]+=tmp[t-1];
            }
            for(int t=0;t<2*MAXN;t++){
                if(tmp[t])r[t]++;
            }
        }
        int ans=0;
        for(int t=0;t<2*MAXN;t++)ans=max(ans,r[t]);
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();   
}

Measured memory_bytes: 2944
import sys

input = sys.stdin.readline

P = 10 ** 9 + 7


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()

    if N % 2 == 0:
        is_ok = True
        for i in range(N//2):
            if not A[2*i] == A[2*i+1] == (2*i+1):
                is_ok = False
        if is_ok:
            ans = pow(2, N//2, P)
        else:
            ans = 0

    else:
        is_ok = True
        if not A[0] == 0:
            is_ok = False
        for i in range((N-1)//2):
            if not A[2*(i+1)-1] == A[2*(i+1)] == 2*(i+1):
                is_ok = False
        if is_ok:
            ans = pow(2, (N-1)//2, P)
        else:
            ans = 0

    print(ans)


if __name__ == "__main__":
    main()


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(3 * N);
    REP(i, 3 * N) cin >> a[i];

    priority_queue<ll, vector<ll>, greater<ll>> head;
    ll headSum = 0;
    REP(i, N)
    {
        head.push(a[i]);
        headSum += a[i];
    }
    map<ll, ll> headSumMap;
    headSumMap[0] = headSum;
    for (ll k = 1; k <= N; ++k)
    {
        headSum += a[N - 1 + k];
        head.push(a[N - 1 + k]);
        headSum -= head.top();
        head.pop();
        headSumMap[k] = headSum;
    }

    priority_queue<ll> tail;
    ll tailSum = 0;
    REP(i, N)
    {
        tail.push(a[2 * N + i]);
        tailSum += a[2 * N + i];
    }
    map<ll, ll> tailSumMap;
    tailSumMap[N] = tailSum;
    for (ll k = 1; k <= N; ++k)
    {
        tailSum += a[2 * N - k];
        tail.push(a[2 * N - k]);
        tailSum -= tail.top();
        tail.pop();
        tailSumMap[N - k] = tailSum;
    }

    ll ans = LONG_MIN;
    for (ll k = 0; k <= N; ++k)
    {
        ans = max(ans, headSumMap[k] - tailSumMap[k]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 16628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll rep = n / (a + b);
    ll amari = n % (a + b);
    ll blue;
    if (a >= amari)
    {
        blue = rep * a + amari;
    }else{
        blue = rep * a + a;
    }
    cout << blue << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

using ull = long long int;

ull Patty[101] = {};
ull Burger[101] = {};

int main() {

	ull N, X, answer = 0;
	cin >> N >> X;

	Patty[0] = 1;
	Burger[0] = 1;

	for (int i = 0; i < 100; i++)
	{
		Burger[i + 1] = 2 * Burger[i] + 3;
	}

	for (int i = 0; i < 100; i++)
	{
		Patty[i + 1] = 2 * Patty[i] + 1;
	}

	for (int i = N;X > 0 && i >= 0; i--) 
	{
		if (X >= Burger[i]) {
			X -= Burger[i];
			answer += Patty[i];

			i++;

			if (X != 0) {
				X--;
				answer++;
			}
		}
		else {
			X--;
		}
	}

	cout << answer << endl;

	return 0;
}

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

int max_points(vector<int>a) {
	int max(a[0]);
	for (int i(1); i < a.size(); i++) {
		if (max<a[i])max=a[i];
	}
	if (max < 0)max = 0;
	return max;
}

int main(void) {
	int n;
	cin >> n;
	vector<string>s;
	for (int i(0); i < n; i++) {
		string tmp;
		cin >> tmp;
		s.push_back(tmp);
	}
	int m;
	cin >> m;
	vector<string>t;
	for (int i(0); i < m; i++) {
		string tmp;
		cin >> tmp;
		t.push_back(tmp);
	}
	vector<int>points;
	for (int i(0); i < n; i++) {
		points.push_back(0);
	}
	for (int i(0); i < n; i++) {
		for (int j(0); j < n; j++) {
			if (s[i] == s[j])points[i]++;
		}
	}
	for (int i(0); i < n; i++) {
		for (int j(0); j < m; j++) {
			if (s[i] == t[j])points[i]--;
		}
	}
	cout << max_points(points) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

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

  		
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	int frs[] = new int[n];
      	int prs = 0;
      	
      	for(int i = 0;i < n;i++) frs[i] = sc.nextInt();
      	Arrays.sort(frs);
      	for(int i = 0;i < k;i++) prs += frs[i];
      
      	System.out.println(prs);
        
	}
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y,z; cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def check(i, s, t):
    new_t_list = t[i:] + t[:i]
    if new_t_list == s:
        return True
    else:
        return False

if __name__ == '__main__':
    s = input()
    t = input()
    s_head = s[0]
    for i in range(len(t)):
        if t[i] == s_head:
            b = check(i, s, t)
            if b:
                print("Yes")
                sys.exit()
    print("No")

Measured memory_bytes: 3064
from sys import stdin

a=int(input())

i = list(map(int,input().split()))

e = 0
mini = i[0]
count = 0

while e < a:
    if e == 0:
        count += 1
    elif i[e] < mini:
        count += 1
        mini = i[e]
    e += 1

print(count)

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
int n, m;
map<int, int> mp;
/**********************************************/

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

    cin >> n >> m;

    REP(i, m){
        int a, b;
        cin >> a >> b;
        mp[a]++; mp[b]++;
    }

    REP(i, n){
        cout << mp[i+1] << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const int di[] = {0, 1, 0, -1};
const int dj[] = {1, 0, -1, 0};
const int dwi[] = {1, 2, 1, 0};
const int dwj[] = {1, 0, 0, 0};


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

    while(1){

        int w, h;
        cin >> w >> h;

        if(w == 0) break;

        vector<vector<int>> wall(2*h+1, vector<int>(w+1, 2));
        rep1(i, 2*h){
            if(i%2) rep1(j, w) cin >> wall[i][j];
            else rep(j, w) cin >> wall[i][j];
        }

        const int INF = 1001001001;
        vector<vector<int>> dist(h, vector<int>(w, INF));
        dist[0][0] = 0;
        queue<pair<int, int>> q;
        q.push((make_pair(0, 0)));

        while(!q.empty()){
            int i = q.front().first;
            int j = q.front().second;
            q.pop();

            rep(dir, 4){
                int ni = i + di[dir];
                int nj = j + dj[dir];
                int wi = 2*i + dwi[dir];
                int wj = j + dwj[dir];

                if(wi<0 || wi>=2*h+1 || wj<0 || wj>=w+1) continue;
                if(ni<0 || ni>=h || nj<0|| nj>=w) continue;
                if(wall[wi][wj] != 0) continue;
                if(dist[ni][nj] != INF) continue;

                dist[ni][nj] = dist[i][j] + 1;
                q.push(make_pair(ni, nj));
            }
        }

        if(dist[h-1][w-1] == INF) cout << 0 << endl;
        else cout << dist[h-1][w-1]+1 <<endl;
    }

    return 0;
}


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

int main(){
  string s,ans;
  cin >>s;
  
  if(s.size()==2)ans = s;
  else {
    reverse(s.begin(),s.end());
    ans = s;
  }
  
  cout <<ans <<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
const int N=1e4+5;
int n,p,cnt[N];
string s;
int main()
{
    cin>>n>>p>>s;
    int size=s.size();
    ll ans=0;
    if(p==2||p==5)rep(i,0,size-1){if((s[i]-'0')%p==0)ans+=i+1;}
    else{
        ll base=1,now=0;
        cnt[0]=1;
        per(i,size-1,0){
            now=(((s[i]-'0')*base)%p+now)%p;
            base=(base*10)%p;
            ans+=cnt[now];++cnt[now];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 644
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <ctime>
#include <map>
#include <queue>

using namespace std; using ll=long long; using P=pair<ll,ll>; const int INF=1e9; const ll LNF=1e18;

int main(){
  int n,a,b; cin>>n>>a>>b;
  int c[n]; for(int i=0;i<n;i++) c[i]=i+1;

  if (n<a||n<b) {
    cout<<-1<<endl;
    return 0;
  }

  int ii=0, p=n, q=1;
  reverse(c,c+b);
  ii = b; p -= b-1; q = b;

  while(ii < n && p > a) {
    if (p-a >= b-1) {
      if (ii+b > n) break;
      reverse(c+ii,c+ii+b);
      ii += b; p -= b-1;
    } else {
      if (ii+p-a+1 > n) break;
      reverse(c+ii,c+ii+p-a+1);
      ii += p-a; p -= p-a;
    }
  }
  if (p != a || q != b) {
    cout<<-1<<endl;
    return 0;
  } else {
    for(int i=0;i<n;i++) {
      cout<<c[i]<<" ";
    } cout<<endl;
  }
}


Measured memory_bytes: 3328
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    if !block_given?
      @comp = Proc.new { |x, y| x <= y }
    else
      @comp = comp
    end
  end
  attr_reader :heap

  def push(x)
    i = @node_num # 自分のノード番号
    @node_num += 1
    while i > 0
      par = (i - 1) / 2 # 親のノード番号
      break if @comp.call(@heap[par], x) # 逆転してないなら抜ける
      # 親ノードを下ろして自分を上に
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end

  alias_method(:<<, :push)

  def pop
    # 最(小|大)値
    ret = @heap[0]
    # 根にもってくる値
    @node_num -= 1
    x = @heap[@node_num]
    # 根から下ろしていく
    i = 0
    while i * 2 + 1 < @node_num
      # 子どうしを比較
      a, b = i * 2 + 1, i * 2 + 2
      a = b if b < @node_num && !@comp.call(@heap[a], @heap[b])
      break if @comp.call(x, @heap[a])
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    return ret
  end

  def get
    @node_num == 0 ? nil : @heap[0]
  end

  def empty?
    return get.nil?
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
q = PriorityQueue.new { |x, y| x > y }
a.each do |ai|
  q << ai
end
m.times do
  q << (q.pop() / 2)
end
p q.heap.inject(:+)


Measured memory_bytes: 9556
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) ll(x.size())
using namespace std;

int main() {
  ll n,ans=1,hmax,h;
  cin >> n >> hmax;
  rep(i,n-1){
  	cin >> h;
    if(hmax<=h){
    	ans++;
    	hmax=max(h,hmax);
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep (i, h) cin >> s[i];
    vector<vector<int> > r(h, vector<int>(w + 1)), c(h + 1, vector<int>(w));
    rep (i, h) {
        bool ok = false;
        int start = 0, end = -1, cnt = 0;
        rep (j, w) {
            if (s[i][j] == '#') {
                if (ok && start != -1) {
                    end = j;
                    r[i][start] += cnt;
                    r[i][end] -= cnt;
                    end = -1, cnt = 0;
                    if (s[i][j + 1] != '#') start = j + 1;
                } else {
                    if (s[i][j + 1] != '#') start = j + 1;
                }
            } else {
                ok = true;
                cnt++;
            }
            if (j == w - 1 && cnt != 0) {
                r[i][start] += cnt;
                r[i][j + 1] -= cnt;
            } 
        }
    }
    
    rep (i, h) {
        FOR (j, 1, w + 1) r[i][j] += r[i][j - 1];
    }
    

    rep (i, w) {
        bool ok = false;
        int start = 0, end = -1, cnt = 0;
        rep (j, h) {
            if (s[j][i] =='#') {
                if (start != -1) {
                    end = j;
                    c[start][i] += cnt;
                    c[end + 1][i] -= cnt;
                    start = j, end = -1, cnt = 0;
                } else {
                    start = j;
                }
            } else {
                ok = true;
                cnt++;
            }
            if (j == h - 1 && cnt != 0) {
                c[start][i] += cnt;
                c[j + 1][i] -= cnt;
            } 
        }
        
    }
    rep (i, w) {
        FOR (j, 1, h + 1) c[j][i] += c[j - 1][i];
    }
    int res = 0;
    rep (i, h) {
        rep (j, w) {
            if (s[i][j] == '#') continue;
            int tmp = 0;
            tmp = r[i][j] + c[i][j] - 1;
            res = max(res, tmp);
        }
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 35968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        WriteLine(Max(n[0] * n[1], n[2] * n[3]));
        ReadLine();
    }
}


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

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<int> pq;
    rep(i, N) {
        int a;
        cin >> a;
        pq.push(a);
    }

    rep(i, M) {
        int a = pq.top();
        pq.pop();
        pq.push(a / 2);
    }

    ll ans = 0;
    rep(i, N) {
        int a = pq.top();
        pq.pop();
        ans += a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
 ios::sync_with_stdio(false);
    ll n;
    std::cin >> n;
    set<string> s;
    for (int i = 0; i < n; i++) {
        string t;
        std::cin >> t;
        s.insert(t);
    }
    std::cout << s.size() << std::endl;
}



Measured memory_bytes: 19204
use proconio::input;
use std::collections::{HashMap, BinaryHeap};
use std::cmp::Reverse;

fn main() {
    input! {
        n: usize,
        k: usize,
        aa: [usize; n],
    }

    let mut map = HashMap::new();
    for a in aa {
        *map.entry(a).or_insert(0) += 1;
    }

    let mut heap = BinaryHeap::new();

    for (_, value) in map {
        heap.push(Reverse(value));
    }


    let mut count = 0;
    while heap.len() > k {
        if let Some(Reverse(i)) = heap.pop() {
            count += i;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 11416
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s[] = new String [n];
    for(int i = 0;i < n;i++){
      s[i] = sc.next();
    }
    int m = sc.nextInt();
    String t[] = new String [m];
    for(int i = 0;i < m;i++){
      t[i] = sc.next();
    }
    int count = 0;
    int max = 0;

    for(int i = 0;i < n;i++){
      count = 0;
      for(int j = 0;j < n;j++){
        if(s[i].equals(s[j])){
          count++;
        }
      }
      for(int j = 0;j < m;j++){
        if(s[i].equals(t[j])){
          count--;
        }
      }
      if(count > max){
        max = count;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 21972
while True:
    line = input()
    if line == 'END OF INPUT':
        break

    output_count_list = []
    count = 0
    for c in line:
        if c != ' ':
            count += 1
        else:
            output_count_list.append(str(count))
            count = 0
    output_count_list.append(str(count))
    print(''.join(output_count_list))


Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D,E,F,INF=999999999;
vector<int> v,w;

void vecsort(vector<int> w){
  sort(w.begin(),w.end());
  reverse(w.begin(),w.end());
}

int main(){
  cin>>A>>B>>C>>D>>E>>F;
  for(int i=0;100*A*i<=F;i++){
    for(int j=0;100*B*j<=F;j++){
      if(100*A*i+100*B*j<=F) v.push_back(100*A*i+100*B*j);
    }
  }

  for(int i=0;C*i<=F;i++){
    for(int j=0;D*j<=F;j++){
      if(C*i+D*j<=F) w.push_back(C*i+D*j);
    }
  }

  int weight=1,sugar=0;
  for(int i=0;i<v.size();i++){
    for(int j=0;j<w.size();j++){
      if(v[i]+w[j]<=F){
        if(w[j]*(100+E)<=(v[i]+w[j])*E){
          if(w[j]*(weight)>=(v[i]+w[j])*sugar){
            sugar=w[j];
            weight=v[i]+w[j];
          }
        }
      }
    }
  }

  cout<<weight<<" "<<sugar<<endl;
}


Measured memory_bytes: 1400
import java.util.*;


public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+1];
		for(int i = 0; i<n-1; i++) {
			int x = sc.nextInt();
			a[x]++;
		}
		for(int j= 1; j<=n ;j++){
			System.out.println(a[j]);
		}
		sc.close();		
	}

}

Measured memory_bytes: 62168
n,k = map(int,input().split())

s1 = 1/n
s2 = 1/2
result = 0
for i in range(1,n+1):
    res = i
    cnt = 0
    while res < k:
        res *= 2
        cnt += 1
    result += s1*pow(s2,cnt)
print(result)

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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define SIZE(arr) ((int)arr.size())
#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;

using namespace std;

using ll = long long;

const int MOD = 1e9 + 7;
const ll INF_LLONG = 1e18 + 9;
const int INF_INT = 1e9 + 9;

int dist[2001][2001];


int main()
{
	//	#ifndef ONLINE_JUDGE
	//		(void)freopen("input.txt", "r", stdin);
	//		(void)freopen("output.txt", "w", stdout);
	//	#endif
	FAST_IO;
	ll x, y, A, B, C;
	cin >> x >> y >> A >> B >> C;
	vector<ll> a(A);
	vector<ll> b(B);
	vector<ll> c(C);
	for (int i = 0; i < A; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < B; ++i) {
		cin >> b[i];
	}
	for (int i = 0; i < C; ++i) {
		cin >> c[i];
	}
	sort(a.begin(), a.end(), greater<ll>());
	sort(b.begin(), b.end(), greater<ll>());
	ll ans = 0;
	for (int i = 0; i < x; ++i) {
		c.push_back(a[i]);
	}
	for (int i = 0; i < y; ++i) {
		c.push_back(b[i]);
	}
	sort(c.begin(), c.end(), greater<ll>());
	for (int i = 0; i < x + y; ++i)
		ans += c[i];
	cout << ans;
	return 0;
}




Measured memory_bytes: 6384
#include <bits/stdc++.h>
#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)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

ll A,B,C,K;
cin >> A >> B >> C >> K;

if(K <= A) {
    cout << K << endl;
} else if(K <= A+B) {
    cout << A << endl;
} else {
    cout << A - (K - (A+B)) << endl;
}

return 0;
}

Measured memory_bytes: 3604
abc = list(map(int, input().split()))
abc_even = [x % 2 == 0 for x in abc]
ans = 0
if abc_even.count(True) == 2:
  abc = [x + 1 if x_flg == True else x for x,x_flg in zip(abc,abc_even)]
  ans += 1
elif abc_even.count(False) == 2:
  abc = [x + 1 if x_flg == False else x for x, x_flg in zip(abc, abc_even)]
  ans += 1
mx = max(abc)
for i in range(len(abc)):
  while abc[i] < mx:
    abc[i] += 2
    ans += 1
print(ans)

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

int main() {
  int total, coin1;
  cin >> total >> coin1;
  
  if (total % 500 == 0){
    cout << "Yes" << endl;
  }else if (total % 500 < coin1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3584
n = int(input())
#エラトステネスの篩（素数列挙）さらに合成数をふるい落とした素数を記録
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
    if is_prime[i] != True:
        continue
    for j in range(i * 2, n + 1, i):
        is_prime[j] = i



def factorization3(l):
    #素因数分解で、余計な素数を探索せずに済む！
    num = 1
    temp = l 
    
    while is_prime[temp] != True and temp != 1:
        k = is_prime[temp]
        cnt=0
        while temp % k == 0:
            cnt+=1
            temp //= k
        num *= (cnt+1)

    if temp!=1:
        num *= 2

    if num == 1:
        num *= 2

    return num
#ここまでの計算量はO(NloglogN(前処理) + logN(実際の分解))

total = 1
for x in range(2,n):
  y = factorization3(x)
  total += y
print(total)  
    
  

Measured memory_bytes: 16708
import java.util.Scanner;

public class Main{

	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int k = scan.nextInt();

		// System.out.println(a);
		// System.out.println(b);
		// System.out.println(c);

		// int one[]=new int[a];
		// int zero[]=new int[b];
		// int minus[]=new int[c];
		int anser = 0;

		int k1 = 0;
		int k2 = 0;
		//int k3 = 0;

		if(k>a || k==a){
		for(int i=0; i<a; i++){
			anser++;
		}
		k1 = k-a;
	}else if(a>k){
		for(int i=0; i<k; i++){
			anser++;
		}
		k1 = 0;
	}

		if(k1>b || k1==b){
		for(int i=0; i<b; i++){
			anser = anser + 0;
		}
		k2 = k1-b;
	}
		for(int i=0; i<k2; i++){
			anser =anser -1;
	}
		System.out.println(anser);
	}
}

Measured memory_bytes: 27032
#include<cstdio>
#include<algorithm>
using namespace std;
char p[201000];
int n, a, b, c, d, S[201000], w[201000];
int main() {
	int i;
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	scanf("%s", p+1);
	for (i = 1; i <= n; i++) {
		if (p[i] == '#')w[i] = 1;
		S[i] = S[i - 1] + w[i];
	}
	for (i = 1; i < n; i++) {
		if (w[i] && w[i + 1]) {
			if (a <= i && i + 1 <= c) {
				puts("No");
				return 0;
			}
			if (b <= i && i + 1 <= d) {
				puts("No");
				return 0;
			}
		}
	}
	if (c <= d) {
		puts("Yes");
		return 0;
	}
	for (i = b; i <= d; i++) {
		if (!w[i - 1] && !w[i] && !w[i + 1]) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 1920
N,M=map(int,input().split())
INF = 10**5
D=[[INF]*N for _ in range(N)]
for i in range(N):
  D[i][i]=0
path=[]
for i in range(M):
  a,b,c = map(int,input().split())
  D[a-1][b-1]=c
  D[b-1][a-1]=c
  path.append([a-1,b-1,c])
for k in range(N):
  for i in range(N-1):
    for j in range(i+1,N):
      D[i][j]=min(D[i][j],D[i][k]+D[j][k])
      D[j][i]=D[i][j]
ans=0
for a,b,c in path:
  if D[a][b]<c:
    ans+=1
print(ans)


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

using namespace std;

typedef long long int64;

inline int64 modPow(int64 x, int64 n, int64 mod)
{
  if(n == 0) return (1);
  int64 ret = modPow(x, n >> 1, mod);
  (ret *= ret) %= mod;
  if(n & 1) (ret *= x) %= mod;
  return (ret);
}

inline int64 modInv(int64 a, int64 mod)
{
  return (modPow(a, mod - 2, mod));
}

int a();

int b();

int c();


string T;
int64 mod, now;


int c()
{
  if(T[now] == '(') {
    ++now;
    auto get = a();
    ++now;
    return (get);
  }
  int get = 0;
  while(isdigit(T[now])) (get = get * 10 + T[now++] - '0');
  return (get);
}

int b()
{
  auto get = c();
  while(T[now] == '*' || T[now] == '/') {
    char op = T[now++];
    auto res = c();
    if(op == '*') (get *= res) %= mod;
    else if(res == 0) throw 0;
    else (get *= modInv(res, mod)) %= mod;
  }
  return (get);
}

int a()
{
  auto get = b();
  while(T[now] == '+' || T[now] == '-') {
    char op = T[now++];
    auto res = b();
    if(op == '+') (get += res) %= mod;
    else (get += mod - res) %= mod;
  }
  return (get);
}

int main()
{
  while(getline(cin, T), T != "0:") {
    T.erase(remove(begin(T), end(T), ' '), end(T));
    int64 ptr = 0;
    mod = 0;
    while(T[ptr] != ':') mod = mod * 10 + T[ptr++] - '0';
    T = T.substr(++ptr);
    try {
      now = 0;
      auto get = a();
      cout << T << " = " << get << " (mod " << mod << ")" << endl;
    } catch(int e) {
      cout << "NG" << endl;
    }
  }
}

Measured memory_bytes: 3276
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = 5;
    let mut seq = vec![0; n];
    let mut ans = 0;
    let mut minimum_remainder = 10;
    for i in 0..n {
        seq[i] = read::<usize>();
        ans += (seq[i] + 9) / 10 * 10;
        if seq[i] % 10 != 0 {
            minimum_remainder = std::cmp::min(minimum_remainder, seq[i] % 10);
        }
    }
    ans -= 10 - minimum_remainder;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<climits>
#include<cstring>

using namespace std;

char num[12];
int upper;
int len=12;
int in;
int main () {

  while ( true ) {
    cin >> in;

    if ( in == 0 )
      break;


    upper = 0;
    
    bool carry = false;
    for ( int i=0; i<len; i++ ) {
      num[i] = 0;
    }

    for ( int i=11; i>=0; i-- ) {
      
      num[i] = in%8+'0';
      in = in/8;
    }
  
    int count = 0;
    while ( num[count] == '0' )
      count++;
  

    for ( int i=count;i <len; i++ ) {
      if ( num[i] == '4' )
	cout << '5';
      else if ( num[i] >'4' )
	cout << (char)(num[i]+2);
      else
	cout << num[i];
    }
    cout << endl;
  }

}

Measured memory_bytes: 852
#include <cmath>
#include <vector>
#include <algorithm>
#include <iostream>
 
using namespace std;

//double???2?¬????????????????
struct vec{
    long double x,y;
    vec(double x, double y): x(x), y(y){};
    //eps??????????????´???????????¨
    inline double add(double a, double b){
        return abs(a+b)<(1e-10)*(abs(a)+abs(b)) ? 0.0 : a+b;
    }
    vec operator-(vec b){
        return vec(add(x,-b.x),add(y,-b.y));
    }
    vec operator+(vec b){
        return vec(add(x,b.x),add(y,b.y));
    }
    vec operator*(long double d){
        return vec(x*d,y*d);
    }
    bool operator==(vec b){
        return x==b.x&&y==b.y;
    }
    bool operator!=(vec b){
        return x!=b.x||y!=b.y;
    }
    bool operator<(const vec&r) const{
    return this->x==r.x?this->y<r.y:this->x<r.x;
    }
    long double dot(vec v){//??????
        return add(x*v.x,y*v.y);
    }
    long double cross(vec v){//??????
        return add(x*v.y,-y*v.x);
    }
    long double norm(){//?????????
        return hypot(x,y);
    }
};

//????????¢??°CCW
int ccw(vec& a, vec& b, vec& c){
    vec ab = b-a, ac = c-a;
    double o = ab.cross(ac);
    if(o>0) return 1; //CCW
    if(o<0) return -1; //CW
    if(ab.dot(ac)<0){
        return 2; //C-A-B
    }else{
        if(ab.dot(ab)<ac.dot(ac)){
            return -2; //A-B-C
        }else{
            return 0; //A-C-B
        }
    }
}

//??????
vector<vec> convex_hull(vector<vec>& V){
    vector<vec> C;
    sort(V.begin(),V.end(),[](const vec& a, const vec& b){return a.y==b.y ? a.x < b.x : a.y< b.y;});
    //?????´
    for(int i=0; i<V.size(); i++){
        vec v = V[i];
        while(C.size()>=2&&(v-C[C.size()-2]).cross(C.back()-C[C.size()-2])>0) C.pop_back();
        C.push_back(v);
    }
    //?????´
    for(int i=V.size()-2; i>=0; i--){
        vec v = V[i];
        while(C.size()>=2&&(v-C[C.size()-2]).cross(C.back()-C[C.size()-2])>0) C.pop_back();
        C.push_back(v);
    }
    C.pop_back();
    return C;
}
 
int main(){
    int n;
    cin >> n;
    vector<vec> V,C;
    while(n--){
        int x,y;
        cin>>x>>y;
        V.push_back(vec(x,y));
    }
    C=convex_hull(V);
    cout << C.size() << endl;
    for(auto& i : C) cout << i.x << " " << i.y << endl;
    return 0;
}

Measured memory_bytes: 11368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(k<e-a) cout << ":(" << endl;
    else cout << "Yay!" << endl;



}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(string& s) {
        const int N = 2019;
        vector<long long> dp(N, 0);
        vector<long long> ndp(N, 0);
        int n = s.length();
        long long res = 0;
        for (int i = 0; i < n; ++i) {
            int d = s[i] - '0';
            dp[0] += 1;
            fill(ndp.begin(), ndp.end(), 0);
            for (int j = 0; j < N; ++j) {
                if (dp[j] == 0) {
                    continue;
                }
                // cout << i << " " << j << " " << dp[j] << endl;
                int nj = (j << 3) + (j << 1) + d;
                // int nj = j * 10 + d;
                nj %= N;
                ndp[nj] += dp[j];
            }
            swap(ndp, dp);
            res += dp[0];
        }

        
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    Solution sol;
    cout << sol.solve(s) << "\n";

    return 0;
}

Measured memory_bytes: 3772
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N ;
    cin >> N ;
    int a[2];
    a[0] = N % 10 ;
    a[1] = (N - a[0])/10 ;
    

    bool c = false ;
    if(a[0] == 9){
        c = true ;
    }else if(a[1]== 9 ){
        c = true ;
    }

    if(c == true){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl ;
    }
    return 0;
}

Measured memory_bytes: 256
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)
	x, y := iScan(), iScan()
	if x*(y-1)%y == 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(x * (y - 1))
	}
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

struct Bulb
{
	set<int> swich;
	int m;
};

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m; cin>>n>>m;
	vector<Bulb> vb(m);
	For(i,0,m-1)
	{
		int t; cin>>t;
		For(j,1,t)
		{
			int tmp; cin>>tmp;
			vb[i].swich.emplace(tmp-1);
		}
	}
	For(i,0,m-1) cin>>vb[i].m;
	int ans=0;
	For(i,0,pow(2,n)-1)
	{
		For(j,0,m-1)
		{
			int t=i,cnt=0;
			For(k,0,n-1)
			{
				if(t%2==1 && vb[j].swich.count(k)) cnt++;
				t/=2;
			}
			if(cnt%2!=vb[j].m) goto FAIL;
		}
		ans++;
		FAIL:;
	}
	cout<<ans<<"\n";
	return 0;
}















Measured memory_bytes: 512