akhauriyash/Code-Regression huggingface dataset:
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    n,d = invr()
    c = 0
    for i in range(n):
        x,y = invr()
        if math.sqrt((x ** 2) + (y ** 2)) <= d:
            c = c + 1
    print(c)
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

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

  vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

    int a ,b;
    vector<int> c;
    for (int i = 0; i < 1000; i++) {
      for(int y : divisor(x)) {
        if(pow(i, 5) - pow(i - y, 5) == x) {
          a = i;
          b = i - y;
          goto OUT;
        }
      }
     }

    OUT:
     cout << a << " " << b << endl; 
  
 }

Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std; 
using lint = long long int;
using pint = pair<int,int>;
using plint = pair<lint,lint>;
#define vli vector<lint>
#define pb push_back
#define ALL(x) begin(x),end(x)
#define inf (1LL<64)-1
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);

/*
   -------
         |
    **   |
   -------      
   |
   ------------------------------------------------------------------------------------------------------
*/

void solve()
{
  lint n,a,b;cin>>n>>a>>b;

  lint rb=n/(a+b);
  lint ans=rb*a;
  rb=n%(a+b);
  rb=min(a,rb);
  ans+=rb;

  cout<<ans<<endl;
}

int main()
{   
     f_ip
  
      solve();

     return 0;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		sc.close();
		int res = 180 * (N-2);
		out.println(res);
	}
	private long max(long a, long b) {
		return Math.max(a, b);
	}
	private long min(long a, long b) {
		return Math.min(a, b);
	}
	private static int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	private static long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}
	static long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}

}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
#include<algorithm>
#include<cstring>
#include<string>
#include<stdio.h>
#include<map>
#include<vector>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#include<set>
#define maxn 1000005
#define INF 1e9
#define ll long long
int n, a[205];
int  main()
{
	while (cin >> n) {
		for (int i = 0; i < 2 * n; i++)
			cin >> a[i];
		sort(a, a + 2 * n);
		int sum = 0;
		for (int i = 0; i < 2 * n; i += 2)
			sum += a[i];
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#!/bin/ruby
n=gets.to_i
s,l,p=n.times.map{gets.split.map(&:to_i)}.transpose
mp=Array.new(444,0)
n.times do |i|
  (s[i]..l[i]).each do |j|
    mp[j]=[mp[j],p[i]].max
  end
end
m=gets.to_i
puts m.times.map{
  w=gets.to_i
  dp=Array.new(w+1,-1e99)
  dp[0]=0
  mp.each_with_index do |e,i|
    next if e==0
    (i..w).each do |j|
      u=dp[j-i]+e
      if u>dp[j] then
        dp[j]=u
      end
    end
  end
  if dp[w]<0 then
    puts -1
    exit
  end
  dp[w]
}

Measured memory_bytes: 6160
#include<iostream>
#include<cstdio>
const int N=10005;
typedef long long ll;
int n,a[N],b[N];
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    for(int i=1;i<=n;i++) scanf("%d",b+i);
    ll L=0,R=0;
    for(int i=1;i<=n;i++) if(a[i]>=b[i]) L+=a[i]-b[i];else R+=(b[i]-a[i])/2*2;
    if(L*2>R) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  vector<ll> a(3, 0);
  REP(i, 2) {
    ll b;
    cin >> b;
    b--;
    a[b] = true;
  }
  REP(i, 3) {
    if (!a[i]) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int N,x;
int a[200002];
bool used[200002];
int main(){
  int temp;
  int i=1,j=1;
  scanf("%d %d",&N,&x);
  if(x==1 || x==2*N-1){
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  if(x==2){
    a[N-1]=x+1;a[N]=x;a[N+1]=x-1;a[N+2]=x+2;
    used[x+1]=true;used[x]=true;used[x-1]=true;used[x+2]=true;
  }
  else{
    a[N-1]=x-1;a[N]=x;a[N+1]=x+1;a[N+2]=x-2;
    used[x-1]=true;used[x]=true;used[x+1]=true;used[x-2]=true;
  }
  for(i=1;i<=2*N-1;i++){
    if(N-1<=i && i<=N+2) continue;
    while(used[j]==true){
      j++;
      if(2*N-1<j)j=1;
    }
    a[i]=j;used[j]=true;
  }
  
  for(i=1;i<=2*N-1;i++)printf("%d\n",a[i]);
  return 0;
}


Measured memory_bytes: 2432
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    long K = Long.parseLong(S[1]);
    long[] num = new long[100001];
    
    for(int i = 0; i < N; i++){
      String[] T = sc.nextLine().split(" ");
      int A = Integer.parseInt(T[0]);
      int B = Integer.parseInt(T[1]);
      num[A] += B;
    }
    
    long n = 0;
    int ans = 0;
    for(int i = 1; i < 100001; i++){
      n += num[i];
      if(n >= K){
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}
    

Measured memory_bytes: 114060
#include <iostream>

using namespace std;


int main(){
    int N, d;
    cin >>N;
    int ans =0;
    int mochi[110] = {};

    for(int i =0 ; i < N; i++){
        cin >> d;
        if(mochi[d] == 0) ans++;
        mochi[d]++;
    }
    
    cout << ans << endl;
    return 0;
}
    

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

int main() {
	int n;
	cin >> n;
	vector<int64_t> as(n);
	for (auto &a : as) {
		cin >> a;
	}
	reverse(as.begin(), as.end());
	int64_t l = 2, r = 2;
	for (auto &a : as) {
		l = (l + a - 1) / a * a;
		r = r / a * a + a - 1;
		if (l > r) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << l << ' ' << r << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MAXN = 1e5  + 10;
int dp[3010][3010];
int  p[3010][3010];

int main() {
	string a, b;
	cin >> a >> b;
	a = "#" + a;
	b = "@" + b;
	
	for (int i = 1; i < (int)a.size(); i++) {
		for (int j = 1; j < (int)b.size(); j++) {
			if (a[i] == b[j]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
				p[i][j] = 0;
			} else if (dp[i - 1][j] > dp[i][j -1]) {
				dp[i][j] = dp[i - 1][j];
				p[i][j] = 1;
			} else {
				dp[i][j] = dp[i][j - 1];
				p[i][j] = 2;
			}
		}
	}
	
	int i = (int)a.size() - 1, j = (int)b.size() - 1;
	
	string ans = "";
	while (i > 0 && j > 0) {
		if (p[i][j] == 0) {
			ans += a[i];
			i--;
			j--;
		} else if (p[i][j] == 1) {
			i--;
		} else {
			j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}

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

int main(){
  cin>>n;
  for(int i=1;i<=n;i++) ans+=(n-1)/i;
  cout<<ans;
}

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

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	if (s == t.substr(0, t.size() - 1))
		cout << "Yes\n";
	else
		cout << "No\n";
}



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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, Q;
    cin >> N >> Q;
    ll ai, bi, pi, xi;
    vector<vector<ll>> G(N);
    for(int i=0;i<N-1;i++){
        cin >> ai >> bi;
        ai--; bi--;
        G[ai].push_back(bi);
    }
    vector<ll> count(N, 0);
    for(int i=0;i<Q;i++){
        cin >> pi >> xi;
        pi--;
        count[pi] += xi;
    }
    vector<ll> res(N, 0);
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        auto v = q.front(); q.pop();
        res[v] += count[v];
        for(auto c : G[v]){
            res[c] += res[v];
            q.push(c);
        }
    }
    for(int i=0;i<N;i++){
        cout<<res[i]<<" ";
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 16512
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

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

    std::string a, b, c;
    std::cin >> a >> b >> c;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && b[i] == c[i]) {
            continue;
        }

        if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) {
            ans += 2;
        } else {
            ans++;
        }
    }
    std::cout << ans << std::endl;
}


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

using namespace std;

int main() {
    stack<char> stk;
    string x;
    cin >> x;
    for (int i = 0; i < x.size(); i++) {
        if (!stk.empty()) {
            if (stk.top() == 'S' && x[i] == 'T') {
                stk.pop();
                continue;
            }
        }
        stk.push(x[i]);
    }
    cout << (stk.empty() ? 0 : stk.size());
    // string x;
    // cin >> x;
    // bool flag = true;
    // while (flag) {
    //     flag = false;
    //     bool beforeisS = false;
    //     int snum;
    //     for (int i = 0; i < x.size(); i++) {
    //         if (x[i] == 'A') {
    //             continue;
    //         }
    //         if (beforeisS && x[i] == 'T') {
    //             x[snum] = 'A';
    //             x[i] = 'A';
    //             beforeisS = false;
    //             flag = true;
    //             continue;
    //         }
    //         if (x[i] == 'S') {
    //             beforeisS = true;
    //             snum = i;
    //             continue;
    //         }
    //         beforeisS = false;
    //     }
    // }
    // int ans = 0;
    // for (int i = 0; i < x.size(); i++) {
    //     if (x[i] != 'A')
    //         ans++;
    // }
    // cout << ans;
}

Measured memory_bytes: 644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main() {
    int N;
    int dp[110000];
    vector<int> coin;

    cin >> N;
    coin.push_back(1);
    for (int i=6; i<=N; i*=6) coin.push_back(i);
    for (int i=9; i<=N; i*=9) coin.push_back(i);

    fill(dp, dp+N+1, 1e8);
    dp[0] = 0;
    
    for (int i=0; i<=N; i++) {
        for (int j=0; j < coin.size(); j++) {
            if (i >= coin[j]) {
                dp[i] = min(dp[i], dp[i-coin[j]] + 1);
            }
        }
    }

    cout << dp[N] << endl;

}


Measured memory_bytes: 640
n = int(input())
s = []
total = 0
for i in range(n):
	a = int(input())
	total += a
	s.append(a)
if total % 10 != 0:
	print(total)
else:
	s.sort()
	b = 0
	for i in range(n):
		if s[i] % 10 != 0:
			b = s[i]
			break
	if b != 0:
		print(total - b)
	else:
		print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> P(N);
    rep(i, N) cin >> P.at(i);
    rep(i, N){
        P.at(i)--;
    }
    vector<ll> C(N);
    rep(i, N) cin >> C.at(i);
    vector<vector<ll>> score(N, vector<ll>(N+1, 0));
    vector<ll> loop(N, 0);
    rep(i, N){
        ll now = i;
        bool ring = false;
        rep(j, N){
            score.at(i).at(j+1) = score.at(i).at(j) + C.at(P.at(now));
            now = P.at(now);
            if(now == i && !ring){
                loop.at(i) = j+1;
                ring = true;
            }
        }
    }
    ll ans = -1 * INF;
    rep(i, N){
        rep2(j, 1, min(K, N)+1){
            chmax(ans, score.at(i).at(j));
        }
    }
    if(K <= N){
        cout << ans << endl;
        return 0;
    }
    rep(i, N){
        ll tmp = 0;
        ll q = K / loop.at(i);
        ll r = K % loop.at(i);
        if(q >= 2){
            tmp += (q-1) * score.at(i).at(loop.at(i));
            chmax(ans, tmp);
            ll now = i;
            rep(j, r+loop.at(i)){
                tmp += C.at(P.at(now));
                chmax(ans, tmp);
                now = P.at(now);
            }
        }
        else{
            tmp += q * score.at(i).at(loop.at(i));
            chmax(ans, tmp);
            ll now = i;
            rep(j, r){
                tmp += C.at(P.at(now));
                chmax(ans, tmp);
                now = P.at(now);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 199252
s = input()
t = input()
a = set()
for i in range(len(s) - len(t) + 1):
  u = s[i: i + len(t)]
  k = len(t)
  for j in range(len(t)):
    if u[j] == t[j]:
      k -= 1
  a.add(k)
ans = min(list(a))
print(ans)

Measured memory_bytes: 8996
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <stack>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <string.h>
#include <set>
using namespace std;



int main()
{
	int H, M;
	while (scanf("%d%d", &H, &M) != EOF) {
		int N;
		scanf("%d", &N);
		int num;
		vector<int> vec;
		for (int i = 1; i <= N; ++i) {
			scanf("%d", &num);
			for (int j = 1; j <= num; ++j)
				vec.push_back(i);
		}
		for (int i = 0; i != H; ++i){
			if(i%2==0)
			for (int j = 0; j != M; ++j) {
				printf("%d%c", vec[i*M + j], j == M - 1 ? '\n' : ' ');
			}
			else {
				for(int j=0;j!=M;++j)
					printf("%d%c", vec[(i+1)*M - j-1], j == M - 1 ? '\n' : ' ');
			}
		}


	}
	return 0;
	
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (long i = 0; i < (n); ++i)

using namespace std;
using P = pair<long, long>;

void solve(long N, vector<long> A) {
  vector<P> pair_v(N);
  rep(i, N)
    pair_v[i] = P(A[i], i + 1);

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

  rep(i, N)
    cout << pair_v[i].second << (i < N - 1 ? " " : "");
  cout << endl;
}

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

  long N;
  cin >> N;
  vector<long> A(N);
  for(int i = 0 ; i < N ; i++){
    cin >> A[i];
  }
  solve(N, move(A));
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>

using namespace std;

int main() {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    int dx=x2-x1, dy=y2-y1;
    int x3=x2-dy, y3=y2+dx;
    int x4=x3-dx, y4=y3-dy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int n;
int b[105];
int main(){
	cin>>n;
	rep(i,n)cin>>b[i];
	bool flag=true;
	int ma=0;
	rep(i,n){
		if(b[i]>i+1)flag=false;
		ma=max(ma,b[i]);
	}
	if(flag){
		int ans[105]={0};
		for(int x=ma;x>=1;x--){
			for(int ind=n-1;ind>=0;ind--){
				int cnt=0;
				if(b[ind]==x){
					for(int i=0;i<ind;i++)if(b[i]<=x)cnt++;
					int num=n-1;
					int cnt2=cnt-x+2;
					while(cnt2){
						if(ans[num]==0)cnt2--;
						num--;
					}
					ans[num+1]=x;
				}
			}
		}
		rep(i,n)cout<<ans[i]<<endl;
	}else{
		cout<<-1<<endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll COST[45][415][415];

int main(){
  ll N,MA,MB,ans=INF;
  cin>>N>>MA>>MB;
  ll A[N],B[N],C[N];
  REP(i,N) cin>>A[i]>>B[i]>>C[i];
  
  REP(k,45){
    REP(i,415){
      REP(j,415){
        COST[k][i][j]=INF;
      }
    }
  }
  COST[0][0][0]=0;
  
  RREP(k,N){
    REP(i,401){
      REP(j,401){
        chmin(COST[k][i+A[k-1]][j+B[k-1]],COST[k-1][i][j]+C[k-1]);
        chmin(COST[k][i][j],COST[k-1][i][j]);
      }
    }
  }
  
  REP(i,401){
    REP(j,401){
      if(MA*j==MB*i && i*j!=0){
        chmin(ans,COST[N][i][j]);
      }
    }
  }
  
  if(ans==INF) ans=-1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 64132
#include <bits/stdc++.h>
using namespace std;
long double a,b,h,m;
#define PI 3.14159265358
int main()
{
#ifdef MY
    freopen("input.txt","r",stdin);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #define endl '\n';
#endif
    cin>>a>>b>>h>>m;
    long double angleHours=360/12*h+360*m/12/60;
    long double angleMin=360/60*m;
    long double angle=max(angleHours,angleMin)-min(angleHours,angleMin);
    long double answ=a*a+b*b-2*a*b*cos(angle*PI/180);
    answ=sqrt(answ);
    cout<<fixed<<setprecision(10);
    cout<<answ;
}


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

int main(void) {
	string s, t, u; cin >> s >> t;
	int a, b; cin >> a >> b;
	cin >> u;

	if (s == u) {
		a--;
	}
	else {
		b--;
	}
	cout << a << " " << b << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
h=[int(i) for i in input().split()]
count=n
for i in reversed(range(1,n)):
    for j in reversed(range(0,i)):
        #print(count)
        #print(h[i],h[j])
        if h[i]<h[j]:
            count-=1
            break
print(count)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int A[1000][1000]={{}};
int b[1000]={};
int main(){
 int n, m, i, j;
 int sum;
 cin >> n >> m;
 for(i=0; i<n; i++){
     for(j=0;j<m;j++){
         cin >> A[i][j];
     }
 }
 for(i=0; i<m; i++){
     cin >>b[i];
 }
 for(i=0; i<n; i++){
     sum = 0;
     for(j=0; j<m; j++){
         sum += A[i][j] * b[j];
     }
     cout << sum << endl;
 }
}


Measured memory_bytes: 3464
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;


int main(){
	int sx,sy,tx,ty;
	int x,y;
	cin>>sx>>sy>>tx>>ty;
	x=tx-sx;
	y=ty-sy;
	for(int i=0;i<x;i++){
		cout<<"R";
	}
	for(int i=0;i<y;i++){
		cout<<"U";
	}
	for(int i=0;i<x;i++){
		cout<<"L";
	}
	for(int i=0;i<y;i++){
		cout<<"D";
	}
	cout<<"D";
	for(int i=0;i<x+1;i++){
		cout<<"R";
	}
	for(int i=0;i<y+1;i++){
		cout<<"U";
	}
	cout<<"L";
	cout<<"U";
	for(int i=0;i<x+1;i++){
		cout<<"L";
	}
	for(int i=0;i<y+1;i++){
		cout<<"D";
	}
	cout<<"R"<<endl;
}

Measured memory_bytes: 256
N = int(input())
dp = list(range(N+1))

i = 6
while i <= N:
    for j in range(i, N+1):
        dp[j] = min(dp[j], 1+dp[j-i])
    i = i*6
i = 9
while i <= N:
    for j in range(i, N+1):
        dp[j] = min(dp[j], 1+dp[j-i])
    i = i*9
print(dp[N])

Measured memory_bytes: 6900
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
    int a;
  cin>>a;
  vector<int> b(12);
  b={1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
  int dp[15][100010];
  rep(i,15)rep(j,100010){
  dp[i][j]=INF;
  }
  dp[0][0]=0;
  rep(i,12)rep2(j,a){
  if(j>=b[i])
    dp[i+1][j]=min(dp[i][j],dp[i+1][j-b[i]]+1);
    chmin(dp[i+1][j],dp[i][j]);
  }
  cout<<dp[12][a]<<endl;
}

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

public class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int ab = int.Parse(input[0] + input[1]);
        double sq = Math.Sqrt(ab);
        if ((int)sq == sq)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

signed main() 
{
    int x1,y1,x2,y2,x3,y3,x4,y4; 
    cin >> x1 >> y1 >> x2 >> y2; 

    x3 = x2 +(y1-y2);
    y3 = y2 -(x1-x2);

    x4 = x3 + x1-x2;
    y4 = y3 + y1-y2;

    cout << x3 << " " << y3 <<" " << x4 << " " << y4; 
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int bipartite_matching(vector<pair<int, int>> &E, int X, int Y){
	int V = X + Y + 2;
	vector<set<int>> E2(V);
	for (int i = 0; i < X; i++){
		E2[0].insert(i + 1);
	}
	for (int i = 0; i < E.size(); i++){
		int v = E[i].first;
		int w = E[i].second;
		E2[v + 1].insert(X + 1 + w);
	}
	for (int i = X + 1; i < V - 1; i++){
		E2[i].insert(V - 1);
	}
	int F = 0;
	while (1){
		vector<bool> used(V, false);
		vector<int> prev(V, -1);
		used[0] = true;
		queue<int> Q;
		Q.push(0);
		while (!Q.empty()){
			int v = Q.front();
			Q.pop();
			for (int w : E2[v]){
				if (!used[w]){
					used[w] = true;
					prev[w] = v;
					Q.push(w);
				}
			}
		}
		if (!used[V - 1]){
			break;
		}
		int c = V - 1;
		while (c != 0){
			E2[prev[c]].erase(c);
			E2[c].insert(prev[c]);
			c = prev[c];
		}
		F++;
	}
	return F;
}
int main(){
  int X, Y, e;
  cin >> X >> Y >> e;
  vector<pair<int, int>> E(e);
  for (int i = 0; i < e; i++){
    int x, y;
    cin >> x >> y;
    E[i] = make_pair(x, y);
  }
  cout << bipartite_matching(E, X, Y) << endl;
}


Measured memory_bytes: 3364
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rpd(i,s,e,d) for(int i=(s);i<(int)(e);i+=(d))

int gcd_all(vi &A){ int g = 0; for(int a:A) g = gcd(g, a); return g; }

int sum_array(vi &C, int start, int end, int step){
	int c = 0;
	rpd(i, start, end, step) c += C[i];
	return c;
}

bool is_pairwise(vi &A){
	int MAX_A = 1000000 + 1;
	vi C(MAX_A, 0); for(int a:A) C[a]++;
	if(sum_array(C, 2, MAX_A, 2) > 1) return false;
	rpd(i, 3, MAX_A, 2) if(sum_array(C, i, MAX_A, i) > 1) return false;
	return true;
}

int solve(vi &A){
	if(is_pairwise(A)) return 0;
	if(gcd_all(A) == 1) return 1;
	return 2;
}

int main(){
	int N; cin>>N;
	vi A(N); for(auto& a:A) cin>>a;
	cout<< vector<string>{"pairwise","setwise","not"}[solve(A)] <<" coprime\n";
}


Measured memory_bytes: 11180
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
using namespace std;
typedef long long ll;

int main(){
    int n;
    scanf("%d",&n);
    int dist[101],num[101],ban[101];
    for(int i=0;i<=100;i++){
        dist[0]=num[0]=0;
    }
    for(int i=0;i<n;i++){
        int b,d,v;
        scanf("%d%d%d",&b,&d,&v);
        ban[i]=b;
        dist[i]=d;
        num[i]=v;
    }
    double dp[1<<n][n];
    double before[1<<n][n];
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            dp[i][j]=3000000;
        }
    }
    for(int i=0;i<n;i++){
        dp[1<<i][i]=dist[i]/(2000/70.0);
    }
    for(int i=1;i<(1<<n);i++){
        int wei=0;
        for(int j=0;j<n;j++){
            if(i&(1<<j)) wei+=num[j]*20;
        }
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                int befst=i-(1<<j);
                for(int k=0;k<n;k++){
                    if(befst&(1<<k)){
                        double next=dp[befst][k]+(double)abs(dist[j]-dist[k])/(2000/(70.0+(wei-num[j]*20)));
                        if(next<dp[i][j]){
                            dp[i][j]=next;
                            before[i][j]=k;
                        }
                    }
                }
            }
        }
    }
    int mi=3000000,at;
    for(int i=0;i<n;i++){
        if(dp[(1<<n)-1][i]<mi){
            mi=dp[(1<<n)-1][i];
            at=i;
        }
    }
    int kei[101];
    int nowst=(1<<n)-1,nowat=at,tmp;
    for(int i=0;i<n;i++){
        kei[i]=nowat;
        tmp=nowat;
        nowat=before[nowst][nowat];
        nowst=nowst-(1<<tmp);
    }
    for(int i=n-1;i>=1;i--){
        printf("%d ",ban[kei[i]]);
    }
    printf("%d\n",ban[kei[0]]);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define mod 1000000007
#define pp pair<ll,ll>
typedef long long int ll;
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++)    
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll, ll);
ll modadd(ll, ll, ll);
ll modpower(ll, ll, ll);
ll gcd(ll, ll );
ll modinv(ll, ll);
 

int main()
{
   string a,b;
   cin>>a>>b;
   ll count=0;
   rep(i,3){
      if(a[i]==b[i]) count++;
   }
   cout<<count<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b, ll m){
   return ((a%m)*(b%m))%m;
}
ll modadd(ll a, ll b, ll m){
   return ((a%m)+(b%m)+m)%m;
}
ll modpower(ll a, ll n, ll m){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a,m);
      a = modmulti(a,a,m);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a, ll m){
   return modpower(a,m-2,m);
}

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

#define INF 900000000
#define LINF 9000000000000000000

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

ll n;
priority_queue<ll, vector<ll>, greater<ll> > pq;



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

	cin >> n;
	ll ans;
	ll c = n;
	while (c != 0) {
		c/=10; ans++;
	}
	for (ll i = 1ll; i*i <= n; i++) {
		if (n % i != 0) continue;
		ll a = n / i;
		ll b = i;
		ll cnta=0, cntb=0;
		while (a != 0) {
			a/=10;
			cnta++;
		}
		while (b != 0) {
			b/=10;
			cntb++;
		}
		ans = min(ans, max(cnta, cntb));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
n = int(raw_input()) # トッピングの種類
a, b = map(int, raw_input().split(' ')) # 生地の値段、各トッピングの値段
c = int(raw_input()) # 生地のカロリー

toppings = [int(raw_input()) for x in xrange(n)]

toppings.sort(reverse=True)

part_sum = [0] * (n + 1)
for index, cal in enumerate(toppings):
    part_sum[index + 1] = part_sum[index] + cal

ans = 0

for x in xrange(n + 1):
    p = (c + part_sum[x]) / (a + b * x)
    ans = max(ans, p)

print ans

Measured memory_bytes: 4240
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        String S = reader.next();
        for (int i=0; i<S.length(); i++) {
            if ((i%2==0 && S.charAt(i)=='L') || (i%2==1 && S.charAt(i)=='R')) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
    
    public static void solver() {
        // write logic
    }
    
    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 22484
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	A=LI()
	B=LI()
	pos=0
	neg=0

	for i,j in zip(A,B):
		if j-i>=0:
			pos+=(j-i)//2
		else:
			neg+=-j+i
	if pos>=neg:
		ans="Yes"
	else:
		ans="No"

	print(ans)






if __name__ == "__main__":
	main()


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

#include "bits/stdc++.h"

using namespace std;
#define int long long


class AMultipleOf2AndN {
public:
    void solve(std::istream &in, std::ostream &out) {
      int n;
      in >> n;
      if (n % 2 == 0) {
        out << n << endl;
      } else {
        out << n * 2 << endl;
      }
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  AMultipleOf2AndN solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
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<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(){
    ll n, k;
    cin >> n >> k;
    
    
    cout<< min (n%k, k - (n%k)) <<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
const int N=1e5+5;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,ans;bool a[N];int b[N];
int main(){
	n=read();m=read();
	rep(i,1,n)a[i]=0,b[i]=1;a[1]=1;
	rep(i,1,m){
		int x=read(),y=read();
		a[y]|=a[x];b[y]+=1;
		b[x]-=1;if(b[x]==0)a[x]=0;
	}
	rep(i,1,n)ans+=a[i];
	return printf("%d\n",ans),0;
}

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

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);

LL cnt[10][10];
int main()
{
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        int L = i % 10;
        int F = i;
        while(F >= 10)F = F/10;
        cnt[F][L]++;
    }
    LL ans = 0;
    for(int i = 1;i <= n;i++){
        int L = i % 10;
        int F = i;
        while(F >= 10)F = F/10;
        ans = ans + cnt[L][F];
    }
    cout << ans << "\n";
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;

int main(){
	long long int n,a,b,c,l[2000],fin=1,four[10]={1,4,16,64,256,1024,4096,16384,65536,262144},res=9999999999,tmp=0;
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++){
		
		cin>>l[i];
		fin*=4;
	}
	
	for(int i=0;i<fin;i++){
		
		long long int three[5]={},cost[5]={};
		int copy=i;
		for(int j=0;j<n;j++){
			
			if((copy/four[j])%4==0){
				
			}else{
				if(three[(copy/four[j])%4]!=0)
				{
					cost[(copy/four[j])%4]+=10;
				}
				three[(copy/four[j])%4]+=l[j];
			}
			
		}
		
		if(three[1]*three[2]*three[3]==0)
		{
			continue;
		}else{
			tmp=cost[1]+cost[2]+cost[3];
			tmp+=abs(three[1]-a);
			tmp+=abs(three[2]-b);
			tmp+=abs(three[3]-c);
			
			if(res>tmp){
				res=tmp;
			}
		}
		
	}	
	cout<<res;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int N,max1=0,max2=0,temp,ans1=0,ans2;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
    if(A[i]>max1){
      max1=A[i];
      ans1=i;
    }
    else if(A[i]>max2){
      max2=A[i];
      ans2=i;
    }
  }
  for(int h=0;h<N;h++){
    if(h==ans1) cout<<max2<<endl;
    else cout<<max1<<endl;
  }
}

Measured memory_bytes: 2432
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut vec: Vec<i64> = Vec::with_capacity(n);

    let mut first: i64 = 0;
    let mut second: i64 = 0;
    for _i in 0..n {
        let a: i64 = iterator.next().unwrap().parse().unwrap();
        if a > first {
            second = first;
            first = a;
        } else if a > second {
            second = a;
        }
        vec.push(a);
    }

    let mut answer = String::new();

    for i in 0..n {
        let a = vec[i];
        if a == first {
            answer += &format!("{}\n", second);
        } else {
            answer += &format!("{}\n", first);
        }
    }

    return answer;
}


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

int main() {
  int N;
  cin >> N;
  vector <int> A(N);
  for (int i=0;i<N;i++){
  cin >> A.at(i);
  }
  vector <int> B(N);
  for (int i=0;i<N;i++){
  B.at(A.at(i)-1)=i+1;
  }
  for (int i=0;i<N;i++){
   cout << B.at(i);
  if (i<N-1){
   cout << " "; 
  }
  else {
   cout << endl;
  }
  }
 }

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var xy = Array.ConvertAll(ReadLine().Split(' '), ulong.Parse);
        var res = 0;
        while (xy[0] <= xy[1])
        {
            xy[0] *= 2;
            res++;
        }
        WriteLine(res);
    }
}


Measured memory_bytes: 11092
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
a = ""
ans = []
for i in range(N):
  if a == "": a = A[i]
  elif a != A[i]: a = A[i]
  elif A[i] == a:
    ans.append(A[i])
    a = ""
    if len(ans) == 2: break
print(0 if len(ans) != 2 else ans[0] * ans[1])

Measured memory_bytes: 14608
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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



	int H, W, K;
	cin >> H >> W >> K;
	int SX, SY, GX, GY;
	cin >> SX >> SY >> GX >> GY;
	SX--;
	SY--;
	GX--;
	GY--;

	int C[1000000];
	ll D[4000000];

	rep(i, H * W * 4) {
		D[i] = 1e18;
	}
	rep(i, H) {
		string S;
		cin >> S;
		rep(j, W) {
			if (S[j] == '.') {
				C[i * W + j] = 0;
			}
			else {
				C[i * W + j] = 1;
			}
		}
	}

#define PT pair<ll, int>
	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;

	auto CHK = [&](int t, ll d) {
		if (!C[t / 4] && D[t] > d) {
			D[t] = d;
			q.push({ d, t });
		}
	};

	int st = SX * W + SY;
	int gl = GX * W + GY;

	D[st * 4] = 0;
	D[st * 4 + 1] = 0;
	D[st * 4 + 2] = 0;
	D[st * 4 + 3] = 0;
	q.push({ 0, st * 4});
	q.push({ 0, st * 4 + 1 });
	q.push({ 0, st * 4 + 2 });
	q.push({ 0, st * 4 + 3 });
	while (q.size()) {
		PT p = q.top();
		q.pop();
		int f = p.second;
		if (D[f] != p.first) continue;

		int dir = f % 4;
		int hw = f / 4;
		int h = hw / W;
		int w = hw % W;

		ll up = (D[f] + K - 1) / K * K;
		if (h > 0) CHK((hw - W) * 4, dir == 0 ? D[f] + 1 : up + 1);
		if (h < H - 1) CHK((hw + W) * 4 + 1, dir == 1 ? D[f] + 1 : up + 1);
		if (w > 0) CHK((hw - 1) * 4 + 2, dir == 2 ? D[f] + 1 : up + 1);
		if (w < W - 1) CHK((hw + 1) * 4 + 3, dir == 3 ? D[f] + 1 : up + 1);
	}

	//rep(i, H) {
	//	rep(j, W) {
	//		int hw = i * W + j;
	//		hw *= 4;
	//		cesp(*min_element(D + hw, D + hw + 4));
	//	}
	//	ce("");
	//}

	ll kotae = (*min_element(D + gl * 4, D + gl * 4 + 4) + K - 1) / K;
	if (kotae > 1e11) co(-1);
	else co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 42464