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

#define reint register int
#define coint const int

using namespace std;

int main(void) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    printf("%d\n", max(0, c - (a - b)));
    return 0;
}



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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  ll ans = 0;
  for (int i = 1; i < n; ++i) {
    ans += min((ll)(x[i] - x[i - 1]) * a, (ll)b);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int multiple = a * b;
        if (multiple % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 24020
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;

int main(){
    int N,C;
    cin >> N >> C;
    
    int D[C][C];
    for(int i=0; i<C; i++){
        for(int j=0; j<C; j++){
            cin >> D[i][j];
        }
    }
    
    int colors[N][N];
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cin >> colors[i][j];
            colors[i][j]--;
        }
    }
    

    int iwa[3][C];
    for(int i=0; i<3; i++){
        for(int j=0; j<C; j++){
            iwa[i][j]=0;
        }
    }

    
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            for(int color=0; color<C; color++){
                iwa[(i+j)%3][color]+=D[colors[i][j]][color];
            }
        }
    }
    
    int ans=-1;
    for(int c0=0; c0<C; c0++){
        for(int c1=0; c1<C; c1++){
            for(int c2=0; c2<C; c2++){
                if(c0==c1 || c0==c2 || c1==c2){
                    continue;
                }
    
                if(ans==-1){
                    ans=iwa[0][c0]+iwa[1][c1]+iwa[2][c2];
                }else{
                    ans=min(ans,iwa[0][c0]+iwa[1][c1]+iwa[2][c2]);
                }
            }
        }
    }
    
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007
#define pb push_back
#define F first
#define S second
using namespace std;

