akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        m: usize,
        ab: [(usize1, usize1); n + m - 1],
    }
    let mut g = vec![vec![]; n];
    let mut indeg = vec![0; n];
    for (a, b) in ab {
        g[a].push(b);
        indeg[b] += 1;
    }
    let mut que = VecDeque::new();
    for i in 0..n {
        if indeg[i] == 0 {
            que.push_back(i);
        }
    }
    let mut par = vec![None; n];
    while let Some(v) = que.pop_front() {
        // Find v's children
        for &w in &g[v] {
            indeg[w] -= 1;
            if indeg[w] == 0 {
                par[w] = Some(v);
                que.push_back(w);
            }
        }
    }
    for i in 0..n {
        let val = match par[i] {
            None => 0,
            Some(k) => k + 1,
        };
        puts!("{}\n", val);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 19324
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;
struct M {
  int n,m;
  vector<vector<int>> a;
  M(int _n,int _m) : n(_n),m(_m) {
    a.resize(n,vector<int>(m));
  }
  M operator*(const M& b) {
    auto c = M(n,b.m);
    for(int i=0;i<n;i++)
    for(int j=0;j<b.m;j++)
    for(int k=0;k<m;k++) {
      c.a[i][j] += a[i][k]*b.a[k][j];
      c.a[i][j] %= mod;
    }
    return c;
  }
};
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n,k;
  cin >> n >> k;
  M a(n,n);
  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      cin >> a.a[j][i];
      // if i do: cin >> a.a[i][j] then this also works
      // because the answer is aggregated in the end.
      // But is that correct in case case of asking individually?.
      // I don't think so.
    }
  }
  auto res = M(n,n);
  for(int i=0;i<n;i++) res.a[i][i] = 1;
  while(k) {
    if (k%2) {
      res = res * a;
    }
    a = a * a;
    k /= 2;
  }
  auto unitM = M(n,1);
  for(int i=0;i<n;i++) unitM.a[i][0] = 1;
  auto ans = res * unitM;
  int fans = 0;
  for(int i=0;i<n;i++) fans = (fans + ans.a[i][0])%mod;
  cout << fans << '\n';
  return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin>>n;
  ll total1 = 0;
  vector<ll> v1;
  rep(i,0,n){
    ll a;
    cin>>a;
    v1.pb(a);
    total1 += a;
  }
  ll total2 = 0;
  vector<ll> v2;
  rep(i,0,n){
    ll a;
    cin>>a;
    v2.pb(a);
    total2 += a;
  }
  if(total1<total2){
    cout << -1 << endl;
    return 0;
  }
  ll flag = 1;
  rep(i,0,v1.sz){
    if(v1[i]<v2[i])flag = 0;
  }
  if(flag==1){
    cout << 0 << endl;
    return 0;
  }
  ll d = total1-total2;
  ll c0 = 0;
  ll c1 = 0;
  vector<ll> v3;
  rep(i,0,v1.sz){
    if(v1[i]==v2[i])c0++;
    else if(v1[i]<v2[i])c1+=v2[i]-v1[i];
    else v3.pb(v1[i]-v2[i]);
  }
  sort(all(v3));
  reverse(all(v3));
  ll index = 0;
  while(1){
    c1-=v3[index];
    if(c1<=0)break;
    index++;
  }
  cout << n-c0-(v3.sz-(index+1)) << endl;
  return 0;
}

Measured memory_bytes: 2804
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var DTS = GetInput_long();

            var moveEnable = DTS[1] * DTS[2];
            if (moveEnable >= DTS[0])
            {
                Console.WriteLine("Yes");
            }else Console.WriteLine("No");
        }
        
        #region input


        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion
        
    }
}

Measured memory_bytes: 27480
fn input_one<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn main() {
    let n: usize = input_one().unwrap();
    let s: String = input_one().unwrap();
    if n % 2 == 1 {
        println!("No");
    } else if s.chars().take(n / 2).zip(s.chars().skip(n / 2)).any(|(a, b)| a != b) {
        println!("No");
    } else {
        println!("Yes")
    }
}


Measured memory_bytes: 2096
#include<stdio.h>

int main(void)
{
	int x,n,i,j,k,count;

	while (1)
	{
		scanf("%d %d", &n, &x);

		if (n + x == 0) break;
		count = 0;
		for (i = 1; i <= n-2; i++)
		{
			for (j = i + 1; j <= n-1; j++)
			{
				for (k = j + 1; k <= n; k++)
				{
					if (i + j + k == x)
					{
						count++;
					}
				}
			}
		}

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

	return 0;
}


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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

const std::string YES = "YES";
const std::string Yes = "Yes";
const std::string NO = "NO";
const std::string No = "No";

bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }

