akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  int n,k;cin>>n>>k;
  ll ans = 0;
  rep(i,n){
    ll h;cin>>h;
    if(h >= k){
      ans++;
    }

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


Measured memory_bytes: 636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()

	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = readInt()
	}
	maxCount := 0
	count := 0
	for i := 0; i < n-1; i++ {
		if h[i] >= h[i+1] {
			count++
			if count > maxCount {
				maxCount = count
			}
			continue
		}
		count = 0

	}
	fmt.Println(maxCount)
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;


int main(void){
	ll l,r;
	cin>>l>>r;
	if(r-l > 2017)cout<<0<<endl;
	else{
		int min=10000;
		for(int i=l;i<r;i++){
			int id = i%2019;
			for(int j=i+1;j<r+1;j++){
				if(((i%2019)*(j%2019))%2019 < min)min=((i%2019)*(j%2019))%2019;
			}
		}
		cout<<min<<endl;
	}
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    string a,b;
    cin>>a>>b;
    x = 0;
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i])x++;
        }
        cout<<x;
            

    return 0;
}

Measured memory_bytes: 3800
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		sc.close();

		int ans = 0;
		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if (i + j <= s && s <= i + j + k) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22736
n, k = map(int, input().split())
k += 1
s = "01" + input().rstrip()
n += 2
ans = 0
i = 0
left = 2
right = 1
while i < n:
    if k > 0:
        pos = s.find('01', i)
        if pos == -1:
            i = n
            right = n - 1
        else:
            pos = s.find('10', pos + 1)
            if pos == -1:
                i = n
                right = n - 1
            else:
                right = pos
                i = pos + 1
        k = k - 1
        ans = max(ans, right - left + 1)
    else:
        pos = s.find('01', left)
        left = pos + 1
        k = k + 1

print(ans)


Measured memory_bytes: 3316
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let r = get!();
    let ans = 3 * r * r;
    println!("{}", ans);
    
}

Measured memory_bytes: 4352
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

       while(in.hasNextInt()) {
	       int H = in.nextInt();
	       int W = in.nextInt();
	       if(H == 0 && W == 0) return;

	       for(int i=1;i<=H;i++) {
		       for(int j=1;j<=W;j++) {
			       if(i==1 || i == H || j == 1 || j == W)
				       System.out.printf("#");
			       else
				       System.out.printf(".");
		       }
		       System.out.println("");
	       }
	       System.out.println("");
       }
    }
}

Measured memory_bytes: 42552
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <deque>
#include <functional>

template <class Weight>
struct edge {
  using value_type = Weight;
  size_t src, dst;
  value_type cost;