int main(void) {
	boost;
	ll n;
	cin >>n;
	vector<ll> v;
	ll ans=0;
	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		v.pb(a);
	}for(int i=0;i<n;i+=2){
		if(v[i]%2!=0){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3616
a,b,c=map(int,input().split())
check_list=[0 for _ in range(b)]

mod=a%b
i=mod
while check_list[i]==0:
  check_list[i]=1
  i+=mod
  i%=b
  if i==c:
    break
if i==c:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include <vector>
#include <queue>
#include <utility>
#include <iostream>
#include <tuple>

using ll = long long;
using lli = long long int;

lli n, m, a, b, src_num;
std::queue<std::vector<lli>> q;;
std::vector<std::vector<lli>> vec;
std::vector<std::vector<lli>> visited;

int main() {
    std::cin >> n >> m;
    visited.assign(n+1, std::vector<lli>(3, -1));
    vec.assign(n+1, std::vector<lli>(0, 0));
    for (lli i = 0; i < m; i++) {
        std::cin >> a >> b;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    q.push({1, 0, 0});
    while (!q.empty()) {
        auto pa = q.front();
        int vec_index = pa[0];
        if (visited[vec_index][0] == -1) {
            visited[vec_index] = pa;
        }
        else {
            q.pop();
            continue;
        }
        for (int i = 0; i <vec[vec_index].size(); i++) {
            if (visited[vec[vec_index][i]][0] == -1) {
                q.push({vec[vec_index][i], visited[vec_index][1]+1, vec_index});
            }
        }
        q.pop();
    }
    std::cout << "Yes" << std::endl;
    for (int i = 2; i < visited.size(); i++) {
        //std::cout << "{" << visited[i][0] << "," << visited[i][1] << "," << visited[i][2] << "}" << std::endl;
        std::cout << visited[i][2] << std::endl;
    }
}


Measured memory_bytes: 23332
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

int b[30],a[30][30];

int main() {
    int n,m,c;
    cin>>n>>m>>c;
    for(int i=0;i<m;++i)cin>>b[i];
    for(int i=0;i<n;++i)for(int j=0;j<m;++j)cin>>a[i][j];
    int ans=0;
    for(int i=0;i<n;++i){
        int sum=c;
        for(int j=0;j<m;++j){
            sum+=b[j]*a[i][j];
        }
        if(sum>0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def f():
 w=m=0;n,q=map(int,input().split());s=[0]*-~n
 for e in sys.stdin:
  a,v=map(int,e.split());s[a]+=v
  if v<0 and a==w:m=max(s);w=s.index(m)
  elif s[a]>m:w,m=a,s[a]
  elif s[a]==m and w>a:w=a
  print(w,m)
f()


Measured memory_bytes: 13712
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 998244353

int ans = INFL;
int N;
string s;
int sum[200200];
bool flag;

signed main(){
    cin >> N;
    cin >> s;
    for(int i = N - 1; i >= 0; i--){
        if(s[i] == '.')sum[i]++;
        else flag = true;
        sum[i] += sum[i + 1];
    }
    if(!flag){
        printf("0\n");
        return 0;
    }
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(s[i] == '#'){
            ans = min(ans, sum[i] + cnt);
            cnt++;
        }
    }
    cout << min(ans, cnt) << endl;

    return 0;
}
/*



*/

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

using namespace std;

const int MOD = 1e9 + 7;
const int MAX = 2 * 1e5 + 10;
long long a[MAX];
int N;
int sameIdx[2];
bool used[MAX];

long long factArray[MAX], invFactArray[MAX], invArray[MAX];

long long powMod(long long a, long long p) {
  if (p == 0) {
   return 1;
  }
  if (p % 2) {
    return a * powMod(a, p - 1) % MOD;
  } else {
    long long t = powMod(a, p / 2);
    return t * t % MOD;
  }
}

long long inv(long long n) {
  return powMod(n, MOD - 2);
}

long long fact(int n) {
  if (factArray[n] != -1) {
    return factArray[n];
  }
  return factArray[n] = n * fact(n - 1) % MOD;
}

long long invFact(int n) {
  if (invFactArray[n] != -1) {
    return invFactArray[n];
  }
  return invFactArray[n] = inv(fact(n)) % MOD;
}

long long nCr(int n, int r) {
  if (n < r) {
    return 0;
  }
  return fact(n) % MOD * invFact(n - r) % MOD * invFact(r) % MOD;
}

void init() {
  memset(invArray, -1, sizeof(invArray));
  memset(factArray, -1, sizeof(factArray));
  memset(invFactArray, -1, sizeof(invFactArray));
  factArray[0] = invFactArray[0] = 1;
  for (int i = 0; i < MAX; i++) {
    fact(i);
  }
  for (int i = 0; i < MAX; i++) {
    invFact(i);
  }
}

long long calc(int cnt) {
  long long res = nCr(N + 1, cnt) % MOD;

  res = res - nCr(N - (sameIdx[1] - sameIdx[0]), cnt - 1);
  res += MOD;
  res %= MOD;

  return res;
}

int main() {
  init();
  scanf("%d", &N);
  memset(sameIdx, -1, sizeof(sameIdx));
  memset(used, false, sizeof(used));
  for (int i = 0; i < N + 1; i++) {
    scanf("%lld", a + i);
    if (used[a[i]]) {
      assert(sameIdx[0] == sameIdx[1] && sameIdx[0] == -1);
      sameIdx[1] = i;
      for (int j = 0; j < N + 1; j++) {
        if (a[j] == a[i]) {
          sameIdx[0] = j;
          break;
        }
      }
      assert(sameIdx[0] < sameIdx[1]);
    } else {
      used[a[i]] = true;
    }
  }
  assert(sameIdx[0] != -1);
  for (int i = 0; i < N + 1; i++) {
    printf("%lld\n", calc(i + 1));
  }
}



Measured memory_bytes: 7424
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int K; cin >> K;
	
	int N = (1 << K);
	
	multiset<int> data;
	
	F0R(i, N) {
		int cur; cin >> cur; data.insert(cur*-1);
	}
	
	vi vals;
	vals.pb(*data.begin());
	data.erase(data.begin());
	
	F0R(iteration, K) {
		vi newVals;
		F0R(i, sz(vals)) {
			if (data.upper_bound(vals[i]) == data.end()) {
				cout << "No" << endl; return 0;
			}
			newVals.pb(*(data.upper_bound(vals[i])));
			data.erase(data.upper_bound(vals[i]));
		}
		
		F0R(i, sz(newVals)) {
			vals.pb(newVals[i]);
		}
		sort(all(vals));
	}
	
	cout << "Yes" << endl; return 0;	
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


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

int main() {
	// your code goes here
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long ans = max(a * c, b * d);
	ans = max(ans, max(a * d, b * c));
	cout << ans << endl; 
	
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n;
ll a[200010];
map<ll,int> mp;

void input() {
    cin >> n;
    REP(i,n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(a,a+n);
}

void solve() {
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (!mp.count(a[i])) continue;
        ll k = 2;
        while (k <= a[i]) k *= 2;
        mp[a[i]]--;
        if (mp[a[i]] == 0) {
            mp.erase(a[i]);
        }
        if (mp.count(k - a[i])) {
            ans++;
            mp[k - a[i]]--;
            if (mp[k - a[i]] == 0) mp.erase(k - a[i]);
        }
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    input();
    solve();
    return 0;
}


Measured memory_bytes: 14336
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
LL int N,E,cnt;
LL int par[100005];
LL int find(LL int n){
	return n==par[n]?n:find(par[n]);
}
int main(){
	while(scanf("%lld%lld",&N,&E)==2){
		getchar();
		if(N==0&&E==0) break;
		for(int i=1;i<N;i++){
			scanf("%lld",&par[i+1]);
		}
		par[1]=1;getchar();
		char c;
		long long int sum = 0;
		for(int i=0;i<E;i++){
			scanf("%c %lld",&c,&cnt);
			getchar();
			if(c=='M') par[cnt]=cnt;
			else{
				sum += find(cnt);
			}
		} 
		cout<<sum<<endl;
	}
}


Measured memory_bytes: 3916
#1
import sys
n = int(input())
a = []
for i in range(n):
    j = int(input())
    a.append(j)
    
point = a[0]
cnt = 1
for i in range(n):
    if point == 2:
        print(cnt)
        sys.exit()
    point = a[point-1]
    cnt +=1
    
print("-1")

Measured memory_bytes: 12800
import java.util.Scanner;

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

        String S = sc.next();
        String T = sc.next();

        char[] Sarray = S.toCharArray();
        char[] Tarray = T.toCharArray();

        int result = 0;

        for(int i=0; i<Sarray.length; i++) {
            if(Sarray[i] != Tarray[i]) {
                result++;
            }
        }

        System.out.println(result);

    }
}

Measured memory_bytes: 41824
#include <stdio.h>
int main()
{
	int n,c[4][13]={0};
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int rank;
		char design;
		scanf("%*c%c%*c%d",&design,&rank);
		switch(design){
			case 'S':
				c[0][rank-1]=1;
				break;
			case 'H':
				c[1][rank-1]=1;
				break;
			case 'C':
				c[2][rank-1]=1;
				break;
			case 'D':
				c[3][rank-1]=1;
				break;
		}
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++){
			if(c[i][j]==0){
				switch(i){
					case 0:
						printf("S %d\n",j+1);
						break;
					case 1:
						printf("H %d\n",j+1);
						break;
					case 2:
						printf("C %d\n",j+1);
						break;
					case 3:
						printf("D %d\n",j+1);
						break;
				}
			}
		}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
	}
	return 0;
}

Measured memory_bytes: 1024
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N = input()

    print('Yes') if N == N[::-1] else print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 10360
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define pqb priority_queue<int>
#define setbits(x) __builtin_popcountll(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define ll long long
#define inf INT_MAX
#define ninf INT_MIN
#define pi 3.14159265358979323846264338327950
 
const int mod=1e9+7;
int main()
{
    int a,b,c,d; cin>>a>>b>>c>>d;
    int k=0;
    
    while(a>0&&c>0)
    {
        if(k==0)
        c-=b;
        else 
        a-=d;
        k^=1;
    }
    
    if(c<=0) cout<<"Yes";
    else cout<<"No";
   return 0;
} 


Measured memory_bytes: 3636
import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce

sys.setrecursionlimit(10**6) 

I=sys.stdin.readline

 #s="abcdefghijklmnopqrstuvwxyz"

"""
x_move=[-1,0,1,0,-1,1,1,-1]
y_move=[0,1,0,-1,1,1,-1,-1]
"""
def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))
def mi():
	return map(int,I().strip().split())

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
def divi(n):
	if n==1:
		return 1
	cnt=2
	for i in range(2,int(n**.5)+1):
		if n%i==0:
			if i==n//i:
				cnt+=1
			else:
				cnt+=2
	return cnt


def main():
	n=I().strip()
	if n[-1]=='s':
		print(n+'es')
	else:
		print(n+'s')
	

























	
	
	





if __name__ == '__main__':
	main()

Measured memory_bytes: 9436
S = input()
T = ["AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR"\
    ,"KIHBARA","KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR"\
    ,"KIHBRA","KIHBAR","KIHABR","AKIHBR","KIHBR"]
print("YES" if S in T else "NO")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

struct LowestCommonAncestor{
  int n,h;
  vector<vector<int> > G,par;
  vector<int> dep;
  LowestCommonAncestor(){}
  LowestCommonAncestor(int n):n(n),G(n),dep(n){
    h=1;
    while((1<<h)<=n) h++;
    par.assign(h,vector<int>(n,-1));
  }

  void add_edge(int u,int v){
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  
  void dfs(int v,int p,int d){
    par[0][v]=p;
    dep[v]=d;
    for(int u:G[v])
      if(u!=p) dfs(u,v,d+1);
  }
  
  void build(int r=0){
    dfs(r,-1,0);
    for(int k=0;k+1<h;k++){
      for(int v=0;v<n;v++){
        if(par[k][v]<0) par[k+1][v]=-1;
        else par[k+1][v]=par[k][par[k][v]];
      }
    }
  }
  
  int lca(int u,int v){
    if(dep[u]>dep[v]) swap(u,v);
    for(int k=0;k<h;k++){
      if((dep[v]-dep[u])>>k&1){
        v=par[k][v];
      }
    }
    if(u==v) return u;
    for(int k=h-1;k>=0;k--){
      if(par[k][u]!=par[k][v]){
        u=par[k][u];
        v=par[k][v];
      }
    }
    return par[0][u];
  }

  int distance(int u,int v){
    return dep[u]+dep[v]-dep[lca(u,v)]*2;
  }
};


//INSERT ABOVE HERE
signed main(){
  int n,x,y;
  cin>>n>>x>>y;
  x--;y--;
  // G: sugim, H: sigma
  vector<vector<int> > G(n),H(n);
  for(int t=0;t<2;t++){
    auto &T=(t==0?H:G);
    for(int i=1;i<n;i++){
      int a,b;
      cin>>a>>b;
      a--;b--;
      T[a].emplace_back(b);
      T[b].emplace_back(a);
    }
  }
  
  LowestCommonAncestor lca(n);
  lca.G=G;
  lca.build(y);
  
  vector<int> dist(n,-1);
  queue<int> q;
  dist[x]=0;
  q.emplace(x);

  auto WIN=[](){cout<<-1<<endl;exit(0);};
  int ans=0;
  while(!q.empty()){
    int v=q.front();q.pop();
    chmax(ans,lca.dep[v]);
    for(int u:H[v]){
      if(~dist[u]) continue;
      if(lca.distance(u,v)>=3) WIN();
      
      dist[u]=dist[v]+1;
      if(dist[u]>=lca.dep[u]) continue;
      q.emplace(u);            
    }
  }
  cout<<ans*2<<endl;
  return 0;
}


Measured memory_bytes: 53876
import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

x, n =na()
p = na()

ans = x
for i in range(100):
    temp = x - i
    if not temp in p:
        print(temp)
        quit()
    temp = x + i
    if not temp in p:
        print(temp)
        quit()

Measured memory_bytes: 9184
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(void){
    int N;
    scanf("%d", &N);
    int array[100000 + 10] = {0};
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        array[tmp] = i + 1;
    }
    for (int i = 1; i <= N; i++) {
        printf("%d ",array[i]);
    }
}


Measured memory_bytes: 1152
def solve(a,b,c):
    if a<b and b<c:
        print("Yes")
    else:
        print("No")

def answer():
    line = list(map(int, input().split()))
    a = line[0]
    b = line[1]
    c = line[2]
    solve(a,b,c)

if __name__ =='__main__':
    answer()



Measured memory_bytes: 5600
#include<cstdio>
#include<set>

int main() {
	int n, nd[5], k, i, tmp;
	scanf("%d%d", &n, &k);
	for (i = 0; i < 4; i++) {
		nd[i] = n - (n / 10) * 10;
		n = n / 10;
	}
	nd[4] = 0;
	std::set<int> s;
	for (i = 0; i < k; i++) {
		scanf("%d", &tmp);
		s.insert(tmp);
	}
	i = 3;
	while (nd[i] == 0) {
		i--;
	}
	while (i>=0 && s.count(nd[i])==0) {
		i--;
	}
	if (i >= 0) {
		while (s.count(nd[i]) > 0) {
			nd[i]++;
			while (nd[i] >= 10) {
				nd[i] == 0;
				nd[i + 1]++;
				i++;
			}
		}
		i--;
		if (i >= 0) {
			tmp = 0;
			while (s.count(tmp) > 0) {
				tmp++;
			}
			while (i >= 0) {
				nd[i] = tmp;
				i--;
			}
		}
	}
	n = 0;
	for (i = 4; i >= 0; i--) {
		n = 10 * n + nd[i];
	}
	printf("%d", n);
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iomanip>
#include <iostream>
#define sqr(x) ((x)*(x))

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	int x[8]; int y[8];
	for(int i = 0; i < n; i++)
		cin >> x[i] >> y[i];
	
	double sum = 0;
	for(int i = 0; i < n - 1; i++)
		for(int j = i + 1; j < n; j++)
			sum += sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));
	
	cout << fixed;
	cout << setprecision(10) << sum * 2 / n << endl;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
