akhauriyash/Code-Regression huggingface dataset:
use std::collections::VecDeque;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let h: i64 = read();
    let w: i64 = read();
    let a: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();

    let mut visited = vec![vec![false; w as usize]; h as usize];
    let mut dist = vec![vec![0; w as usize]; h as usize];
    let mut queue = VecDeque::new();

    for i in 0..h {
        for j in 0..w {
            if a[i as usize][j as usize] == '#' {
                queue.push_back((i, j));
                visited[i as usize][j as usize] = true;
            }
        }
    }

    while let Some((i, j)) = queue.pop_front() {
        for &(k, l) in [(0, -1), (0, 1), (1, 0), (-1, 0)].iter() {
            if i + k < 0 || j + l < 0 {
                continue;
            }

            if i + k >= h || j + l >= w {
                continue;
            }
            if !visited[(i + k) as usize][(j + l) as usize] {
                dist[(i + k) as usize][(j + l) as usize] = dist[i as usize][j as usize] + 1;
                visited[(i + k) as usize][(j + l) as usize] = true;
                queue.push_back((i + k, j + l));
            }
        }
    }

    let ans = *dist.iter().map(|x| x.iter().max().unwrap()).max().unwrap();

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 29428
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N, K, min=1, i=0;
  cin >> N >> K;
  for(i;i<N;i++)
  {
    if(2*min<min+K)
      min*=2;
    else
      min+=K;
  }
  cout << min << endl;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){ 
  int N;
  cin >> N;
  int ans = 0;
  FOR(i, 1, N+1){
    int x = i, cnt = 0;
    while(x != 0){
      x /= 10;
      cnt++;
    }
    if(cnt % 2){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
typedef pair<int, int> P;

const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}

// テーブルを作る前処理
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;
	}
}