// 4近傍（右, 下, 左, 上）
const std::vector<int> dy = { 0, -1, 0, 1 };
const std::vector<int> dx = { 1, 0, -1, 0 };

using namespace std;


int solve(int N, int W, const vector<int> &v, const vector<int> &w) {
    // dp[i][j] = i番目までみたとき、重さjで達成できる価値の最大値
    vector<vector<int>> dp(N + 1, vector<int>(W + 1, -1));
    dp[0][0] = 0;
    FOR(i, 0, N) {
        int value = v[i];
        int weight = w[i];

        FOR(j, 0, dp[0].size()) {
            if (dp[i][j] == -1) { continue; }

            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

            if (j + weight <= W) {
                dp[i + 1][j + weight] = max(dp[i + 1][j + weight], dp[i][j] + value);
            }
        }
    }

    int ans = 0;
    FOR(j, 0, dp[0].size()) {
        ans = max(ans, dp[N][j]);
    }

    return ans;
}


vector<vector<int>> memo;
int dfs(int i, int W, const vector<int> &v, const vector<int> &w) {
    if (i >= v.size()) {
        return 0;
    }

    if (memo[i][W] != -1) {
        return memo[i][W];
    }

    int value = v[i];
    int weight = w[i];

    // not use
    int ans = dfs(i + 1, W, v, w);

    // use
    if (W >= weight) {
        ans = max(ans, dfs(i + 1, W - weight, v, w) + value);
    }

    return memo[i][W] = ans;
}


int main() {
    int N , W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    FOR(i, 0, N) {
        cin >> v[i] >> w[i];
    }

//    memo.resize(N + 1, vector<int>(W + 1, -1));
//    cout << dfs(0, W, v, w) << endl;
    cout << solve(N, W, v, w) << endl;

    return 0;
}


Measured memory_bytes: 6828
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int r, g, b, n; cin >> r >> g >> b >> n;
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      int k = n-r*i-g*j;

      if (k < 0 or k % b != 0) continue;
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
mod = 10**9+7
def inv(x):
        return pow(x, mod-2, mod)
def fact(x):
        f = 1 
        for i in range(1, x + 1): 
                f *= i
                f %= mod    
        return f
def comb(n, r): 
        return (fact(n) * inv(fact(n-r)) * inv(fact(r))) % mod 
if (x + y) % 3 != 0:
  print(0)
else:
  n = (x + y) // 3
  if n > x or n > y:
    print(0)
  else:
    nx = x - n
    print(comb(n, nx))
  

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

long long MOD = 1000000007;