h={12=>6,13=>10,14=>12,15=>14,16=>27,17=>33,23=>7,24=>9,25=>12,26=>23,27=>30,34=>5,35=>8,36=>20,37=>27,45=>5,46=>17,47=>26,56=>12,57=>23,67=>10}
while(a=gets.to_i)>0
	x,y=gets.split.map(&:to_i)
	y+=x*60
	b=gets.to_i
	x,z=gets.split.map(&:to_i)
	z+=x*60
	c=h[a*10+b]
	c/=2.0 if c<27&&((1050<=y&&y<=1170)||(1050<=z&&z<=1170))
	p c.ceil*50
end

Measured memory_bytes: 2400
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, V = input_number_list()  # 鬼
    B, W = input_number_list()  # 子供
    T = input_number()  # 制限時間
    sd = abs(B - A)
    ss = V - W
    is_ng = False
    if ss <= 0:
        is_ng = True
    elif sd / ss > T:
        is_ng = True
    print(["YES", "NO"][is_ng])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9144
#include <iostream>
#include <cstdio>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <numeric>
#include <stack>
#include <deque>
#include <queue>
#include <unordered_map>
#include <bitset>

#define f first
#define s second
#define pplipii pair<pair<long long, int>, pair<int, int> >
#define mp make_pair
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
using namespace std;

