akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    vector<P> r(n), b(n);
    REP(i,n){
        cin >> r[i].first >> r[i].second;
    }
    REP(i,n){
        cin >> b[i].first >> b[i].second;
    }

    sort(ALL(r));
    sort(ALL(b));

    int ans = 0;
    multiset<int> st;
    int j = n-1;
    FORR(i,n-1,0){
        while (j >= 0 && b[j].first > r[i].first){
            st.insert(b[j].second);
            j--;
        }
        if (st.upper_bound(r[i].second) != st.end()){
            st.erase(st.upper_bound(r[i].second));
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func check() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)

	max := scanInt(sc)
	count := 1

	for i := 1; i < n; i++ {
		h := scanInt(sc)
		if h < max {
			continue
		} else {
			max = h
			count++
		}

	}
	fmt.Printf("%d\n", count)

}

func main() {
	check()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
	int n;
	cin >> n;
	ll ans = 0LL;
	rep(i, n) {
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")
cin = input.split(/ |\n/), cid = 0
const next = () => cin[cid++]
const nexts = (n) => cin.slice(cid, cid+=n).map(j=>parseInt(j))

const N = next()
H = nexts(N)
H.pop()
M = Array(N)

for (i = 0; i < N; i++) {
    if (i == 0) {
        M[i] = 0
    } else if (i == 1) {
        M[i] = M[i-1] + Math.abs(H[i] - H[i-1])
    } else {
        M[i] = Math.min(
            M[i-2] + Math.abs(H[i] - H[i-2]),
            M[i-1] + Math.abs(H[i] - H[i-1])
            )
        }
    }
    console.log(M.pop())


Measured memory_bytes: 33344
#include <bits/stdc++.h>
using namespace std;
int main( )
{
    int n,m;
    map<string,int>mp1,mp2;
    int i,j,k,l;
    string s;
    vector<string>v;
    cin>>n;
    for (i =0;i<n;i++){
        cin >> s;
        v.push_back(s);
        mp1[s]++;
    }
    cin>>m;
    for (i=0;i<m;i++){
        cin >> s;
        mp2[s]++;
    }
    int mx=0;
    for (i=0;i<n;i++){
        int x = mp1[v[i]];
        int y = mp2[v[i]];
        mx=max(mx,x-y);
    }
    cout<<mx<<endl;
    return 0;
}


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

using namespace std;

const int M = 1e9 + 7;

int gcd(int a, int b , int c){
  return __gcd(a , __gcd(b , c));
}

int main() {
  int n ; cin>>n;
  int ans = 0;
  for(int i = 1 ; i <= n; ++i){
    for(int j = 1 ; j <= n; ++j){
      for(int k = 1 ; k <= n; ++k){
        ans += gcd(i , j , k);
      }
    }
  }
  cout<<ans<<"\n";
}

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

#include <iostream>
#include <string>
using namespace std;

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

	int N;
	long long A[100002] = {0};

	cin >> N;
	for(int i=1; i<=N; i++){
		cin >> A[i];
		if(A[i] == 0){
			cout << "0" << endl;
			return 0;
		}
	}

	long long lim = 1;
	for(int i=0; i<18; i++){
		lim *= 10;
	}

	long long ans = 1;
	for(int i=1; i<=N; i++){
		if(ans == 0){
			cout << "0" << endl;
			return 0;
		}
		if(ans != 0 && A[i] > lim){
			cout << "-1" << endl;
			return 0;
		}
		if((lim / ans) + 1 <= A[i]){
			cout << "-1" << endl;
			return 0;
		}
		ans *= A[i];
		if(ans > lim){
			cout << "-1" << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 4436
# D
N, W = map(int, input().split())

import numpy as np
dp = np.zeros(W+1, dtype="int64")

for i in range(1, N+1):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[0:W-w+1] + v)

print(dp[-1])

Measured memory_bytes: 15408
#include <iostream>
#include <string>

using namespace std;

int main() {
	int a,b,c,d;
	cin >> a >> b >> c >> d;

	int x = 0;
	
	for (int i = 0; true; i++)
	{
		c = c - b;
		if (c <= 0)
			break;

		a = a - d;
		if (a <= 0)
		{
			x = 1;
			break;
		}


	}
	
	if (x == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;

	}



	return 0;
}




Measured memory_bytes: 3672
public class Main {
  public static void main(String[] args) {
    String S = new java.util.Scanner(System.in).nextLine();
    if (S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

typedef long long ll;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int D = max({A, B, C}) * 3 - A - B - C;
    if (D % 2) D += 3;
    cout << D / 2 << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int A, B, C;

int main() {
  cin >> A >> B >> C;

  int counter = 0;
  if(A == B) counter++;
  if(B == C) counter++;
  if(C == A) counter++;
  if(counter == 1) cout <<"Yes";
  else cout << "No";
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	// all -q, add 1 if they got it right
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> sub(n, q);
	for(int i = 0; i < q; i++) {
		int x;
		cin >> x;
		x--;
		sub[x]--;
	}
	
	for(int i = 0; i < n; i++) {
		if(sub[i] < k) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}
}


Measured memory_bytes: 1024
#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[i];
  }
  sort(A.begin(), A.end(), greater<int>());
  
  long long s1 = 0, s2 = 0;
  
  for(int i = 0; i < N - 1; i++){
    if(A[i] == A[i+1]) {
      if(s1) {
        s2 = (long long)A[i];
        break;
      }else{
        s1 = (long long)A[i];
      }
      i++;
    }
  }
  
  cout << s1 * s2;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_`{|}~"); // ok
//string HOGE(";<=>?@[\\]^_`{|}~"); // bad
//string HOGE(".!\"#&%&'()*+,-/:"); // ok
//string HOGE(".!\"#&%&'("); // bad
//string HOGE(".!\"#&%&'()*+,-/:"); // ok
string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_`{|}~"); // ok

int main(void) {
	string s;

	int total = 0;

	while (cin >> s) {
		replace_if(s.begin(), s.end(), [](char c){ return isalpha(c) || c == '.' || HOGE.find(c) != string::npos; }, ' ');
		
		istringstream iss(s);
		int num;
		while (iss >> num) {
			total += num;
		}
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    cin >> S;
    rep(i, 3) {
        if (S[i] == '1') S[i] = '9';
        else S[i] = '1';
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
using namespace std;

const long double PI = 3.14159265358979323846;
long double A, B, H, M;
int main() {
	cin >> A >> B >> H >> M;
	long double a = ((60*H) + M)/720 * 2*PI;
	long double b = (M/60) * 2*PI;

	long double rad = abs(a-b); rad > PI ? 2*PI - rad : rad;
	long double ans = A*A + B*B - 2*A*B*cos(rad);
	ans = sqrt(ans);
	cout << fixed << setprecision(20) << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

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

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  // FOR(i, 1, 19) { ans += N / (POW(10, i)); }
  // cout << N << endl;

  FOR(i, 1, 27) { ans += ((N / 2) / POW(5LL, i)); }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*
This is code of SuperJ6 for Atcoder.
Don't copy my code during f*kin' contests.

2.71828182845904523536
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <iomanip>
using namespace std;
#define endl '\n'

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(7);
	
	int n;
	cin >> n;
	
	long double sum = 0;
	for(int i = 0; i < n; i++){
		long double x;
		cin >> x;
		sum += 1 / x;
	}
	
	cout << (1 / sum) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,x;
    char ch;
    cin >> n;
    int a[4][13];
    for(int i = 0;i < 4;i++){
        for(int j = 0;j < 13;j++){
          a[i][j]=0;
        }
    }
    for(int i = 0;i < n;i++){
        cin >> ch >> x;
        if(ch == 'S'){
            a[0][x-1] = 1;
        }else if(ch == 'H'){
            a[1][x-1] = 1;
        }else if(ch == 'C'){
            a[2][x-1] = 1;
        }else if(ch == 'D'){
            a[3][x-1] = 1;
        }
    }

    // cout << "start\n";
    for(int i = 0;i < 4;i++){
        for(int j = 0;j < 13;j++){
          // cout << a[i][j] << "\n";
            if(a[i][j]==0){
                switch(i){
                    case 0:
                    cout << 'S' << " " << j+1 << "\n";
                    break;
                    case 1:
                    cout << 'H' << " " << j+1 << "\n";
                    break;
                    case 2:
                    cout << 'C' << " " << j+1 << "\n";
                    break;
                    case 3:
                    cout << 'D' << " " << j+1 << "\n";
                    break;
                }
            }
        }
    }
    return 0;
}


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

int main(){
  string T;
  cin >> T;
  int N=0, S=0, E=0, W=0;
  for(int i=0; i<T.size(); i++){
    if(T.at(i)=='N'){
      N=1;
    }
    if(T.at(i)=='S'){
      S=1;
    }
    if(T.at(i)=='E'){
      E=1;
    }
    if(T.at(i)=='W'){
      W=1;
    }
  }
  if(N!=S || E!=W){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;
	static int[] par, dep, ch;

	static void solve() {
		char[] s=ir.next().toCharArray();
		int ret=0;
		for(int i=0;i<s.length;i++)
			ret+=s[i]-'0';
		out.println(ret);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

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

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 21076
n = int(input())
s = [input() for _ in range(n)]
M = A = R = C = H = 0
for i in range(len(s)):
    if s[i][0] == 'M':
        M += 1
    if s[i][0] == 'A':
        A += 1
    if s[i][0] == 'R':
        R += 1
    if s[i][0] == 'C':
        C += 1
    if s[i][0] == 'H':
        H += 1
ans = (M*A*R) + (M*A*C) + (M*A*H) + (M*R*C) + (M*R*H) + (M*C*H) + (A*R*C) + (A*R*H) + (A*C*H) + (R*C*H)
print(ans)

Measured memory_bytes: 9752
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define int long long

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)

#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

#define mi(N) int N; cin >> N;
#define ms(s) string s; cin >> s;
#define md(d) double d; cin >> d;
#define mv(v, N) vi v(N); rep(N)cin >> v[i];

#define mod 1000000007
#define out_of_grid(x, y) x < 0 || y < 0 || x >= h || y >= w

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

namespace mp = boost::multiprecision;
using INT = mp::cpp_int;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

void Yay(bool b) {
	if (b)say("Yay!");
	else say(":(");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

template<typename T>
vector<vector<T>> fill_vector(int h, int w, T val) {
	vector<vector<T>> ret;
	vector<T> v(w, val);
	rep(h)ret.push_back(v);
	return ret;
}

signed main() {
	cout.precision(16);
	ms(s);
	int cnt = 0;
	for (char c : s)if (c == 'x')cnt++;
	YN(cnt < 8);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#AGC2 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
cnt = [1]*n
check = [True if i == 0 else False for i in range(n)]
for _ in range(m):
    x,y = LI()
    if check[x-1]:
        check[y-1] = True
        cnt[x-1] -= 1
        cnt[y-1] += 1
        if cnt[x-1] == 0:
            check[x-1] = False
    else:
        if cnt[x-1] > 0:
            cnt[x-1] -= 1
            cnt[y-1] += 1
ans = check.count(True)
print(ans)

Measured memory_bytes: 45552
#include <vector>
//#include <optional> // C++17
#include <boost/optional.hpp>
auto const none = boost::none;


template<class T> struct AdjMat {
  using size_t = std::size_t;
  size_t n; std::vector< std::vector< boost::optional<T> > > dat;
  AdjMat() {}
  AdjMat(size_t n) : n(n), dat(n, std::vector<boost::optional<T>>(n)) {}
  void init(size_t n) { this->n = n; dat.resize(n); for(size_t i=0;i<n;++i) dat[i].assign(n, none); }
  auto& operator[](size_t i) { return dat[i]; }
  void de(size_t i, size_t j, T v) { dat[i][j] = v; }
  void e(size_t i, size_t j, T v) { de(i, j, v); de(j, i, v); }
  auto begin() { return dat.begin(); }
  auto end() { return dat.end(); }
  size_t size() const { return n; }
  void wf() {
    for(size_t k=0; k<size(); ++k) for(size_t i=0; i<size(); ++i) for(size_t j=0; j<size(); ++j) {
      if(!dat[i][k] || !dat[k][j]) continue;
      T v = *dat[i][k] + *dat[k][j];
      if(!dat[i][j] || v < *dat[i][j]) dat[i][j] = v;
    }
  }
};
using Graph = AdjMat<long long>;


#include <iostream>

void abc143_e() {
  using namespace std;
  int N, M; long long L;
  cin >> N >> M >> L;
  Graph g(N);
  for(int i=0;i<M;++i) {
    int A, B, C;
    cin >> A >> B >> C;
    g.e(--A, --B, C);
  }

  g.wf();
  for(auto& v : g) for(auto& e : v) if(e && *e <= L) e = 1; else e = none;
  g.wf();

  int Q; cin >> Q;
  for(int i=0;i<Q;++i) {
    int s, t;
    cin >> s >> t;
    --s; --t;
    cout << (g[s][t] ? *g[s][t]-1 : -1) << '\n';
  }
}

signed main() {

  abc143_e();

  return 0;
}


Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Node
    {
        internal List<int> target;
        internal int inDegree;
        internal bool isVisit;

        public Node()
        {
            target = new List<int>();
        }
    }

    class SearchOrder
    {
        Node[] list;
        List<int> result;

        public SearchOrder(int m)
        {
            list = Enumerable.Range(0, m).Select(a => new Node()).ToArray();
            result = new List<int>();
        }

        public void MakeList(int s, int t)
        {
            list[s].target.Add(t);
            list[t].inDegree++;
        }

        public void Print()
        {
            TopologicalSort(list);

            StringBuilder sb = new StringBuilder();

            foreach (int node in result)
            {
                sb.AppendLine((node + 1).ToString());
            }
            Console.Write(sb);
        }

        private void TopologicalSort(Node[] NL)
        {
            for (int i = 0; i < NL.Length; i++)
            {
                if (NL[i].inDegree == 0 && !NL[i].isVisit)
                {
                    BFS(NL, i);
                }
            }
        }

        private void BFS(Node[] NL, int s)
        {
            Queue<int> que = new Queue<int>();
            que.Enqueue(s);

            NL[s].isVisit = true;

            while (que.Count > 0)
            {
                int u = que.Dequeue();
                result.Add(u);

                for (int i = 0; i < NL[u].target.Count; i++)
                {
                    int v = NL[u].target[i];
                    NL[v].inDegree--;

                    if (NL[v].inDegree == 0 && !NL[v].isVisit)
                    {
                        NL[v].isVisit = true;
                        que.Enqueue(v);
                    }
                }
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int m = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());

            SearchOrder S = new SearchOrder(m);

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int x = int.Parse(input[0]) - 1;
                int y = int.Parse(input[1]) - 1;

                S.MakeList(x, y);
            }
            S.Print();
        }
    }
}

Measured memory_bytes: 10612
#d...縦で入力された複数の要素を配列で取得
n = int(input())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
a = [int(m) for m in d]#int型に直す
a.sort()
A = sum(a)
for i in range(n):
    if A % 10 != 0:
        print(A)
        exit()
    else:
        A -= a[i]
        if i != 0:
            A += a[i - 1]
print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int main(){
  int a,b,c;
  while(~scanf("%d%d%d",&a,&b,&c)){
    bool f[11];
    REP(i,11)f[i]=true;
    f[0]=false;
    f[a]=false;
    f[b]=false;
    f[c]=false;
    int up = 0;
    int down = 0;
    REP(i,11){
      if(!f[i])continue;
      if(a+b+i<=20)++down;
      else ++up;
    }
    if(down>=up)printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 1168
N = int(input())
L = list(map(int, input().split()))

L.sort()

ans = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if L[i] < L[j] < L[k] and L[k] < L[i] + L[j]:
        ans += 1
print(ans)


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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    string s;
    cin>>s;
    int y=((int)s[0]-'0')*10+((int)s[1]-'0');
    int m=((int)s[2]-'0')*10+((int)s[3]-'0');

    if(y==0||y>12){
        if(m==0||m>12){
            cout<<"NA"<<endl;
        }
        else cout<<"YYMM"<<endl;
    }
    else{
        if(m==0||m>12){
            cout<<"MMYY"<<endl;
        }
        else cout<<"AMBIGUOUS"<<endl;
    }
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int n;
    ll c, k;
    cin >> n >> c >> k;
    vector<ll>t(n);
    rep(i, 0, n)cin >> t[i];
    sort(t.begin(),t.end());
    int ans=0;
    ll cnt = 0;
    
    for(int i=0; i<n;){
        ans++;
        int start = i;
        while(i<n && t[start]+k>=t[i] && start+c>i)i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3972
h, w = map(int, input().split())

a = [list(input()) for _ in range(h)]
cnt = 1
for x in range(h):
    for y in range(w):
        if a[x][y] == '#':
            cnt += 1
            

if cnt == h+w:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
  int N; cin >> N;

  int total = 0;
  vector<int> W(N);
  for (int i = 0; i < N; i++) {
    cin >> W[i];
    total += W[i];
  }

  int sum = 0, sum_b;
  for (int i = 0; i < N; i++) {
    sum += W[i];
    if (sum*2 >= total) {
      sum_b = sum - W[i];
      break;
    }
  }

  cout << min(abs(total-sum*2), abs(total-sum_b*2)) << endl;
    
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    set<string> tbl;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        tbl.insert(s);
    }
    cout << tbl.size() << endl;
    return 0;
}

Measured memory_bytes: 19100
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

template<class T> void chmin(T &a, T b){a=min(a, b);}
template<class T> void chmax(T &a, T b){a=max(a, b);}

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modRev(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modRev(fact(k)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  int p[n];
  rep(i,n){
    cin>>p[i];
    p[i]--;
  }
  int a[n],b[n];
  for(i=0;i<n;i++){
    a[i]=2*n*(i+1);
    b[i]=2*n*(n-i);
  }
  for(i=0;i<n;i++){
    b[p[i]]+=i;
  }
  cout<<a[0];
  for(i=1;i<n;i++)cout<<" "<<a[i];
  cout<<endl;
  cout<<b[0];
  for(i=1;i<n;i++)cout<<" "<<b[i];
  cout<<endl;
}


Measured memory_bytes: 896
import java.util.Scanner;

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

        String a = sc.next();
        String b = sc.next();

        int num = Integer.valueOf(a + b);

        int ans = 1;
        for (int i = 2; i * i <= num; i++) {
            if (num % i == 0) {
                ans = i;
            }
        }

        System.out.println((ans * ans == num)? "Yes": "No");
    }
}

Measured memory_bytes: 23764
N = int(input())

res = {}
for i in range(N):
    s = input()
    if not s in res:
        res[s] = 1
    else:
        res[s] += 1

m = max(res.values())
keys = [k for k, v in res.items() if v == m]
keys.sort()

for i in range(len(keys)):
  print(keys[i])




Measured memory_bytes: 32096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(){
    ll n;
    cin >> n;
    ll h[100000];
    for (ll i = 0; i < n;i++){
        cin >> h[i];
    }
    ll dp[100000];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n;i++){
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1792
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  str s; cin >> s;
  if(s == "ABC") fin("ARC");
  else fin("ABC");
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


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

int main(){
  string A,B,C;cin >> A >> B >> C;
  if(A[A.size()-1]==B[0]&&B[B.size()-1]==C[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3612
import itertools 
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
X=[a,b,c,d,e]
S=list(itertools.combinations(X,2))
ans='Yay!'
for i in range(len(S)):
    if abs(S[i][0]-S[i][1])>k:
        ans=':('
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int n,q;cin >> n >> q;
  string s;cin >> s;
  string key = "AC";
  vector<int> data(s.size(),0);
  REP(i,0,s.size()-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      data[i+1] = data[i]+1;
    }
    else data[i+1] = data[i];
  }
  /*for(auto &i:data) cout << i << " ";
  cout << endl;*/
  rep(i,q){
    int l,r;cin >> l >> r;
    int ans = 0;
    l--,r--;
    cout << data[r]-data[l] << endl;
  }

}


Measured memory_bytes: 1408
A, B, C, X, Y = map(int, input().split())
if A + B > 2 * C:
    a = min(X, Y)
    c = a * 2 * C
    if a == Y:
        if A > 2 * C:
            print(c + 2 * C * (X - a))
        else:
            print(c + (X - a) * A)
    else:
        if B > 2 * C:
            print(c + 2 * C * (Y - a))
        else:
            print(c + (Y - a) * B)
else:
    print(A * X + B * Y)


Measured memory_bytes: 3064
def main():
    N = int(input())
    H = [0] * N
    retval = 0
    for i in range(N):
        a, b = tuple(map(int, input().split()))
        retval -= b
        key = a+b
        H[i] = key
    H.sort(reverse=True)
    retval += sum(H[::2])

    print(retval)


if __name__ == "__main__":
    main()


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

using namespace std;

int main () {
    int N, H;
    cin >> N >> H;
    long long katana[100000];
    for (int i = 0; i < N; i++) {
        long long a, b;
        cin >> a >> b;
        katana[i] = a + (b << 30);
    }
    sort(katana, katana + N);
    int c = 0;
    int ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        long long k = katana[i];
        int b = (int)(k >> 30);
        if (b < c) {
            break;
        }
        H -= b;
        ans++;
        if (H <= 0) {
            c = 0;
            break;
        }
        int a = (int)(k & (1 << 30) - 1);
        c = max(c, a);
    }
    if (c > 0) {
        ans += (H - 1) / c + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4388
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;
const int INF = 1e9;

int main(){
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); ++i){
	   if (s==t){
			cout << "Yes" << endl;
			return 0;
		} else {
			s = s[s.size()-1] + s.substr(0, s.size()-1);
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 384
import kotlin.collections.ArrayDeque

@kotlin.ExperimentalStdlibApi
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val result = Array(n) {""}

    println(0)
    result[0] = readLine()!!
    if (result[0] == "Vacant") return

    println(n-1)
    result[n-1] = readLine()!!
    if (result[n-1] == "Vacant") return

    val bfs = ArrayDeque<Pos>()
    bfs.addLast(Pos(n/2, 0, n-1))

    while (bfs.isNotEmpty()) {
        val pos = bfs.removeFirst()

        println(pos.idx)
        result[pos.idx] = readLine()!!
        if (result[pos.idx] == "Vacant") return

        val lowerCnt = pos.idx - pos.lower - 1
        val upperCnt = pos.upper - pos.idx - 1

        if (lowerCnt % 2 == 1 && result[pos.idx] != result[pos.lower]) {
            val lowerIdx = (lowerCnt+1) / 2
            bfs.addLast(Pos(pos.lower+lowerIdx, pos.lower, pos.idx))
        } else if (lowerCnt > 0 && lowerCnt % 2 == 0 && result[pos.idx] == result[pos.lower]) {
            val lowerIdx = lowerCnt / 2
            bfs.addLast(Pos(pos.lower+lowerIdx, pos.lower, pos.idx))
        } else if (upperCnt % 2 == 1 && result[pos.idx] != result[pos.upper]) {
            val upperIdx = (upperCnt+1) / 2
            bfs.addLast(Pos(pos.idx+upperIdx, pos.idx, pos.upper))
        } else if (upperCnt > 0 && upperCnt % 2 == 0 && result[pos.idx] == result[pos.upper]) {
            val upperIdx = upperCnt / 2
            bfs.addLast(Pos(pos.idx+upperIdx, pos.idx, pos.upper))
        } else {
            // looks ok -> add both upper/lower bounds
            if (lowerCnt > 0) {
                val lowerIdx = (lowerCnt+1) / 2
                bfs.addLast(Pos(pos.lower+lowerIdx, pos.lower, pos.idx))
            }
            if (upperCnt > 0) {
                val upperIdx = (upperCnt+1) / 2
                bfs.addLast(Pos(pos.idx+upperIdx, pos.idx, pos.upper))
            }
        }
    }
}

data class Pos(val idx: Int, val lower: Int, val upper: Int)

Measured memory_bytes: 39248
A, B, C, X, Y = map(int,input().split())
Z = max(2*X, 2*Y)
ans = 10 ** 9
for z in range(0, Z+2, 2):
    ans = min(ans, A * max(0, X-z//2) + B * max(0, Y-z//2) + C * z)
print(ans)

Measured memory_bytes: 3060
a,b,c=map(int,input().split())
if a==b==c:
  print(-1 if a%2==0 else 0)
else:
  x=0
  while ((a-1)*(b-1)*(c-1))%2==1:
    a,b,c=(b+c)//2,(a+c)//2,(a+b)//2
    x+=1
  print(x)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

signed main() {
    int N, M;
    cin >> N >> M;
    int ans = 0;
    RANGE(i,2){
        if(N>M){
            ans += N;
            N = N-1;
        }else{
            ans += M;
            M = M-1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAX = 100000;


int main(int argc, char *argv[])
{
  string v;
  cin >> v;
  for (int i = 0; i < v.size(); i += 2) {
      cout << v[i];
  }
  puts("");
}


Measured memory_bytes: 512
def project(x,y):
    base=[x2-x1,y2-y1]
    hypo=[x-x1,y-y1]
    r=(base[0]*hypo[0]+base[1]*hypo[1])/(base[0]**2+base[1]**2)
    return x1+base[0]*r,y1+base[1]*r


x1,y1,x2,y2=map(int,input().split())
q=int(input())
for i in range(q):
    x,y=map(int,input().split())
    print(*project(x,y))


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = long long;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;


int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    u64 N, height = 0;
    cin >> N;
    u64 prev = 0;
    while (N--) {
        u64 present;
        cin >> present;
        if (present >= prev) {
            prev = present;
        } else {
            height += prev - present;
        }
    }
    
    cout << height << endl;
    
    return 0;
    
}


Measured memory_bytes: 3620
"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function

# import itertools as it
# import collections
import sys


def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

def main():
    N = int(input())
    xs = [int(s) for s in input().split()]
    h_prev = 100000000000
    res = True
    for h in reversed(xs):
        if h - h_prev > 1:
            res = False
            break
        elif h == h_prev + 1:
            h_prev = h - 1
        else:
            h_prev = h

    if res:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 63984
def d_disjoint_set_of_common_divisors():
    from fractions import gcd
    A, B = [int(i) for i in input().split()]

    def prime_factorization_dict(n):
        """nを素因数分解したときの素数とその指数の辞書"""
        from collections import defaultdict
        if n == 1:
            return {2: 0}  # 1は素数の0乗の積とみなす
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table
    g = gcd(A, B)
    return len(prime_factorization_dict(g).keys()) + 1 if g > 1 else 1

print(d_disjoint_set_of_common_divisors())

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

int main() {
  int N;
  cin >> N;
  double odd;
  if (N%2 == 0) {
    odd = N/2;
  }
  else {
    odd = N/2+1;
  }
  double answer = odd/N;
  cout << fixed << setprecision(7);
  cout << answer << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)

n, m = map(int, input().split())

graph = [[] for _ in range(n + 1)]

for i in range(m):
    f, t = map(int, input().split())
    graph[t].append(f)

dp = [-1] * (n + 1)
def dfs(now):
    if dp[now] != -1:
        return dp[now]

    if not graph[now]:
        return 0

    r = max(dfs(parent) for parent in graph[now]) + 1
    dp[now] = r
    return r

print(max(dfs(i) for i in range(1, n + 1)))


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

int main(){
    int n,m;
    int sum = 0;
    cin >> n;
    vector<int> t(n,0);
    for(int i = 0; i < n; i++){
        cin >> t[i];
        sum = sum + t[i];
    }
    cin >> m;
    vector<int> p(m,0),x(m,0);
    for(int j = 0; j < m; j++){
        cin >> p[j] >> x[j];
    }
    for(int j = 0; j < m; j++){
        cout << sum - t[p[j] - 1] + x[j] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n, sum, b1;

  cin >> n;
  cin >> b1;
  sum = b1;
  for (int i = 0; i < n-2; i++) {
    int b2;
    cin >> b2;
    if (b1 < b2) {
      sum += b1;
    } else {
      sum += b2;
    }
    b1 = b2;
  }
  cin >> b1;
  sum += b1;

  cout << sum << endl;
  return 0;
}


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

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

class DGreedyCustomers {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,_;
        in>>n;
        vector<int> a(n);
        for(auto&i:a) in>>i;
        ll ans=0;
        int b=1;
        for(auto i:a){
            if(b==1) ans+=i-1,b=2;
            else if(i==b) ++b;
            else ans+=(i-1)/b;
        }
        out<<ans<<endl;
    }
};

int main() {
    DGreedyCustomers solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
int main(){
  while(true){
    int N,M,ans=0;
    cin>>N>>M;
    if(N==0&&M==0) break;
    int h[N+1],w[M+1];
    h[0]=0;
    w[0]=0;
    int value;
    for(int i=1;i<=N;i++){
      cin>>value;
      h[i]=h[i-1]+value;
    }
    for(int i=1;i<=M;i++){
      cin>>value;
      w[i]=w[i-1]+value;
    }
    int val[1500000]={};
    for(int i=0;i<N;i++){
      for(int j=i+1;j<=N;j++){
        val[abs(h[j]-h[i])]++;
      }
    }
    for(int i=0;i<M;i++){
      for(int j=i+1;j<=M;j++){
        if(abs(w[j]-w[i])!=0)ans+=val[abs(w[j]-w[i])];
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 8960
// new day,new strength,new thougts
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) int((c).size())
#define REP(i,n)  for(int i=0;i<int(n);i++)
#define REPD(i,n) for(int i=int(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FORD(i,a,b) for(int i=int(a);i>=int(b);i--)
#define all(s) (s).begin(),(s).end()
#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=2e5+10;
const ll mod=1e9+7;

int main(){
    ld n,m,d;cin>>n>>m>>d;
    if(d==0)
	cout<<setprecision(10)<<fixed<<(((n)*(m-1))/(n*n));
    else
	cout<<setprecision(10)<<fixed<<((2*(n-d)*(m-1))/(n*n));
}


Measured memory_bytes: 256