akhauriyash/Code-Regression huggingface dataset:
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    s = input().strip()
    for i in range(1, len(s)):
        if s[i-1] == s[i]:
            return f'{i} {i+1}'
        if i > 1 and s[i-2] == s[i]:
            return f'{i-1} {i+1}'
    return '-1 -1'


if __name__ == '__main__':
    print(solve())


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

using namespace std;
typedef long long ll;
const int MAXN = 1e3 + 5;
const int MAXD = 1e6 + 5;
const int MOD = 1e9 + 7;


int main() {

ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

int a,b;
cin >> a >> b;
cout << a * b;


}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const ll INF = (ll)1 << 60;

int main() {
    int N,Y;
    cin >> N >> Y;
    int ans[3] = {-1, -1, -1};
    rep(i, N+1) {
        rep(j, N+1) {
            int m = (Y-10000*i-5000*j);
            if (m%1000==0 && m >= 0 && i+j+m/1000 == N) {
                ans[0] = i, ans[1] = j, ans[2] = m/1000;
            }
        }
    }
    cout << ans[0]<< ' ' << ans[1]<< ' ' << ans[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int try(long n, long div){
	return (n % div) ? (n % div == 1) : try(n/div, div);
}

int main(void){
	long n;
	int count = 0;

	scanf("%ld", &n);

	for(long i=1; i*i <= n; i++) {
		if((n-1) % i == 0) {
			count++;
			if(i != (n-1) / i)
				count++;
		}
		if(n % i == 0) {
			if(i != 1 && try(n, i))
				count++;
			if(i != n / i && try(n, n/i))
				count++;
		}
	}
	count--;
	printf("%d", count);

	return 0;
}


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

int main() {
    int d, n;
    cin >> d >> n;
    int ans;
    if (n == 100) {
        ans = 101 * pow(100, d);
    } else {
        ans = n * pow(100, d);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3756
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, A, B; cin >> n >> A >> B;
  ++n;
  ll ans = n;
  ll rest = n-A;
  if (rest >= 0) {
    ll t = rest/2;
    ll sum = A + (B-A) * t;
    rest -= t * 2;
    sum += rest;
    chmax(ans, sum);
  }
  cout << ans << endl;
}


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 D = sc.nextInt();
		int X = sc.nextInt();
		int[] A = new int[N];
		for (int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}
		int res = X;
		for (int j=0; j<N; j++) {
			for (int i=1; i<=D; i++) {
				if ((i-1)%A[j] == 0) {
					res++;
				}
			}
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int N, K;
int a[110];
int dp[100010];

int main() {
    cin >> N >> K;
    rep(i, N) cin >> a[i];
    memset(dp, 0, sizeof(dp));

    for (int i = 1; i <= K; i++) {
        int f = 0;
        for (int j = 0; j < N; j++) {
            if (i >= a[j] && !dp[i - a[j]]) {
                f = 1;
                break;
            }
        }
        if (f) dp[i] = 1;
    }
    cout << (dp[K] ? "First" : "Second") << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int fnc(string s,int i,int l)
{
	int j=i;
	for(j=i;j<l;j++)
	{
		if(s[j]==s[l-1-j])
		continue;
		return 0;
	}
	return 1;
}
int main()
{
 string s;
 cin>>s;
 if(fnc(s,0,s.length())==1 && fnc(s,0,(s.length()-1)/2)==1 && fnc(s,(s.length()-1)/2+1,s.length())==1)
 cout<<"Yes"<<endl;
 else
 cout<<"No"<<endl;
 return 0;
}


Measured memory_bytes: 256
program main
  integer k, a, b
  read (*, *) k, a, b
  
  if (a - a / k * k == 0) then
    write (*, *) "OK"
    stop
  endif
  
  if (b - b / k * k == 0) then
    write (*, *) "OK"
    stop
  endif
  
  if (b / k - a / k > 0) then
    write (*, *) "OK"
    stop
  endif
  
  write (*, *) "NG"
end program main


Measured memory_bytes: 2856
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	double a[200000],maxe=0,max2=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]+=i*0.000001;
		maxe=max(maxe,a[i]);
	}
	for(int i=0;i<n;i++)
		if(a[i]!=maxe)
			max2=max(max2,a[i]);
	for(int i=0;i<n;i++)
		cout<<int(a[i]==maxe?max2:maxe)<<endl;

}


Measured memory_bytes: 3200
import math


n, d = map(int, input().split())
x = []
for i in range(n):
    x.append(list(map(int, input().split())))

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        y = 0
        for k in range(d):
            y += (x[i][k] - x[j][k])**2

        y = math.sqrt(y)
        if y.is_integer():
            ans += 1
print(ans)


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

int main(){
    string s, t;
    cin >> s >> t;
    string ans = "Yes";
    for (int i = 0; i < s.size(); i++){
        if(s.at(i) == t.at(i)){
            continue;
        }
        else{
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n, i;
  cin >> n;
  double x;
  string u;
  double sum = 0;
  double rate = 380000;
  for (i = 0; i < n; i++) {
    cin >> x >> u;
    sum += (u == "JPY") ? x : (x*rate);
  }
  cout << sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination MOD prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint p(int n, int k) {
        return fact[n]*ifact[n-k];
    }
} comb(10000007);
// comb(5, 2) → 10, comb.p(5, 2) → 20
// comb.fact[4] → 24, 2のN乗 → mint(2).pow(N)

const int MAX_A = 3003;
mint dp[MAX_A+1];

int main() {
    // ApplePen、ansにその都度足していく
    // 左を決める
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    mint ans = 0;
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
        int a = A[i];
        mint prev[MAX_A+1];
        memcpy(prev, dp, sizeof(dp)); // 左端が既に決まっていて、A[i]を集合の要素として選ばないもの
        for (int j = 0; j < min(S+1, MAX_A); j++) {
            dp[j] += prev[j]; // 左端が既に決まっていて、A[i]を集合の要素として選ぶ
            if (j + a <= min(S+1, MAX_A)) {
                dp[j+a] += prev[j]; // 左端がA[i]でA[i]を足す
            }
        }
    }
    cout << dp[S] << '\n';
    return 0;
}

Measured memory_bytes: 159360
import qualified Data.IntSet as S
import Data.Char
 
div1 x y = let (d,m) = divMod x y in d + signum m
 
unionMap f s = S.foldr (\e acc -> S.union acc (f e)) S.empty s
 
main = do
 [h,w,k] <- map read . words <$> getLine
 m <- filter isPrint <$> getContents
 let ixm = zip [(i,j) | i<-[1..h], j<-[1..w]] m
 let (si,sj) = fst (head (filter ((=='S') . snd) ixm))
 let cand ((i,j),c) = elem c ".S" && abs (si-i) + abs (sj-j) <= k
 let ps = S.fromDistinctAscList (map ((\(i,j) -> i*1000+j) . fst) (filter cand ixm))
 print (escape h w k ps (1000*si + sj))
 
type Height = Int
type Width = Int
type Opened = S.IntSet
type Point = Int
type Init = Point
 
escape :: Height -> Width -> Int -> Opened -> Init -> Int
escape h w k ps s = minimum (map (nmagic h w k) (S.elems (reachable k ps s)))
 
nmagic :: Height -> Width -> Int -> Point -> Int
nmagic h w k ij = minimum (map (flip div1 k) [i-1,h-i,j-1,w-j]) + 1
 where (i,j) = divMod ij 1000
 
reachable :: Int -> Opened -> Point -> Opened
reachable k ps s = reachable' k (S.singleton s) (S.singleton s)
 where
  reachable' 0 acc _ = acc
  reachable' k' acc b = reachable' (k'-1) (S.union acc next) (S.difference next acc)
   where next = unionMap (neighbor ps) b

neighbor :: Opened -> Point -> Opened
neighbor ps ij = S.fromList (filter (flip S.member ps) [ij,ij+1000,ij-1000,ij+1,ij-1])


Measured memory_bytes: 55676
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

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




Measured memory_bytes: 3636
A,B,C,K=map(int,input().split())
#Aは1 Bは0　Cは-1 枚数はK

AA = 0
BB = 0
CC = 0
Nokori = K 
if Nokori >= A:
    AA = A
    Nokori = Nokori - A
elif Nokori == 0:
    pass
else:
    AA = Nokori
    Nokori = 0
if Nokori >= B:
    BB = B
    Nokori = Nokori - B
elif Nokori == 0:
    pass
else:
    BB = Nokori
    Nokori = 0
if Nokori >= C:
    CC = C
elif Nokori == 0:
  pass
else:
    CC = Nokori
print(AA*1+BB*0+CC*(-1))

Measured memory_bytes: 9208
import sys


def main():
    n = int(sys.stdin.readline())
    i = 1
    while i <= n:
        x = i
        if x % 3 == 0:
            print(' {}'.format(i), end='')
        else:
            while x > 1:
                if int(x) % 10 == 3:
                    print(' {}'.format(i), end='')
                    break
                x /= 10
        i += 1
    print()
    return


if __name__ == '__main__':
    main()



Measured memory_bytes: 5888
s = input()
ans = ""
for i in range(len(s)-1):
    if s[i] == "?":
        if i != 0 and ans[i-1] == "P":
            ans += "D"
        elif s[i+1] == "D":
            ans += "P"
        elif s[i+1] == "P":
            ans += "D"
        else:
            ans += "P"
    else:
        ans += s[i]

if s[-1] == "?":
    ans += "D"
else:
    ans += s[-1]

print(ans)


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

int main() 
{
      int n,k;
      cin>>n>>k;
      int arr[n];
      for(int i=0; i<n;i++)
      cin>>arr[i];
      vector<bool>dp(k+1); //dp[i] tells if with pile of height i is equal to true
       
       for(int i=0; i<=k; i++)
       {
         for(int j=0; j<n ; j++)
         {
              if(i-arr[j]>=0 && dp[i-arr[j]]==false)
                dp[i]=true;
         }
       }
       if(dp[k])
        cout<<"First"<<endl;
        else
        cout<<"Second"<<endl;
       
        return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=1e9+7;
LL n,h,d,fac[1000010],f[1000010],s[1000010];
int main()
{
	scanf("%lld %lld %lld",&n,&h,&d);
	fac[0]=fac[1]=1;
	for(LL i=2;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	f[1]=s[1]=fac[n];
	LL p=0;for(LL i=0;i<=n;i++) (p+=fac[i])%=mod;
	for(LL i=2;i<=d;i++) s[i]=(s[i-1]+(f[i]=f[i-1]*p%mod))%mod;
	for(LL i=d+1;i<=h;i++)
	{
		f[i]=(s[i-1]-s[i-d-1])%mod*(p-1)%mod;
		s[i]=(s[i-1]+f[i])%mod;
	}
	printf("%lld",(f[h]+mod)%mod);
}

Measured memory_bytes: 23680
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,k;
	
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
	
	if(e-a>k)
		printf(":(");
	else
		printf("Yay!");
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  S+='R';
  int L=S.size();
  vector<int> C(L-1);
  int rcnt=0; int lcnt=0; int spot=0;
  for(int i=0; i<L-1; i++){
    if(S.at(i)=='R' && S.at(i+1)=='R'){
      C.at(i)=0;
      rcnt++;
    }
    if(S.at(i)=='L' && S.at(i+1)=='L'){
      C.at(i)=0;
      lcnt++;
    }
    if(S.at(i)=='R' && S.at(i+1)=='L'){
      spot=i;
      rcnt++;
    }
    if(S.at(i)=='L' && S.at(i+1)=='R'){
      lcnt++;
      if((rcnt+lcnt)%2==0){
        C.at(spot)=(rcnt+lcnt)/2;
        C.at(spot+1)=(rcnt+lcnt)/2;
      }
      else if(rcnt%2!=0){
        C.at(spot)=(rcnt+lcnt)/2+1;
        C.at(spot+1)=(rcnt+lcnt)/2;
      }
      else{
        C.at(spot)=(rcnt+lcnt)/2;
        C.at(spot+1)=(rcnt+lcnt)/2+1;
      }
      rcnt=0;
      lcnt=0;
    }
  }
  for(int i=0; i<L-1; i++) cout << C.at(i) << ' ';
  cout << endl;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
ps = list(map(int,input().split()))

window = [sum(ps[:k])]
for i in range(n-k):
  n = window[i]
  m = n - ps[i] + ps[i+k]
  window.append(m)


print((max(window)-1)*0.5+1+0.5*(k-1))

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;

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

    sort(a.begin(), a.end());

    ll ans = a[0];

    for (ll i = 1; i < n; ++i) {
        if (ans == 0) {
            cout << ans << endl;
            return 0;
        }

        if ((ll)2e18 / ans < a[i]) {
            cout << -1 << endl;
            return 0;
        }

        ans *= a[i];

        if (ans > (ll)1e18) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
}

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

int main(void) {
	int tmp;
	int n,i;
	
	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		int  a=0,b=0,c=0;
	
		scanf("%d %d %d", &a, &b, &c);
				
		if(a<b) {tmp=a; a=b; b=tmp;}
		if(a<c) {tmp=a; a=c; c=tmp;}	
		
		
		
		if( a == sqrt(b*b + c*c) ) printf("YES\n");
		else printf("NO\n");
		
	}
	
	return 0;
}

Measured memory_bytes: 580
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1007;

void nope()
{
	printf("Impossible\n");
	exit(0);
}

void tak()
{
	printf("Possible\n");
}

int n;
char wcz[nax];
int dasie[nax];

vector <pii> wek;

vector <pii> operator + (vector <pii> a, vector <pii> b)
{
	if (a.empty())
		return b;
	if (b.empty())
		return a;
	a.pop_back();
	for (pii i : b)
		a.push_back(i);
	return a;
}

vector <pii> odw(vector <pii> a)
{
	reverse(a.begin(), a.end());
	return a;
}

vector <pii> daj(int x)
{
	vector <pii> ret;
	ret.push_back({0, 0});
	for (int i=0; i<=x; i++)
		ret.push_back({i, 1});
	ret.push_back({x, 0});
	ret.push_back({x+1, 0});
	for (int i=x+1; i>=0; i--)
		ret.push_back({i, 1});
	ret.push_back({0, 0});
	return ret;
}

vector <pii> zdobo(int mas)
{
	int x=__builtin_ctz(mas);
	if (__builtin_popcount(mas)==1)
		return daj(x);
	if (__builtin_popcount(mas)==2)
	{
		int y=__builtin_ctz(mas^(1<<x));
		auto xx=daj(x);
		auto yy=daj(y);
		return xx+yy+odw(xx)+odw(yy);
	}
	vector <pii> ret=daj(x);
	auto wez=zdobo(mas^(1<<x));
	return wez+ret+odw(wez)+odw(ret);
}

int main()
{
	scanf("%d", &n);
	scanf("%s", wcz);
	for (int i=0; i<(1<<n); i++)
		dasie[i]=wcz[i]-'0';
	for (int i=0; i<(1<<n); i++)
	{
		for (int j=0; j<(1<<n); j++)
		{
			if ((i&j)==i && dasie[j] && !dasie[i])
			{
				nope();
			}
		}
	}
	tak();
	wek={{0, 0}};
	for (int i=0; i<(1<<n); i++)
	{
		if (dasie[i])
			continue;
		auto x=zdobo(i);
		wek=wek+x;
	}
	printf("%d\n", (int)wek.size()-1);
	for (pii i : wek)
		printf("%d %d\n", i.first, i.second);
	return 0;
}


Measured memory_bytes: 3912
L, R = map(int, input().split())

diff = R//2019 - L//2019

if L % 2019 == 0:
    answer = 0
elif diff > 0:
    answer = 0
else:
    _min = 2019
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            _min = min(_min, (i * j) % 2019)
    answer = _min

print(answer)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
int main(){
    int n, p = 1, ans = 0;
    std::string s;
    std::cin >> n >> s;
    for (int i = 0; i < n; ++i){
        for (; s.substr(p, n-p).find(s.substr(i, p-i)) != std::string::npos; ++p){
            ans = std::max(ans, p - i);
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;  // 1e9+7
const int INF = 1050000000;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  vector<string> s(N);
  unordered_map<string, int> mp;
  REP(i, N) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
    mp[s[i]]++;
  }
  ll ans = 0;
  for (auto tmp : mp) {
    ll x = tmp.second;
    ans += x * (x - 1) / 2;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 16036
S = input()
N = int(len(S))

S_list = list(S)
reversed_S = list(reversed(S_list))

kore = S_list[0:int((N-1)/2-1)+1]
sore = list(reversed(kore))

dore = S_list[int((N+3)/2-1):int(N-1)+1]
kusa = list(reversed(dore))

if S_list == reversed_S and kore == sore and kore == kusa:
    print("Yes")
else:
    print("No")

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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef long double ld;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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





int main(){

    bool flag=false;
    ll ans=0,sum=0;

    double D,T,S;
    cin>>D>>T>>S;
    //cout <<fixed<<setprecision(16)<< << endl;

    if(T >= (D/S))cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){  
    int n;
    cin>>n;
    vector<int>a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        a[i]--;
    }
    vector<int>b(n);
    for (int i = 0; i < n; i++)
    {
        cin>>b[i];
    }
    vector<int>c(n-1);
    for (int i = 0; i < n-1; i++)
    {
        cin>>c[i];
    }
    int ans=b[a[0]];
    for (int i = 1; i < n; i++)
    {
        ans+=b[a[i]];
        if (i!=0 && a[i]==a[i-1]+1)
        {
            ans+=c[a[i-1]];
        }
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
  static void Main(string[] args)
  {
    var line = Console.ReadLine();
    var lineInts = line.Split(' ').Select(s => Int64.Parse(s)).ToArray();
    var x = lineInts[0];
    var y = lineInts[1];

    Console.WriteLine(x + y / 2);
  }
}


Measured memory_bytes: 13268
N = gets.to_i
a = gets.split(' ').map(&:to_i)

def sum(arr)
  arr.inject(&:+)
end

ans = 10**10
su = 0
ara = a.inject(&:+)
N.times do |i|
  break if i == N-1
  su += a[i]
  ara -= a[i]

  cal = (su-ara).abs
  ans = [ans, cal].min

  break if ans == 0
end

p ans

Measured memory_bytes: 19204
N = int(input())
P = list(map(int,input().split()))

ans = 0
minmemo = [10**6]*(N+1)
for i in range(1,N+1):
    minmemo[i] = min(P[i-1],minmemo[i-1])
    if minmemo[i] >= P[i-1]:
        ans += 1
        
print(ans)

Measured memory_bytes: 26012
#include <set>
#include <iostream>
#include <cstdio>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

using namespace std;

const int mod = 1000000007;

int h, w;
int g[50][16];
int debug[50][16];

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

void debug_print(){
  REP(i, h){
    REP(j, w) printf("%d ", debug[i][j]);
    printf("   ");
    REP(j, w) printf("%d ", g[i][j]);
    puts("");
  }
}

void process(int y, int x, bool put){
  int p = put ? 1 : 2;

  // debug[y][x] = put ? 1 : 0;

  REP(i,8){
    int yy = y + dy[i];
    int xx = x + dx[i];

    if(ISIN(xx, yy, w, h)){
      g[yy][xx] = (g[yy][xx] + p) % 3;
    }
  }
}

bool check(int bw){
  REP(i,2) if(h - 1 - i >= 0){
    int st = ((h - 1 - i) % 2 + (bw ^ 1)) % 2;
    for(int j = st; j < w; j += 2){
      if(g[h - 1 - i][j] != 0) return false;
    }
  }
  return true;
}

int solve(int y, int x, int bw){
  if(y == h){
    bool ok = check(bw);
    // printf("debug(%d): %d\n", bw, ok); debug_print(); puts("");
    return ok ? 1 : 0;
  }

  assert((x + y) % 2 == bw);

  int yy = y;
  int xx = x + 2;

  int ret = 0;

  if(xx >= w){
    yy = y + 1;
    xx = (yy % 2 + bw) % 2;
  }

  bool put    = true;
  bool notput = true;

  if(y > 1 && x > 0){
    if(g[y-2][x-1] == 0){
      put = false;
    }else if(g[y-2][x-1] == 1){
      put = notput = false;
    }else{
      notput = false;
    }
  }

  if(y > 1 && x == w - 2){
    if(g[y-2][x+1] == 0){
      put = false;
    }else if(g[y-2][x+1] == 1){
      put = notput = false;
    }else{
      notput = false;
    }
  }

  if(notput){
    ret += solve(yy, xx, bw); ret %= mod;
  }
  if(put){
    process(y, x, true);
    ret += solve(yy, xx, bw); ret %= mod;
    process(y, x, false);
  }

  return ret;
}

int main(){
  h = getInt();
  w = getInt();

  REP(i,h) REP(j,w)
    g[i][j] = getInt();

  if(h < w){
    REP(i,w) REP(j,i)
      swap(g[i][j], g[j][i]);
    swap(h, w);
  }


  if(w == 1){
    bool ok = true;
    REP(i,h) if(g[i][0] != 0) ok = false;
    if(ok){
      int ans = 1;
      REP(i,h) ans = (ans * 2) % mod;
      printf("%d\n", ans);
    }else{
      puts("0");
    }
    return 0;
  }

  int black = solve(0, 0, 0);
  int white = (w == 1 ? solve(1, 0, 1) : solve(0, 1, 1));
  int ans   = (((long long)white) * black) % mod;

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = unsigned long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;
int main() {
  string s;
  in(s);
  int N = sz(s);
  vector<char> ans ;
  int cnt = 0;
  rep(i,N){
    if(s[i]!='B'){
      ans.pb(s[i]);
    cnt++;
    }
      else if(cnt!=0&&s[i]=='B') {
        ans.pop_back();
     cnt--;
      }
      }
  rep(i,cnt) cout <<ans[i];
  cout <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(k,nu)    for(int i=k; i<nu;  i++)
#define rep2(k,n)   for(int j=k; j<n;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define ll long long
#define pb pop_back
template<typename T> inline void chMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return ((a+b-1)/b);}
const double PI = acos(-1);

int main(){
    int s, w; cin >> s >> w;
    cout << (w>=s? "unsafe" : "safe") << endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3544
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int64_t separate = -1;
  int64_t sum_values = 0;
  for (int64_t i = 0; i <= N - 2; ++i) {
    sum_values += A[i];
    if (sum_values * 2 < A[i + 1]) {
      separate = i;
    }
  }
  cout << N - separate - 1 << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int x = sc.nextInt();
		
		if (500 * k >= x) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
/*--ILRS-- sr4saurabh  */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define popb pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=10000000+6;
#define M_PI           3.14159265358979323846
//--------------------------------------------


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





//============================================
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
       freopen ("INPUT.txt" , "r" , stdin);
       freopen ("OUTPUT.txt", "w" , stdout);
    #endif

	//THE WATER WAS DEEP, I DROWNED AND THEN CAME FLOATING UP,DEAD!!

	
	       string st;
         cin>>st;
         ll ans = 0;

         if(st[0]==st[1] && st[1]==st[2] && st[0]=='R')
          ans = 3;
          else
          if((st[0]==st[1] || st[1]==st[2]) && st[1]=='R')
            ans = 2;
          else
            if(st[0] == 'R' || st[1]=='R' || st[2]=='R')
              ans = 1;
          else
            ans = 0;


          cout<<ans<<'\n';






return 0;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

struct swimmer{
	double pos;
	//double prepos;
	int t;
	int rest_loop;
	int lane;
};

swimmer ss[100];
int order[100];

bool finish(int &n){
	int cnt = 0;
	rep(i, n) if(ss[i].rest_loop){
		cnt++;
	}
	if(cnt == 0) return true;
	n = cnt;
	return false;
}

void move(int n){
	/*
	cout << "************************" << endl;
	cout << "begin" << endl;
	rep(i, n)cout << ss[i].pos << " " << ss[i].rest_loop << " " << ss[i].lane << endl;
	cout << "***********************" << endl;
	*/
	double m[2] = {1.0, 1.0};
	rep(i, n) if(ss[i].rest_loop){
		//ss[i].prepos = ss[i].pos;
		ss[i].pos += 1.0 / ss[i].t;
	}
	rep(i, n){
		if(ss[i].rest_loop == 0) continue;
		if(ss[i].pos > m[ss[i].lane]){
			ss[i].pos = m[ss[i].lane];
		}else{
			m[ss[i].lane] = ss[i].pos;
		}
	}

	rep(i, n){
		if(ss[i].rest_loop == 0) continue;
		if(abs(ss[i].pos - 1.0) < EPS) {
			ss[i].pos = 0.0;
			if(ss[i].lane == 0){
				ss[i].lane = 1;
			}else{
				ss[i].lane = 0;
				ss[i].rest_loop--;
			}
		}
	}
	/*
	cout << "************************" << endl;
	cout << "end" << endl;
	rep(i, n)cout << ss[i].pos << " " << ss[i].rest_loop << " " << ss[i].lane << endl;
	cout << "***********************" << endl;
	*/
}

bool comp(const swimmer &s1, const swimmer &s2){
	if(s1.rest_loop == 0 || s2.rest_loop == 0) return s1.rest_loop > s2.rest_loop;
	else if(s1.lane != s2.lane) return s1.lane < s2.lane;
	else if(abs(s1.pos - s2.pos) < EPS){
		if(s1.pos < EPS && s2.pos < EPS) return s1.t < s2.t;
		else return s1.t > s2.t;
	}else{
		return s1.pos > s2.pos;
	}
}

int main(){
	int n;
	while(cin >> n && n){
		rep(i, n){
			cin >> ss[i].t >> ss[i].rest_loop;
			ss[i].lane = 0;
			ss[i].pos = 0.0;
		}


		int cnt = 0;
		sort(ss, ss + n, comp);
		while(true){
			if(finish(n)){
				cout << cnt << endl;
				break;
			}
			cnt++;
			move(n);
			sort(ss, ss + n, comp);
			assert(cnt < 800000);
		}
	}
	return 0;
}

Measured memory_bytes: 868
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        readonly static long mod = 1000000000 + 7;
        static long MAX = 10000000;
        static long[] fac = new long[MAX];
        static long[] finv = new long[MAX];
        static long[] inv = new long[MAX];

        static void COMinit()
        {
            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for (int i = 2; i < MAX; i++)
            {
                fac[i] = fac[i - 1] * i % mod;
                inv[i] = mod - inv[mod % i] * (mod / i) % mod;
                finv[i] = finv[i - 1] * inv[i] % mod;
            }
        }

        static long Combination(int n ,int k)
        {
            if (n < k) return 0;
            if (n < 0 || k < 0) return 0;
            return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
        }

        static void Main(string[] args)
        {
            COMinit();
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int x = s[0];
            int y = s[1];
            long sum = x + y;
            if (sum % 3 != 0)
            {
                WriteLine(0);
                return;
            }
            int n = ((2 * x) - y) / 3;
            int m = -((x - (2 * y)) / 3);
            WriteLine(Combination(n+m,n));
        }

        
    }
}


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

int main(){
  int n;
  while(cin >> n && n){
    int A=0,B=0;
    for(int i=0;i<n;i++){
      int a,b;
      cin >> a >> b;
      if(a > b) A += a + b;
      else if(a < b) B += a + b;
      else {
	A += a;
	B += b;
      }
    }
    cout << A << ' '<< B << endl;
  }
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main(){
  int a, b, c, x;cin>>a>>b>>c>>x;
  int cnt = 0;
  for(int i=0;i<=a;i++){for(int j=0;j<=b;j++){for(int k=0;k<=c;k++){if(500*i+100*j+50*k==x)cnt++;}}}
  cout<<cnt<<endl;
}


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

int main(){
	int a,b;
	cin>>a>>b;
	int c=16-a-b;
	
	if(b>a) swap(a,b);
	
	
	if(a<=b+c) cout<<"Yay!"<<endl;//a枚（多い方）の間の数aがb枚（少ない方）と残りc枚の合計より少なければよい。
	else cout<<":("<<endl;
	
  
	return 0;
}		

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

int main(){
    int N, M;
    cin >> N;
    if(N > 3){
        for(int i = 0; i * 4 <= N; i++){
            M = i * 4;
            for(int j = 0; M + j * 7 <= N; j++){
                if (M+j*7 == N){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }

    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
H = list(map(int,input().split()))

bad = {}

for i in range(M):
    A,B = map(int,input().split())
    if H[A-1] <= H[B-1]:
        bad[A] = 1
    if H[A-1] >= H[B-1]:
        bad[B] = 1

print(N-len(bad))        


Measured memory_bytes: 20108
import math
a,b,c=map(float,input().split())
h=b*math.sin(c/180.0*math.pi)
ad=a-b*math.cos(c/180.0*math.pi)
d=(h*h+ad*ad)**0.5
l = a + b + d
s = a * h / 2.0
print('{0:.6f}'.format(s))
print('{0:.6f}'.format(l))
print('{0:.6f}'.format(h))

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;


int n;
int c[maxn];
vector<int> g[maxn];
int siz[maxn];


ll ans[maxn];


// mp_to[c]: # of nodes trapped under to's subtree, where the root is color=c.
// size[to] - mp_to[c] is the # of nodes in the air gap between the to and a node with color=c.

void dfs(int at, int p, map<ll,ll>& mp) {
    siz[at]=1;
    int C = c[at];
    for (int to: g[at]) {
	if (to == p) continue;
	map<ll,ll> mp_to;
	dfs(to, at, mp_to);
	siz[at]+=siz[to];
	ll middle = siz[to]-mp_to[C];
	ans[C] -= (middle*(middle+1)/2);
	if (mp.size() < mp_to.size()) {
	    swap(mp, mp_to);
	}
	for (auto pr: mp_to) {
	    mp[pr.first] += pr.second;
	}
    }
    
    mp[C] = siz[at];
}

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

    
    cin>>n;
    for (int i=1; i<=n; i++) {
	cin>>c[i];
    }

    for (int i=0; i<n-1; i++) {
	int u,v; cin>>u>>v;
	g[u].push_back(v);
	g[v].push_back(u);
    }

    for (int i=1; i<=n; i++) {
	ans[i]=1ll*n*(n+1)/2;
    }

    map<ll,ll> mp;
    dfs(1,0,mp);

    for (int i=1; i<=n; i++) {
	ll top = n-mp[i];
	ans[i] -= (top*(top+1)/2);
    }

    for (int i=1; i<=n; i++) {
	cout<<ans[i]<<"\n";
    }
    
    
    return 0;
}


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

// 値が 0 であれば偽・それ以外は真

bool check_num(int n){
    // if (0 == n % 3){
    //     return 1;
    // } else {
    //     return 0;
    // }

    return (0 == n % 3);

    // int x = n;
    // while(x){
    //     if(0 == n % 3){
    //         return true;
    //     }
    //     x /= 10;
    // }
    // return false;
}

// void include3(int n){
bool include3(int n){
    // if (3 == n % 10){
    //     return 1;
    // } else {
    //     return 0;
    // }

    int x = n;
    while(x){
        if(3 == x % 10){
            return true;
        }
        x /= 10;
    }
    return false;

    // return (3 == n % 10);
}

int main(){
    int n;

    cin >> n;

    for(int i = 1; i <= n; i++){
        if(check_num(i) || include3(i)){
            if(1 != i){
                cout << " ";
            }
            cout << i;
        } else {
            // cout << 0;
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		int n  = scan.nextInt();
		while(n != 0){
			int sam = 0;
			for(int i = 0 ; i < n/4 ; i++){
				int t = scan.nextInt();
				sam += t;
			}
			System.out.println(sam);
			n = scan.nextInt();
		}
	}
}

Measured memory_bytes: 26272
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out = "";
    while (scanner.hasNext()) {
      int h = scanner.nextInt();
      int w = scanner.nextInt();
      scanner.nextLine();
      if (w == 0 && h == 0) {
        break;
      }
      String[][] f = new String[h][w];
      for (int row = 0; row < h; row++) {
        String line = scanner.nextLine();
        for (int col = 0; col < w; col++) {
          f[row][col] = line.substring(col, col + 1);
        }
      }

      for (int row = 0, col = 0, step = 0;;step++) {
        if (f[row][col].equals(".")) {
          out += String.format("%d %d\n", col, row);
          break;
        }
        if (step > w * h) {
          out += "LOOP\n";
          break;
        }
        if (f[row][col].equals(">")) {
          col++;
        } else if (f[row][col].equals("<")) {
          col--;
        } else if (f[row][col].equals("v")) {
          row++;
        } else if (f[row][col].equals("^")) {
          row--;
        }
      }

    }
    System.out.print(out);
  }
}

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

int N, A, B;
int main(){
    scanf("%d%d%d",&N,&A,&B);
    if(A>N || B>N) return !printf("-1\n");
    vector<int> v(N); for(int i=0;i<N;i++) v[i] = i+1;
    vector<int> ret;

    for(int i=0;i<A;i++){
        ret.push_back(v.back());
        v.pop_back();
    }
    reverse(ret.begin(),ret.end());

    int b = 1;
    while(!v.empty()){
        if(b>=B) return !printf("-1\n");
        int n = v.size();
        int x = b+1+n-B;
        if(x<=0) return !printf("-1\n");

        int cur = min(x, A);
        vector<int> tmp;
        for(int i=0;i<cur;i++){
            tmp.push_back(v.back());
            v.pop_back();
        }
        while(!tmp.empty()){
            ret.push_back(tmp.back());
            tmp.pop_back();
        }
        b++;
    }
    if(b!=B) return !printf("-1\n");

    for(int x:ret) printf("%d ", x);
    printf("\n");
}


Measured memory_bytes: 4668
use proconio::input;

#[proconio::fastout]
fn main() {
    input! {
        a: i64,
        b: i64,
        n: i64,
    }
    if n >= b {
        println!("{}", f(a, b, b - 1));
    } else {
        println!("{}", f(a, b, n));
    }
}

fn f(a: i64, b: i64, x: i64) -> i64 {
    ((a * x) / b) - a * (x / b)
}


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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BRobotArms {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<P> v(N);
        REP(i, N) {
            int x, l;
            cin >> x >> l;
            v[i] = {x + l, x - l};
        }
        sort(v.begin(), v.end());

        int f = -INF;
        int res = 0;
        REP(i, v.size()) {
            if (v[i].second >= f) {
                res++;
                f = v[i].first;
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BRobotArms solver;
    solver.solve(in, out);
    return 0;
}


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

int main(){
  ll N,x;
  cin >> N >> x;
  vector<ll> a(N);
  for(ll i=0;i<N;i++){
    cin >> a[i];
  }
  ll y=x;
  
  sort(a.begin(),a.end());
  
  ll ans=0;
  
  for(ll i=0;i<N;i++){
    x=x-a[i];
    ans++;
    
    if(x==0){
      break;
    }
    else if(x<0){
      ans=ans-1;
      break;
    }
  }
  
  ll sum;
  
  for(ll i=0;i<N;i++){
    sum=sum+a[i];
  }

    
  
  if(y>sum){
    cout << N-1 << endl;
  }
  
  else{  
    cout << ans << endl;
  }

}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    n = len(s)
    ss = "".join(s.replace("x", ""))
    if ss != ss[::-1]:
        print(-1)
        exit()

    res = 0
    left = 0
    right = n - 1
    while left <= right:
        if s[left] == s[right]:
            left += 1
            right -= 1
        else:
            if s[left] == "x":
                left += 1
            else:
                right -= 1
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()


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

void solve(long long A, long long B){
    cout << max({A+B, A-B, A*B}) << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
#define pii pair<ll,ll>
#define mkp make_pair
#define fi first
#define sc second
#define gc getchar
#define pb push_back
using namespace std;
const int N=1e6+10,mod=1e9+7;
typedef double db;

int n,frc[N],nv[N],ans;

inline void ad(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline int dc(int x,int y){x-=y;return x<0?x+mod:x;} 

inline int C(int n,int m)
{
	if(m<0 || m>n) return 0;
	if(n==m || m==0) return 1;
	return (ll)frc[n]*nv[m]%mod*(ll)nv[n-m]%mod;
}

int main(){
	int i,j,x;frc[0]=frc[1]=nv[0]=nv[1]=1;
    scanf("%d",&n);
    for(i=2;i<=n;++i) 
	  frc[i]=(ll)frc[i-1]*i%mod,
	  nv[i]=(ll)(mod-mod/i)*nv[mod%i]%mod;
	for(i=2;i<=n;++i) nv[i]=(ll)nv[i]*nv[i-1]%mod;
	ans=frc[--n];
	for(i=1;i<n;++i){
		ad(ans,(ll)dc(C(n,i),C(i-1,(i<<1)-n-1))*frc[i]%mod*(ll)frc[n-i]%mod);
	}
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 8064
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Trained?
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int as[MAX_N], ds[MAX_N];

/* subroutines */

/* main */

int main() {
  int n = 0;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) scanf("%d", &as[i]), as[i]--;

  fill(ds, ds + n, INF);

  int cur = 0;
  ds[cur] = 0;

  while (cur != 1) {
    int nxt = as[cur];
    if (ds[nxt] < INF) break;
    ds[nxt] = ds[cur] + 1;
    cur = nxt;
  }

  if (ds[1] >= INF) puts("-1");
  else printf("%d\n", ds[1]);
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long s;
  cin >> s;
  unordered_set<long> st;
  st.insert(s);
  long i = 2;
  while (true) {
    s = (s % 2 == 0) ? (s / 2) : (3 * s + 1);
    if (st.count(s) > 0) {
      cout << i << endl;
      return;
    }
    st.insert(s);
    i++;
  }
}

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


Measured memory_bytes: 256