typedef long long ll;
#define MAX 200010
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.0000001
#define vvi vector<vector<ll>>
int main()
{
    string s, c, z;
    cin >> s >> c >> z;
    cout << s[0] << c[1] << z[2];
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
cin >>s;
int a,b,c,d;
a = s[0]-'0';
b = s[1]-'0';
c = s[2]-'0';
d = s[3]-'0';

int ans=0,z;
while(1){
ans = a+b+c+d; if(ans==7) {z=0;break;}
ans = a+b+c-d; if(ans==7) {z=1;break;}
ans = a+b-c+d; if(ans==7) {z=2;break;}
ans = a+b-c-d; if(ans==7) {z=3;break;}
ans = a-b+c+d; if(ans==7) {z=4;break;}
ans = a-b+c-d; if(ans==7) {z=5;break;}
ans = a-b-c+d; if(ans==7) {z=6;break;}
ans = a-b-c-d; if(ans==7) {z=7;break;}
}
if(z==0) cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<7<<endl;
if(z==1) cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<7<<endl;
if(z==2) cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<7<<endl;
if(z==3) cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<7<<endl;
if(z==4) cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<7<<endl;
if(z==5) cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<7<<endl;
if(z==6) cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<7<<endl;
if(z==7) cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<7<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

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


int main() {
    ll n; cin >> n;
    Vl a(n), b(n);
    rep(i, 0, n) cin >> a[i] >> b[i];
    sort(ALL(a));
    sort(ALL(b));
    ll am, bm;
    if(n%2 != 0){
        am = a[(n-1)/2], bm = b[(n-1)/2];
        co(bm-am+1);
    }else{
        am = a[(n-1)/2]+a[n/2], bm = b[(n-1)/2]+b[n/2];
        // co(am << " " << bm);
        ll ans = bm - am + 1;
        co(ans);
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

bool check(vector<int> v, ll p, int k)
{
  ll sum = 0;
  int n = v.size();
  int ntrucks = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i] > p) { return false; }
    if (sum + v[i] > p) {
      if (++ntrucks > k) { return false; }
      sum = 0;
    }
    sum += v[i];
  }
  ntrucks += sum > 0;
  return ntrucks <= k;
}