//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
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;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n, y,a,b,c;
	cin >> n >> y;
	for (int i = 0; i <= y / 10000; i++) {
		for (int j = 0; j <= (y - i * 10000) / 5000; j++) {
			int a = (y - i * 10000 - j * 5000) / 1000;
			if (a + i + j == n) {
				cout << i << " " << j << " " << a << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 3596
n=int(input())
a,b=[],[]
for i in range(n):x,y=map(int,input().split());a.append(x);b.append(y)
c=float("inf")
for i in range(n):
 if a[i]>b[i]:c=min(c,b[i])
print(max(0,sum(a)-c))

Measured memory_bytes: 10796
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  long long N, K;
  cin >> N >> K;
  const long long Mod = 1000000007;
  
  long long ans = 0;
  for (long long i = K; i <= N + 1; i++) {
    long long min_right_digits;
    if ((i - 1) % 2 == 1) {
      min_right_digits = (i * ((i - 1) / 2)) + (i / 2);   
    } else {
      min_right_digits = i * (i - 1) / 2;
    }

    long long max_right_digits;
    max_right_digits = N * i - min_right_digits;
    
    ans += max_right_digits - min_right_digits + 1;
  }

  cout << ans % Mod << endl;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 105

vector<int> G[MAX_N];
vector<P> E;

int main() {
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        E.push_back(P(a,b));
    }

    vector<P> v;

    // 点付き木
    rep(i,n){
        int use[n] = {};
        int ma = 1;
        ll a[101]; rep(i,101)a[i] = 1;
        queue<P> que;
        que.push(P(i,1));
        use[i] = 1;
        while(que.size() > 0){
            int x = que.front().first;
            int y = que.front().second;
            que.pop();
            ll sz = 0;
            rep(j,G[x].size()){
                if(use[G[x][j]] == 0){
                    sz++;
                    use[G[x][j]] = 1;
                    que.push(P(G[x][j], y+1));
                }
            }
            ma = max(ma, y);
            a[y] = max(a[y], sz);
        }
        ll ans = 1;
        rep(j,101)ans *= a[j];
        v.push_back(P(ma, ans));
    }


    // 辺付き木
    rep(i,n-1){
        int use[n] = {};
        int ma = 1;
        ll a[101]; rep(i,101)a[i] = 1;
        queue<P> que;
        que.push(P(E[i].first, 1));
        que.push(P(E[i].second, 1));
        use[E[i].first] = 1;
        use[E[i].second] = 1;
        while(que.size() > 0){
            int x = que.front().first;
            int y = que.front().second;
            que.pop();
            ll sz = 0;
            rep(j,G[x].size()){
                if(use[G[x][j]] == 0){
                    sz++;
                    use[G[x][j]] = 1;
                    que.push(P(G[x][j], y+1));
                }
            }
            ma = max(ma, y);
            a[y] = max(a[y], sz);
        }
        ll ans = 1;
        rep(j,101)ans *= a[j];
        v.push_back(P(ma, ans*2));
    }

    sort(v.begin(), v.end());
    cout << v[0].first << ' ' << v[0].second << endl;
    return 0;
}
 
 


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

using ll = int64_t;
using ii = pair<int, int>;

int main() {
	ios::sync_with_stdio(true);cin.tie(nullptr);
	ll X; cin >> X;
	int ans = 0; ll B = 100;

	while (true) {
		ll add = B / 100;
		B += add;
		++ans;

		if (B >= X) {
			cout << ans << '\n';
			break;
		}
	}
}

 


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
int main(){
	ll n;
	cin>>n;
	double in[n+1];
	double dp[n+1][n+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++){
		cin>>in[i];
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		dp[i][0]=(1-in[i])*dp[i-1][0];
		for(int j=1;j<=i;j++){
			dp[i][j]=dp[i-1][j]*(1-in[i])+dp[i-1][j-1]*in[i];
		}
	}
	double sum=0;
	for(int i=n/2+1;i<=n;i++){
		sum+=dp[n][i];
	}
	cout<<fixed<<setprecision(9)<<sum;
	return 0;
	
}

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

using namespace std;
using ll = long long;

void solve(){
	int h,a;
	cin >> h >> a;
	cout << h/a + (h%a!=0 ? 1 : 0) << '\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){ 
		solve();
	}
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> ac(n);
    vector<ll> wa(n);
    rep(i,m){
        ll p;
        string s;
        cin >> p >> s;
        p--;
        if(s == "AC"){
            ac.at(p)++;
        }
        if(s == "WA"){
            if(ac.at(p) == 0){
                wa.at(p)++;
            }
        }
    }

    ll ac_ans = 0;
    ll wa_ans = 0;
    rep(i,n){
        if(ac.at(i) != 0){
            ac_ans++;
            wa_ans += wa.at(i);
        }
    }
    
    cout << ac_ans << " " << wa_ans << endl;

}


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

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


int main() {
    ll n; cin >> n;
    ll ans = 1000 - n%1000;
    if(ans%1000 == 0) ans = 0;
    co(ans);

    return 0;
}


Measured memory_bytes: 3632
#include "iostream"
using namespace std;

int N, A, MAX = 1, MINI = 1001, i;
int main(){
	cin >> N;
	for (i = 1; i <= N; i++){
		cin >> A;
		if (MAX < A){ MAX = A; }
		if (MINI > A){ MINI = A; }
	}
	cout << MAX - MINI << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
keys=[]
for i in range(10**4):
  keys.append(str(i+1))
values=[0]*(10**4)
d=dict(zip(keys, values))
for x in range(1, 150):
  for y in range(x,150):
    tmp=(x+y)**2
    for z in range(y, 150):
      if tmp+(y+z)**2+(x+z)**2>20000:
        break
      if (tmp+(y+z)**2+(x+z)**2)%2==1:
        continue
      s=(tmp+(y+z)**2+(x+z)**2)//2
      key=str(s)
      if x==y and y==z:
        v=1
      elif (x==y and y<z) or (x<y and y==z):
        v=3
      elif x<y and y<z:
        v=6
      d[key]+=v

for i in range(N):
  print(d[str(i+1)])

Measured memory_bytes: 10228
N=int(input())
A=list(map(int,input().split()))
B=sorted([(i,a) for i,a in enumerate(A)],key=lambda x:x[1])[::-1]+[(N,0)]
d=[0]*N
m=N
for i in range(N):
    m=min(m,B[i][0])
    d[m]+=(i+1)*(B[i][1]-B[i+1][1])
print(*d,sep='\n')

Measured memory_bytes: 28640
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[][] D = new int[N][2];

		for(int i = 0;i<N ; i++) {
			D[i][0]=sc.nextInt();
			D[i][1]=sc.nextInt();
		}
		boolean ans = false;
		int zoro = 0;

		for(int i = 0;i<N ; i++) {
			if(D[i][0]==D[i][1]) {
				zoro++;
			}else {
				zoro=0;
			}
			if(zoro==3) {
				ans = true;
				break;
			}
		}

		if(ans) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

	//素数判定
	public static boolean isPrime(long num) {
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

		double sqrtNum = Math.sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{
				// 素数ではない
				return false;
			}
		}

		// 素数である
		return true;
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 36048
#include <iostream>

using namespace std;

int main(){

    int x,y;
    int ans = 0;
    int money[3] = {300000, 200000, 100000};

    cin >> x >> y;

    if(x < 4){
        ans += money[x-1];
    }
    if(y < 4){
        ans += money[y-1];
    }
    if(x == 1 && y == 1){
        ans += 400000;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll a, b;
    cin >> a >> b;

    cout << max(0LL, a-2*b) << endl;

    return 0;
}


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

int main() {
	int n,m,ans,ml=1,mr=100000;
	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		int l,r;
		cin >> l >> r;
		ml=max(ml,l);
		mr=min(mr,r);
	}
	ans = max(0,mr - ml + 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3580
// failed to generate code

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

long long N,K;
long long h[100000];
long long dp[100000];

int main(){
	scanf("%lld",&N);
	scanf("%lld",&K);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&h[i]);
	}
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(long long i = 2 ; i <= N-1 ; i++){
		dp[i] = 10000000011;
		for(long long j = 1 ; j <= min(K,i) ; j++){
			dp[i] = min(abs(h[i]-h[i-j])+dp[i-j],dp[i]);
		}
	}
	printf("%lld\n", dp[N-1]);
	return 0;
}


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

#define COUT(x) cout << #x << " = " << (x) << ", "
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
typedef long long ll;
const int MOD = 1000000007;

int main(){
  int N; cin >> N;
  vector<ll> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  ll sum = 0;
  ll cost = 0;
  for(int i = 0; i < N; i++){
    sum += a[i];
    if(i % 2 == 0){
      if(sum <= 0){
	cost += -sum + 1;
	sum = 1;
      }
    }else{
      if(sum >= 0){
	cost += sum + 1;
	sum = -1;
      }
    }
  }
  ll sum2 = 0;
  ll cost2 = 0;
  for(int i = 0; i < N; i++){
    sum2 += a[i];
    if(i % 2 == 0){
      if(sum2 >=  0){
	cost2 += sum2 + 1;
	sum2 = -1;
      }
    }else{
      if(sum2 <= 0){
	cost2 += - sum2 + 1;
	sum2 = 1;
      }
    }
  }
  ll ans = min(cost, cost2);
  cout << ans << endl;
}


Measured memory_bytes: 1024
N, K = list(map(int, input().split()))
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))
# print(N, K , d, A)

