akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector> 
#include<math.h>
#include <algorithm>
using namespace std; 
int main()
{ 
double a,b,c,d,e,f,i;
cin>>a>>b;
double g=0;
for(i=0;i<a;i++)
{

cin>>c>>d;
e=sqrt(c*c+d*d);


if(e<=b)g++;
}
cout<<g;
}

Measured memory_bytes: 3788
#include <vector>
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

#define pb push_back

void solution(int n, int k, std::vector<int>& heights);
void solution1(int n, int k, std::vector<int>& heights);
void solution2();

int main(void){

	int n, k;
	cin >> n >> k;
	std::vector<int> heights(n);
	for(int i = 0;i < n;i++)
		cin >> heights[i];

	solution(n, k, heights);
	// solution1(n, k, heights);
}

// iterative
void solution(int n, int k, std::vector<int>& heights){
	std::vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for(int j = 1;j < n;j++){
		for(int i = 1;i <= k && j >= i;i++){
			dp[j] = min(dp[j], dp[j-i] + abs(heights[j]-heights[j-i]));
		}
	}
	cout << dp[n-1] << endl;
	return;
}

int helper(int n, int k, std::vector<int>& heights, int x, std::vector<int>& dp){
	if(dp[x] != -1)
		return dp[x];
	if(x == 0){
		dp[x] = 0;
		return dp[x];
	}
	dp[x] = INT_MAX;
	for(int i = 1;i <= k && i <= x;i++){
		dp[x] = min(dp[x], helper(n, k, heights, x-i, dp) + abs(heights[x] - heights[x-i]));
	}
	return dp[x];
}

// recursive
void solution1(int n, int k, std::vector<int>& heights){
	std::vector<int> dp(n, -1);
	int ans = helper(n, k, heights, n-1, dp);
	cout << ans << endl;
	return;
}

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

int main(){
  string T;
  cin >> T;
  
  for(int i = 0; i < T.size(); i++){
    if(T[i] != '?')
      cout << T[i];
    else
      cout << 'D';
  }
  
  cout << endl;
  
  return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    string s; cin >> s;
    vi cs(2);
    FOR(i, 0, s.size() - 1) {
        cs[i % 2 ^ (s[i] == '0')]++;
    }
    cout << s.size() - max(cs[0], cs[1]) << endl;
}

Measured memory_bytes: 3748
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if(a>=b*2){
    System.out.println(a-(b*2));
    }else if(a<b*2){
    System.out.println(0);
    }
}

}

Measured memory_bytes: 21972
n = int(input())
a = list(map(int, input().split()))

total = 0
for i in range(1,n):
    total += abs(a[i] - a[i-1])

total +=  abs(a[0]) + abs(a[-1])