int main()
{
  int n, k;
  fscanf(stdin, "%d %d", &n, &k);
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &v[i]);
  }

  ll left = 0, right = 100000LL * 10000;
  ll mid = 0;
  while (left < right) {
    mid = (left + right) / 2;
    // fprintf(stderr, "DEBUG: left=%lld, right=%lld, mid=%lld\n", left, right, mid);
    if (check(v, mid, k)) {
      // fprintf(stderr, "DEBUG: ok, mid=%lld\n", mid);
      right = mid;
    }
    else { left = mid + 1; }
  }
  fprintf(stdout, "%lld\n", right);
  return 0;
}

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

int main(void)
{
    string s; cin >> s;
    string t; cin >> t;
    bool flag = true;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i]) flag = false;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1005000000
#define MOD 1000000007
#define N 100005
#define M 1000005
#define LOG 20
#define KOK 32000
using namespace std;

int n;
int a[N];
ll ans;

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%d",&n);

	for(int i=1;i<=n;i++) {

		scanf("%d",&a[i]);

	}

	sort(a+1,a+1+n,greater<int>());

	if(n&1) {

		for(int i=1;i<=(n+1)/2-2;i++) ans+=2*a[i];

		ans+=a[(n+1)/2-1]+a[(n+1)/2];

		for(int i=(n+1)/2+1;i<=n;i++) ans-=2*a[i];

		ll tut=ans;

		ans=0;

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

		ans-=a[n/2+1]+a[n/2+2];

		for(int i=n/2+3;i<=n;i++) ans-=2*a[i];

		umax(ans,tut);

	}
	else { 

		for(int i=1;i<=n/2-1;i++) ans+=2*a[i];

		ans+=a[n/2]-a[n/2+1];

		for(int i=n/2+2;i<=n;i++) ans-=2*a[i];

	}

	printf("%lld",ans);

}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
	
#define WHATS(var)cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
	return os;
}
using ll=long long ;

int main() {
	ios::sync_with_stdio(false);
	int a,b,c,d;cin>>a>>b>>c>>d;
	cout<<(int(b>d))<<endl;
	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,d; cin >> n >> d;
    ll res = (n + 2* d)/(2*d+1);
    out(res);
}


