akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
  //cin>>t;
  int tt=1;
  while(t--){
    int x,a;
    cin>>x>>a;
    if(x<a)
      cout<<0;
    else cout<<10;
    
    }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int x;
    cin >> x;
    ll n = 0;
    rep(i, x)
    {
        n += i + 1;
        if (n >= x)
        {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
    long long n,x,t;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    x = a[0];
    t=0;
    for(int i=1;i<n;i++){
        if(x>a[i])
            t += (x-a[i]);
        x = max(x,a[i]);
    }
    cout<<t<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  ll ans = 0;
  for (int i = 0; i < (1 << (s.size() - 1)); i++) {
    string n;
    ll sum = 0;
    for (int j = 0; j < s.size(); ++j) {
      n += s[j];
      if (j >= s.size() - 1) {
        sum += stoll(n);
        n = "";
      } else if (i & (1 << j)) {
        sum += stoll(n);
        n = "";
      }
    }

    ans += sum;
  }

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

Measured memory_bytes: 3644
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;

namespace Queue
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var limit = ReadLine().Split(' ').Select(int.Parse).ToList();
            var queue = new Queue<Process>(limit[0]);
            
            for (var i = 0; i < limit[0]; i++)
            {
                var read = ReadLine().Split(' ');
                var process = new Process(read[0], int.Parse(read[1]));
                queue.Enqueue(process);
            }

            var sw=new StreamWriter(OpenStandardOutput()){AutoFlush = false};
            SetOut(sw);
            var time = 0;
            while (!queue.IsEmpty())
            {
                var q = queue.Dequeue();
                var t = q.time;
                if (q.Run(limit[1]))
                {
                    time += limit[1];
                    queue.Enqueue(q);
                }
                else
                {
                    time += t;
                    WriteLine(q.name + " " + time);
                }
            }
            Out.Flush();
        }
        
        
    }

    public class Process
    {
        public string name { get; private set; }
        public int time { get; private set; }

        public Process(string name, int time)
        {
            this.name = name;
            this.time = time;
        }

        public bool Run(int q)
        {
            time -= q;
            return time > 0;
        }
    }

    public class Queue<T>
    {
        private readonly T[] process;
        private int head, tail;

        public Queue(int max)
        {
            process = new T[max+1];
            head = tail = 0;
        }

        public void Enqueue(T val)
        {
            process[tail] = val;
            if (tail + 1 >= process.Length)
                tail = 0;
            else
                tail++;
        }

        public T Dequeue()
        {
            var x = process[head];
            if (head + 1 == process.Length)
                head = 0;
            else
                head++;
            return x;
        }

        public bool IsEmpty()
        {
            return head == tail;
        }

    }
}


Measured memory_bytes: 21876
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, k, beforFood, count, ans int
	allFood := []int{}
	fmt.Scanf("%d %d", &n, &m)
	for i := 0; i < n; i++ {
		fmt.Scan(&k)
		foods := make([]int, k)
		for j := 0; j < k; j++ {
			fmt.Scan(&foods[j])
		}
		allFood = append(allFood, foods...)
	}
	if n == 1 {
		fmt.Println(len(allFood))
		return
	}
	sort.Sort(sort.IntSlice(allFood))
	for _, food := range allFood {
		if beforFood == food {
			count++
			if count == n {
				ans++
			}
		} else {
			count = 1
		}
		beforFood = food
	}
	fmt.Println(ans)
}

Measured memory_bytes: 640
let rec q()=Scanf.scanf"%d %d
"(fun m d->if m<>0&&d<>0then(let rec($)i z=if i>m-2then z else(i+1)$((z+[|31;29;31;30;31;30;31;31;30;31;30;31|].(i))mod 7)in q(print_endline([|"Mon";"Tues";"Wednes";"Thurs";"Fri";"Satur";"Sun"|].((d+(0$2))mod 7)^"day"))));;q()

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

using namespace std;

int n, k;

map <int, bool> mp;