a.insert(0, 0)
a.append(0)
for i in range(1,n+1):
    if a[i-1] <= a[i] and a[i] <= a[i+1]:
        print(total)
    elif a[i+1] <= a[i] and a[i] <= a[i-1]:
        print(total)
    elif max(a[i-1], a[i+1]) < a[i]:
        print(total - abs(a[i] - max(a[i-1], a[i+1]))*2)
    elif a[i] < min(a[i-1], a[i+1]):
        print(total - abs(a[i] - min(a[i-1], a[i+1]))*2)

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

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

    while(true){
        C -= B;
        if(C<=0){
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A<=0){
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3624
//自力ではない
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

template< int mod >
struct ModInt {
	int x;

	ModInt() : x(0) {}

	ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

	ModInt& operator+=(const ModInt& p) {
		if ((x += p.x) >= mod) x -= mod;
		return *this;
	}

	ModInt & operator-=(const ModInt & p) {
		if ((x += mod - p.x) >= mod) x -= mod;
		return *this;
	}

	ModInt & operator*=(const ModInt & p) {
		x = (int)(1LL * x * p.x % mod);
		return *this;
	}

	ModInt& operator/=(const ModInt & p) {
		*this *= p.inverse();
		return *this;
	}

	ModInt operator-() const { return ModInt(-x); }

	ModInt operator+(const ModInt & p) const { return ModInt(*this) += p; }

	ModInt operator-(const ModInt & p) const { return ModInt(*this) -= p; }

	ModInt operator*(const ModInt & p) const { return ModInt(*this) *= p; }

	ModInt operator/(const ModInt & p) const { return ModInt(*this) /= p; }

	bool operator==(const ModInt & p) const { return x == p.x; }

	bool operator!=(const ModInt & p) const { return x != p.x; }

	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while (b > 0) {
			t = a / b;
			swap(a -= t * b, b);
			swap(u -= t * v, v);
		}
		return ModInt(u);
	}

	ModInt pow(int64_t n) const {
		ModInt ret(1), mul(x);
		while (n > 0) {
			if (n & 1) ret *= mul;
			mul *= mul;
			n >>= 1;
		}
		return ret;
	}

	friend ostream& operator<<(ostream & os, const ModInt & p) {
		return os << p.x;
	}

	friend istream& operator>>(istream & is, ModInt & a) {
		int64_t t;
		is >> t;
		a = ModInt< mod >(t);
		return (is);
	}

	static int get_mod() { return mod; }
};

using modint = ModInt< mod >;
template< typename T = modint >

struct Combination {
	vector< T > _fact, _rfact, _inv;

	Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
		_fact[0] = _rfact[sz] = _inv[0] = 1;
		for (int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
		_rfact[sz] /= _fact[sz];
		for (int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
		for (int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
	}

	inline T fact(int k) const { return _fact[k]; }

	inline T rfact(int k) const { return _rfact[k]; }

	inline T inv(int k) const { return _inv[k]; }

	T P(int n, int r) const {
		if (r < 0 || n < r) return 0;
		return fact(n) * rfact(n - r);
	}

	T C(int p, int q) const {
		if (q < 0 || p < q) return 0;
		return fact(p) * rfact(q) * rfact(p - q);
	}

	T H(int n, int r) const {
		if (n < 0 || r < 0) return (0);
		return r == 0 ? 1 : C(n + r - 1, r);
	}
};


int main() {
	 
	long N, K; cin >> N >> K;
	Combination<modint> comb(N);

	for (int i = 1; i <= K; i++) cout << comb.C(N - K + 1, i) * comb.C(K - 1, i - 1) << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  int k=2;
  while(k*(k-1)<2*n)++k;
  if(k*(k-1)!=2*n){
    ECHO("No");
    return 0;
  }

  int s[k][k-1];
  queue<int> q[k];
  int x=1, w;
  for(int i=0; i<k; ++i){
    for(int j=0; j<i; ++j){
      w = q[j].front();
      q[j].pop();
      s[i][j]=w;
      //cout<<i<<" "<<j<<" "<<w<<endl;
    }
    for(int j=i; j<k-1; ++j){
      s[i][j]=x;
      q[i].push(x);
      //cout<<i<<" "<<j<<" "<<x<<endl;
      ++x;
    }
  }
  ECHO("Yes");
  ECHO(k);
  REP(i, k){
    cout<<k-1<<" ";
    REP(j, k-1){
      if(j<k-2) cout<<s[i][j]<<" ";
      else cout<<s[i][j]<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2688
MOD = 10 ** 9 + 7

N, M = map(int, input().split())

broken = [False for _ in range(N+1)]
for _ in range(M):
	broken[int(input())] = True

dp = [0 for _ in range(N + 1)]
dp[0] = 1
if(broken[1] == False):
  dp[1] = 1

for i in range(2, N+1):
	if broken[i]:
		continue
	else:
		dp[i] = dp[i-1] + dp[i-2]
		dp[i] %= MOD
print(dp[N])

Measured memory_bytes: 7836
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
nom = [0] * (10**5+1)
n = ini()
a = inl()
ans = sum(a)
for i in a:
        nom[i] += 1
q = ini()
for i in range(q):
        b,c = inm()
        d = c-b
        ans += nom[b] * d
        print(ans)
        nom[c] += nom[b]
        nom[b] = 0


Measured memory_bytes: 21600
N=int(input())
A=[int(a) for a in input().split()]
B=[int(b) for b in input().split()]
x,y=0,0
for i in range(N):
  d=B[i]-A[i]
  if d>0:
    x+=d//2+d%2
    y+=d%2
  else:
    y-=d
print(['No','Yes'][x>=y])

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

int main(){
	int W, H, x, y, r;
	
	cin>> W >> H >> x >> y >> r;
	
	if(x - r < 0 || y - r < 0 || x + r > W || y + r > H){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3096
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn solve(as_: Vec<i64>) -> i64 {
    let mut sum1 = 0;
    let mut sum2 = 0;
    let mut count1 = 0;
    let mut count2 = 0;

    if as_[0] <= 0 {
        count1 = 1 - as_[0];
        sum1 = 1;
    } else {
        sum1 = as_[0];
    }

    if as_[0] >= 0 {
        count2 = 1 + as_[0];
        sum2 = -1;
    } else {
        sum2 = as_[0];
    }

    for i in 1..as_.len() {
        let cur = as_[i];
        if sum1 > 0 {
            if cur + sum1 < 0 {
                sum1 += cur;
            } else {
                let exp = -1 - sum1;
                count1 += cur - exp;
                sum1 = -1;
            }
        } else if sum1 < 0 {
            if cur + sum1 > 0 {
                sum1 += cur;
            } else {
                let exp = 1 - sum1;
                count1 += exp - cur;
                sum1 = 1;
            }
        }
    }

    for i in 1..as_.len() {
        let cur = as_[i];
        if sum2 > 0 {
            if cur + sum2 < 0 {
                sum2 += cur;
            } else {
                let exp = -1 - sum2;
                count2 += cur - exp;
                sum2 = -1;
            }
        } else if sum2 < 0 {
            if cur + sum2 > 0 {
                sum2 += cur;
            } else {
                let exp = 1 - sum2;
                count2 += exp - cur;
                sum2 = 1;
            }
        }
    }
    std::cmp::min(count1, count2)
}

fn main() {
    input!{
        n: usize,
        as_: [i64; n],
    }
    println!("{}", solve(as_));
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string S; cin>>S;

    int match=0;
    bool is_1=true;
    for(auto s:S){
        int i=s-'0';
        if(is_1) match+=i;
        else match+=!i;
        is_1=!is_1;
    }

    cout<<min(S.size()-match,(uint64_t)match)<<endl;
}

Measured memory_bytes: 512
// Problem: D - Simple Knapsack
// Contest: AtCoder - AtCoder Regular Contest 073
// URL: https://atcoder.jp/contests/arc073/tasks/arc073_b
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 101;

int n, W;
ll w1, dp[N][N][N << 2];
int w[N], v[N];

void baka() {
  cin >> n >> W >> w[1] >> v[1];
  w1 = w[1];
  w[1] = 0;
  for (int i = 2; i <= n; i++) {
    cin >> w[i] >> v[i];
    w[i] -= w1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      for (int k = 0; k <= 3 * n; k++) {
        dp[i][j][k] = dp[i - 1][j][k];
        if (k >= w[i])
          dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j - 1][k - w[i]] + v[i]);
      }
    }
  }
  ll ans = 0;
  for (int j = 1; j <= n; j++) {
    for (int k = 0; k <= 3 * n; k++) {
      if (w1 * j + k <= W) {
        ans = max(ans, dp[n][j][k]);
      }
    }
  }
  cout << ans;
}

signed main() { cin.tie(0)->sync_with_stdio(0);
  #define filename ""
  if (fopen(filename".INP", "r"))
  freopen(filename".INP", "r", stdin),
  freopen(filename".OUT", "w", stdout);
  int t = 1;
  // cin >> t;
  while (t--) baka(), cout << (t ? "\n" : "");
}

Measured memory_bytes: 19916
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m;
    scanf("%lld%lld",&n,&m);
    if(n==1&&m==1){
        printf("%d\n",1);
        return 0;
    }
    if(n==1||m==1){
        printf("%lld\n",n*m-2);
        return 0;
    }
    if(n==2||m==2){
        printf("0\n");
        return 0;
    }
    long long sum=n*m-2ll*n-2ll*m+4ll;
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String saa = sc.next(), sbb = sc.next(), scc = sc.next();
		int na = saa.length(), nb = sbb.length(), nc = scc.length();
		int a = 0, b = 0, c = 0, turn = 0;
		while(true){
			if(turn == 0){
				if(a == na){
					System.out.println('A');
					break;
				}
				turn = saa.charAt(a) - 'a';
				a++;
			}else if(turn == 1){
				if(b == nb){
					System.out.println('B');
					break;
				}
				turn = sbb.charAt(b) - 'a';
				b++;
			}else{
				if(c == nc){
					System.out.println('C');
					break;
				}
				turn = scc.charAt(c) - 'a';
				c++;
			}
		}
	}
}

Measured memory_bytes: 21716
#include<stdio.h>
main(){
  int a,b,c,d,e,f,g,h,i;
  scanf("%d",&a);
  b = a/60/60;
  c = b*60*60;
  d = a-c;
  e = d/60;
  f = e*60;
  g = d-f;
  printf("%d:%d:%d\n",b,e,g);
  return 0;
}
    

Measured memory_bytes: 592
#include<iostream>
#include<math.h>
using namespace std;
int main() {
  int n;cin>>n;
  int* stones = new int[n];
  int* dp = new int[n];
  if(n>=1)cin>>stones[0];
  if(n>=2)cin>>stones[1];
  dp[0]=0;
  dp[1]=abs(stones[1]-stones[0]);
  for(int i=2;i<n;i++) {
    cin>>stones[i];
  	dp[i]=min(dp[i-1]+abs(stones[i]-stones[i-1]),dp[i-2]+abs(stones[i-2]-stones[i]));
  }
  if(n>=1)cout<<dp[n-1]<<endl;
  else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll a, b, n;
  cin >> a >> b >> n;
  cout << floor(a*min(n,b-1)/b) - a*floor((min(n,b-1)/b)) << endl;

  return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <queue>
#include <vector>
#include <cstdio>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;

int e[100010];
int main(void){
	int n, m; cin >> n >> m;
	deque<int> dq;
	rep(i, m){
		int tmp; cin >> tmp;
		e[i] = tmp;
		dq.push_front(tmp);
	}

	set<int> s;
	for (int i = 0; i < m; ++i){
		// printf("dp %d\n", dq[i]);
		if(s.count(dq[i]) == 0){
			printf("%d\n", dq[i]);
		}
		s.insert(dq[i]);
	}
	for (int i = 1; i <= n; ++i){
		if(s.count(i) == 0){
			printf("%d\n", i);
		}
	}
	return 0;
}

Measured memory_bytes: 8428
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372037ll;

void solve()
  {
   string s;
   cin>>s;
   int n = s.size();
   int ans = 0;
   loop(i,0,3)
    {
      int pos = i;
      int cnt = 0;
      while(pos<3 && s[pos] == 'R')
         {
          cnt++;
          pos++;
         }
      ans = max(ans,cnt);
    }
    cout<<ans;
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String t = scanner.nextLine();
        int counter = 0;
        
        for(int i = 1;i<=s.length();i++)
        {
            if(!s.substring(i-1,i).equals(t.substring(i-1,i)))
            {
                counter++;
            }
        }
        System.out.println(counter);
    }
}


Measured memory_bytes: 55948
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    s = input()
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    cnt = 0
    cntmax = 0
    for i in range(len(s)):
        if s[i] =="A" or s[i] =="C" or s[i] =="G" or s[i] =="T":
            cnt += 1
        else:
            cntmax = max(cntmax, cnt)
            cnt = 0

    print(cntmax)
resolve()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int mod = 1000000007;

ll gcd(ll a, ll b){
    if(b == 0) return a;
    
    return gcd(b,a%b);
}

int main() {
    ll a,b;
    cin>>a>>b;
    
    ll g = gcd(a,b);
    ll c = g;
    
    ll till = floor(sqrt(g));
    int cnt = 0;
    
    for(ll i = 2; i<=till; i++){
        if(g%i == 0) cnt++;
        
        while(g%i == 0) g/=i;
    }
    
    if(g!=1) cnt++;
    
    
    cout<<cnt+1;
}

Measured memory_bytes: 256
#![allow(dead_code)]
#![allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{BufWriter, stdin, stdout, Write};
const BITS: usize = 19;

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

    let n: i32 = scan.next();
    let x: i32 = 1000 - (n % 1000);

    if n % 1000 == 0 {
        writeln!(out, "0");
    }
    else {
        writeln!(out, "{}", x);
    }
}

Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, Q;
  cin >> N >> Q;
  
  string S;
  cin >> S;
  
  vector<int> flag(N);
  int count = 0;
  
  flag.at(0) = 0;
  for (int i=0; i<N-1; i++) {
    if (S.at(i) == 'A' && S.at(i+1) == 'C')
        count++;
    flag.at(i+1) = count;
  }
  
  for (int i=0; i<Q; i++) {
    
    int l, r;
    cin >> l >> r;
    
    cout << flag.at(r-1) - flag.at(l-1) << endl;

  }
  
}

Measured memory_bytes: 1408
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(ll N, string S) {
  int s = 0;
  for (char c: S) {
    if (c == '(') ++s; else --s;
  }
  if (s > 0) S = S + string(s, ')');
  else S = string(-s, '(') + S;
  int mi = 0;
  s = 0;
  for (char c: S) {
    if (c == '(') ++s; else --s;
    chmin(mi, s);
  }
  S = string(-mi, '(') + S + string(-mi, ')');
  cout << S << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	string S;
	scanf("%lld", &N);
	cin >> S;
	solve(N, S);
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)
def conv(r,s,p,j):
    if j == 'r':
        return p
    if j == 's':
        return r
    if j == 'p':
        return s
def listint():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
def perse(t,k,num):
    stri = []
    for i in range(k):
        stri.append([])
    for i in range(num):
        stri[i%k].append(t[i])
    return stri
def main(q):
    i = 0
    ans = 0
    while i < len(q)-1:
        if q[i] == q[i+1]:
            ans = ans + conv(r,s,p,q[i])
            i = i+2
        else:
            ans = ans + conv(r,s,p,q[i])
            i = i+1
    if i == len(q)-1:
        ans = ans + conv(r,s,p,q[i])
    return ans
num,k = listint()
r,s,p = listint()
t = input()
afterperse = perse(t,k,num)
ans = 0
for i in range(k):
    ans = ans + main(afterperse[i])
print(ans)

Measured memory_bytes: 13436
e1,e2,e3,e4=map(int,input().split())

if e1==e2 and e3==e4:
    print('yes')
elif e1==e3 and e2==e4:
    print('yes')
elif e1==e4 and e2==e3:
    print('yes')
else:
    print('no')


Measured memory_bytes: 5596
n = int( input() )
s = list( map( int, input().split() ))

total = sum( s )

minimum = total
part1 = total
for i in range( len( s ) ):
  part1 = part1 - s[ i ]
  minimum = min( minimum, abs( total - 2 * part1 ))
  if total - 2 * part1 >= 0:
    break
    
print( minimum )


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



 int main()
{
	int x,y;
	cin>>x>>y;
	if(y%2){
		cout<<"No"<<endl;
		return 0;
	}
	y /= 2;
	if(y-x>=0 && 2*x - y >=0){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No";
}


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

using lint = int64_t;
#define bit(n) ((lint)1 << n);
const int INF = 1e9;
const lint LINF = 1e18;

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

class IoSetup {
    public:
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
        cerr << fixed << setprecision(12);
    }
} iosetup;

template <lint mod>
class ModInt {
    lint val;
    public:
    ModInt(): val(0) {}
    ModInt(lint init_val):
        val((init_val % mod + mod) % mod) {}

    ModInt operator -() {return ModInt(-val);}
    bool operator !() {return val == 0;}
    ModInt& operator ++() {this->val = (this->val + 1) % mod; return *this;}
    ModInt operator ++(int) {ModInt temp = *this; this->val = (this->val + 1) % mod; return temp;}
    ModInt& operator --() {
        this->val = ((this->val - 1) % mod + mod) % mod; return *this;}
    ModInt operator --(int) {
        ModInt temp = *this; this->val = ((this->val - 1) % mod + mod) % mod; return temp;}
    
    ModInt& operator += (const ModInt that) {val = (val + that.val) % mod; return *this;}
    ModInt& operator -= (const ModInt that) {val = ((val - that.val) % mod + mod) % mod; return *this;}
    ModInt& operator *= (const ModInt that) {val = (val * that.val) % mod; return *this;}
    ModInt& operator /= (const ModInt that) {
        lint res = 1, n = that.val, p = mod - 2;
        while (p > 0) {
            if (p % 2 == 1) res = res * n % mod;
            n = n * n % mod; p /= 2;
        }
        val = val * res % mod; return *this;
    }

    bool operator == (const ModInt& that) {return val == that.val;}
    bool operator != (const ModInt& that) {return val != that.val;}
    ModInt operator + (const ModInt& that) {return ModInt(*this) += that;}
    ModInt operator - (const ModInt& that) {return ModInt(*this) -= that;}
    ModInt operator * (const ModInt& that) {return ModInt(*this) *= that;}
    ModInt operator / (const ModInt& that) {return ModInt(*this) /= that;}

    friend istream& operator >> (istream& is, ModInt& a) {
        lint val; cin >> val; a = ModInt(val); return is;}
    friend ostream& operator << (ostream& os, const ModInt& a) {
        return os << a.val;}
};
using mint = ModInt<MOD>;
// using mint = double;

int main() {
    int n, m;
    cin >> n >> m;
    vector<mint> a(n + 1, 1);
    for (int i = 0; i < m; i++) {
        int b;
        cin >> b;
        a[b] = 0;
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] == 0) {
            continue;
        }
        if (i == 1) {
            a[i] = a[i - 1];
        } else {
            a[i] = a[i - 1] + a[i - 2];
        }
    }

    cout << a[n] << endl;
    return 0;
}

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