int main() {
  long long N, M;
  scanf("%lld %lld", &N, &M);
  if (llabs(N - M) > 1) {
    printf("0\n");
    return 0;
  }
  
  long long ret = 1;
  if (N == M) ret = 2;
  for (long long i = 1; i <= N; i++) {
    ret = (ret * i) % MOD;
  }
  for (long long i = 1; i <= M; i++) {
    ret = (ret * i) % MOD;
  }
  
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 100020
#define M 17
using namespace std;

int n, a[N];
int f[M][N];

int MaxRMQ(int l, int r)
{
    int t;

    t = 31 - __builtin_clz(r - l + 1);

    return max(f[t][l], f[t][r - (1 << t) + 1]);
}

int BSFindL(int x, int v)
{
    int l, m, r;

    for(l = -1, r = x + 1; l + 1 < r; )
    {
        m = (l + r) >> 1;
        if(MaxRMQ(m, x) > v)
            l = m;
        else
            r = m;
    }

    return l;
}

int BSFindR(int x, int v)
{
    int l, m, r;

    for(l = x - 1, r = n; l + 1 < r; )
    {
        m = (l + r) >> 1;
        if(MaxRMQ(x, m) > v)
            r = m;
        else
            l = m;
    }

    return r;
}

int main(void)
{
    int i, j, x;
    long long o;

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
    {
        scanf("%d", &a[i]);
        a[i] --;
        f[0][i] = a[i];
    }
    for(i = 1; i < M; i ++)
        for(j = 0; j + (1 << i) - 1 < n; j ++)
            f[i][j] = max(f[i - 1][j], f[i - 1][j + (1 << (i - 1))]);

    // while(1){int l,r;cin>>l>>r;cout<<MaxRMQ(l,r)<<endl;}

    for(i = o = 0; i < n; i ++)
    {
        x = BSFindL(i, a[i]);
        // printf("at %d : left %d\n", i, x);
        if(x != -1)
        {
            // printf("getleft %d\n", (x - BSFindL(x - 1, a[i])) * (BSFindR(i, a[i]) - i));
            o += (long long)(a[i] + 1) * (x - BSFindL(x - 1, a[i])) * (BSFindR(i, a[i]) - i);
        }
        x = BSFindR(i, a[i]);
        // printf("at %d : right %d\n", i, x);
        if(x != n)
        {
            // printf("getright %d\n", (BSFindR(x + 1, a[i]) - x) * (i - BSFindL(i, a[i])));
            o += (long long)(a[i] + 1) * (BSFindR(x + 1, a[i]) - x) * (i - BSFindL(i, a[i]));
        }
    }
    printf("%lld\n", o);

    return 0;
}


Measured memory_bytes: 6912
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
ll z = 1000000007 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b){if(b == 0) return 1 ; ll c = power(a , b/2) ; if(b%2 == 0) return ((c*c)%z) ; else return ((((c*c)%z)*a)%z) ;}
ll inverse(ll a ,ll n){return power(a , n-2) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;

string maze[20] ;
ll n , m ;

ll is_valid(ll x , ll y)
{
	if(x >= 0 && x < n)
	{
		if(y >= 0 && y < m)
			return 1 ;
	}
	return 0;
}

ll BFS(ll x , ll y)
{
    if(maze[x][y] != '.')
        return 0 ;
	string str[n] ;
	fo(i , n)
	{
		str[i] = maze[i] ;
	}
	
	ll val[n][m] , vis[n][m];
	fo(i , n)
	{
		fo(j , m)
		{
			val[i][j] = 0 ;
			vis[i][j] = 0 ;
		}
	}
	
	queue <pair<ll ,ll> > q ;
	q.push(mp(x , y)) ;
	vis[x][y] = 1 ;
	ll addx[4] , addy[4] ;
	addx[0] = 1 , addx[1] = -1 , addx[2] = addx[3] = 0 ;
	addy[0] = addy[1] = 0 ;
	addy[2] = -1 , addy[3] = 1 ;
	
	while(!q.empty())
	{
		pair<ll , ll> g = q.front() ;
		q.pop() ;
		ll curr_x = g.first ;
		ll curr_y = g.second ;
		
		fo(i , 4)
		{
			if(is_valid(curr_x + addx[i] , curr_y + addy[i]) && vis[curr_x + addx[i]][curr_y + addy[i]] == 0 && str[curr_x + addx[i]][curr_y + addy[i]] == '.')
			{
				vis[curr_x + addx[i]][curr_y + addy[i]] = 1 ;
				val[curr_x + addx[i]][curr_y + addy[i]] = val[curr_x][curr_y] + 1 ;
				q.push(mp(curr_x + addx[i] , curr_y + addy[i])) ;
			}
		}
	}
	
	ll curr_ans = 0 ;
	fo(i , n)
	{
		fo(j , m)
		{
			curr_ans = max(curr_ans , val[i][j]) ;
		}
	}
	
	return curr_ans ;
}

int main()
{
	
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	
	cin >> n >> m ;
	fo(i , n)
	{
		cin >> maze[i] ;
	}
	ll ans = 0 ;
	fo(i , n)
	{
		fo(j , m)
		{
			ans = max(ans , BFS(i , j)) ;
		}
	}
	cout << ans << endl ;
	return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include<stdbool.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define swap(a,b) {ll tp=a;a=b;b=tp;}
const ll MOD = 1000000007;

int main(){
    int n; scanf("%d", &n);
    int A[100];
    rep(i,n) scanf("%d", A+i);

    ll ans=1000,st=0;
    int up = (A[0]<A[1]?1:0);
    if(up){
        st=1000/A[0];
        ans-=A[0]*st;
    }
    rep(i,n-2){
        if(up){
            if(A[i+1] <= A[i+2]){
            }else{
                up=0;
                ans+=st*(ll)A[i+1];
                st=0;
            }
        }else{
            if(A[i+1] >= A[i+2]){
            }else{
                up=1;
                st=ans/A[i+1];
                ans-=A[i+1]*st;
            }
        }
    }
    if(st){
        ans+=st*A[n-1];
    }
    printf("%lld",ans);
}


Measured memory_bytes: 1708
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
int n,d,a,siz=1;
P p[800010];
int dat[800010],laz[800010];
void init(int x){
    while(siz<x)siz*=2;
    for(int i=0;i<n;i++)dat[i+siz-1]=p[i].se;
    for(int i=siz-2;i>=0;i--)dat[i]=dat[i*2+1]+dat[i*2+2];
}
void eval(int k,int l,int r){
    dat[k]+=laz[k];
    if(r-l>1){
        laz[k*2+1]+=laz[k]/2;
        laz[k*2+2]+=laz[k]/2;
    }
    laz[k]=0;
}
void update(int a,int b,int x,int k=0,int l=0,int r=-1){
    if(r==-1)r=siz;
    eval(k,l,r);
    if(r<=a||b<=l)return;
    if(a<=l&&r<=b){
        laz[k]=(r-l)*x;
        eval(k,l,r);
        return;
    }
    update(a,b,x,k*2+1,l,(l+r)/2);
    update(a,b,x,k*2+2,(l+r)/2,r);
}
int query(int a,int k=0,int l=0,int r=-1){
    if(r==-1)r=siz;
    eval(k,l,r);
    if(r-l==1)return dat[k];
    if(a<(l+r)/2)return query(a,k*2+1,l,(l+r)/2);
    return query(a,k*2+2,(l+r)/2,r);
}
signed main(){
    cin>>n>>d>>a;
    rep(i,n){
        cin>>p[i].fi>>p[i].se;
        p[i].se=(p[i].se-1)/a+1;
    }
    sort(p,p+n);
    int h[200010];
    rep(i,n)h[i]=p[i].fi;
    init(n);
    int ans=0;
    rep(i,n){
        int q=query(i);
        if(q>0){
            ans+=q;
            update(i,upper_bound(h,h+n,h[i]+d+d)-h,-q);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 13696
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

VV<ll> edges;
ll N;
map<PLL, ll> color;
ll max_color;

void dfs(ll cur, ll pre = -1, ll pre_c = -1) {
    ll cidx = 1;
    for(ll nxt : edges[cur]) {
        if(nxt == pre) continue;
        if(pre_c == cidx) cidx++;
        color[PLL(min(cur, nxt), max(cur, nxt))] = cidx;
        dfs(nxt, cur, cidx);
        cidx++;
    }
}

int main() {
    cin >> N;
    edges.resize(N);
    V<PLL> tedges(N - 1);
    for(ll i = 1; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        if(a > b) swap(a, b);
        edges[a].push_back(b);
        edges[b].push_back(a);
        tedges[i - 1] = PLL(a, b);
    }

    V<ll> digs(N);
    for(ll i = 0; i < N; i++) digs[i] = edges[i].size();
    ll node = distance(digs.begin(), max_element(ALL(digs)));
    max_color = edges[node].size();
    dfs(node);
    cout << max_color << endl;
    for(auto &&ele : tedges) cout << color[ele] << endl;
    return 0;
}


Measured memory_bytes: 15872
#include <stdio.h>
#define SQ(x) ((x) * (x))
 
typedef struct{
    double x;
    double y;
    double r;
} CIRCLE;
 
int main(void)
{
    CIRCLE a, b;
    int n;
     
    scanf("%d", &n);
     
    while (n-- != 0){
        scanf("%lf%lf%lf%lf%lf%lf", &a.x, &a.y, &a.r, &b.x, &b.y, &b.r);
         
        if (SQ(a.x - b.x) + SQ(a.y - b.y) > SQ(a.r + b.r)){
            printf("0\n");
        }
         
        else if (SQ(a.r + b.r) > SQ(a.x - b.x) + SQ(a.y - b.y) && SQ(a.x - b.x) + SQ(a.y - b.y) > SQ(a.r - b.r)){
            printf("1\n");
        }
         
        else if (SQ(a.x - b.x) + SQ(a.y - b.y) < SQ(a.r - b.r)){
            if (a.r > b.r){
                printf("2\n");
            }
            else {
                printf("-2\n");
            }
        }
        else {
            printf("1\n");
        }
    }
     
    return (0);
}

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

using namespace std;

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

	int answer = 0;
	answer += (a - 1);
	if (b >= a) {
		answer++;
	}

	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using i64 = int64_t;
using u64 = uint64_t;
using f64 = double;
using f80 = __float80;

int main(){
  ll a, b, cnt = 0;
  cin >> a >> b;
  for(; a<=b; a++){
    string tmp = to_string(a);
    ll flag = 1;
    for(ll i=0; i<tmp.size(); i++){
      if(tmp[i] != tmp[tmp.size()-1-i]){
        flag = 0;
        break;
      }
    }
    if(flag == 1)cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int X = in.nextInt();
		int num = X / 100;
		int r = X % 100;
		int count = 0;
		count += r / 5;
		r %= 5;
		count += r / 4;
		r %= 4;
		count += r / 3;
		r %= 3;
		count += r / 2;
		r %= 2;
		count += r / 1;
		System.out.println(count <= num ? 1 : 0);
		in.close();
	}
}

Measured memory_bytes: 23764
a = int(input()) + 1
b = int(input()) + 1
c = int(input()) + 1
x = int(input())
ans = 0

for i in range(a):
    for j in range(b):
        for k in range(c):
            if i*500 + j*100 + k*50 == x:
                ans += 1

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>

// typedef struct{
//         long aa;
//         long bb;
//     }s;
//     int cmp( const void *p, const void *q ) {
//         return ((s*)p)->bb - ((s*)q)->bb;
//     }
long factorial(long a){
    return a=1?a:a*factorial(a-1);
}

int main(void){
    long n,i,j;
    double l=0,al;
    scanf("%ld",&n);
    double x[n],y[n];
    for(i=0;i<n;i++){
        scanf("%lf%lf",&x[i],&y[i]);
    }
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            l+= 2 * sqrt( pow(x[i]-x[j],2) + pow(y[i]-y[j],2) );
        }
    }
    al=l/factorial(n);


    printf("%.10f\n",al);
    return 0;
}


Measured memory_bytes: 256
def xor_from_zero(to):
    fr = 0
    to_copy = to
    b = 2 ** (len(format(to, 'b'))-1)
    while b > 2:
        if to_copy // b > 0:
            fr += b
            to_copy -= b

        b = b // 2

    res = 0
    for a in range(fr, to+1):
        res = res ^ a

    return res

A, B = map(int, input().split())
print(xor_from_zero(A-1)^xor_from_zero(B))

Measured memory_bytes: 9140
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m,i,j,k,a[220],b[220],c[220],h[220],max=0,d[220][110]={0};
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=0;i<m;i++)scanf("%d %d %d",&b[i],&c[i],&h[i]);
  for(i=0;i<m;i++){
    if(b[i]<=a[0]&&a[0]<=c[i])d[0][h[i]]=1;//printf("%d ",d[0][i]);
  }
  for(i=1;i<n;i++){
    for(j=0;j<=100;j++){
      if(d[i-1][j]==0)continue;
      for(k=0;k<m;k++){
	if(b[k]<=a[i]&&a[i]<=c[k])d[i][h[k]]=MAX(d[i][h[k]],d[i-1][j]+abs(j-h[k]));
      }
    }
  }
  /*for(i=0;i<n;i++){
    for(j=0;j<=100;j++)printf("%d ",d[i][j]);printf("\n");
    }*/
  for(i=0;i<=100;i++)max=MAX(max,d[n-1][i]);
  printf("%d\n",max-1);
  return 0;
}

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



vector<vector<int>>adjlist;
vector<int>dp;
int Lpath(int node){
    //cout<<node<<"\n";
    if(dp[node]!=-1){
        return dp[node];
    }

    int sz = adjlist[node].size();
    int mx = 0;
    for(int i=0;i<sz;i++){
        int u = adjlist[node][i];
        mx = max(mx,Lpath(u)+1);
    }
    //cout<<"dpnode: "<<node<<" "<<dp[node]<<"\n";
    return dp[node] = mx;
}
void solve(){
    int v,e;cin>>v>>e;
    adjlist.resize(v);
    dp.resize(v,-1);
    for(int i=0;i<e;i++){
        int a,b;cin>>a>>b;
        adjlist[a-1].push_back(b-1);
    }
    int mx=0;
    for(int i=0;i<v;i++){
        mx = max(mx, Lpath(i));
    }

    cout<<mx<<"\n";
}

int main(){
//    cin.tie(0);
//    cout.tie(0);
//    cin.sync_with_stdio(0);
//    cout.sync_with_stdio(0);


    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 8192
let rec take n = function
  | [] -> []
  | x :: xs ->
      if n = 0 then []
      else x :: take (n - 1) xs

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init (1 lsl n) @@ fun _ ->
    Scanf.scanf "%d " @@ fun a -> a in
  let dp = Array.init (1 lsl n) (fun i -> [i]) in
  for i = 0 to n - 1 do
    for j = 0 to (1 lsl n) - 1 do
      if 0 < j land (1 lsl i) then
        dp.(j) <-
          take 2 @@
          List.sort (fun i j -> compare as_.(j) as_.(i)) @@
          List.sort_uniq compare @@
          dp.(j) @ dp.(j lxor (1 lsl i))
    done
  done;
  let a = Array.map (fun is ->
    List.fold_left ( + ) 0 @@
    List.map (Array.get as_) is) dp in
  for i = 1 to (1 lsl n) - 1 do
    a.(i) <- max a.(i) a.(i - 1);
    Printf.printf "%d\n" a.(i)
  done


Measured memory_bytes: 42432
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, C = [int(x) for x in input().split()]
    if A == B and B != C:
        print("Yes")
        return
    if C == B and B != A:
        print("Yes")
        return
    if C == A and B != C:
        print("Yes")
        return
    print("No")




if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include <iostream>
#include <string>
//#include <algorithm>

#include <stdio.h>
using namespace std;

struct Card {
	char suit, value;
};

void swap(Card &a, Card &b) {
    Card tmp = b;
    b = a;
    a = tmp;
}

void print(Card C[], int N) {
	for (int i = 0; i < N; i++) {
		if (i != 0) cout << " ";
		cout << C[i].suit << C[i].value;
	}
}

bool compare(Card C1[], Card C2[], int N) {
	bool isSame = true;
	for (int i = 0; i < N; i++) {
		if (C1[i].suit != C2[i].suit || C1[i].value != C2[i].value) {
			isSame = false;
			return isSame;
		}
	}
	return isSame;
}

int bubbleSort(Card C[], int N) {
    int sw = 0;
    bool flag = true;
    int i = 0;
    while (flag) {
        flag = false;
        for (int j = N - 1; j > i; j--) {
            if (C[j].value < C[j - 1].value) {
                flag = true;
                swap(C[j], C[j - 1]);
                sw++;
            }
        }
		i++;
    }

    return sw;
}

int selectionSort(Card C[], int N) {
    int sw = 0;
    int i = 0;
	for (int i = 0; i < N - 1; i++) {
		int minj = i;
		for (int j = i + 1; j < N; j++) {
			if (C[j].value < C[minj].value)
				minj = j;
		}
		if (minj != i) {
			swap(C[i], C[minj]);
			sw++;
		}
	}
    return sw;
}

int main(void) {
	int N;
    int sw;
	Card C1[100], C2[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C1[i].suit >> C1[i].value;
		C2[i].suit = C1[i].suit;
		C2[i].value = C1[i].value;
	}
    sw = bubbleSort(C1, N);
    sw = selectionSort(C2, N);

	print(C1, N);
	cout << endl;
	cout << "Stable" << endl;
	print(C2, N);
	cout << endl;

	if (compare(C1, C2, N))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int cntm=1e9;
    for(int i=0;i<s.length();i++)
    {
        if(i+t.length()>s.length())
            break;
        int cnt=0;
        for(int j=0;j<t.length();j++)
        {
            if(s[j+i]!=t[j])
                cnt++;
        }
        cntm=min(cntm,cnt);
    }
   cout<<cntm;
}

Measured memory_bytes: 3628
k = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(k[K - 1])

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 1, inf = 1000111222;

bool check(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3, ll s) {
    if (x1 < 0 || x1 > 1000000000) return 0;
    if (y1 < 0 || y1 > 1000000000) return 0;
    if (x2 < 0 || x2 > 1000000000) return 0;
    if (y2 < 0 || y2 > 1000000000) return 0;
    if (x3 < 0 || x3 > 1000000000) return 0;
    if (y3 < 0 || y3 > 1000000000) return 0;
    return (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1) == s;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    ll s;
    cin >> s;
    ll x1, x2, x3, y1, y2, y3;
    x1 = y1 = 0;
    y2 = 1;
    ll sq = sqrtl(s) + 5;
    while (sq * sq > s) {
        --sq;
    }
    if (sq * sq == s) {
        x2 = sq;
        y3 = sq;
        x3 = 0;
    } else {
        ++sq;
        x2 = sq;
        y3 = sq;
        x3 = sq * sq - s;
    }
    if (!check(x1, y1, x2, y2, x3, y3, s)) {
        exit(228);
    } else {
        cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> A(n, 0);
  vector<ll> B(m, 0);
  rep(i, n) cin >> A.at(i);
  rep(i, m) cin >> B.at(i);
  vector<ll> culsumA(n+1, 0);
  vector<ll> culsumB(m+1, 0);
  reps(i, 1, n+1) culsumA.at(i) = culsumA.at(i-1) + A.at(i-1);
  reps(i, 1, m+1) culsumB.at(i) = culsumB.at(i-1) + B.at(i-1);
  int j = 0;
  while(j <= m && culsumB.at(j) <= k) j++;
  j--;
  int ans = 0;
  for(int i = 0; i < n+1; i++) {
    while(j > 0 && culsumB.at(j) + culsumA.at(i) > k) j--;
    if (culsumB.at(j) + culsumA.at(i) <= k) {
      ans = max(ans, j+i);
    }
  }
  cout << ans << endl;
  
  
  return 0;
}

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for (int i = 0; i < M; i++) cin >> A.at(i);

  int front_cnt = 0;
  int back_cnt = 0;
  for (int i = 0; i < M; i++) {
    if (A.at(i) < X)
      front_cnt++;
    else
      back_cnt++;
  }

  cout << min(front_cnt, back_cnt) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 510;
int n,m,q, sum[maxn][maxn], A[maxn][maxn];

int main()
{
    while (cin >> n >> m >> q) {
        FOR(i,0,maxn) FOR(j,0,maxn) {
            sum[i][j] = A[i][j] = 0;    
        }
        FOR(_,0,m) {
            int a,b; cin >> a >> b;
            FOR(j,b,n+1)
                A[j][a]++;
        }
        FOR(i,0,n+1) FOR(j,1,n+1) {
            sum[i][j] = sum[i][j-1] + A[i][j];
        }
        FOR(_,0,q) {
            int a,b; cin >> a >> b;
            const int x = sum[b][b];
            const int y = sum[b][a-1];
            const int ans = x-y;
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2944
def moving(delta_x,delta_y):
    go_1="U"*delta_y+"R"*delta_x
    back_1="D"*delta_y+"L"*delta_x
    go_2="L"+"U"*(delta_y+1)+"R"*(delta_x+1)+"D"
    back_2="R"+"D"*(delta_y+1)+"L"*(delta_x+1)+"U"
    return(go_1+back_1+go_2+back_2)

sx,sy,tx,ty=map(int,input().split(" "))
delta_x=tx-sx
delta_y=ty-sy
print(moving(delta_x,delta_y))


Measured memory_bytes: 3060
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    ll a, b, k;

    cin >> a >> b >> k;
    ll temp = a;
    a = a - k;
    if (a < 0) a = 0;

    ll rem = k - temp;
    if (rem > 0) b = b - rem;

    if (b < 0) b = 0;
    cout << a << " " << b << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char s;
	scanf("%s",&s);
	if(s=='S'){
		printf("Cloudy\n");
	}
	else if(s=='C'){
		printf("Rainy\n");
	}
	else{
		printf("Sunny\n");
	}
	return 0;
}


Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def ki(p):
    return (p + 1) / 2

def main():
    N, K = LI()
    p = LI()
    p = [ki(x) for x in p]
    cursum = sum(p[:K])
    ans = cursum
    i = K
    for i in range(K, N):
        cursum -= p[i-K]
        cursum += p[i]
        ans = max(cursum, ans)
    print(ans)
main()


Measured memory_bytes: 26820
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<vector<int>> abc(n,vector<int>(3));
    rep(i,n){
        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    }
    vector<vector<int>> dp(n + 1,vector<int>(3,-1));
    dp[0][0] = abc[0][0];
    dp[0][1] = abc[0][1];
    dp[0][2] = abc[0][2];
    rep(i,n-1){
        rep(j,3){
            if(dp[i][j]<0)
                continue;
            dp[i + 1][j] = max(dp[i][(j + 1) % 3] + abc[i+1][j], dp[i][(j + 2) % 3] + abc[i+1][j]);        
        }
    }
    int ans = 0;
    rep(i,3){
        ans = max(ans, dp[n - 1][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <array>
using namespace std;
int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C, K;
	int result;
	cin >> A >> B >> C >> K;
	if (K <= A)
		cout << K;
	else if (K <= A + B)
		cout << A;
	else
		cout << A + A + B - K;

	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#define llint long long

using namespace std;

llint N;
llint C;
llint D[35][35];
llint c[505][505];
llint num[3][35];

int main(void)
{
	cin >> N >> C;
	for(int i = 1; i <= C; i++){
		for(int j = 1; j <= C; j++){
			cin >> D[i][j];
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin >> c[i][j];
		}
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			num[(i+j)%3][c[i][j]]++;
		}
	}
	
	llint ans = 1e18;
	for(int i = 1; i <= C; i++){
		for(int j = 1; j <= C; j++){
			if(i == j) continue;
			for(int k = 1; k <= C; k++){
				if(i == k || j == k) continue;
				
				llint tmp = 0;
				for(int l = 1; l <= C; l++){
					tmp += num[0][l] * D[l][i];
					tmp += num[1][l] * D[l][j];
					tmp += num[2][l] * D[l][k];
				}
				ans = min(ans, tmp);
				
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>

using namespace std;

int solve(int l,int r,vector<int> c){
    int res=0;
    for(int i=l;i<=r;i++){
        if(c[i])res++;
    }
    return res;
}

int max(int x,int y){
    if(x > y)return y;
    else return x;
}

int main(void){
    int n,m,x,c1,c2;
    cin >> n >> m >> x;
    vector<int> cost(n+1,0);
    vector<int> a(m);
    for(int i=0;i<m;i++){
        cin >> a[i];
        cost[a[i]] = 1;
    }
    c1 = solve(x,n,cost);
    c2 = solve(0,x,cost);
    cout << min(c1,c2) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
s=deque(input())
n=int(input())
r=0
for i in range(n):
    strlist=input()
    if strlist[0]=='1':
        r+=1
    elif strlist[0]=='2' and strlist[2] == '1':
        if r%2==0:
            s.appendleft(strlist[4])
        else:
            s.append(strlist[4])
    elif strlist[0]=='2' and strlist[2] =='2':
        if r%2==0:
            s.append(strlist[4])
        else:
            s.appendleft(strlist[4])
if r%2==0:
    for s_ in s:
        print(s_, end='')
else:
    s.reverse()
    for s_ in s:
        print(s_, end='')

Measured memory_bytes: 93784
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef long double ld;


//template<class T>
//inline bool chmax(T &a, T b) {
//    if (a < b) {
//        a = b;
//        return true;
//    }
//    return false;
//}

ll inf = 10000000;
ll mod = 1000000007;

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    cout << min(N * A, B) << endl;
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  string a, b;
  cin >> a >> b;

  int n = stoi(a + b);
  cout << ((int)sqrt(n) * (int)sqrt(n) == n ? "Yes" : "No") << endl;
}


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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<int>cnt(H);
    vector<vector<int>>s(H, vector<int>(W, 0));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char c;
            cin >> c;
            if(c == '#') {
                s[i][j] = 1;
                cnt[i]++;
            }
        }
    }

    int start = 0;
    while (cnt[start] == 0) start++;
    int cur = 1;
    vector<vector<int>>ans(H, vector<int>(W, 0));
    int state = 0;
    for (int j = 0; j < W; ++j) {
        if(s[start][j]){
            if(state == 0) {
                state++;
            } else {
                cur++;
            }
        }
        ans[start][j] = cur;
    }
    cur++;

    // 上
    for (int i = 0; i < start; ++i) {
        for (int j = 0; j < W; ++j) {
            ans[i][j] = ans[start][j];
        }
    }

    // 下
    for (int i = start+1; i < H; ++i) {
        if(cnt[i] == 0){
            for (int j = 0; j < W; ++j) {
                ans[i][j] = ans[i-1][j];
            }
        } else {
            state = 0;
            for (int j = 0; j < W; ++j) {
                if(s[i][j]){
                    if(state == 0) {
                        state++;
                    } else {
                        cur++;
                    }
                }
                ans[i][j] = cur;
            }
            cur++;
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }
    return 0;
}

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



int main() {
    long int n;
    cin >> n;
    
    vector<pair<long int, int>> s;
    for(long int i = 2; i*i <= n; i++) {
        int cnt = 0;
        while(n % i == 0) {
            n /= i;
            cnt++;
        }
        if(cnt != 0)
            s.emplace_back(i,cnt);
    }
    
    int ans = 0;
    if(n != 1)
        ans++;
    
    rep(i,s.size()) {
        int e = 1;
        while(s[i].second - e >= 0) {
            //cout << s[i].first << s[i].second << endl;
            s[i].second -= e;
            e++;
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    ll N;
    ll i,j;
    ll max=0;
    ll now=0;

    cin >> N;
    vector<ll> H(N);

    for(i=0;i<N;i++)
    {
        ll temp;
        cin >> temp;
        H[i] = temp;
    }

    i=0;
    while(i < N)
    {
        now=0;
        for(j=i+1;j<N;j++)
        {
            if(H[j-1] >= H[j])
            {
                now++;
            }
            else
            {
                break;
            }
        }
        if(now > max)
        {
            max=now;
        }

        i=j;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 1024