bool check (int n) {

	while (n > 0) {
		int k = n % 10;
		if (mp[k] == false) return false;
		n /= 10;
	}
	return true;
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> n >> k;
	for (int i = 0; i < 10; i ++) mp[i] = true;
	for (int i = 0; i < k; i ++) {
		int x;
		cin >> x;
		mp[x] = false;
	}
	for (int i = n; ; i ++) {
		if (check(i)) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
// see https://github.com/LumaKernel/vimfiles/tree/master/snippets/cp-cpp/temp.snip
const bool DEBUG = 1;
/// --- .lumrc Template {{{ ///
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = tuple<ll, ll>;
using P3 = tuple<ll, ll, ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VP = vector<P>;
using VS = vector<string>;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define FORI(i,a,b) for(int i=int(a);i<=int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPI(i,n) FORI(i,0,n)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define RFORI(i,a,b) for(int i=int(b);i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)
#define RREPI(i,n) RFORI(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end())
#define PB push_back
#define EACH(i,c) REP(i,(c).size())
#define REACH(i,c) RREP(i,(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

#define BR cout<<"\n";

#define dump(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)<<"\n";
#define dump2(x,y) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n";
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<<"] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)\
<<" , "<<#z<<"="<<(z)<<"\n";

#define SAY(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<(x)<<"\n";

#define YES(x) cout<<((x)?"YES":"NO")<<"\n";
#define Yes(x) cout<<((x)?"Yes":"No")<<"\n";
#define yes(x) cout<<((x)?"yes":"no")<<"\n";

inline int omajinai_int_in(){omajinai;int n;cin>>n;return n;}
inline ll omajinai_ll_in(){omajinai;ll n;cin>>n;return n;}
inline string omajinai_string_in(){omajinai;string n;cin>>n;return n;}
inline int int_in(){int n;cin>>n;return n;}
inline ll ll_in(){ll n;cin>>n;return n;}
inline string string_in(){string n;cin>>n;return n;}
#define oini omajinai_int_in()
#define oinl omajinai_ll_in()
#define oins omajinai_string_in()
#define ini int_in()
#define inl ll_in()
#define ins string_in()

#define isInside(y,x) (0<=(y)&&(y)<h&&0<=(x)&&(x)<w)

#define fi(x) (get<0>(x))
#define se(x) (get<1>(x))
#define th(x) (get<2>(x))
#define fo(x) (get<3>(x))
#define fif(x) (get<4>(x))

template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; EACH(i, v) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }

template <typename T> inline void smax(T &a, T b) { a = a > b ? a : b; }
template <typename T> inline void smin(T &a, T b) { a = a < b ? a : b; }

/// }}}--- ///

constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr int MOD = 1e9+7;

ll ans;

int main() {
  int n=ini;
  VI a;
  REP(i,n)a.PB(ini);
  SORT(a);UNIQUE(a);
  cout << a.size() << endl;
}

//


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

int main() {
    int a , b , c , x ,y;
    cin >> a >> b >> c >> x >> y;
    
    int ans;
    ans = x * a + y * b;
    ans = min(2 * c *max(x, y), ans);
    if (x >= y) {
        ans = min(ans, 2 * c * y + a * (x - y));
    }
    else {
        ans = min(ans, 2 * c * x + b * (y - x));
    }

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

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

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

  bool yes = (a == b && a != c) || (b == c && b != a) || (c == a && c != b);

  if (yes)
    puts("Yes");
  else
    puts("No");
}

Measured memory_bytes: 256
n = int(input())
a = list(map(lambda x: int(x)-1, input()))

cnt = [0]
for i in range(1,n+1):
    x = 0
    while i%2==0:
        x += 1
        i //=2
    cnt.append(cnt[-1]+x)

def comb(k):
    left = cnt[n-1]
    right = cnt[k]+cnt[n-1-k]
    return left-right == 0

f = 1 in a
if f:
    a = [int(i==1) for i in a]
else:
    a = [int(i==2) for i in a]

ans = 0
for i in range(n):
    if comb(i):
        ans += a[i]

ans %= 2
if not f:
    ans *= 2

print(ans)

Measured memory_bytes: 133924
function Main(input) {
    input = input.split("\n");
    const [n, k] = input[0].split(" ").map(s => Number(s));
    const str = input[1];
    console.log(str.slice(0, k - 1) + str[k - 1].toLowerCase() + str.slice(k, n));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>
#include <string.h>
int main (){
	char code[10+1];
	scanf ("%s", &code);
	int len = strlen(code);
	char akhir[len+1] = {0};
	int j = 0;
	for (int i = 0; i < len; i++){
		if (code[i] == '0'){
			akhir[j] = '0';
			j++;
		} else if (code [i] == '1'){
			akhir[j] = '1';
			j++;
		}
		if (code[i] == 'B'){
			if (j != 0){
				j--;
				akhir[j] = '\0';
			}
		}
	} 
printf ("%s\n", akhir);
return 0;
}

Measured memory_bytes: 1604
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    ll ans = 0;
    rep(i,n){
        cin >> a[i];
        if(i!=0) a[i] += a[i-1];
        if(a[i] <= k) ans = max(ans,i+1);
    }
    rep(i,m){
        cin >> b[i];
        if(i!=0) b[i] += b[i-1];
        if(b[i] <= k) ans = max(ans,i+1);
    }
    ll cnt = 0;

    rep(i,n){
        ll tmp = a[i];
        ll left = -1;
        ll right = m;
        if(tmp + b[m-1] <= k){
            ans = max(ans, i+m+1);
            continue;
        }
        if(tmp + b[0] > k){
            continue;
        }
        while(right - left > 1){
            ll mid = (right + left)/2;
            if(tmp + b[mid] > k){
                right = mid;
                continue;
            }
            else{
                left = mid;
                continue;
            }
        }

        ans = max(ans, i+right+1);

    }

    cout << ans << endl;

    
}

Measured memory_bytes: 6380
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << "Christmas ";
    for (int i = 25; i > n; i--) cout << "Eve ";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 10000000000000
#define vll vector<ll>
using namespace std;
const int N=100005;
ll ans,k;
vector<ll>adj[N];
void dfs(ll r,ll par,ll d)
{	
	ll dep,sz;
	dep=min(2LL,d);
	sz=k-dep;
	for(auto it:adj[r])
		if(it!=par)
		{
			ans=(ans*sz--)%mod;
			dfs(it,r,d+1);
		}
}
void solve()
{
	ll n,i,u,v;
	cin>>n>>k;
	for(i=1;i<n;i++)
	{
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}	
	ans=k;
	dfs(1,0,1);
	cout<<ans;
	
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 11648
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    input!(n: usize, abc: [(i64, i64, i64); n]);

    let mut dp = vec![vec![0i64; 3]; n + 10];
    for next in 1..n + 1 {
        for i in 0..3 {
            for j in 0..3 {
                if i == j {
                    continue;
                }
                let value = match j {
                    0 => abc[next - 1].0,
                    1 => abc[next - 1].1,
                    _ => abc[next - 1].2,
                };
                dp[next][i] = max(dp[next][i], dp[next - 1][j] + value);
            }
        }
    }

    let ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
    println!("{}", ans);
}


Measured memory_bytes: 14588
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    n,k = map(int, input().split())

    print(k*(k-1)**(n-1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 65432
M = 10**9+7
import sys
input = sys.stdin.readline

from decimal import *   #通常の割り算が正確に計算できるのは4*10**16までらしい。float型のため

N,K = map(int, input().split())
A = list(map(int, input().split()))
A_ = sorted(A, reverse = True)
ans = 0
ans_ = 0
for i in range(0,N-1):
        for j in range(i+1,N):
            if A[i] > A[j]:
                ans += 1
            if A_[i] > A_[j]:
                ans_ += 1

print(((int(Decimal(K*(K-1)) / Decimal(2))%M)*ans_+ans*K)%M)

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

int main(){
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d)cout<<"Yes"<<endl;
    else      cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

const double PI = 3.14159265359;

int main() {
  int r;
  cin >> r;
  cout << setprecision(3) << fixed << 2 * PI * r << endl;
  return 0;
}

Measured memory_bytes: 3208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
  string s;
  cin >> s;
  int n = (int)s.size();
  bool ok = false;
  rep(i,n-1)repr(j,i+1,n){
      if(s[i] == 'C' && s[j] == 'F')ok = true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define   Y            imag()
#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=509;
int ans[N][N];
void solve(vector<int> &v,int lv)
{
    if(sz(v)==1)
        return ;

    vector<int> a1,a2;
    for(int i=0;i<sz(v);i+=2)
    {
        a1.pb(v[i]);
        for(int j=1;j<sz(v);j+=2)
        {

            ans[v[i]][v[j]]=lv;
            ans[v[j]][v[i]]=lv;
        }
    }
    for(int j=1;j<sz(v);j+=2)
    {
         a2.pb(v[j]);
    }
    solve(a1,lv+1);
    solve(a2,lv+1);
}
int main()
{
    int n;
    cin>>n;
    vector<int> v;
    for(int i=1;i<=n;i++)
    {
        v.pb(i);
    }
    solve(v,1);
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}

































Measured memory_bytes: 1536
#include<stdio.h>
#include<algorithm>
using namespace std;
char in[2];
pair<int,int> rng[110000];
int n;
pair<int,int> d[3100];
int calc(int st,int go){
	int ret=1;
	int now=st;
	for(int i=0;i<3*n;i++){
		if(d[i].second<=now)continue;
		if(d[i].first>=go)break;
		ret++;
		now=d[i].first;
	}
	return ret;
}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	n=a;
	for(int i=0;i<a;i++){
		int x,y;
		scanf("%d%d%s",&x,&y,in);
		y=c-y;
		int X1,X2,Y1,Y2;
		if(in[0]=='E'){
			X1=x+y;
			X2=x+(c-y);
			Y1=0;
			Y2=c;
			if(X1>b){
				Y1+=X1-b;
				X1=b;
			}
			if(X2>b){
				Y2-=X2-b;
				X2=b;
			}
		}
		if(in[0]=='W'){
			X1=x-y;
			X2=x-(c-y);
			Y1=0;
			Y2=c;
			if(X1<0){
				Y1+=-X1;
				X1=0;
			}
			if(X2<0){
				Y2-=-X2;
				X2=0;
			}
			swap(X1,X2);
			swap(Y1,Y2);
		}	
		if(in[0]=='N'){
			X1=0;
			X2=b;
			Y1=y-x;
			Y2=y-(b-x);
			if(Y1<0){
				X1+=-Y1;
				Y1=0;
			}
			if(Y2<0){
				X2-=-Y2;
				Y2=0;
			}
		}
		if(in[0]=='S'){
			X1=0;
			X2=b;
			 Y1=y+x;
			 Y2=y+(b-x);
			if(Y1>c){
				X1+=Y1-c;
				Y1=c;
			}
			if(Y2>c){
				X2-=Y2-c;
				Y2=c;
			}
			swap(X1,X2);
			swap(Y1,Y2);
		}
		int z1,z2;
		if(Y1==0)z1=X1;
		else if(X1==b)z1=b+Y1;
		else if(Y1==c)z1=b+c+b-X1;
		else z1=b+c+b+c-Y1;
		if(Y2==0)z2=X2;
		else if(X2==b)z2=b+Y2;
		else if(Y2==c)z2=b+c+b-X2;
		else z2=b+c+b+c-Y2;
		rng[i]=make_pair(z1,z2);
	//	printf("%d %d, %d %d\n",X1,Y1,X2,Y2);
	}
	int ret=99999999;
	for(int i=0;i<a;i++){
		if(rng[i].first>rng[i].second)rng[i].second+=b*2+c*2;
	}
	for(int i=0;i<a;i++){
		d[i*3]=make_pair(rng[i].second,rng[i].first);
		d[i*3+1]=make_pair(rng[i].second+b*2+c*2,rng[i].first+b*2+c*2);
		d[i*3+2]=make_pair(rng[i].second+b*4+c*4,rng[i].first+b*4+c*4);
		
	}
	std::sort(d,d+a*3);
	for(int i=0;i<a;i++){
		ret=min(ret,calc(rng[i].first,rng[i].first+b*2+c*2));
		ret=min(ret,calc(rng[i].second,rng[i].second+b*2+c*2));
	}
	printf("%d\n",ret);
}

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

int main(){
	long long N;
	scanf("%lld",&N);
	vector<long long> h(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&h[i]);
	}
	long long res = 0;
	while(true) {
		long long l = -1, r = -1;
		bool flg = false;
		for (long long i = 0; i < N; i++) {
			if (h[i] != 0 && l == -1) {
				l = i;
			}
			if (h[i] == 0 && l != -1 && r == -1) {
				r = i;
				break;
			}
			if (i == N-1 && l != -1 && r == -1) {
				r = N;
				break;
			}
			if (i == N-1 && l == -1) {
				flg = true;
				break;
			}
		}
		if (flg) break;
		for (int i = l; i < r; i++) {
			h[i]--;
			//printf("%lld\n", h[i]);
		}
		res++;
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
map<string,int> vis;
set<string> s;
set<string>::iterator it;
string str;
int maxx;
int main()
{
    int n,m;
    scanf("%d",&n);
    while(n--)
    {
        cin>>str;
        s.insert(str);
        vis[str]++;
    }
    scanf("%d",&m);
    while(m--)
    {
        cin>>str;
        vis[str]--;
    }
    for(it=s.begin();it!=s.end();it++)
    {
        maxx=max(maxx,vis[*it]);
    }
    printf("%d\n",maxx);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
 
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;
const int INF = 1e9 + 5;
signed main() {
    FAST_IO;
 
    int n,k;
    cin>>n>>k;
    int jumps[n];
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) cin >> jumps[i];
    for (int i = 0; i < n; i++){
        for(int j=i+1;j<=i+k;j++){
            if(j<n)
                dp[j] = min(dp[j], dp[i]+ abs(jumps[j]-jumps[i]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 4016
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

D, G = map(int, input().split())
P = [] * D
C = [] * D
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

ans = float('inf')
for i in range(1<<D):
    total = 0
    num = 0
    for j in range(D):
        if ((i >> j) & 1):
            total += C[j] + 100*P[j]*(j+1)
            num += P[j]

    if total >= G:
        ans = min(ans, num)
    else:
        for j in range(D-1, -1, -1):
            if ((i >> j) & 1):
                continue

            for k in range(P[j]-1):
                if total >= G:
                    break
                total += 100*(j+1)
                num += 1

        if total >= G:
            ans = min(ans, num)

print(ans)

Measured memory_bytes: 3316
#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(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    int res = a*x+b*y;

    int z = 0;
    while((x>=1) or(y>=1)){
        z++;
        if(x>0) x--;
        if(y>0) y--;

        res = min(a*x+b*y+2*c*z,res);
    }

    cout << res << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int n;
	while (cin>>n) {
		if (!n) break;
		vector<int> dp(n+3,0);
		dp[0] = 1;
		for (auto i = 0; i < n; i++)
			for (auto j = 1; j <= 3; j++)
				dp[i+j] += dp[i];
		int day = dp[n]/10+!!(dp[n]%10),
		    year = day/365+!!(day%365);
		cout << year << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;

int main(void){
    long n, neg_num, ans;

    cin >> n;

    vector<long> a(n), b(n);


    neg_num = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        b[i] = abs(a[i]);
        if(a[i] < 0)    neg_num++;
    }

    ans = 0;
    if(neg_num % 2){
        sort(b.begin(), b.end());
        b[0] = -1 * b[0];
        for(int i = 0;i < n;i++)    ans += b[i];
        cout << ans << endl;

    }else{
        for(int i = 0;i < n;i++)    ans += b[i];
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 1792
n,k=[int(j) for j in input().split()]
a=[int(j) for j in input().split()]
s=sum(a)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
l=make_divisors(s)
ans=1
from itertools import accumulate
for i in l[::-1]:
    ll=[]
    for j in a:
        ll.append(j%i)
    ll.sort()
    if sum(ll[:n-sum(ll)//i])<=k:
        print(i)
        exit()




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int inf = 1e9 + 5;
const int nax = 1e6 + 5;

int t[nax];

int main() {
	int n;
	scanf("%d", &n);
	RI(i, n) scanf("%d", &t[i]);
	int ans = 0;
	RI(i, n) ans += t[t[i]] == i;
	printf("%d\n", ans / 2);
	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, s: "List[int]", c: "List[int]"):
    if(pow(10,N-1)==1):x=0
    else:x=pow(10,N-1)
    for i in range(x,pow(10,N)):    
        f=True
        for j in range(M):
            if not(str(i)[s[j]-1]==str(c[j])):f=False
            if(not f):break
        if(f):
            print(i)
            return
    print(-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>                                                             
using namespace std;
                       
static const int MAX_N = 200010;
int n;                 
int a[MAX_N];          
int b[MAX_N];          
                       
void solve(){          
  cin >> n;            
  for(int i = 1; i <= n; i++) cin >> a[i];
  int end, start;   
  if(n % 2 == 0){ end = 2; start = 1; }
  else { end = 1; start = 2; }
  int j = 0;           
  for(int i = n; i >= end; i-=2)
    b[j++] = a[i];  
  for(int i = start; i <= n-1; i+=2)
    b[j++] = a[i];  
  cout << b[0];        
  for(int i = 1; i < n; i++)
    cout << ' ' << b[i];
  cout << endl;
}          
           
int main(){
  solve(); 
  return 0;
}   

Measured memory_bytes: 3712
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func norm2(x, y float64) float64 {
	return x*x + y*y
}

func main() {
	scanner.Split(bufio.ScanWords)

	p1x, _ := nextFloat64()
	p1y, _ := nextFloat64()
	p2x, _ := nextFloat64()
	p2y, _ := nextFloat64()

	intercept := 0.0
	if p1x == p2x {
		intercept = 0
	} else {
		intercept = (p2x*p1y - p1x*p2y) / (p2x - p1x)
	}
	p1y -= intercept
	p2y -= intercept

	norm2 := norm2(p1x-p2x, p1y-p2y)

	nQueries := nextInt()
	for i := 0; i < nQueries; i++ {
		p3x, _ := nextFloat64()
		p3y, _ := nextFloat64()
		p3y -= intercept

		dot := (p2x-p1x)*p3x + (p2y-p1y)*p3y
		// fmt.Println(dot, norm2)
		cx := dot * (p2x - p1x) / norm2
		cy := dot*(p2y-p1y)/norm2 + intercept
		fmt.Println(2*cx-p3x, 2*cy-(p3y+intercept))
	}
}



Measured memory_bytes: 1168
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <tuple>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};

//other
//--------------------------------------------
#define RANGE(a, c, b) ((a <= b) && (b < c))

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int solve(string snake){
	if(snake[0] != '>') return 0;
	if(snake[1] == '\''){
		int i = 2;
		while(snake[i] == '='){
			i++;
		}
		if(snake[i] != '#') return 0;
		int length = i - 2;
		i++;
		while(snake[i] == '='){
			i++;
		}
		int length2 = i -3 - length;
		if(length2 != length) return 0;
		if(length > 0 &&
			snake[i] == '~' && 
			i == snake.length() - 1){
			return 1;
		}
	}else if(snake[1] == '^'){
		int i = 2;
		int length = 0;
		while(snake[i] =='Q' &&
			snake[i + 1] == '='){
			i += 2;
			length++;
		}
		if(length > 0 &&
			snake[i] == '~' &&
			snake[i + 1] == '~' &&
			i + 1 == snake.length() - 1){
			return 2;
		}
	}
	return 0;
}

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	REP(i, n){
		string snake;
		cin >> snake;
		string ans;
		switch(solve(snake)){
			case 0:
			ans = "NA";
			break;

			case 1:
			ans = "A";
			break;

			case 2:
			ans = "B";
			break;
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    vector<int> A(N), B(N);
    rep(n, N) {
        int b = 0;
        for (int i = 0, j, k; i < (int)S[n].size(); i = k) {
            for (j = i; j < (int)S[n].size(); ++j) {
                if (S[n][j] == ')') break;
            }
            for (k = j; k < (int)S[n].size(); ++k) {
                if (S[n][k] == '(') break;
            }

            int x = j - i, y = k - j;
            if (x < y) {
                if (b < y - x) {
                    A[n] += y - x - b;
                    b = 0;
                }
                else {
                    b -= y - x;
                }
            }
            else {
                b += x - y;
            }
        }
        B[n] = b;
    }

    bool allA = true, allB = true, allAB = true;
    rep(i, N) {
        if (A[i] == 0 && B[i] == 0) continue;
        if (A[i] == 0) allA = false;
        if (B[i] == 0) allB = false;
        allAB = false;
    }

    bool ans = true;
    if ((allA || allB) && !allAB) ans = false;
    else {
        vector<int> C, D;
        rep(i, N) {
            if (A[i] < B[i]) C.push_back(i);
            else D.push_back(i);
        }
        sort(all(C), [&](int l, int r) { return A[l] < A[r]; });
        sort(all(D), [&](int l, int r) { return B[l] < B[r]; });

        int L = 0, R = 0;
        rep(i, C.size()) {
            if (A[C[i]] > L) ans = false;
            L += B[C[i]] - A[C[i]];
        }
        rep(i, D.size()) {
            if (B[D[i]] > R) ans = false;
            R += A[D[i]] - B[D[i]];
        }

        if (L != R) ans = false;
    }

    write(ans ? "Yes" : "No");
}

Measured memory_bytes: 46424
use proconio::{input, marker::Usize1};

fn main() {
    input!(n: usize, m: usize, ab: [(Usize1, Usize1); m]);
    let mut g = vec![vec![]; n];
    ab.iter().for_each(|&(a, b)| g[a].push(b));

    let mut min_reachable = vec![vec![None; n]; n];
    let mut max_reachable = vec![vec![None; n]; n];
    for a in 0..n {
        fn search(i: usize, a: usize, ckd: &mut [Option<usize>], g: &[Vec<usize>]) {
            let c = g[a][i];
            if ckd[c].is_some() {
                return;
            }
            let mut que = std::collections::VecDeque::from(vec![c]);
            ckd[c] = Some(i);
            while let Some(x) = que.pop_front() {
                for y in g[x].iter().copied().filter(|&y| y != a) {
                    if ckd[y].is_some() {
                        continue;
                    }
                    ckd[y] = Some(i);
                    que.push_back(y);
                }
            }
        }
        for i in 0..g[a].len() {
            search(i, a, &mut min_reachable[a], &g);
        }
        for i in (0..g[a].len()).rev() {
            search(i, a, &mut max_reachable[a], &g);
        }
    }

    for (a, b) in ab {
        let a_to_b = min_reachable[a][b] != max_reachable[a][b];
        let b_to_a = min_reachable[b][a].is_some();
        println!("{}", if a_to_b == b_to_a { "same" } else { "diff" });
    }
}


Measured memory_bytes: 41112
a,b,c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
while(1):
    c-=b
    if(c<=0):
        print("Yes")
        break
    a-=d
    if(a<=0):
        print("No")
        break


Measured memory_bytes: 9184
a = gets.to_i
s = gets.chomp

if a % 2 != 0
  puts 'No'
else
  num = a / 2
  s1 = s.slice(0..(num-1))
  s2 = s.slice(num..s.length)
  if s1 == s2
    puts 'Yes'
  else
    puts 'No'
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    string S;
    cin >> S;
    ll n = S.size();
    vll mod(n+1, 0);
    vll powm(0);
    powm.emplace_back(1);
    for(int i=1; i<200001; i++){
        powm.emplace_back((powm[i-1]*10)%2019);
    }
    
    mod[1] = S[n-1]-'0';
    for(int i=1; i<n; i++){
        int k = S[n-1-i] - '0';
        mod[i+1] = (mod[i] + k*powm[i])%2019;
    }

    vll h(2020, 0);
    for(int i=0; i<n+1; i++){
        h[mod[i]]++;
    }
    ll ans = 0;
    for(int i=0; i<2019; i++){
        ans += (h[i]*(h[i]-1))/2;
    }
    cout << ans;
}

Measured memory_bytes: 7016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	if ((a == b && a != c) || (a == c && a != b) || (b == c && b != a))
	{
		cout<<"Yes"<<'\n';
	}
	else
	{
		cout<<"No"<<'\n';
	}
	return 0;
}

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

int		main(void)
{
	int		a, b;	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0)
		cout << "Possible" << endl;
	else
		cout << ((a + b) % 3 == 0 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
n, m, l = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(m)]

C = []
for i in range(n):
    line = []
    for j in range(l):
        c = 0
        for k in range(m):
            c += A[i][k]*B[k][j]
        line.append(c)
    C.append(line)
    
for line in C:
    print(*line)



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

int main() {
  int n,m;
  cin >> n >> m;
  int a,b;
  int c[m];
  for(int i = 0;i < m;i++){
    c[i] = 0;
  }
  for(int i = 0;i < n;i++){
    cin >> a;
    for(int j = 0;j < a;j++){
      cin >> b;
      c[b-1] += 1;
    }

  }
  int k = 0;
  for(int i = 0;i < m;i++){
    if(c[i] == n){
      k++;
    }
  }
  cout << k << endl;
}


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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int a[N];
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int cnt =0;
    int ans =0;
    for(int i=1;i<n;i++){
        if(a[i]<=a[i-1]){
            cnt++;
        }else{
            cnt=0;
        }
        ans=max(cnt,ans);
    }
    // ans=max(ans,cnt);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
vector<int> G[100010];
ll a[100010],b[100010],l[100010],u[100010],inf = 10000000000000000,ans = inf;
string s;
ll dfs(int v, int p){
	ll mx = -1,mn = inf;
	b[v] = a[v];
	if(G[v].size()==1 && p!=-1){
		l[v] = 0; u[v] = 0;
		return l[v]/2;
	}
	for(int x:G[v]){
		if(x==p) continue;
		dfs(x,v);
		l[v] += l[x] + b[x];
		b[v] += b[x];
		if(mx<l[x] + b[x]){
			if(mx==l[x] + b[x]){
				mn = min(u[x] + b[x],mn);
			}else{
				mn = u[x] + b[x];
			}
			mx = l[x] + b[x];
		}
	}
	ll sum = l[v] - mx;
	if(l[v]&1){
		if(mn>sum) mn--;
		else sum--;
		u[v] = max(1LL,mn - sum + 1);
	}else{
		u[v] = max(0LL,mn - sum);
	}
	return l[v]/2;
}

int main(){
	int i,j,n;
	cin >> n >> s;
	for(i=0;i<n;i++){
		a[i] = s[i] - '0';
	}
	for(i=0;i<n-1;i++){
		int u,v;
		cin >> u >> v; u--; v--;
		G[u].push_back(v); G[v].push_back(u);
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			b[j] = 0; l[j] = 0; u[j] = 0;
		}
		ll num = dfs(i,-1);
		if(u[i]==0){
			ans = min(ans,num);
		}
	}
	if(ans!=inf){
		cout << ans << endl;
	}else{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 3968
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a_arr = readLine()!!.split(" ").map { it.toInt() }
    val b_arr = readLine()!!.split(" ").map { it.toInt() }
    val c_arr = readLine()!!.split(" ").map { it.toInt() }
    var ans = b_arr.sum()
    for(i in 0 until (n-1)) {
        if(a_arr[i] + 1 == a_arr[i+1]) {
            ans += c_arr[a_arr[i]-1]
        }
    }
    println(ans)
}

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
    ll N;
    cin>>N;
    vector<ll> f(N+1,1);
    f[1]=1;
    ll max_num = (ll)sqrt(N+1);
    ll n;
    ll d;
    rep(i,N-2){
        n=i+2;
        if(f[n]!=1) continue;
        d = 1;
        while(n<=N){
            rep(j,N/n){
                f[n*(j+1)] = f[n*(j+1)]/d*(d+1);
            }
            n*=(i+2);
            ++d;
        }
    }

    
    ll ans = 1;
    rep(i,N-1){
        ans += (i+2)*max((ll)2,f[i+2]); // 素数の処理
        // cout<<f[i+2]<<"\n";
    }
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 81348
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self, n):
        fact, invfact = [1] * (n + 1), [1] * (n + 1)
        for i in range(1, n + 1): fact[i] = i * fact[i - 1] % MOD
        invfact[n] = pow(fact[n], MOD - 2, MOD)
        for i in range(n - 1, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % MOD
        self._fact, self._invfact = fact, invfact

    def fact(self, n):
        return self._fact[n]

    def invfact(self, n):
        return self._invfact[n]

    def comb(self, n, k):
        return self._fact[n] * self._invfact[k] % MOD * self._invfact[n - k] % MOD if 0 <= k <= n else 0

    def perm(self, n, k):
        return self._fact[n] * self._invfact[n - k] % MOD if 0 <= k <= n else 0

def resolve():
    k = int(input())
    n = len(input())
    mf = modfact(n + k)
    ans = 0
    for i in range(n, n + k + 1):
        ans += mf.comb(n + k, i) * pow(25, n + k - i, MOD)
        ans %= MOD
    print(ans)
resolve()

Measured memory_bytes: 103428
#include<bits/stdc++.h>
using namespace std;
int f[310][310][310],kk,ans,l;
char s[1000];
int main(){
	scanf("%s",s);scanf("%d",&kk);;l=strlen(s);
	memset(f,10,sizeof(f));for (int i=0;i<=l+5;i++){
		memset(f[i][0],0,sizeof(f[i][0]));memset(f[i][1],0,sizeof(f[i][1]));
	}for (int j=2;j<=l;j++)
		for (int i=1;i+j-1<=l;i++)
			for (int k=0;k<=kk;k++){
				if (k)f[i][j][k]=f[i+1][j-2][k-1];
				if (s[i-1]!=s[i+j-2]){
					if (k)f[i][j][k]=min(f[i][j][k],f[i+1][j-2][k-1]);
				}else f[i][j][k]=min(f[i][j][k],f[i+1][j-2][k]);
				f[i][j][k]=min(f[i][j][k],min(f[i][j-1][k],f[i+1][j-1][k])+1);
			}
	printf("%d\n",l-f[1][l][kk]);
}


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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n;

int main() {
    fast_io;

    cin >> n;
    if (n % 2 == 1) return cout << 0 << endl, 0;

    ll ans = n / 10;
    for (ll i = 1; i <= 25; i++) {
        ans += n / (poww(5, i, INF) * 10);
    }
    cout << ans << endl;

    return 0;
}
/*

*/


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

int main(){
    ll H, W;
    cin >> H >> W;

    if ( (H == 1) || (W == 1) ){
        cout << 1 << endl;
    }else{
        if ( (H % 2 == 1) && (W % 2 == 1) ){
            ll ans = W * H + 1;
            ans = ans / 2;
            cout << ans << endl;
        }else{
            ll ans = W * H;
            ans = ans / 2;
            cout << ans << endl;
        }
    }

    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string ans = "";
            string v1 = Console.ReadLine();
            string v2 = Console.ReadLine();

            if (v1.Length > v2.Length)
            {
                ans = "GREATER";
            }
            else if (v1.Length < v2.Length)
            {
                ans = "LESS";
            }
            else
            {
                for (int i = 0; i < v1.Length; i++)
                {
                    if (v1[i] > v2[i])
                    {
                        ans = "GREATER";
                        break;
                    }
                    else if (v1[i] < v2[i])
                    {
                        ans = "LESS";
                        break;
                    }
                    else
                    {
                        ans = "EQUAL";
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092