Measured memory_bytes: 256
n500= int(input())
n100= int(input())
n50= int(input())
total = int(input())
#print(n500,n100,n50)
count500,count100,count50 =0,0,0
hit = 0
for i in range(0,n500+1):
  count500 =i
  for i in range(0,n100+1):
    count100 =i
    for i in range(0,n50+1):
      count50 =i
      if (count500*500 + count100*100 + count50* 50) == total:
        hit +=1
#print(count500,count100,count50)          
print(hit)        


Measured memory_bytes: 3064
#include<stdio.h>
using namespace std;

int main(){
  int a, b, d, r;
  double f;
  scanf("%d %d", &a, &b);
  d = a / b;
  r = a % b;
  f = double(a) / double(b);
  printf("%d %d %.5f\n",d, r, f);
  return 0;
}



Measured memory_bytes: 2748
from collections import deque

def main():
  N,M=map(int,input().split())

  r=[[]for i in range(N)]
  for i in range(M):
    a,b=map(int,input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)

  p=[-1]*N
  q=deque([0])
  while q:
    i=q.popleft()
    for j in r[i]:
      if p[j]==-1:
        p[j]=i
        q.append(j)

  print('Yes')
  for i in range(1,N):
    print(p[i]+1)

main()


Measured memory_bytes: 34056
import sys
import itertools
import numpy as np
from collections import Counter
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, H, M = map(int, input().split(' '))

hdeg = H/12*2*math.pi+M/60*math.pi/6
mdeg = M/60*2*math.pi
diff = abs(hdeg-mdeg)

ans = math.sqrt(A**2+B**2-2*A*B*math.cos(diff))
print(ans)


Measured memory_bytes: 27200
#include<stdio.h>

long int Max(long int a, long int b, long int c, long int d){
  long int m;
  if(a >= b)
    m = a;
  else
    m = b;
  if(m <= c)
    m = c;
  if(m <= d)
    m = d;
  return m;
}

int main(void){
  long int a,b,c,d,m;
  scanf("%ld %ld %ld %ld", &a, &b, &c, &d);
  m = Max(a*c, a*d, b*c, b*d);
  printf("%ld", m);
  
  return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#define ll long long 
using namespace std;
int a[200010];
int ans[200010];
int main(){
	int n;
	cin>>n;
	for(int i=2;i<=n;i++){
		cin>>a[i];
	}
	for(int i=2;i<=n;i++){
		ans[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 4660
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    ll n;
    cin>>n;
    pair<ll,ll> ab;
    auto comp=[](pair<ll,ll> pa,pair<ll,ll> pb){return pa.second>pb.second;};
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,decltype(comp)> q(comp);
    for(int i=0;i<n;i++){
        cin>>ab.first>>ab.second;
        q.push(ab);
    }
    ll time=0;
    bool flag=1;
    while(!q.empty() && flag){
      	pair<ll,ll> p=q.top(); q.pop();
        time+=p.first;
        if(time>p.second) flag=0; 
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  long long N, C;
  cin >> N >> C;
  vector<pair<long long, long long>> sushi(N);
  rep(i, N)
  {
    cin >> sushi[i].first >> sushi[i].second;
  }
  vector<long long> right(N), left(N);
  vector<long long> bestRight(N), bestLeft(N);

  rep(i, N)
  {
    right[i] = sushi[i].second;
    left[i] = sushi[N - 1 - i].second;
  }

  rep(i, N - 1)
  {
    right[i + 1] += right[i];
    left[i + 1] += left[i];
  }
  rep(i, N)
  {
    right[i] -= sushi[i].first;
    left[i] -= C - sushi[N - 1 - i].first;
  }

  bestRight = right;
  bestLeft = left;
  bestRight.insert(bestRight.begin(), 0);
  bestLeft.insert(bestLeft.begin(), 0);
  rep(i, N)
  {
    bestRight[i + 1] = max(bestRight[i + 1], bestRight[i]);
    bestLeft[i + 1] = max(bestLeft[i + 1], bestLeft[i]);
  }

  long long ans = 0;
  rep(i, N - 1)
  {
    long long leftCalory = left[i] + bestRight[N - 1 - i] - (C - sushi[N - 1 - i].first);
    long long rightCalory = right[i] + bestLeft[N - 1 - i] - sushi[i].first;
    ans = max({ans, leftCalory, rightCalory});
  }
  ans = max({ans, bestRight[N], bestLeft[N], (long long)0});

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int n = scan.nextInt();
		int[] a = new int[n];
		int[] arr = new int[n];
		
		long min = 0;
		
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
			if (i > 0) {
				arr[i-1] = a[i] - a[i - 1];
				min += arr[i-1]; 
			}
		}
		if (a[0] > 0) {
			arr[n - 1] = a[0];
		}
		arr[n - 1] += k - a[n-1];
		
		int i = 1;
		int e = n - 1;
		long nextMin = min;
		while (i < n) {
			
			nextMin = nextMin - arr[i - 1] + arr[e++];
			min = Math.min(min, nextMin);
			
			if (e >= n) {
				e = 0;
			}
			i++;
		}
		System.out.println(min);
	}

}


Measured memory_bytes: 86572
n = int(input()) #整数
a = [int(i) for i in input().split() ]

a = list(set(a))
a.sort()
while len(a) > 1:
    while (a[0] < a[1]):
        a[1] %= a[0]
    x = a[1]
    a[1] = a[0]
    a[0] = x
    if a[0] == 0:
        a.pop(0)
    if a[0] == 1:
        break
print(a[0])

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

int main(){
  long long  n,count1=0,count2=0,ans=0;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n;i++)cin >> b[i];
  for(int i=0;i<n;i++)cin >> c[i];
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());

  for(int i=0;i<n;i++){
    count1 = distance(a.begin(),lower_bound(a.begin(),a.end(),b[i]));
    count2 = distance(upper_bound(c.begin(),c.end(),b[i]),c.end());
    ans += count1*count2;
  }
  cout << ans;
}


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