sunuke_tachi = list(range(1, N + 1))
for Ai in A:
    sunuke_tachi = list(set(sunuke_tachi) - set(Ai))

answer = len(sunuke_tachi)

print(answer)


Measured memory_bytes: 9196
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) puts("Possible");
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    int ans=min(a,b);
    int ans2=a+b-n;
    if(ans2<0) ans2=0;
    printf("%d %d\n",ans,ans2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int aa[N+2],bb[N+2],cc[N+2],dd[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  long n,a,b;cin>>n>>a>>b;

  cout<<(n/(a+b))*a+min(a,n%(a+b))<<"\n";
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int c,f,bj;
int main()
{
	string s;
	cin>>s;
	for(register int i=0;i<s.length();i++)
	{
		if(s[i]=='C')c++;
		if(c>=1&&s[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    int N, M, l, r; cin>>N>>M;
    int s[M], c[M];
    for(int i=0; i<M; i++){
        cin>>s[i]>>c[i];
    }
    string I;
    l=pow(10, N-1);
    r=pow(10, N);
    if(l==1){
        l=0;
    }
    for(int i=l; i<r; i++){
        I=to_string(i);
        for(int j=0; j<M; j++){
            if(I.at(s[j]-1)-'0' !=c[j]){
                goto OUT;
            }
        }
        cout<<i<<endl;
        return 0;;
        OUT:;
    }
    cout<<"-1"<<endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderProject
{
    static class Program
    {
        static int N;
        static int M;
        static List<int> X;

        static void Main(string[] args)
        {
            var input = ReadLineSplitInt32();
            N = input[0];
            M = input[1];
            X = ReadLineSplitInt32();
            X.Sort();

            Console.WriteLine(dfs());
        }

        static int dfs()
        {
            if (N >= M) return 0;
            var diff = CalcDiff().ToList();
            diff.Sort((a, b) => a - b);

            return diff.Take(M-N).Sum();
        }
        static IEnumerable<int> CalcDiff()
        {
            for (int i = 1; i < X.Count; i++)
            {
                yield return X[i] - X[i - 1];
            }
        }

#if DEBUG
        static string input = @"
2 5
10 12 1 2 14
";
        static string _ReadLineImpl() => queue.Dequeue();
        static Queue<string> queue;
        static Program()
        {
            queue = new Queue<string>();
            foreach (var line in input.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
                queue.Enqueue(line);
        }
#else
        private static string _ReadLineImpl() => Console.ReadLine();
#endif
        static string ReadLine() => _ReadLineImpl();
        static int ReadLineInt32() => int.Parse(ReadLine());
        static double ReadLineDouble() => double.Parse(ReadLine());
        static List<string> ReadLineSplit() => ReadLine().Split().ToList();
        static List<int> ReadLineSplitInt32() => ReadLine().Split().Select(s => int.Parse(s)).ToList();
        static List<double> ReadLineSplitDouble() => ReadLine().Split().Select(s => double.Parse(s)).ToList();

        static IEnumerable<string> RepeatReadLines(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLine();
        }
        static IEnumerable<int> RepeatReadLinesInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineInt32();
        }
        static IEnumerable<List<string>> RepeatReadLinesSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineSplit();
        }
    }
}


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

int main(){
    int x,y;
    cin >> x >> y;
    if(x<y) swap(x,y);
    int r=x%y;
    while(r!=0){
        x=y;
        y=r;
        r=x%y;
    }
    cout << y << endl;
    return 0;
}


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

using namespace std;

template <typename T>
class RollingHash2D
{
    int h, w;
    static const uint64_t b1 = 9973, b2 = 100000007; // (1000000007, 1000000009)
    std::vector<uint64_t> rh, rw;
    std::vector<std::vector<uint64_t>> hash;

  public:
    RollingHash2D(const std::vector<std::vector<T>> &mat) : h(mat.size()), w(mat[0].size()), rh(h + 1), rw(w + 1), hash(h + 1, std::vector<uint64_t>(w + 1))
    {
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                hash[i + 1][j + 1] = hash[i + 1][j] * b2 + mat[i][j];
            }
            for (int j = 0; j < w; j++)
            {
                hash[i + 1][j + 1] += hash[i][j + 1] * b1;
            }
        }
        rh[0] = rw[0] = 1;
        for (int i = 0; i < h; i++)
            rh[i + 1] = rh[i] * b1;
        for (int i = 0; i < w; i++)
            rw[i + 1] = rw[i] * b2;
    }
    // [sx, gx) * [sy, gy) のハッシュ値を取得
    uint64_t query(int sx, int sy, int gx, int gy)
    {
        assert(0 <= sx && sx <= gx && gx <= h);
        assert(0 <= sy && sy <= gy && gy <= w);
        uint64_t h1 = hash[gx][gy] - hash[gx][sy] * rw[gy - sy];
        uint64_t h2 = hash[sx][gy] - hash[sx][sy] * rw[gy - sy];
        return h1 - h2 * rh[gx - sx];
    }
};

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

    int H, W;
    cin >> H >> W;
    vector<vector<char>> mat(H, vector<char>(W));
    for (int i = 0; i < H; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++)
        {
            mat[i][j] = s[j];
        }
    }
    int R, C;
    cin >> R >> C;
    vector<vector<char>> pattern(R, vector<char>(C));
    for (int i = 0; i < R; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < C; j++)
        {
            pattern[i][j] = s[j];
        }
    }
    RollingHash2D<char> rh(mat);
    RollingHash2D<char> p(pattern);
    auto ret = p.query(0, 0, R, C);
    for (int i = 0; i + R <= H; i++)
    {
        for (int j = 0; j + C <= W; j++)
        {
            auto v = rh.query(i, j, i + R, j + C);
            if (ret == v)
                cout << i << " " << j << endl;
        }
    }
}