using namespace std;
#define MAX 100010

int box[ MAX ];
bitset< MAX > pos;

int main() {
    ios::sync_with_stdio(false), cin.tie( NULL );
    int n , m;
    //memset( box , 0 , sizeof box );
    cin >> n >> m;
    for( int i = 0 ; i < n ; ++i )
        box[ i ]=1;
    int u ,v;
    pos.reset();
    pos[ 0 ] = 1;
    for( int i = 0 ;i < m ; ++i )
    {
        cin >> u >>v;
        u--;
        v--;
        if( pos[ u ] )
            pos[ v ] = true;
        box[ u ]--;
        box[ v ]++;
        if( pos[ u ] && !box[ u ] )
            pos[ u ] = false;

    }
    int tot = 0;
    for( int i = 0; i < n ; ++i )
    {
        if( box[ i ] && pos[ i ] )
            tot++;
    }
    cout << tot << "\n";
    return 0;
}


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

int main(){
 string s,first,last;
  cin >> s;
 cout<< s.at(0) << s.size() -2 << s.at(s.size() -1) << endl;
}

Measured memory_bytes: 3552
export class Main {
  static main(input): string {
    const tmp: number[] = input.split("\n").map(s => Number(s.split(" ")[0]));
    let index: number = 0;
    let minR: number = Infinity;
    for (let i = 0; i < 5; i++) {
      const r: number = tmp[i] % 10;
      if (0 < r && r < minR) {
        minR = r;
        index = i;
      }
    }
    let result: number = tmp[index];
    for (let i = 0; i < 5; i++) {
      if (i != index) {
        const r: number = tmp[i] % 10;
        result += tmp[i] - r + (r === 0 ? 0 : 10);
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    use itertools_num::ItertoolsNum as _;
    input! {
       X: usize,
    }

    let mut ans: usize = 0;
    let ans = if X < 600 {
        8
    } else if X < 800 {
        7
    } else if X < 1000 {
        6
    } else if X < 1200 {
        5
    } else if X < 1400 {
        4
    } else if X < 1600 {
        3
    } else if X < 1800 {
        2
    } else if X < 2000 {
        1
    } else {
        0
    };

    echo!(ans);
}


Measured memory_bytes: 2112
N = int(input())
S = input()

current = ''
result_sum = 0
for i in range(N):
    if i == 0:
        current = S[i]
        result_sum = 1
        continue
    if current == S[i]:
        continue
    result_sum += 1
    current = S[i]

print(result_sum)

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

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

	double result;
	result = 0.0;

	if(l % 3 == 0) {
		result = (l / 3) * (l / 3) * (l / 3);
	} else {
		double r1;
		r1 = l / 3.0;
		result = r1 * r1 * r1;
	}

	printf("%lf\n",result);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int a, b, c, k;
void init(){
    cin >> a >> b >> c >> k;
}
void solve(){
    int ans = 0;
    if (k >= a) k -= a, ans += a;
    else  ans +=  k, k = 0;
    if (k >= b) k -= b;
    else  k = 0;
    if (k >= c) k -= c, ans -= c;
    else  ans -= k, k = 0;
    cout << ans << endl;
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 3624
N,K = map(int,input().split())
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))
counter = [0] * N
for i in range(K):
    for j in range(d[i]):
        counter[A[i][j] - 1] += 1
ans = 0
for a in counter:
    if a == 0:
        ans += 1
print(ans)

Measured memory_bytes: 9204
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<map>
#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int z = 1000000007;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main() {
    int k;
    cin >> k;
    int modk7 = 7 % k;
    int mod_k = 7 % k;
    int ans = 1;
    if (k % 2 == 0) {
        cout << -1 << endl;
        return 0;
    }
    while (1) {
        if (ans > 10000000) {
            ans = -1;
            break;
        }
        if (mod_k == 0)
            break;
        mod_k = (mod_k * 10 + modk7) % k;
        ans++;
    }
    cout << ans << endl;;
    return 0;
    
}


Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=2005;
int a[3*maxn],maxx[maxn][maxn],maxval[maxn],nxtval[maxn];
void chmax(int &x,int y)
{
    x=max(x,y);
    return;
}
void upd(int val,int t,int x,int y)
{
    if(val==-1) return;
    int nxt=max(maxx[x][y],val+t);
    maxx[x][y]=maxx[y][x]=nxt;
    chmax(nxtval[x],nxt);
    chmax(nxtval[y],nxt);
    return;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=3*n;i++)
        scanf("%d",&a[i]);
    memset(maxx,-1,sizeof(maxx));
    memset(maxval,-1,sizeof(maxval));
    maxx[a[1]][a[2]]=maxx[a[2]][a[1]]=0;
    maxval[a[1]]=maxval[a[2]]=0;
    int add=0;
    for(int i=1;i<n;i++)
    {
        memset(nxtval,-1,sizeof(nxtval));
        int u=a[i*3],v=a[i*3+1],w=a[i*3+2];
        if(u==v&&v==w) {add++; continue;}
        else if(u==v||v==w||w==u)
        {
            int p=max(min(u,max(v,w)),min(v,w)),q=u+v+w-2*p;
            for(int nxt=1;nxt<=n;nxt++)
            {
                if(nxt==p||nxt==q) continue;
                upd(maxx[p][nxt],1,q,nxt);
            }
            int tmp=maxx[q][q];
            upd(maxx[p][q],1,q,q);
            upd(maxx[p][p],1,p,q);
            upd(tmp,1,p,p);
        }
        else
        {
            upd(maxx[u][u],1,v,w);
            upd(maxx[v][v],1,u,w);
            upd(maxx[w][w],1,u,v);
        }
        for(int nxt=1;nxt<=n;nxt++)
        {
            upd(maxval[nxt],0,u,nxt);
            upd(maxval[nxt],0,v,nxt);
            upd(maxval[nxt],0,w,nxt);
        }
        int allmax=-1;
        for(int j=1;j<=n;j++)
            chmax(allmax,maxval[j]);
        upd(allmax,0,u,v);
        upd(allmax,0,u,w);
        upd(allmax,0,v,w);
        for(int j=1;j<=n;j++)
            maxval[j]=max(maxval[j],nxtval[j]);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j++)
            if(~maxx[i][j])
                chmax(ans,maxx[i][j]+(i==a[3*n]&&j==a[3*n]));
    printf("%d\n",ans+add);
    return 0;
}
/*
2
1 2 1 2 2 1

3
1 1 2 2 3 3 3 2 1

3
1 1 2 2 2 3 3 3 1
👍🌹❤️😃😎👌❓❗⭕❌🅰️🅱️💯0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣🔟✔️✖️➕➖➗👋✌️👊👏💪✏️😄😆😂🙂😉😊😙😋😝😏😴😵😳😭😱👻👽😺🙈💔🇨🇳
  */