const int _ = 1e6 + 7;
vector < int > pot[26];
int N; char S[_] , T[_];

int main(){
	scanf("%d %s %s" , &N , S , T);
	for(int i = 0 ; i < N ; ++i) pot[S[i] - 'a'].push_back(i);
	int mx = 0 , mrk = 0; char curc; deque < int > q; q.push_back(1e9);
	for(int i = N - 1 ; ~i ; --i){
		if((q.front() + mrk <= i ? curc : S[i]) != T[i]){
			if(pot[T[i] - 'a'].empty()){puts("-1"); return 0;}
			int t = pot[T[i] - 'a'].back(); curc = T[i];
			for(int j = min(i , q.front() + mrk - 1) ; j >= t ; --j) pot[S[j] - 'a'].pop_back();
			--mrk; q.push_front(t - mrk); while(q.back() + mrk >= i) q.pop_back();
			q.push_back(i - mrk); mx = max(mx , (int)q.size() - 1);
		}
		if(q.front() + mrk > i) pot[S[i] - 'a'].pop_back();
	}
	cout << mx; return 0;
}


Measured memory_bytes: 10680
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>

using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

int main() {
    //std::ifstream in("0_normal_2");
    //std::cin.rdbuf(in.rdbuf());
    int N;
    std::cin >> N;
    std::cout << N*N*N << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		//variables
		int num1, num2;

		//scanner
		Scanner sc = new Scanner(System.in);
		
		num1 = sc.nextInt();
		num2 = sc.nextInt();

		//deciding output
		System.out.println("");
		if(((num1 <= 9) && (num1 >=1)&&((num2 <= 9) && (num2 >=1))))
		{

			System.out.println(num1*num2);
		}
		else

			System.out.println("-1");

	}
}

Measured memory_bytes: 23892
#include<stdio.h>
int main(){
    int  a,b,c,d,m,i;
    scanf("%d",&a);


      if(a==1){
          printf("Hello World\n");}
      else if(a==2){
          scanf("%d%d",&c,&d);
          printf("%d\n",c+d);
      }
    return 0;
}


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


int main(){
    int N,L;
    cin >> N >> L;
    vector<string> word(N);
    for(int i=0;i<N;i++){ cin >> word.at(i); }
    
    sort(word.begin(), word.end());
    for(int i=0;i<N;i++){ cout << word.at(i); }
}


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

int main() {
	int a,b;
	cin >> a >> b;
	
	int c = a / b;
	int d = a % b;
	double e = double(a) / double(b);
	
	cout << c << ' ' << d << ' ' << fixed << setprecision(6) << e << endl;
}