  edge(size_t src, size_t dst, value_type cost=1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(const edge<value_type> &rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <class Weight>
struct graph: public std::vector<std::vector<edge<Weight>>> {
  using value_type = Weight;
  graph(size_t n): std::vector<std::vector<edge<value_type>>>(n) {}

  void connect_with(size_t src, size_t dst, value_type cost=1) {
    (*this)[src].emplace_back(src, dst, cost);
    (*this)[dst].emplace_back(dst, src, cost);
  }
};

template <class Tp, class Compare>
using priority_queue = std::priority_queue<Tp, std::deque<Tp>, Compare>;

template <class Tp>
constexpr Tp inf = Tp(1) << (8*sizeof(Tp)-3);

template <class Weight>
std::vector<Weight> shortest(const graph<Weight>& g, size_t s) {
  // based on Dijkstra algorithm
  std::vector<Weight> res(g.size(), inf<Weight>);
  priority_queue<std::pair<Weight, size_t>, std::greater<>> q;
  res[s] = 0;
  q.emplace(0, s);
  while (!q.empty()) {
    Weight w;
    size_t v;
    std::tie(w, v) = q.top();
    q.pop();
    if (w > res[v]) continue;

    for (const auto& e: g[v]) {
      if (res[e.dst] > w + e.cost) {
        res[e.dst] = w + e.cost;
        q.emplace(res[e.dst], e.dst);
      }
    }
  }
  return res;
}

int main() {
  size_t N;
  scanf("%zu", &N);

  graph<intmax_t> g(N);
  for (size_t i = 1; i < N; ++i) {
    size_t a, b;
    intmax_t c;
    scanf("%zu %zu %jd", &a, &b, &c);
    --a;
    --b;
    g.connect_with(a, b, c);
  }

  size_t Q, K;
  scanf("%zu %zu", &Q, &K);
  --K;
  auto dist = shortest(g, K);
  for (size_t i = 0; i < Q; ++i) {
    size_t x, y;
    scanf("%zu %zu", &x, &y);
    --x;
    --y;
    printf("%jd\n", dist[x]+dist[y]);
  }
}


Measured memory_bytes: 12208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int num=1;
  for(int i=1; i<n; i++){
    if(s[i]!=s[i-1])num++;
  }
  cout << num << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long ans,temp,a,b;
int main(){
	int n,t;
    cin>>n>>t;
    cin>>a;
    ans+=t;
    for(int i=2;i<=n;i++)
      {
      	  cin>>b;
      	  if(b-a<=t) ans+=b-a;
      	  else
      	     {
      	     	ans+=t;
      	     }
      	    a=b;
      	  
      }
      cout<<ans;
	return 0;
} 


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

int main(){
	string s;
	cin >> s;
	map<char,int> m;
	for (auto& i:s) m[i]++;
	bool op=false;
	for (auto& i:m){
		if (i.second != 2) op=true;
	}
	if (op) cout << "No";
	else cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int x, n; std::cin >> x >> n;
	std::vector<int> num(n); for (auto& a : num) std::cin >> a;
	std::sort(num.begin(), num.end());
	for (auto i = 0; true; ++i) {
		if (!std::binary_search(num.begin(), num.end(), x - i)) {
			std::cout << x - i << '\n';
			return 0;
		}
		else if (!std::binary_search(num.begin(), num.end(), x + i)) {
			std::cout << x + i << '\n';
			return 0;
		}
	}
}

Measured memory_bytes: 3640
N = int(input())
T = [int(input()) for i in range(N)]

def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

def lcm(m,n):
  return int(m * n // gcd(m,n))

ans = 1
for i in range(N):
    ans = lcm(T[i], ans)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
  int x,y,t;

  while(1)
    {

      scanf("%d %d" , &x,&y);
      if(x==0 && y==0)break;
      if(x > y) t =x ,x=y , y=t;
      printf("%d %d\n" , x,y);
    }

  return 0;

}

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

int main(void)
{
    int i, a, b, x, k=1;

    scanf("%d%d", &a, &b);

    while (b/k!=0)  k*=10;

    x = a*k + b;
    i = sqrt(x);

    if (i*i==x) printf("Yes\n");
    else        printf("No\n");

    return 0;
}

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

void solve(vector<vector<int> > &e, vector<vector<int> > &w, vector<int> &ans, int v, int prev){
	int i;
	for(i = 0; i < e[v].size(); i++){
		if(e[v][i] != prev){
			ans[e[v][i]] = (ans[v] ^ w[v][i]);
			solve(e, w, ans, e[v][i], v);
		}
	}
}

int main(){
	int N, i, a, b, c;
	scanf("%d", &N);
	vector<vector<int> > e(N, vector<int>());
	vector<vector<int> > w(N, vector<int>());
	for(i = 1; i < N; i++){
		scanf("%d%d%d", &a, &b, &c);
		a--;
		b--;
		c %= 2;
		e[a].push_back(b);
		w[a].push_back(c);
		e[b].push_back(a);
		w[b].push_back(c);
	}
	vector<int> ans(N);
	ans[0] = 0;
	solve(e, w, ans, 0, -1);
	for(i = 0; i < N; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}

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

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  for(int i = 0;i < M;i++) cin >> B.at(i);
  
  int ans = 0;
  for(int i = 0;i < N;i++){
    int sum = C;
    for(int j = 0;j < M;j++){
      int A;
      cin >> A;
      
      sum += A * B.at(j);
    }
    
    if(sum > 0) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3580
import bisect
import itertools
import sys

A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]


def most_simRL(ds, x):
    index = bisect.bisect_left(ds, x)
    if index == 0:
        return [ds[0]]
    elif index == len(ds):
        return [ds[-1]]
    return ds[index-1:index+1]


for x in X:
    s_RL = most_simRL(s, x)
    t_RL = most_simRL(t, x)
    ans = sys.maxsize
    for a, b in itertools.product(s_RL, t_RL):
        ans = min(ans, min(abs(a-x), abs(b-x)) + abs(a-b))
    print(ans)


Measured memory_bytes: 16156
#include <stdio.h>

#define NIL -1

typedef struct{
  int p, l, r;
} node;

node t[10000];
int n;

void preparse(int u)
{
  if (u == NIL)
    return;
  printf(" %d",u);
  preparse(t[u].l);
  preparse(t[u].r);
}

void inparse(int u)
{
  if (u == NIL)
    return;
  inparse(t[u].l);
  printf(" %d",u);
  inparse(t[u].r);
}

void postparse(int u)
{
  if (u == NIL)
    return;
  postparse(t[u].l);
  postparse(t[u].r);
  printf(" %d",u);
}

int main()
{
  int i, x, l, r, root;

  scanf("%d",&n);
  for (i = 0; i < n; i++)
    t[i].p = NIL;
  for (i = 0; i < n; i++){
    scanf("%d%d%d",&x,&l,&r);
    t[x].l = l;
    t[x].r = r;
    if (l != NIL)
      t[l].p = x;
    if (r != NIL)
      t[r].p = x;
  }
  for (i = 0; i < n; i++)
    if (t[i].p == NIL)
      root = i;
  printf("Preorder\n");
  preparse(root);
  printf("\n");
  printf("Inorder\n");
  inparse(root);
  printf("\n");
  printf("Postorder\n");
  postparse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2108
import java.util.*;
import java.io.*;

public class Main {

	private static void solve(){
		//Implement solution here.
		String S = next();
		int xcnt = 0;
		for(char c:S.toCharArray()){
			if(c == 'x')xcnt++;
			if(xcnt > 7)break;
		}
		
		System.out.println(xcnt > 7 ? "NO" : "YES");
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 25392
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

string MakeString(string);
string CastStringInt(int);

int main(){
  int i, n;
  string str;

  while(1){
    cin >> n;
    if(n == 0) break;
    cin >> str;

    for(i=0; i<n; ++i)
      str = MakeString(str);

    cout << str << endl;
  }

  return 0;
}

string MakeString(string s){
  int i, j, count;
  string t, u;

  for(i=0; i<s.size(); i=j){
    j = i;
    count = 0;
    while(1){
      if(j == s.size() || s[i] != s[j]) break;
      ++j;
      ++count;
    }

    u = CastStringInt(count);
    copy(u.begin(), u.end(), back_inserter(t));
    t.push_back(s[i]);
  }

  return t;
}

string CastStringInt(int x){
  int i, y, digit=1, count=0;
  char c;
  string str;

  while(1){
    digit *= 10;
    ++count;
    if(x < digit) break;
  }

  for(i=0; i<count; ++i){
    digit /= 10;
    y = x / digit;
    x = x - y * digit;
    c = y + 48;
    str.push_back(c);
  }

  return str;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdbool.h>

int k(long a, long b);

int b(long c, long d);

int main() {
	long i, j, l, r, N, A[100000], L[100000], R[100000], max = 0;
	bool flag = true;

	scanf("%ld", &N);

	for (i = 0; i < N; i++) scanf("%ld", &A[i]);

	{
		L[0] = 0;
		R[N-1] = 0;
		for (i = 1; i < N; i++) {
			L[i] = k(A[i - 1], L[i - 1]);
		}
		for (i = N - 2; i >= 0; i--) {
			R[i] = k(A[i + 1], R[i + 1]);
		}
	}

	for (i = 0; i < N; i++) {
		max = b(max, k(L[i], R[i]));
	}

	printf("%ld\n", max);

	return 0;
}

int k(long a, long b) {
	long long int tmp, r;

	if (a<b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	if (b == 0) return a;

	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

int b(long c, long d) {
	if (c > d) return c;
	else return d;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int MAX = 2010000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll f(ll x,ll y){
  return COM(x+y,x);
}
ll g(ll x,ll y){
  return f(x+1,y+1);
}
int main(){
  ll n,m,k,i,j,result=0;
  ll c1,c2,r1,r2;
  int a[200010];
  string s;
  COMinit();
  cin >> r1 >> c1 >> r2 >> c2;
  result = g(r2,c2)+g(r1-1,c1-1)-g(r2,c1-1)-g(r1-1,c2);
  if(result<0) result += 2*MOD;
  result %= MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 50688
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n,m;cin>>n>>m;
    
    vvl ans(100,vl(100));
    rep(i,50)rep(j,100)ans[i][j]=1;
    --n;--m;
    
    rep(i,50)rep(j,100){
        if(i%2&&j%2&&n){
            ans[i][j]=0;
            --n;
        }
    }
    rep(i,50,100)rep(j,100){
        if(i%2&&j%2&&m){
            ans[i][j]=1;
            --m;
        }
    }

    cout<<"100 100"<<endl;
    rep(i,100){
        rep(j,100){
            cout<<(ans[i][j]?'#':'.');
        }
        cout<<endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream> 
using namespace std;
int main(){
	char s[200010],t[200010];
	int c=0;
	scanf("%s %s",s,t);
	for(int i=0;i<strlen(s);i++){
		// printf("%c ",s[i]);
		if(s[i]==t[i]){
			c++;
		}
	}
	printf("%ld\n",(strlen(s)-c));
}

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

int n;

int main() {
  cin >> n;
  vector<string> s(n);
  rep (i, n) {
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  int ans = 1;
  rep (i, n-1) {
    if (s[i] != s[i+1]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9536
using System;
using static System.Console;

namespace RoundOne
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(ReadLine());
            int b = int.Parse(ReadLine());

            if(a + b == 3) WriteLine("3");
            else if(a + b == 4) WriteLine("2");
            else if(a + b == 5) WriteLine("1");
        }
    }
}


Measured memory_bytes: 11092
N,M =map(int,input().split())
abn = [list(map(int,input().split())) for i in range(N)]

abn.sort(key=lambda x:x[0])
ans=0
for ab in abn:
    if M < 0:
        break
    else:
        if M>ab[1]:
            M-=ab[1]
            ans+=ab[0]*ab[1]
        else:
            ans+=ab[0]*M
            break
print(ans)

Measured memory_bytes: 29020
import sys
input = sys.stdin.readline

def main():
    H,N = map(int,input().split())
    AB = [[int(i) for i in input().split()] for _ in range(N)]

    dp = [float("inf")] * (H+1)

    dp[H] = 0

    for i in range(H,-1,-1):
        for j in range(N):
            tmp = max(0,i-AB[j][0])
            dp[tmp] = min(dp[tmp], dp[i]+AB[j][1])

    print(dp[0])

if __name__ == "__main__":
    main()

Measured memory_bytes: 42716
import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
graph = [[] for _ in range(n+1)]
for i in range(n-1):
    a, b = map(int, sys.stdin.readline().split())
    graph[a].append( [b, i])
    graph[b].append( [a, i])

maxc = 0

nexts = [1]
color = [0] * (n-1)
while len(nexts) > 0:
    target = nexts.pop()
    used = set()
    fillable = set()
    for i in range(len(graph[target])):
        cr = color[graph[target][i][1]]
        if cr == 0:
            fillable.add(i)
        else:
            used.add(cr)
    mins = 1
    for i in list(fillable):
        while mins in used:
            mins += 1
        color[graph[target][i][1]] = mins
        nexts.append(graph[target][i][0])
        if mins > maxc:
            maxc = mins
        mins += 1

print(maxc)
for i in color:
    print(i)

Measured memory_bytes: 83872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static System.Math;
class Program
{
    public static void Main(string[] args)
    {
        var s = Console
            .ReadLine()
            .Split(' ')
            .Select(x => int.Parse(x))
            .ToArray();
        var sum = s
            .Concat(s.Select(x => x - 1))
            .OrderByDescending(x => x)
            .Take(2)
            .Sum();
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11476
using System;

namespace A_FiftyFifty
{
    class Program
    {
        static void Main(string[] args)
        {
            string num = Console.ReadLine();
            char[] a = new char[4];

            for(int i=0; i<4; i++)
            {
                a[i] = num[i];
            }

            int numcounter = 0;

            for(int i=0; i<4; i++)
            {
                for(int j=0; j<4; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }
                    else if (a[i] == a[j])
                    {
                        numcounter = numcounter + 1;
                    }
                }
            }

            if(numcounter == 4)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
           
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>

#define FAST ios_base::sync_with_stdio(false); cin.tie(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__)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(a,b) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;
typedef pair<int, int> P;


int main() {
	FAST;

	int n;
	cin >> n;

	int a[n];
	rep(i,n) cin >> a[i];

	sort(a, a+n);

	int ans = a[n-1] - a[0];

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=2e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=(xx<<3)+(xx<<1)+ch-'0';ch=getchar();}
    return xx*ff;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	fastio;

	int n; cin>>n;
	ld a[n]; forn(i,n) cin>>a[i];
	ll ak[n];

	cout<<setprecision(15)<<fixed;

	ll val[20][20];
	forn(i,20) forn(j,20) val[i][j] = 0;

	forn(i,n){
		ak[i] = (ll)round(1000000000 * a[i]);
		// cout<<i<<" "<<a[i]<<" "<<ak[i]<<endl;
		ll pow2 = 0, pow5 = 0;
		while(ak[i]%2 == 0){
			pow2++;
			ak[i] /= 2;
		}
		while(ak[i]%5 == 0){
			pow5++;
			ak[i] /= 5;
		}
		// cout<<pow2<<" "<<pow5<<ln;
		pow2 = min(18ll, pow2);
		pow5 = min(18ll, pow5);
		val[pow2][pow5]++;
	}

	ll ans = 0;
	forn(i,20){
		forn(j,20){
			forn(k,20){
				forn(l,20){
					if(i+k < 18) continue;
					if(j+l < 18) continue;
					if(i != k || j != l) ans += val[i][j] * val[k][l];
					else ans += val[i][j] * (val[i][j] - 1);
				}
			}
		}
	}
	cout<<ans/2<<ln;



	return 0;
}

Measured memory_bytes: 8456
N = int(input())
B = list(map(int, input().split()))
ans = []
max_b = max(B)
for i in range(N):
    for b in range(max_b, 0, -1):
        if len(B) > b-1 and B[b-1] == b:
            ans += [B.pop(b-1)]
            break

if len(ans) != N:
    print(-1)
else:
    for a in ans[::-1]:
        print(a)


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

using namespace std;

string str;

bool all1(const string &str) {
    int cnt = 0;
    for (auto it: str)
        cnt += (it == '1');
    return cnt == str.size();
}

int main()
{
    cin >> str;

    int ans = str.size();
    for (char ch = 'a'; ch <= 'z'; ++ ch) {
        string str2;
        for (int i = 0; i < str.size(); ++ i)
            if (str[i] == ch)
                str2 += '1';
            else
                str2 += '0';

        int passes = 0;
        while (!all1(str2)) {
            ++ passes;
            string str3;
            for (int i = 0; i + 1 < str2.size(); ++ i)
                if (str2[i] == '1' || str2[i + 1] == '1')
                    str3 += '1';
                else
                    str3 += '0';
            str2 = str3;
        }
        ans = min(ans, passes);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
list = [[0 for i in range(2)] for j in range(Q)]

b = [0] * (N+1)
for i in range(N):
    if S[i:i+2] == 'AC':
        b[i+1] = b[i] + 1
    else:
        b[i+1] = b[i]
for i in range(Q):
    l,r = map(int, input().split())
    print(b[r-1]-b[l-1])

Measured memory_bytes: 19628
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

typedef long long int ll;

int main()
{
	ll n,a,b;
	ll x[100000] = {0};

	cin >> n >> a >> b;

	ll d[100000] = {0};

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

		//cout << "x == " << x[i] << endl;
	}

	for(int i = 0; i < n-1; i++)
	{
		d[i] = (x[i+1] - x[i]) * a;

		if (d[i] > b)
		{
			d[i] = b;
		}
	}

	ll sum = 0;

	for(int i = 0; i < n-1; i++)
	{
		//printf("d[%d] = %d\n", i, d[i]);
		sum += d[i];
	}

	cout << sum << endl;

	return 0;
}
	


Measured memory_bytes: 1792
import numpy as np
N = int(input())
v = np.array(list(map(float, input().split())))
v = np.sort(v)[::-1]
while len(v) > 1:
  v[-2] = (v[-2] + v[-1])*0.5
  v = np.delete(v, -1)
print(v[0])

Measured memory_bytes: 12396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    string s;
    int k;
    cin >>s >>k;

    int n = s.size();

    vector<string> v;
    rep(i,n){
        for(int j=1; j<=5; ++j){
            if(i+j>n) break;
            v.pb(s.substr(i,j));
        }
    }

    sort(all(v));
    v.erase(unique(all(v)), v.end());
    cout << v[k-1] << endl;
    return 0;
}


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

int main () {

	int n,str1[26],str2[26],l;
	string s,ans;

	cin >> n;
	for(int i=0;i<26;i++)str1[i]=50;


	for (int i=0;i<n;i++){
		cin >> s;
		l = s.size();
		for(int j=0;j<26;j++)str2[j]=0;
		for(int j=0;j<l;j++){
			str2[s[j]-'a']++;
		}
		for(int j=0;j<26;j++){
			str1[j] = min(str1[j],str2[j]);
		}
	}

	for(int i=0;i<26;i++){
		for(int j=0;j<str1[i];j++){
			ans.push_back('a'+i);
		}
	}
	cout << ans;

	
    return 0;
}

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

#define int long long

int n,sz;
int a[100001], b[100001], p[100001];
int BIT[200001];

void update(int x)
{
	if (x == 0) x = 1;
	for(;x<=200000;x+=x&(-x))	
		BIT[x]++;
	return;
}

int query(int x)
{
	int ans = 0;
	for(;x>0;x-=x&(-x))
		ans += BIT[x];
	return ans;
}

bool check(int x)
{
	for (int i=1;i<=n;i++)
	{
		if (a[i] >= x)
			b[i] = 1;
		else
			b[i] = 0;
		p[i] = p[i-1] + b[i];
	}
	for (int i=0;i<=200000;i++)
		BIT[i] = 0;
	update(100000);
	int cur = 0;
	for (int i=1;i<=n;i++)
	{
		cur += query(2*p[i] - i + 100000);
		update(2*p[i] - i + 100000);
	}
	return (cur >= sz);
}

int32_t main() 
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n;
	for (int i=1;i<=n;i++)
		cin >> a[i];
	sz = n*(n+1)/2;
	sz = (sz+1)/2;
	int l = 1, r = 1e9;
	int res;
	while(l <= r)
	{
		int mi = (l+r)/2;
		if (check(mi))
		{
			res = mi;
			l = mi + 1;
		}
		else
			r = mi - 1;
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 4224
let rec p x y c =
    match x with
    | x when x > y -> []
    | _ -> if (c mod x) = 0 then x :: p (x+1) y c else p (x+1) y c
let _ = Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c ->
  print_endline (string_of_int (List.length (p a b c)))
)


Measured memory_bytes: 2400
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    long A = scanner.nextLong();
    long B = scanner.nextLong();
    int[] primes = primes(1000000);
    Set<Long> aFactors = primeFactors(A, primes);
    Set<Long> bFactors = primeFactors(B, primes);
    int count = 0;
    for (long f : aFactors) {
      if (bFactors.contains(f)) count++;
    }
    System.out.println(count);
  }

  private static int[] primes(int num) {
    boolean[] isPrime = new boolean[num + 1];
    Arrays.fill(isPrime, true);
    isPrime[0] = false;
    isPrime[1] = false;
    for (int i = 2; i <= num; i++) {
      if (isPrime[i]) {
        for (int j = i * 2; j <= num; j += i) {
          isPrime[j] = false;
        }
      }
    }
    List<Integer> list = new ArrayList<>();
    for (int i = 1; i <= num; i++) {
      if (isPrime[i]) list.add(i);
    }
    int[] res = new int[list.size()];
    for (int i = 0; i < list.size(); i++) {
      res[i] = list.get(i);
    }
    return res;
  }

  private static Set<Long> primeFactors(long num, int[] primes) {
    Set<Long> res = new HashSet<>();
    res.add(1L);
    for (int i = 0; i < primes.length && num > 1; i++) {
      if (num % primes[i] == 0) {
        res.add((long) primes[i]);
        while (num % primes[i] == 0) num /= primes[i];
      }
    }
    res.add(num);
    return res;
  }
}


Measured memory_bytes: 26196
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
typedef long long ll;
using namespace std;
#define INF (1 << 30)
#define INFLL (1LL << 60)
#define rep(i, n) for(int i=0; i<(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
	int N; cin >> N;
	int ans = 0, bf = 0;
	rep(i, N) {
		int h; cin >> h;
		if (h >= bf) ans = ans + h - bf;
		bf = h;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3140
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

constexpr int MOD = 1000000007;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int H, W;
string s[26][26];

int main() {
    cin >> H >> W;
    for (int j = 0; j < H; ++j) {
        for (int k = 0; k < W; ++k) {
            cin >> s[j][k];
        }
    }
    for (int j = 0; j < H; ++j) {
        for (int k = 0; k < W; ++k) {
            if (s[j][k] == "snuke") {
                cout << (char)(k+'A') << (j+1) << endl;
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 384
n = int(input())
list_test = []
for i in range(n):
    x, y = input().split()
    a = [float(x), y]
    list_test.append(a)
    
ans = 0

for i in range(n):
    if list_test[i][1] == "JPY":
        ans += int(list_test[i][0])
    else:
        ans += list_test[i][0]*380000

print(ans)

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

const int N = 1e5 + 5;

bool ok(ll x) {
	for (int i = 2; i * i <= x; i++) {
		if(x % i == 0)
			return false;
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll x;
	cin >> x;
	while(!ok(x)) {
		x++;
	}
	cout << x << "\n";
}

Measured memory_bytes: 256
/*
    ( ´-ω･)︻┻┳══━一一一一一一一				(× _ ×)
	
	Stay Low. Go Fast
	Kill First. Die Last
	One Shot. One Kill
	No Luck. Pure Skill 
*/

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

/*************************** MACROS **************************/
#define ld long double
#define ll long long  
#define ull unsigned long long
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x;i>=y;i--)
#define vll vector<ll>
#define pb push_back
#define S second
#define F first
#define B begin()
#define E end()
#define W(x) while(x--)
#define pll pair< ll,ll >
#define vpll vector< pll >
#define qll queue<ll>
#define dqll deque<ll>
#define qpll queue<pll>
#define dqpll deque<pll>
#define pqll priority_queue<ll>
#define pqpll priority_queue<pll>
#define Line cout<<"\n**************************\n\n";

/*************************** CONST ******************************/

const ll MOD = 1000000007;
const ll MOD1 = 998244353;
const ll MIN_LL = -1e18;
const ll MAX_LL = 1e18;
const int MAX_INT = 1e9;
const int MIN_INT = -1e9;
const ld pie = 3.1415926535;
 
/************************** POW UTIL *****************************/
 
ll fpow(ll n,ll p){;ll m=1;while(p){if(p%2)m*=n;p>>=1;n*=n;}return m;}
ll mfpow(ll n,ll p,ll M){ll m=1;n%=M;while(p){if(p%2)m=(m*n)%M;n=(n*n)%M;p>>=1;}return m%M;}
 
/************************* PRINT UTIL *****************************/

template<class T> inline ostream& operator<<(ostream& o,vector<T> v){for(auto i:v)o<<i<<" ";return o;};
template<class T> inline ostream& operator<<(ostream& o,set<T> s){for(auto i:s)o<<i<<" ";return o;}
template<class T> inline ostream& operator<<(ostream& o,multiset<T> s){for(auto i:s)cout<<i<<" ";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,pair<T1,T2> p){o<<p.F<<" "<<p.S<<"\n";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,map<T1,T2> m){for(auto p:m)o<<p.F<<" "<<p.S<<"\n";return o;}

/*************************** VARIABLES **************************/

const vll days={31,28,31,30,31,30,31,31,30,31,30,31};
 
bool br,br1,br2; 
char ch,ch1,ch2;
 

ll n,m,k,x,y,z,mini,maxi,l,r,sum,t,w;
pll p,p1,p2;

string s,s1,s2;

set<ll> st,st1,st2;
multiset<ll> mst; 

map<ll,ll> mp;

/**************************** FXNS ****************************/

void solve()
{

	ld x,y;

	cin>>n;
	y = 1;

	loop(i,0,n)
	{
		cin>>x;

		if(y != -1)y *= x;

		if(x == 0)y = 0;

		if(y < 0 || y > 1e18)y = -1;

	}

	cout<<((ll)y)<<endl;

}
 
/*************************** MAIN ****************************/
 
int main(){
 
 
	// #ifndef ONLINE_JUDGE
	        // freopen("input.txt", "rt", stdin);
	        // freopen("output.txt", "wt", stdout);
	// #endif
 
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);

	solve();
 
	return 0;
}


Measured memory_bytes: 3820
import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li():
    return list(map(int, sys.stdin.readline().split()))


def num():
    return map(int, sys.stdin.readline().split())


def nu():
    return int(input())


def find_gcd(x, y):
    while (y):
        x, y = y, x % y
    return x


def lcm(x, y):
    gg = find_gcd(x, y)
    return (x * y // gg)


mm = 1000000007

def solve():
    t = 1
    for tt in range(t):
        a,b,c,d=num()
        if(a+b>=d):
            print(min(a,d))
        else:
            z=d-a-b
            print(a-z)

                 


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9944
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,y;
    cin>>x>>y;
   
    if(x==2||y==2){
        cout<<"No"<<endl;
    
    }
    else if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
         if(y==1||y==3||y==5||y==7||y==8||y==10||y==12)cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
    }

    
    
    
    else if(x==4||x==6||x==9||x==11){
         if(y==4||y==6||y==9||y==11)cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
    }
}
   
    

    

Measured memory_bytes: 256
n=int(input())
x=[[int(x),i] for i,x in enumerate(input().split())]
ans=[0]*n
x.sort(key=lambda x: x[0])
#print(x)
for i,val in enumerate(x):
    #n-1 is odd pos=(n-1+1)//2
    pos=(n-1)//2
    if i>pos:
        ans[val[1]]=x[pos][0]
    else:
        ans[val[1]]=x[pos+1][0]
for i in ans:
    print(i)


Measured memory_bytes: 51392
#pragma GCC optimize("O3")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
typedef long long ll;
using namespace std;

struct edge {
	int to, dist;
};

int N, M, L, Q;
int dist[300][300];
vector<edge>v[300];

int main() {
	scanf("%d%d%d", &N, &M, &L);
	for (int i = 0; i < M; i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		if (c > L)continue;
		a--;
		b--;
		v[a].push_back({ b,c });
		v[b].push_back({ a,c });
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dist[i][j] = -1;
		}
	}
	for (int i = 0; i < N; i++) {
		priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int>>, greater<pair<pair<int, int>, int>>>pq;
		pq.push({ {0,0},i });
		while (!pq.empty()) {
			int x = pq.top().second;
			int f = pq.top().first.first;
			ll d = pq.top().first.second;
			pq.pop();
			if (dist[i][x] == -1) {
				dist[i][x] = f;
				for (edge e : v[x]) {
					if (dist[i][e.to] == -1) {
						if (d + e.dist > L) {
							pq.push({ {f + 1,e.dist},e.to });
						}
						else {
							pq.push({ {f,d + e.dist}, e.to });
						}
					}
				}
			}
		}
	}
	scanf("%d", &Q);
	while (Q--) {
		int s, t;
		scanf("%d%d", &s, &t);
		s--;
		t--;
		printf("%d\n", dist[s][t]);
	}
}


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

vector<int> l;
int n, a, b, c, ans;
int dfs(int, int, int, int, int, int);
int solve(int);

int main(){
  cin >> n >> a >> b >> c;
  l.resize(n);
  rep(i,n,0) cin >> l[i];
  ans = a+b+c;
  
  rep(j,4,0){
    ans = dfs(0, 0, 0, 0, 0, j);
  }
  cout << ans << endl;
}

int dfs(int depth, int asum, int bsum, int csum, int mp, int next){
  if(depth == n){
    if(asum != 0 && bsum != 0 && csum != 0){
      mp += abs(a-asum) + abs(b-bsum) + abs(c-csum);
      ans = min(ans, mp);
    }
    return ans;
  }
  if(next == 1){
    if(asum > 0) mp += 10;
    asum += l[depth];
  }
  if(next == 2){
    if(bsum > 0) mp += 10;
    bsum += l[depth];
  }
  if(next == 3){
    if(csum > 0) mp += 10;
    csum += l[depth];
  }
  rep(i,4,0) dfs(depth+1, asum, bsum, csum, mp, i);
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  ll a;
  string b;
  cin >> a >> b;
  int bb = (b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0');
  a *= bb;
  a /= 100;
  cout << a << endl;
}

Measured memory_bytes: 3376
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

const int N = 1e6 + 5;

vector< int> conn[N];
int inDegree[N], present[N];
vector< int> top;


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

    int n;
    cin >> n;

    for (int i = 1; i <= n; i ++) {
        int last = -1;
        for (int j = 1; j <= n - 1; j ++) {
            int y;
            cin >> y;
            int x = i;
            if (x > y) swap(x, y);
            x --, y --;

            if (last != -1) {
                inDegree[x * n + y] ++;
                conn[last].push_back(x * n + y);
            }
            last = x * n + y;
            present[last] = 1;
        }
    }

    vector< int> zero;
    for (int i = 0; i < n * n; i ++) {
        if (inDegree[i] == 0) zero.push_back(i);
    }

    int answer = 0, processed = 0;

    while (!zero.empty()) {
        answer ++;
        int k = zero.size();
        processed += k;
        vector< int> nxtZero;

        for (const int& x : zero) {
            for (const int &y : conn[x]) {
                inDegree[y] --;
                if (inDegree[y] == 0) {
                    nxtZero.push_back(y);
                }
            }
        }
        zero = nxtZero;
    }

    if (processed != n * n) cout << -1 << endl;
    else {
        cout << answer << endl;
    }

}

Measured memory_bytes: 49272