Measured memory_bytes: 19600
n, t = list(map(int, input().split()))
routes = [list(map(int, input().split())) for _ in range(n)]

min_c = 1001
for (c, time) in routes:
    if time <= t:
        min_c = min(min_c, c)
if min_c == 1001:
    min_c = "TLE"
print(min_c)



Measured memory_bytes: 2940
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a,n;
  cin >> n;
  a=n%10;
  if(a==2 || a==4 || a==5 || a==7 || a==9){
    printf("hon\n");
  }
  else if(a==3){
    printf("bon\n");
  }
  else{
    printf("pon");
  }
  return 0;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(ld p){printf("%.12Lf\n",p);}
template<class T>inline                             void outml(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outol(T V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int K;
  in(K);
  queue<long>q;
  up(i,1,9)q.push(i);
  rep(i,K){
    long x=q.front();
    q.pop();
    if(i==K-1){
      out(x);
      return;
    }
    if(x%10!=0)q.push(x*10+x%10-1);
    q.push(x*10+x%10);
    if(x%10!=9)q.push(x*10+x%10+1);
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

#define int long long
#define MOD 1000000007

int n, k;
vector<int> graph[100010];
int a[100010];

void dfs(int idx, int oya){
    int cnt = (idx == oya ? 1 : 2);

    for(int i = 0;i < graph[idx].size();i++){
        int ko = graph[idx][i];
        if(ko != oya){
            a[ko] = max(0ll, k-cnt);
            cnt++;
            dfs(ko, idx);
        }
    }
}

signed main(){
    cin >> n >> k;

    int ax, b;
    for(int i = 0;i < n-1;i++){
        cin >> ax >> b;
        ax--;
        b--;
        graph[ax].push_back(b);
        graph[b].push_back(ax);
    }

    dfs(0, 0);


    int ans = k;
    for(int i = 1;i < n;i++){
        ans = (ans * a[i]) % MOD;
    }

    cout << ans << endl;

    return 0;
}



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

int main(){
    string s;
    cin>>s;
    if (s.length()<6){
        cout<<"No";
    }
    else if (s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
K = gets.to_i

d = [1E10.to_i] * K
q = [d[1] = 1]
until q.empty?
  break if (n = q.shift).zero?
  n1 = (10 * n) % K
  if d[n1] > d[n]
    d[n1] = d[n]
    q.unshift(n1)
  end
  n2 = (n + 1) % K
  if d[n2] > d[n] + 1
    d[n2] = d[n] + 1
    q.push(n2)
  end
end
puts d[0]

Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
ll cnt = 0;
int ans = 0;
int tmp;
int main(){
    ll Q, H, S, D;
    cin >> Q >> H >> S >> D >> N;
    ll a = min(2 * Q, H);//0.5
    ll b = min(2 * a, S);//1.0
    ll c = min(2 * b, D);//2.0
    if(N > 1){
        if(N % 2 == 0){
            cnt = c * (N / 2);
        }else{
            cnt = c * (N / 2) + b;
        }
    }else
        cnt = b;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
int max_r[maxn];
int n, m, h[maxn];

signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	for (int i = 1;i <= n;++i)
		cin >> h[i];
	for (int a, b;m--;) {
		cin >> a >> b;
		max_r[a] = max(max_r[a], h[b]);
		max_r[b] = max(max_r[b], h[a]);
	}
	int cnt = 0;
	for (int i = 1;i <= n;++i)
		cnt += max_r[i] < h[i];
	cout << cnt << '\n';
}



Measured memory_bytes: 4432
name1, a1, b1 = map(str, input().split())
name2, a2, b2 = map(str, input().split())
name3, a3, b3 = map(str, input().split())
name4, a4, b4 = map(str, input().split())
name5, a5, b5 = map(str, input().split())
name6, a6, b6 = map(str, input().split())
name7, a7, b7 = map(str, input().split())
name8, a8, b8 = map(str, input().split())
name9, a9, b9 = map(str, input().split())

print(name1,int(a1)+int(b1),int(a1)*200+int(b1)*300)
print(name2,int(a2)+int(b2),int(a2)*200+int(b2)*300)
print(name3,int(a3)+int(b3),int(a3)*200+int(b3)*300)
print(name4,int(a4)+int(b4),int(a4)*200+int(b4)*300)
print(name5,int(a5)+int(b5),int(a5)*200+int(b5)*300)
print(name6,int(a6)+int(b6),int(a6)*200+int(b6)*300)
print(name7,int(a7)+int(b7),int(a7)*200+int(b7)*300)
print(name8,int(a8)+int(b8),int(a8)*200+int(b8)*300)
print(name9,int(a9)+int(b9),int(a9)*200+int(b9)*300)


Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <bitset>
#define ll long long
using namespace std;


int main(){//cout<<1<<endl;
 int path[100][100];
  vector <int> a(0);
  vector <int> b(0);
  
 
    int p,q;
    cin>>p>>q;
    a.push_back(p);
    b.push_back(q);
//  cout<<a.back()<<endl;
    
    path[a.back()][b.back()]=100;
    path[b.back()][a.back()]=100;
  
 // cout<<a.back()<<" "<<b.back()<<" "<<   path[a.back()][b.back()] <<endl;;
  
  int p2,q2;
  cin>>p2>>q2;
  a.push_back(p2);
  b.push_back(q2);
  
  
  path[a.back()][b.back()]=100;
  path[b.back()][a.back()]=100;
  
  // cout<<a.back()<<" "<<b.back()<<" "<<   path[a.back()][b.back()] <<endl;;
  
  int p3,q3;
  cin>>p3>>q3;
  a.push_back(p3);
  b.push_back(q3);
  
  
  path[a.back()][b.back()]=100;
  path[b.back()][a.back()]=100;
  
   //cout<<a.back()<<" "<<b.back()<<" "<<   path[a.back()][b.back()] <<endl;;
   //if(flag13) cout<<111111<<endl;
  
  
  bool ans=false;
  bool flag12 = path[1][2]==100 ? true : false;
  bool flag23 = path[2][3]==100 ? true : false;
  bool flag34 = path[3][4]==100 ? true : false;
  bool flag14 = path[4][1]==100 ? true : false;
 
  bool flag13 = path[1][3]==100 ? true : false;
  bool flag24 = path[2][4]==100 ? true : false;
  //if(flag13) cout<<111111<<endl;
  
  if(flag13 and flag12 and flag24) {ans=true;}//cout<<1<<endl;}
  if(flag34 and flag12 and flag24) {ans=true;}//cout<<2<<endl;}
  if(flag13 and flag34 and flag24) {ans=true;}//cout<<3<<endl;}
  if(flag13 and flag12 and flag34) {ans=true;}//cout<<4<<endl;}
  
  if(flag23 and flag12 and flag34) {ans=true;}//cout<<5<<endl;}
  if(flag23 and flag13 and flag24) {ans=true;}//cout<<6<<endl;}
  
  if(flag14 and flag12 and flag34) {ans=true;}//cout<<7<<endl;}
  if(flag14 and flag13 and flag24) {ans=true;}//cout<<8<<endl;}
  
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
  return 0;
  
}


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

#define MAX 500000
#define numMAX 1000000000

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int count=0;

int main()
{
  int n,i,S[MAX];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&S[i]);
    }

  mergeSort(S,0,n);

  for(i = 0 ; i < n ; i++)
    {
      printf("%d",S[i]);
      if(i < n-1) printf(" ");
    }

  printf("\n%d\n",count);

  return 0;
}

void merge(int A[],int left,int mid,int right)
{
  int n1,n2,L[mid - left + 1],R[right - mid + 1],i,j,k,lc=0,rc=0;

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0 ; i < n1 ; i++)
    {
      L[i] = A[left + i];
      lc++;  /* leftの要素のカウント */
    }
  
  for(i = 0 ; i < n2 ; i++)
    {
      R[i] = A[mid + i];
      rc++;  /* rightの要素のカウント */
    }

  L[n1] = INFINITY;
  R[n2] = INFINITY;

  i = 0;
  j = 0;

  for(k = left ; k < right ; k++)
    {
      
      count++;
      
      if(L[i] <= R[j])
	{
	  lc--;
	  A[k] = L[i];
	  L[i] = numMAX;  /* 比べ終わったら最大値を代入 */
	  if(lc > 0) i++;  /* leftがまだあるなら */
	}
	    
      else
	{
	  rc--;
	  A[k] = R[j];
	  R[j] = numMAX;  /* 比べ終わったら最大値を代入 */
	  if(rc > 0) j++;  /* rightがまだあるなら */
	}
    }

  return;
}

void mergeSort(int A[],int left,int right)
{
  int mid;

  if(left + 1 < right)
    {
      mid = (left + right) / 2;
      mergeSort(A,left,mid);
      mergeSort(A,mid,right);
      merge(A,left,mid,right);
    }
  return;
}



Measured memory_bytes: 5604
#include <iostream>

using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if (a==b){
        cout<<"Draw";
    }
    else{
        if (a==1){
            cout<<"Alice";
        }
        else if(b==1){
            cout<<"Bob";
        }

         else if(a>b){
            cout<<"Alice";
        }
        else{
            cout<<"Bob";
        }
    }





    return 0;
}


Measured memory_bytes: 256