Measured memory_bytes: 3284
# -*- coding: utf-8 -*-
from itertools import product
def inpl(): return list(map(int, input().split()))
N = int(input())
ans = 0
for L in range(1, len(str(N))+1):
    for X in product("357", repeat=L):
        for s in "357":
            if not s in X:
                break
        else:
            ans += int("".join(X)) <= N

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  int n,m; cin >> n >> m;
  vector<vector<int>> G(n);

  rep(i, m) {
    int a,b; cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> ans(n, -1); // from

  queue<int> q;
  q.push(0);

  while(!q.empty()) {
    int cur = q.front(); q.pop();

    rep(i, G[cur].size()) {
      int next = G[cur][i];
      if(ans[next] == -1) {
        ans[next] = cur;
        q.push(next);
      }
    }
  }

  bool ok = 1;
  rep1(i, n - 1) {
    if(ans[i] == -1) {
      ok = 0;
      break;
    }
  }

  if(!ok) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;

    rep1(i, n - 1) {
      cout << ans[i] + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 10164
N,m=int(input()),10**9+7

from collections import defaultdict

memo=[defaultdict(int) for i in range(N+1)]

def ok(last4):
    if 'AGC' in last4:
        return False
    for i in range(3):
        t=list(last4)
        t[i],t[i+1]=t[i+1],t[i]
        if 'AGC' in ''.join(t):
            return False
    return True

memo[0]['TTT']=1
for i in range(1,N+1):
    for last3 in memo[i-1].keys():
        v = memo[i-1][last3]%m
        tmp=0
        for c in ['A','G','T','C']:
            if ok(last3+c):
                memo[i][last3[1:]+c]+=v

print(sum(memo[N].values())%m)


Measured memory_bytes: 4184
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {

    int H = 0;
    int W = 0;
    int[][] cell = null;

    int h = 0;
    int w = 0;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      final String[] tmp = br.readLine().split("\\s");
      H = Integer.parseInt(tmp[0]);
      W = Integer.parseInt(tmp[1]);
      cell = new int[H][W];

      final String[] hw = br.readLine().split("\\s");
      h = Integer.parseInt(hw[0]);
      w = Integer.parseInt(hw[1]);

    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    int sum = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < W; j++) {
        cell[i][j] = 1;
        sum++;
      }
    }

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < w; j++) {
        if (cell[i][j] == 0) {
          cell[i][j] = 1;
          sum++;
        }
      }
    }

    System.out.print(H * W - sum);
  }
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
	ll H,W;cin>>H>>W;
	ll N;cin>>N;
	vector<ll>a(N);
	for(int i=0;i<N;i++)cin>>a[i];
	vector<vector<ll>>map(H+3,vector<ll>(W+3,0));
	
	
	for(int i=0;i<=H+1;i++){
		map[i][0]=-1;
		map[i][W+1]=-1;
	}
	for(int i=0;i<=W+1;i++){
		map[0][i]=-1;
		map[H+1][i]=-1;
	}
	
	ll k=0;
	ll h=1;
	ll w=1;
	for(int i=1;i<=N;i++){
		for(int j=0;j<a[i-1];j++){
			map[h][w]=i;
			if(map[h+dx[k]][w+dy[k]]!=0){
				k++;
				k=(4+k)%4;
			}
			h+=dx[k];
			w+=dy[k];
			//cout<<i<<" "<<j<<endl;
			//cout<<"now..."<<h<<" "<<w<<endl;*/
		}
	}
	
	
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cout<<map[i][j]<<" ";
		}
		cout<<endl;
	}
	
}


Measured memory_bytes: 512
#include<iostream>
#include<math.h>
using namespace std;

void insertion_sort(int array[],int n){
    for(int i = 1;i<n;i++){
       int key = array[i];
       int j = i-1;
       while(j>=0 && array[j] > key){
           array[j+1] = array[j];
           j = j-1;
       }
       array[j+1] = key;
       for(int k =0;k<n;k++){
           
           if(k == n-1){
               cout<<array[k]<<endl;
           }else{
               cout<<array[k]<<" ";
           }
       }
    }
}

int bubble_sort(int array[],int n){
    int count = 0;
   for(int i = 0;i < n;i++){
       for(int j = n-1;j> i;j--){
           if(array[j] < array[j-1]){
               int temp = array[j];
               array[j] = array[j - 1];
               array[j - 1] = temp;
               count++;
           }
       }
   }
   for(int k = 0;k<n;k++){
       cout<<array[k]<<" ";
       if(k == n-1){
           cout<<endl;
       }
   }
   cout<<count<<endl;
   return count;
}

int selectionSort(int array[],int n){
    int count = 0;
    for(int i = 0;i<n;i++){
        int min = i;
        for(int j = i;j<n;j++){
            if(array[j] < array[min]){
                min = j;       
            }
        }
        if(i != min){
            int temp = array[i];
            array[i] = array[min];
            array[min] = temp;
            count++;
        }
    }
    for(int k = 0;k<n;k++){
        if(k < n-1){
        cout<<array[k]<<" ";
        }
       else{
           cout<<array[k]<<endl;
       }
   }
   cout<<count<<endl;
   return count;
}

int main(){
    int n,a,b;
    cin>>n;
    int array[100] = {0};
    for(int i = 0;i<n;i++){
        cin>>array[i];           
    }
    int count = selectionSort(array,n);
    
}


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

using namespace std;


int main(void) {
    int a,N,M,X,Y,x,y,z;

    cin >> N >> M >> X >> Y >> x;

    for( z=1 ; z<N ; z++ ){
        cin >> a;
        if( x < a ) x = a;
    }

    cin >> y;
    for( z=1 ; z<M ; z++ ){
        cin >> a;
        if( y > a ) y = a;
    }

    if( x<y && x<Y && y>X ) cout << "No War\n";

    else cout << "War\n";


}

Measured memory_bytes: 256