akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(Int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(Int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using Int = long long;
using ll = long long;
using P = pair<Int,Int>;
using vi = vector<Int>;
using vvi = vector<vi>;
using vp = vector<P>;
using vvp = vector<vp>;

const Int INF = (1LL<<50);


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
  Int s = 0;
  rrep(i, N-1){
    A[i] += s;
    Int m = A[i] % B[i];
    if(m) s += B[i] - m;
  }
  cout << s << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
    scanf("%lld",&B[i]);
  }
  solve(N, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;


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


ll m = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



ll T[101];
int main() {
	int N;
	cin >> N;
	ll ans = 1;
	REP(i, N) {
		ll t;
		cin >> t;
		ans = lcm(ans, t);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
 
int main() {
 
  int long long N,K,t=0,i,j=0,a;
  int long long ans=0;
  
  cin >> N >> K;
  if (N<=K)
  {
    ans=0;
  }else{
  
  std::vector<int long long> H(N);
  for ( i = 0; i < N; i++)
  {
    cin >> a;
    H[i]=a;
    ans+=a;
  }
  sort(H.begin(), H.end() ,greater<>());
  for ( i = 0; i < K; i++)
  {
    ans-=H[i];
  }
  
 }
 
  printf ("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
using namespace std;
const int dy[]={-1,-1,0,0,1,1};
const int dx[]={-1,0,-1,1,0,1};
int main(){

	int n,t;
	const int base=150;
	const int MAX_P=301;
	while(cin>>t>>n&&!(t==0&&n==0)){
		bool passed[MAX_P][MAX_P];
		bool isArrival[2][MAX_P][MAX_P];
		bool obj[MAX_P][MAX_P];
		memset(isArrival,0,sizeof(isArrival));
		memset(obj,0,sizeof(obj));
		memset(passed,0,sizeof(passed));
		for(int i = 0; i < n; i++){
			int x,y;
			cin>>x>>y;
			obj[y+base][x+base]=true;
		}
		int sy,sx;
		cin>>sx>>sy;
		isArrival[0][sy+base][sx+base]=true;
		passed[sy+base][sx+base]=true;
		for(int l = 0; l < t; l++){
			for(int i = 0; i < MAX_P; i++){
				for(int j = 0; j < MAX_P; j++){
					if(isArrival[l%2][i][j]){
						for(int k = 0; k < 6; k++){
							int ny=i+dy[k];
							int nx=j+dx[k];
							if(!obj[ny][nx]){
								isArrival[(l+1)%2][ny][nx]=true;
								passed[ny][nx]=true;
							}
						}
						isArrival[l%2][i][j]=false;
					}
				}
			}
		}
		int cnt=0;
		for(int i = 0; i < MAX_P; i++){
			for(int j = 0; j < MAX_P; j++){
				if(passed[i][j])
					cnt++;
			}
		}
		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

int main(){
  int a,c[4]={};
  bool f=1;
  fr(i,6){cin>>a;c[--a]++;}
  sort(c,c+4);
  fr(i,2) f*=(c[i]==1);
  fr(i,2) f*=(c[i+2]==2);
  cout<<(f?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 1; i < 10; i++) {
			for(int j = 1; j < 10; j++) {
				list.add(i * j);
			}
		}
		if(list.contains(N)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 22484
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner s = new Scanner(System.in);
        long n = s.nextLong();
        
        long smallest = Long.MAX_VALUE;
        
        for (int i = 0; i < 5; i ++) {
            long in = s.nextLong();
            if (in < smallest)
                smallest = in;
        }
        
        long div;
        
        if (n % smallest == 0)
            div = n / smallest;
        else
            div = n / smallest + 1;
        
        
        System.out.println(div + 4);
        
    }
    
}


Measured memory_bytes: 22736
import java.util.*;

class Main{

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

		int cnt = S.length();

		String ans = "";

		for(int i = 0; i<cnt; i++){
			ans += "x";
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 22100
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    ds <- getIntList
    print $ solve ds

solve ds = (sum [x * y| x <- ds, y <- ds] - sum [x * x| x <- ds]) `div` 2

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

int main(void) {
	int d, n;
	cin >> d >> n;
	switch(d){
		case 0:
			if (n == 100) cout << "101" << endl;
			else cout << n << endl;
			break;
		case 1:
			if (n == 100) cout << "10100" << endl;
			else cout << n * 100 << endl;
			break;
		case 2:
			if (n == 100) cout << "1010000" << endl;
			else cout << n * 10000 << endl;
			break;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) 
{
	int s;
	double w, h, BMI;
	while(scanf("%d, %lf, %lf", &s, &w, &h) != EOF) {
		BMI = w / h / h;
		if (BMI >= 25)
			printf("%d\n", s);
	}
	return 0;
}


Measured memory_bytes: 1984
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int N;
    int[] A;
    private void solve() {
        N = nextInt();
        A = new int[N];
        int max = 0;
        for(int i = 0;i < N;i++) {
            A[i] = nextInt();
            max = Math.max(max, A[i]);
        }

        TreeMap<Integer, Integer> map = new TreeMap<>();
        for(int i = 0;i < N;i++) {
            map.put(A[i], map.getOrDefault(A[i], 0) + 1);
        }

        for(int i = 0;i < N;i++) {
            if (A[i] == max) {
                if (map.get(A[i]) > 1) {
                    out.println(A[i]);
                } else {
                    out.println(map.lowerKey(A[i]));
                }
            } else {
                out.println(max);
            }
        }
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


Measured memory_bytes: 48416
lines = $stdin.read
array = lines.split("\n")
S = array[0]
N = S.length

ans = [N-1]

for i in 1...N
  first, second = S[i-1], S[i]
  if first != second
    ans << [i-1, N-i-1].max
  end
  # p ans
end

puts (ans.min).to_i + 1

Measured memory_bytes: 4220
import math
k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        tmp = math.gcd(a, b)
        if tmp == 1:
            ans += k
        else:
            for c in range(1, k+1):
                ans += math.gcd(tmp, c)

print(int(ans))


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

const int N = 1e5;
ll x[N], nx[N];
int w[N];

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ll n, l, t; cin >> n >> l >> t;
  for(int i = 0; i < n; i++) {
    cin >> x[i] >> w[i];
    if(w[0] == 2) x[i] = l - 1 - x[i];
    if(w[0] == w[i]) nx[i] = (x[i] + t) % l;
    else nx[i] = ((x[i] - t) % l + l) % l;
  }

  int g1 = 0;
  int g2 = (x[0] + 2 * t) / l;
  int p1 = x[0];
  int p2 = (x[0] + 2 * t) % l;
  ll ch = 0;
  for(int i = 1; i < n; i++) {
    if(w[0] == w[i]) continue;
    int p = x[i];
    if(g1 == g2) {
      if(p1 <= p && p <= p2) ch++;
    } else {
      if(p1 <= p) ch++;
      if(p <= p2) ch++;
      ch += g2 - g1 + 1 - 2;
    }
  }
  int fi;
  if(w[0] == 2) fi = (n - ch) % n;
  else fi = ch % n;
  ll fx = nx[0];
  if(w[0] == 2) {
    for(int i = 0; i < n; i++) nx[i] = l - 1 - nx[i];
    fx = l - 1 - fx;
  }
  sort(nx, nx + n);

  int ti;
  if(w[0] == 2) {
    ti = lower_bound(nx, nx + n, fx) - nx;
  } else {
    ti = upper_bound(nx, nx + n, fx) - nx - 1;
  }
  ti = (n + ti - fi) % n;
  for(int i = 0; i < n; i++) {
    cout << nx[ti] << endl;
    ++ti%=n;
  }
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
 
using namespace std;
const ll maxn=1e6+100,inf=1e18,LOG=23,mod=998244353;
int block = 300, timer = 0;
const ld EPS = 1e-7;
 
#define bt(i) (1 << (i))
#define int ll

int n, dp[maxn], cost[maxn], a[20][20];

main()
{
	IOS
	cin >> n;
	forn(1, i, n)
	{
		forn(1, j, n)
		{
			cin >> a[i][j];
		}
	}
	forn(0, mask, (1 << n))
	{
		forn(0, i, n)
		{
			if((mask & (1 << i)) > 0)
			{
				cost[mask] = cost[(mask ^ (1 << i))];
				//cout << mask << " " << i << " " << (mask ^ (1 << i)) << endl;
				forn(i + 1, j, n)
				{
					if((mask & (1 << j)) > 0)
					{
						cost[mask] += a[i + 1][j + 1];
					}
				}
				break;
			}
		}
	}
	//cout << cost[(1 << n) - 1] << endl;
	forn(0, mask, (1 << n))
	{
		for(int s = mask; s; s = (s-1) & mask)
		{
			dp[mask] = max(dp[mask], dp[(mask ^ s)] + cost[s]);
		}
	}
	cout << dp[(1 << n) - 1];
}

Measured memory_bytes: 4864
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int a,b;

int main(){
    cin>>a>>b;
    if((a+b)%2==0){
        out((a+b)/2);
    }
    else{
        out((a+b)/2+1);
    }
}


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

int h, w;
char c[105][105];

int main() {
  cin >> h >> w;
  for(int i = 0; i < h + 2; ++i)
    for(int j = 0; j < w + 2; ++j) c[i][j] = '#';
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) cin >> c[i + 1][j + 1];
  for(int i = 0; i < h + 2; ++i) {
    for(int j = 0; j < w + 2; ++j) cout << c[i][j];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		sc.close();

		if (a >= 3200)
			System.out.println(s);
		else

			System.out.println("red");

	}
}

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

int main() {
  string S, T;
  cin >> S >> T;

  int ans = 0;

  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i)) ans++;
  }

  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n;
ll a[maxn], b[maxn], ans;

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

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	for (int i = n - 1; i >= 0; i--)
	{
		//cerr << '#' << i << ' ' << b[i] - ((a[i] + ans) % b[i]) << endl;
		if ((ans + a[i]) % b[i])
			ans += (b[i] - ((a[i] + ans) % b[i]));
	}
	cout << ans << endl;
}



Measured memory_bytes: 1792
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
string s,t;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>s>>t;
	int l=t.size();
	s.pb(t[l-1]);
	if(s==t) puts("Yes");
	else puts("No");
	return 0;
}

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

namespace id_0012cs
{

    class Program
    {

        static void Main(string[] args)
        {
            string line;
            while( (line = Console.ReadLine()) != null)
            {
                double[] vs = line.Split(' ').Select(x => double.Parse(x)).ToArray();
                double cp1 = CrossProduct(vs[0], vs[1], vs[2], vs[3], vs[6], vs[7]);
                double cp2 = CrossProduct(vs[2], vs[3], vs[4], vs[5], vs[6], vs[7]);
                double cp3 = CrossProduct(vs[4], vs[5], vs[0], vs[1], vs[6], vs[7]);
                if ((cp1 < 0 && cp2 < 0 && cp3 < 0) || (cp1 > 0 && cp2 > 0 && cp3 > 0)){
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }

        static double CrossProduct(double ax,double ay,double bx, double by,double px,double py)
        {
            return (bx - ax) * (py - ay) - (by - ay) * (px - ax);
        }
    }
}



Measured memory_bytes: 9548
def main():
    N = int(input())
    H = list(map(int, input().split()))
    max = 0
    tmp = 0
    s = H[0]

    for i in range(1, len(H)):
        if H[i] <= s:
            s = H[i]
            tmp += 1
            if tmp > max:
                max = tmp
        else:
            s = H[i]
            if tmp > max:
                max = tmp
            tmp = 0
    print(max)

if __name__ == '__main__':
    main()

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

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  for(int i = 0;i < n;i++){
    cin >> str;
    sort(str.begin(),str.end());
    mp[str]++;
  }
  ll ans = 0;
  
  for(auto& p:mp){
    int s = p.second;
  ans += (ll)s*(s-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 11136
n,d = map(int,input().split())
arr = [list(map(int,input().split())) for i in range(n)]
from math import sqrt
count = 0
from itertools import combinations
for kumi in combinations(range(n),2):
    inroot = 0
    for i in range(d):
        inroot += (arr[kumi[0]][i]-arr[kumi[1]][i])**2
    if sqrt(inroot)%1==0:
        count += 1

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
	int p, m, k;
	p = a + b;
	m = a - b;
	k = a * b;
	if (p > m) {
		if ( p > k) cout << p << endl;
		else cout << k << endl;
	}
	else if (m > k) {
		cout << m << endl;
	}
	else {
		cout << k << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;


void solve() {
	int n; 
	cin >> n; 
	int a[n + 1];
	for(int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		a[x] = i + 1;
		}
		for(int i = 1; i <= n;  ++i) cout << a[i] << " "; cout << endl;
}


int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}
 
 
 



Measured memory_bytes: 4040
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		long N = I.nextLong();
		int[] a = new int[10]; //right most indicates ones digit, 2nd rightmost indicates tens
		//digit and so on
		int ans = 0; //GOD
		while (true) {
			UPD(a,9);
			if (!BelowN(a,N)) break;
			//for (int i = 0; i<=9; i++) O.p(a[i]+" ");
			//O.p("\n");
			if (Valid(a)) {
				ans++;
			} 
		}
		O.pln(ans);
	}
	public static void UPD(int[] a, int in) {
		if (a[in]==0) a[in]=3;
		else{
			a[in]+=2;
			if (a[in]>7) {
				a[in]=3; //Reset and recurse backwards
				UPD(a,in-1);
			}
		}
	}
	public static boolean Valid(int[] a) {
		boolean[] vis = new boolean[10];
		for (int i = 0; i<= 9; i++) {
			vis[a[i]]=true; //Remember only valid digits are used
		}
		return vis[3]&&vis[5]&&vis[7]?true:false;
	}
	public static boolean BelowN(int[] a, long N) {
		long sum = 0;
		long mult = 1;
		for (int i = 9; i>= 0; i--) {
			sum+=a[i]*mult;
			mult*=10;
		}
		return sum<=N?true:false;
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 27128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second


int main(){
	ll n, c, cc[35][35], a[510][510], ccc[3][35] = { 0 }, ans = INF2;
	cin >> n >> c;
	for (int i = 1;i <= c;i++) {
		for (int j = 1;j <= c;j++)cin >> cc[i][j];
	}
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= n;j++) {
			cin >> a[i][j];
			for (int k = 1;k <= c;k++) {
				if (k == a[i][j])continue;
				ccc[(i + j) % 3][k] += cc[a[i][j]][k];
			}
		}
	}
	ll m1 = INF2, m2 = INF2, m3 = INF2;
	for (int i = 1;i <= c;i++) {
		for (int j = 1;j <= c;j++) {
			for (int k = 1;k <= c;k++) {
				if (i == j || j == k || i == k)continue;
				ans = min(ccc[0][i] + ccc[1][j] + ccc[2][k], ans);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m,d,ans=0;
int main(){
	scanf("%lld%lld",&m,&d);
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			//cout<<i<<' '<<j<<endl;
			if(j<=99&&j>=10&&(j/10)>=2&&(j%10)>=2&&i==(j%10)*(j/10)) {
				ans++;
			}
		}
	}
	printf("%lld",ans);
	return 0;
}


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

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

	vector<bool> maxValueFlag(n, false);

	int ans = 0;
	while (true) {

		int maxValue = 0;
		for (int i = 0; i < n; i++) {
			if (maxValue <= h[i]) maxValue = h[i];
		}

		if (maxValue == 0) break;

		for (int i = 0; i < n; i++) {		
			if (h[i] == maxValue) maxValueFlag[i] = true;
		}

		for (int i = 0; i < n; ) {

			int tmp = 0;
			if (maxValueFlag[i]) {
				for (int j = i + 1; j < n; j++) {				
					if (maxValueFlag[j]) tmp++;
					else break;
				}			
			
				for (int j = i; j <= i + tmp; j++) h[j]--;
				ans++;
				i += tmp;			
			}
			i++;
		}
		
	}
	
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 256
import math

a,b,c=map(float, input().split())

theta=c/180* math.pi
S=0.5*a*b*math.sin(theta)
h=b*math.sin(theta)
L= math.sqrt(a**2+b**2+-2*a*b*math.cos(theta))+a+b

print(S)
print(L)
print(h)


Measured memory_bytes: 5696
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MAX=1e6;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
typedef struct{int SPF[1000001],Primes[168],sz;}Template;
Template P;
static inline void ready(void)
{
  *P.SPF=1,*P.Primes=2,P.sz=1;
  rep(i,MAX/2)P.SPF[2*(i+1)]=2,P.SPF[2*(i+1)-1]=2*(i+1)-1;
  rep(i,MAX/2-1)
  {
    int x=2*(i+1)+1;if(P.SPF[x]==x){P.Primes[P.sz++]=x;}if(x*x>MAX)break;
    rep(j,P.sz){if(P.Primes[j]<=P.SPF[x]&&x*P.Primes[j]<=MAX)P.SPF[x*P.Primes[j]]=P.Primes[j];else break;}
  }
}
const char common[]="not coprime",disjoint[]="pairwise coprime",several[]="setwise coprime";
char esc[1000000];
static inline int Divise(int x)
{
  if(!x){return 0;}
  rep(i,168)
  {
    if(P.Primes[i]*P.Primes[i]>x)break;
    if(x%P.Primes[i])continue;
    if(esc[P.Primes[i]-1])return 0;
    esc[P.Primes[i]-1]=1;
    while(x%P.Primes[i]==0&&x)x/=P.Primes[i];
  }
  if(x>1){if(esc[x-1])return 0;esc[x-1]=1;}
  return 1;
}
int main(void)
{
  int N=IN(),A=0,flag=0,g=0;ready();
  rep(i,N){A=IN();g=GCD(g,A);if(i&&g!=1){flag=1;}if(!Divise(A)){flag=1;}}
  if(g>1)return puts(common),0;
  if(flag)return puts(several),0;else return puts(disjoint),0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int a, b;
	cin >> a >> b;
	cout << max({a + b, a - b, a * b});


    return 0;
}


Measured memory_bytes: 256
N = int(input())
List = [[] for _ in range(N)] 
for i in range(N):
  A = int(input())
  List[i] = [list(map(int, input().split())) for _ in range(A)]

ans = 0
for j in range(2**N):
  x = 0
  for k in range(N):
    if ((j >> k) & 1):
      for l in range(len(List[k])):
        if ((j >> (List[k][l][0]-1)) & 1) != List[k][l][1]:
          break
      else:
        x += 1
        continue
      break
  else:
    if ans < x:
      ans = x
print(ans)

Measured memory_bytes: 44656
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>n>>m>>l;
    cout<<min(n*m,l)<<"\n";
    return 0;
}



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

import static java.lang.Integer.parseInt;

/**
 * Taro's Shopping
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n, m;
			n = parseInt(line.substring(0, line.indexOf(' ')));
			m = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | m) == 0) break;

			int[] a = new int[n];

			StringTokenizer st = new StringTokenizer(br.readLine());

			for (int i = 0; i < n; i++) {
				a[i] = parseInt(st.nextToken());
			}

			int max = -1;

			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					int b = a[i] + a[j];
					if (b <= m && b > max) max = b;
				}
			}

			System.out.println(max > -1 ? max : "NONE");
		}
	}
}

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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

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

	unordered_set<int> s;

	for (int i = 0; i < n; i++) {
		cin >> a;
		s.insert(a);
	}

	int i = 0;
	while (1) {
		if (s.find(x - i) == s.end()) {
			cout << x - i << endl;
			break;
		}
		else if (s.find(x + i) == s.end()) {
			cout << x + i << endl;
			break;
		}
		else
			i++;
	}

	return 0;
}

Measured memory_bytes: 3644
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

const MIN_SCORE: i64 = -1000000000;

fn f(asum: &Vec<i64>, period: usize, k: usize) -> i64 {
    let repeat_add = max(0, asum[period] - asum[0]);

    let mut ans = MIN_SCORE;
    for i in 0..period {
        for len in 1..=period {
            if len <= k {
                let max_repeat = (k - len) / period;
                let score = asum[i + len] - asum[i] + repeat_add * (max_repeat as i64);
                ans = max(ans, score);
            }
        }
    }

    ans
}

//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        p: [Usize1;n],
        c: [i64;n],
    }

    let mut visited = vec![false; n];
    let mut ans = MIN_SCORE;
    for pos0 in 0..n {
        if !visited[pos0] {
            let mut asum = Vec::with_capacity(n * 2 + 1);
            let mut pos = pos0;
            let mut sum = 0;
            let mut period = 0;
            for i in 0..=n * 2 {
                asum.push(sum);
                sum += c[pos];
                if period == 0 && visited[pos] {
                    period = i;
                }
                visited[pos] = true;
                pos = p[pos];
            }
            ans = max(ans, f(&asum, period, k));
        }
    }

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


Measured memory_bytes: 2376
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
int main(){
    string S;
    int ans=0;
    for(int i=0;i<4;i++){
        cin>>S[i];
        if(i>0) {
            if (S[i] == S[i - 1]) {
                ans = 1;
            }
        }
    }
    if(ans==1){
        cout<<"Bad";
    }
    else{
        cout<<"Good";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, a[200], c = 0;

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		c += a[i];
	}
	
	int s = INF, p = 0;
	for(int i = 0; i < n; i++){
		if(abs(a[i] * n - c) < s){
			p = i;
			s = abs(a[i]*n-c);
		}
	}
	
	cout << p << endl;
	
	return 0;
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;

int main(int argc, char const* argv[])
{
  int h, w, a, b; cin >> h >> w >> a >> b;
  swap(a, b);
  rep(i, h){
    rep(j, w){
      if(i < a && j < b)cout << 1;
      else if(i < a || j < b)cout << 0;
      else cout << 1;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int a, b, c;
	int count=0;
	cin >> a >> b >> c;

	for (int i = a; i <= b; i++) {

		if (c%i == 0) {
			count++;
		}
	}

	cout << count << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  int C[N];
  int V[N];

  for(int i=0; i<N; i++){
    cin >> V[i];
  }
  for(int i=0; i<N; i++){
    cin >> C[i];
  }

  int max = 0;
  for(int i=0; i<pow(2,N); i++){
    int a = i;
    int X = 0;
    int Y = 0;
    for(int j=0; j<N; j++, a/=2){
      if(a%2 == 0){
        X += V[j];
        Y += C[j];
      }
    }
    if(max < X-Y) max = X-Y;
  }
  cout << max;

  return 0;
}


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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int N, K, S;
    cin >> N >> K >> S;

    vector<int> ans;

    rep(i, N) {
        if (i < K) {
            ans.push_back(S);
        } else {
            if (S == 1) {
                ans.push_back(2);
            } else {
                ans.push_back(S - 1);
            }
        }
    }

    rep(i, N) cout << ans[i] << " ";
    cout << endl;
}

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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
ll fact[1001];
void factorial(int n){
    fact[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i,fact[i]%=MOD;
}
ll ncr(ll n,ll r)
{
    if(n<r)
        return -1;
    else{
        ll x=fact[r]*fact[n-r]%MOD;
        return fact[n]*fermat_inv(x)%MOD;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int t=1;
    //cin>>t;
    //SieveOfEratosthenes(1000000);
    //factorial(1000);
    while(t--){
        int n,x,t;
        cin>>n>>x>>t;
        cout<<(n/x)*t+(n%x>0)*t;
    }
}

Measured memory_bytes: 3636
#include <stdio.h>
int main (void)
{
	int h, w;
	int H, W;

	while(1){
		scanf("%d %d",&H, &W);
		if(H==0 && W==0) break;
		for(h=1; h<=H; h++){
			for(w=1; w<=W; w++){
				if(h==1 || w==1 || h==H || w==W)
					printf("#");
				else
					printf(".");			
			}
			printf("\n");
		}
		printf("\n");
	}		
	return 0;
}

Measured memory_bytes: 572
#include<stdio.h>
#include<stdlib.h>
#define N 100000
int cmp_int(const void* _a, const void* _b){
	int* a=(int*)_a;
	int* b=(int*)_b;
	return *a-*b;
}
int main(){
	int n,a[N];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	qsort(a,n,sizeof(a[0]),cmp_int);
	printf("%d",a[n/2]-a[n/2-1]);
	return 0;
}

Measured memory_bytes: 892
from collections import OrderedDict, defaultdict, deque
from enum import Enum
from typing import Dict, Optional


class State(Enum):
    UNVISITED = 0
    VISITED = 1


class Node(object):
    def __init__(self, key: int) -> None:
        self.adj_nodes: Dict[int, Node] = {}  # node key: node
        self.key: int = key
        self.state = State.UNVISITED

    def __repr__(self):
        return "<Node {}>".format(self.key)

    def add_adj_node(self, key) -> None:
        if key not in self.adj_nodes.keys():
            self.adj_nodes[key] = Node(key)


class Graph:
    def __init__(self) -> None:
        self.nodes: Dict[int, Node] = {}

    def add_node(self, key) -> None:
        if key not in self.nodes.keys():
            self.nodes[key] = Node(key)

    def add_edge(self, source: int, dest) -> None:
        if not self.get_node(source):
            self.add_node(source)
        if not self.get_node(dest):
            self.add_node(dest)

        self.get_node(source).add_adj_node(dest)

    def get_node(self, key) -> Optional[Node]:
        try:
            return self.nodes[key]
        except KeyError:
            return None


class BFS:
    def __init__(self, g: Graph, start_key: int):
        self.graph = g
        self.start_key = start_key
        self.history: Dict[int, int] = {}

    def solve(self):
        n = self.graph.get_node(self.start_key)
        n.state = State.VISITED
        queue = deque()
        queue.append(n.key)
        while queue:
            n_key = queue.popleft()
            n = self.graph.get_node(n_key)

            for adj_node_key in n.adj_nodes:
                adj_node = self.graph.get_node(adj_node_key)
                if adj_node.state == State.UNVISITED:
                    self.history[adj_node_key] = n.key
                    adj_node.state = State.VISITED
                    self.visit_func(adj_node_key)
                    queue.append(adj_node_key)

    def visit_func(self, node_key):
        raise NotImplementedError


class Ans(BFS):
    def __init__(self, g, n, start_key=1):
        super().__init__(g, start_key)
        self.n = n
        self.dist = {x: -1 for x in range(1, n + 1)}
        self.dist[self.start_key] = 0

    def visit_func(self, node_key):
        if node_key != self.start_key:
            prev_dist = self.dist[self.history[node_key]]
            self.dist[node_key] = prev_dist + 1

    def show_results(self, n):
        if -1 in set(self.dist.values()):
            print("No")
            return
        print("Yes")
        for i in range(2, n + 1):
            print(self.history[i])


if __name__ == "__main__":
    n, m = map(int, input().split(" "))
    G = Graph()
    for i in range(n):
        G.add_node(i + 1)

    for _ in range(m):
        a, b, = map(int, input().split(" "))
        # print(a, b)
        G.add_edge(a, b)
        G.add_edge(b, a)

    a = Ans(G, n)
    a.solve()
    # a.show_results()
    a.show_results(n)


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

int main(){
	int n;
	cin >> n;
	ll res = 0;
	ll p = 1;
	for(int i = 0; i < n; i++){
		ll a;
		cin >> a;
		if(a == p) p++;
		else if(a < p) continue;
		else{
			ll num = (a - 1) / p;
			res += num;
			if(i == 0) p++;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int N,k,pre,sum=0;
	cin>>N;
	for(int i=1;i<=N;i++){
		k=0;pre=i;
		while(pre>0){k++;pre/=10;}
		sum+=k%2;
	}
	cout<<sum;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

type difficulty struct {
	score, num, bonus int
}

func power2(n int) int {
	if n == 0 {
		return 1
	} else if n == 1 {
		return 2
	} else {
		temp := power2(n / 2)
		if n%2 == 0 {
			return temp * temp
		} else {
			return temp * temp * 2
		}
	}
}

func isOn(n, i int) bool {
	return (n>>uint(i))%2 == 1
}

func perfectScore(d difficulty) int {
	return d.score*d.num + d.bonus
}

func main() {
	var d, g int
	fmt.Scanln(&d, &g)
	difficulties := make([]difficulty, d)
	for j := 0; j < d; j++ {
		difficulties[j].score = (j + 1) * 100
		fmt.Scanln(&difficulties[j].num, &difficulties[j].bonus)
	}
	ans := 1000
	for i := 0; i < power2(d); i++ {
		score := 0
		solved := 0
		for j, d := range difficulties {
			if isOn(i, j) {
				score += perfectScore(d)
				solved += d.num
			}
		}
		if score >= g {
			if ans > solved {
				ans = solved
			}
		} else {
			for j, d := range difficulties {
				if !isOn(i, j) {
					requiredScore := g - score
					requiredNum := (requiredScore + d.score - 1) / d.score
					if d.num >= requiredNum {
						if ans > solved+requiredNum {
							ans = solved + requiredNum
						}
					}
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
	char s[5];
	if(scanf("%s",s)==-1){
		return 1;
	};
	if((s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])||(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])||(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1])){
		printf("%s","Yes");
		}
	else{
		printf("%s","No");
	}
	return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    int n, a[15], x[15][15], y[15][15];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        for (int j = 0; j < a[i]; ++j) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        int cnt = 0;
        bool f = true;
        for (int j = 0; j < n; ++j) {
            if (((1 << j) & i) == 0)
                continue;
            cnt++;
            for (int k = 0; k < a[j]; ++k) {
                if (((i >> x[j][k]) & 1) != y[j][k])
                    f = false;
            }
        }
        if (f) {
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing


int main() {
	int l;
	cin >> l;
	l -= 1;
	int n = 20;
	vector <pair<int, pair<int, int>>> v;
	for (int i = 20; i >= 0; i--) {
		if((1 << i) - 1 <= l) {
			n = i + 1;
			break;
		}
	}
	for (int i = 1; i < n; i++) {
		v.push_back({i, {i + 1, 1 << (n - i - 1)}});
		v.push_back({i, {i + 1, 0}});
	}
	if(l > (1 << (n - 1)) - 1) {
		for (int i = 0; i <= 20; i++) {
			if(l & (1 << i)) {
				int mask = (l & (((1 << 20) - 1) ^ ((1 << (i + 1)) - 1)));
				if(mask != 0)
					v.push_back({1, {n - i, mask}});
			}
		}
		v.push_back({1, {n, l}});
	}
	
	cout << n << " " << (int) v.size() << "\n";
	for (auto g : v) {
		cout << g.ff << " " << g.ss.ff << " " << g.ss.ss << "\n";
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();
        if (u.equals(s)) {
            a -= 1;
        } else {
            b -= 1;
        }
        System.out.println(a + " " + b);

    }

}


Measured memory_bytes: 23764