Measured memory_bytes: 20364
#include<iostream>
using namespace std;
int main()
{

	string S, T, V;
	int Value = 0;
	int startpoint = -1;
	int found;
	bool result = false;
	cin >> S >> T;
	V = S;

	while (true) {
		if (V != "") {
			if (T.find(V) != -1) {


				T.erase(found, V.length());
				result = true;
				break;
			}
			else {


				V.erase(0, 1);

				found = T.find(V);

			}
		}
		else {
			break;
		}
	}
		
		
			if ((T + V) == S) {

				cout << "Yes";

			}
			else {
				cout << "No";
			}
			return 0;

		
	
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b;
  cin >> a >> b;

  cout << max(a+b, max(a-b, a*b)) << endl;
  
  return 0;
}


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

#define ll long long

int main () {
  ll n;
  cin >> n;
  ll l, r, s, ss;
  for (ll i = 0; i < n; i++) {
    if (i == 0) {
      cin >> l >> r;  
    }  
    else {
      cin >> s >> ss;
      if (s >= l && ss >= r) {
        l = s;
        r = ss;  
      }  
      else {
        ll ls = (l % s == 0) ? l / s: l / s + 1;
        ll rss= (r % ss== 0) ? r / ss: r / ss + 1;
        if (ls > rss) {
          l = s * ls;
          r = ss* ls;  
        }  
        else {
          l = s * rss;
          r = ss* rss;  
        }
      }
    }
  }  
  cout << l + r << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>

#define rg register
#define il inline
#define MX (3000 + 5)
#define ll long long

ll n ,m;

ll qpow(ll a ,ll b ,ll mod){
	if(b == 0)	return 1;
	if(b == 1)	return a;
	ll t = qpow(a ,b >> 1 ,mod);
	if(b & 1)	return t * t % mod * a % mod;
	return t * t % mod;
}

int C[MX][MX];
ll g[MX][MX] ,f[MX];

int main(){
	scanf("%lld%lld" ,&n ,&m);
	for(rg int i = 0 ; i <= 3000 ; ++i)	C[i][0] = 1;
	for(rg int i = 1 ; i <= 3000 ; ++i)
		for(rg int j = 1 ; j < MX ; ++j)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % m;
	//g[i][j]表示选中i个topping不合法放在j碗面里的方案 
	for(rg int i = 0 ; i <= n ; ++i)	g[i][0] = 1;
	for(rg int i = 1 ; i <= n ; ++i)
		for(rg int j = 1 ; j <= i ; ++j)
			g[i][j] = (g[i - 1][j] * (j + 1) % m + g[i - 1][j - 1]) % m;
	ll ans = 0;
	for(rg int i = 0 ; i <= n ; ++i){
		ll tmp = qpow(2LL ,qpow(2LL ,n - i ,m - 1) ,m);
		for(rg int j = 0 ; j <= i ;++j){
			f[i] = (f[i] + g[i][j] * qpow(2LL ,(n - i) * j ,m) % m * tmp % m) % m;
		}
		ans += (i & 1 ? -1 : 1) * (ll)C[n][i] * f[i] % m;
		ans = (ans + m) % m;
	}
	
	
	/*
	for(rg int i = n ; ~i ; --i){
		for(rg int j = i + 1 ; j <= n ; ++j){
			f[i] = (f[i] - f[j] * C[n][j] % m + m) % m;
		}
	}
	*/
	printf("%lld" ,ans);
	return 0;
} 

Measured memory_bytes: 104320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s.at(i);
	rep(i,h){
		cout << s.at(i) << endl;
		cout << s.at(i) << endl;
	}
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            List<Character> alice = new ArrayList<>();
            List<Character> bob = new ArrayList<>();
            List<Character> charlie = new ArrayList<>();
            for (char x : in.next().toCharArray()) alice.add(x);
            for (char x : in.next().toCharArray()) bob.add(x);
            for (char x : in.next().toCharArray()) charlie.add(x);
            char next = alice.get(0);
            boolean ans = true;

            while (ans) {
                switch (next) {
                    case 'a':
                        if (alice.size() == 0) {
                            out.println("A");
                            return;
                        }
                        next = alice.get(0);
                        alice.remove(0);
                        break;
                    case 'b':
                        if (bob.size() == 0) {
                            out.println("B");
                            return;
                        }
                        next = bob.get(0);
                        bob.remove(0);
                        break;
                    case 'c':
                        if (charlie.size() == 0) {
                            out.println("C");
                            return;
                        }
                        next = charlie.get(0);
                        charlie.remove(0);
                        break;
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{

   int n,k,t;
   cin>>n>>k>>t;
   int h=0,s=0,i=1;
   while(s<=t)
   {
       s=n*i;
       if(s>t)
       {
           break;
       }
       h=k*i;
       i++;
   }
   cout<<h<<endl;
}


Measured memory_bytes: 3636
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
// use ascii::Chars;
use libm::*;
use proconio::marker::{Bytes, Chars};
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

use lazy_static::lazy_static;
use std::sync::Mutex;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

lazy_static! {
    // static ref PARENTS: Mutex<Vec<usize>> = Mutex::default();
    // static ref CHILDS: Mutex<Vec<Vec<usize>>> = Mutex::default();
    static ref ADJ: Mutex<Vec<Vec<usize>>> = Mutex::default();
}

const MOD: i64 = 1000_000_000 + 7;

//abc177-D
// #[fastout]
fn main() {
    input![n: usize, m: i64, ab: [(usize, usize); m]];

    let mut adj = vec![HashSet::new(); n as usize];

    for (a, b) in ab.iter() {
        let a = a - 1;
        let b = b - 1;

        adj[a].insert(b);
        adj[b].insert(a);
    }

    let adj: Vec<Vec<usize>> = adj
        .into_iter()
        .map(|set| set.into_iter().collect())
        .collect();

    let mut is_visits = vec![false; n];

    let mut ans: i64 = -1;
    for i in 0..n as usize {
        if is_visits[i] {
            continue;
        }

        ans = max(ans, go(0, i, &mut is_visits, &adj) as i64);
    }

    // eprintln!("{:?}", adj);
    println!("{}", ans);
}

fn go(mid_ans: usize, start: usize, is_visits: &mut Vec<bool>, adj: &Vec<Vec<usize>>) -> usize {
    is_visits[start] = true;

    let mut ans = 1;
    for to in adj[start].iter() {
        if is_visits[*to] {
        } else {
            ans += go(mid_ans, *to, is_visits, adj);
        }
    }

    return ans;
}

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000
//  1000000000


Measured memory_bytes: 37316
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
bool h[100005];
string s;
int N;
bool check() {
  FOR(i,0,N) {
    int j = (i + 1) % N; // 真ん中
    int k = (j + 1) % N;
    // 羊の時
    if(h[j]) {
      if(j == N - 1 || j == 0) {
        if(s[j] == 'o' && h[i] != h[k]) return false;
        if(s[j] == 'x' && h[i] == h[k]) return false;
      }
      else h[k] = s[j] == 'o' ? h[i] : h[i] ^ 1;
    } else { 
      if(j == N - 1 || j == 0) {
        if(s[j] == 'o' && h[i] == h[k]) return false;
        if(s[j] == 'x' && h[i] != h[k]) return false;
      }
      else h[k] = s[j] == 'o' ? h[i] ^ 1 : h[i];
    }
  }
  return true;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  cin >> s;
  // 羊羊
  h[0] = h[1] = true;
  if(check()) {
    FOR(i,0,N) cout << (h[i] ? 'S' : 'W');
    cout << endl;
    return 0;
  }
  // 羊狼
  h[0] = true;
  h[1] = false;
  if(check()) {
    FOR(i,0,N) cout << (h[i] ? 'S' : 'W');
    cout << endl;
    return 0;
  }
  // 狼羊
  h[0] = false;
  h[1] = true;
  if(check()) {
    FOR(i,0,N) cout << (h[i] ? 'S' : 'W');
    cout << endl;
    return 0;
  }
  // 狼狼
  h[0] = h[1] = false;
  if(check()) {
    FOR(i,0,N) cout << (h[i] ? 'S' : 'W');
    cout << endl;
    return 0;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    cout << A[N-1]-A[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
  	int h[n];
  	for(int i = 0; i<n ; i++){
		cin >> h[i];
    }
  	sort(h, h+n, greater<>());
  	long long at = 0;
  	for(int i = k; i<n; i++){
      at += h[i];
    }
  	cout << at << endl;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
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; }

//Combination計算
const int LIMIT = 1e6;//1e6→50ms,1e7→500ms,1e8→5000ms程度。
const ll MOD = 1e9+7;
vector<ll> FacMod(LIMIT), InvMod(LIMIT), FacInvMod(LIMIT);
const int dpComTableLIMIT = 3e3+1;
vector<vector<ll>> Com(dpComTableLIMIT,vector<ll>(dpComTableLIMIT,0));
const int ComKTableLIMIT = 1e7;
vector<ll> ComK(ComKTableLIMIT);

void DPComInit(){
  //Com[0][j]は0で初期化されている。
  for(int i=0; i<dpComTableLIMIT; i++){ Com[i][0] = 1; }
  
  for(int i=1; i<dpComTableLIMIT; i++){
    for(int j=1; j<dpComTableLIMIT; j++){
      Com[i][j] = (Com[i-1][j-1]+Com[i-1][j])%MOD;
    }
  }
}

void ComKInit(ll N){
  for(int i=0; i<=ComKTableLIMIT; i++){
    if(0<i && i<=N/2){
      ComK[i] = (ComK[i-1]*(N-i+1)/i)%MOD;
    }else if(i==0){
      ComK[i] = 1;
    }else if(N/2<i && i<=N){
      ComK[i] = ComK[N-i];
    }else{//i>Nの時
      ComK[i] = -1;
    }
  }
}

void ComInit(){//tableを作成
  FacMod[0] = FacMod[1] = 1;
  InvMod[0] = 0; InvMod[1] = 1; //InvMod[0]は定義できない
  FacInvMod[0] = FacInvMod[1] = 1;
  
  for(int i=2; i<LIMIT; i++){
    FacMod[i] = FacMod[i-1]*i%MOD;
    InvMod[i] = -InvMod[MOD%i]*(MOD/i)%MOD + MOD;
    FacInvMod[i] = FacInvMod[i-1] * InvMod[i]%MOD;
  }
}

ll ComMod(int n, int k){
  if(n>=0 && k>=0 && n>=k){
    return FacMod[n]*(FacInvMod[k]*FacInvMod[n-k]%MOD)%MOD;
  }else{
    return 0; //戻り値を0にする方が計算結果に影響が少ない。
  }
}

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int X; int Y; cin >> X >> Y;
  //cout << X << Y << endl;
  
  //main
  int x; int y; 
  if((2*X-Y)%3 == 0){
    y = (2*X-Y)/3;
    x = X-2*y;
  }else{
    cout << 0 << endl; return 0; 
  }
  
  // output
  ComInit();
  ll ans = ComMod(x+y,x);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 172288
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int MOD = 1e9 + 7, N = 4e5 + 9;
int pow2[N];

int add(ll a, int b) {
	a += b;
	while(a >= MOD) a -= MOD;
	while(a < 0) a += MOD;
	return a;
}

int sub(int a, int b) {
	return (a - b + MOD) % MOD;
}

int mul(int a, int b) {
	return (1ll*a*b) % MOD;
}

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	pow2[0] = 1;
	for (int i = 1; i < N; ++i)
		pow2[i] = mul(pow2[i - 1], 2);
	int n, zeros = 0, a1 = 0, a2 = 0;
	map<pair<ll, ll>, int> mp;
	ll x, y;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x >> y;
		if(x == 0 && y == 0) {
			++zeros;
			continue;
		} else if(x == 0) {
			++a2;
			continue;
		} else if(y == 0) {
			++a1;
			continue;
		}
		ll g = __gcd(x, y);
		x /= g, y /= g;
		if(y < 0)
			x = -x, y = abs(y);
		mp[{x, y}]++;
	}
	int ans = add(pow2[a1], pow2[a2]);
	ans = sub(ans, 1);
	for(auto &it: mp) {
		if(!it.second) continue;
		ll y = it.first.first;
		ll x = it.first.second;
		y = -y;
		if(x < 0)
			x = abs(x), y = -y;
		ll cur = 0;
		if(mp.find({x, y}) != mp.end()) {
			cur = mp[{x, y}];
			mp[{x, y}] = 0;
		}
		ans = mul(ans, sub(add(pow2[cur], pow2[it.second]), 1));
		it.second = 0;
	}
	ans = sub(ans, 1);
	ans = add(ans, zeros);
	cout << ans;
	return 0;
}


Measured memory_bytes: 17652
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;
const ll INF = 1ll << 60;

int main()
{

    int n, m;
    cin >> n;
    cin >> m;
    vector<vector<int>> jobs(m);
    REP(i, n)
    {
        int a, b;
        cin >> a;
        cin >> b;
        if (a > m)
            continue;
        jobs[m - a].push_back(b);
    }

    priority_queue<int> q;
    ll ans = 0;
    for (int i = m - 1; i >= 0; --i)
    {
        for (int b : jobs[i])
        {
            q.push(b);
        }
        if (!q.empty())
        {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

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

	if(n%2==1){
		cout<<"No"<<endl;
		return 0;
	}else{
		if(s.substr(0,n/2)==s.substr(n/2,n/2)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}

	return 0;
}
	


Measured memory_bytes: 256
#include <cstdio>

int main() {
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;i++) {
		long long sum=i;
		sum*=(i+1);
		sum/=2;
		if(sum>=N) {
			for(int j=1;j<=i;j++) {
				if(j!=sum-N) printf("%d\n",j);
			}
			return 0;
		}
	}
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
    int k;
    cin >> k;
    int a,b,c;
    ll ans = 0;
    for(a=1;a<=k;a++){
        for(b=1;b<=k;b++){
            for(c=1;c<=k;c++){
                int i,min;
                min = a;
                if(min > b) min = b;
                if(min > c) min = c;
                for(i = min; i > 0;i--){
                    if(a%i == 0 && b%i == 0 && c%i == 0 ){
                        ans += i;
                        break;
                    }
                } 
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
p=[int(i) for i in input().split()]
ans=1
m=p[0]
for i in range(1,n):
    if p[i]<=m: ans+=1
    m=min(m,p[i])
        
print(ans)

Measured memory_bytes: 25132
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


signed main()
{
	speed
	int h,n;cin>>h>>n;
	vector<int> inp(n);
	int sum=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>inp[i];sum+=inp[i];
	}
	if(sum>=h){cout<<"Yes\n";}
	else{cout<<"No\n";}
}

Measured memory_bytes: 1024
S = input()
s = str(S)

num_list = []
for i in range(len(s)-2):
    temp = s[i:i+3]
    num_list.append(temp)

for i in range(len(s)-2):
    num_list[i] = abs(int(num_list[i]) - 753)

num_list_min = min(num_list)

print(num_list_min)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
main(){
    int N,A[100],sum = 0;
    cin >> N;
    for(int i = 0;i < N;i++) cin >> A[i];
    sort(A,A+N);
    for(int i = 0;i < N;i++) sum += A[i];
    if(sum % 10 == 0){
        for(int i = 0;i < N;i++){
            if(A[i] % 10){
                sum -= A[i];
                break;
            }
        }
    }
    if(sum % 10)cout << sum << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod (int)(2e9 + 14)
using namespace std;
int main(){
	long long sum = 0, minus = 0;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		sum += x;
		minus += 1LL * x * x;
		sum %= mod;
		minus %= mod;
	}
	sum *= sum;
	sum %= mod;
	sum -= minus;
	sum += mod;
	cout << (sum / 2) % (mod / 2) << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

vector<vector<P>> sanshou;
vector<ll> iro;

void nibuntansaku(ll ko, ll oya, ll konoiro){
  for(auto&& youso : sanshou.at(ko)){
    iikae mago = youso.first;
    iikae magotonokyori = youso.second;
    iro.at(ko) = konoiro;
    if(mago == oya) continue;
    if(magotonokyori % 2) nibuntansaku(mago, ko, 1 - konoiro);
    else nibuntansaku(mago, ko, konoiro);
  }
}

int main(){
  kyopro;
  ll N;
  cin >> N;
  sanshou.assign(N, vector<P>());
  iro.assign(N, 0);
  rep(i, 0, N-1){
    ll u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    sanshou.at(u).push_back(P(v, w));
    sanshou.at(v).push_back(P(u, w));
  }
  nibuntansaku(0, -1, 0);
  for(auto&& i : iro) cout << i << rt;
}

Measured memory_bytes: 11648