akhauriyash/Code-Regression huggingface dataset:
/*
ID: Asif Jawad
LANG: C++
TASK:
*/

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <iterator>
#include <utility>
#include <sstream>

using namespace std;

#define Read(f) freopen(f,"r",stdin)
#define Write(f) freopen(f,"w",stdout)

#define geti(n) scanf("%d",&n)
#define getll(n) scanf("%lld",&n)
#define getf(n) scanf("%lf",&n);

#define pi acos(-1)
#define eps 1e-9
#define mem(a,n) memset(a,n,sizeof a)
#define countbit(x) __builtin_popcountll(x)

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,a,n) for(int i = (a) ;i < n;i++)
#define REP(i,a,n) for(int i = (a); i >= n;i--)

#define pb push_back
#define sz size()
#define mp make_pair
#define all(c) (c).begin(),(c).end()
//#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ( (c).find(x) != (c).end() )
#define cpresent(c,x) ( find(all(c),x) != (c).end() )
#define ff first
#define ss second

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

inline int Set(int N,int pos)
{
    return N = N | (1 << pos);
}
inline int Reset(int N,int pos)
{
    return N = N & ~ (1 <<pos);
}
inline bool check(int N,int pos)
{
    return (bool) (N & (1 << pos) );
}

template<class T>
T gcd(T a,T b)
{
    return (!b) ? a : gcd( b, a%b );
}

template <class T>
T lcm(T a,T b)
{
    return (a / gcd(a,b)) * b;
}

template<class T>
bool is_prime(T n)
{
    if( (n % 2 == 0 && n > 2) || n < 2 )return 0;

    for( T i = 3; i * i <= n ; i = i + 2 )
    {

        if( n % i == 0 )return 0;
    }
    return 1;
}

//template ends here

int main()
{
    //Read(".in");
    //Write(".out");

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

	ll a,b,c;

	cin >> a >> b >> c;

	if(a%2 == 0 || b % 2 == 0 || c % 2 == 0){
		
		cout << 0 << endl;
		return 0;
	}
	else {
		
		if(a > b)swap(a,b);
		if(b > c)swap(b,c);
		if(b < a)swap(a,b);

		cout << a*b << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n < 3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//  ©   ___MRX___

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

#define ll long long int

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

    if(a > 9 || b > 9) {
        cout << -1 << '\n';
    }
    else {
        cout << a * b << '\n';
    }

    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    ll q = n/(a+b);
    ll r = n%(a+b);
    cout<<q*a + min(r,a);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int main(){
    ll a,b;
    long c,d;
    ll numc,numd,numcd;
    ll cd;

    cin >> a >> b >> c >> d;

    // cout << a << b << c << d<< endl;
    ll num = b - a + 1; 

    // cout << num << endl;

    cd = (c * d )/ gcd(c,d);

    // cout << cd << endl;

    numc = b/c - a/c;
    if(a%c==0)numc++;
    numd = b/d - a/d;
    if(a%d==0)numd++;
    numcd = b/cd -a/cd;
    if(a%cd==0)numcd++;

    num =num - numc - numd + numcd;

    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n, a;
    scanf("%d", &n);
    int aa[101];
    for (int i=0; i<n; ++i) {
        scanf("%d", &aa[i]);
    }
    for (int i=n-1; i>=0; --i) {
        printf("%d", aa[i]);
        if (i > 0) {
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2076
#include<stdio.h>
int main()
{
    long long int n,m,s,i;
    while(~scanf("%lld",&n))
    {
        s=1;
        for(i=1; i<=9; i++)
            s=s*10;
        s=s+7;
        m=1;
        for(i=1; i<=n; i++)
        {
            m=m*i;
            m=m%s;
        }
        printf("%lld\n",m);
    }
    return 0;
}


Measured memory_bytes: 128
use std::cmp;

const INF: usize = 1 << 50;
const V: usize = 51;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let b: Vec<usize> = sc.vec(n);
    let mut dp = vec![vec![INF; V]; 1 << n];
    dp[0][0] = 0;

    let mut masks = (0..(1 << n))
        .map(|mask: usize| (mask.count_ones() as usize, mask))
        .collect::<Vec<_>>();
    masks.sort();

    for (pos, cur_mask) in masks.into_iter() {
        for next_add in 0..n {
            if cur_mask & (1 << next_add) != 0 {
                continue;
            }
            let next_mask = cur_mask | (1 << next_add);

            let mut back_used = 0;
            for i in (next_add + 1)..n {
                if cur_mask & (1 << i) != 0 {
                    back_used += 1;
                }
            }
            let cur_pos = next_add + back_used;
            let distance = cur_pos - pos;

            let d = if pos > next_add {
                pos - next_add
            } else {
                next_add - pos
            };
            let card = if d % 2 == 0 { a[next_add] } else { b[next_add] };

            for cur_v in 0..V {
                let c = dp[cur_mask][cur_v];
                if c == INF {
                    continue;
                }
                if card >= cur_v {
                    dp[next_mask][card] = cmp::min(dp[next_mask][card], c + distance);
                }
            }
        }
    }
    let mut ans = INF;
    for i in 0..V {
        ans = cmp::min(ans, dp[(1 << n) - 1][i]);
    }

    if ans >= INF {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 133372
def segfunc(x,y):#自分で設定
    return max(x,y)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

ide_ele = -1 #単位元 自分で設定してね

N , K = map(int,input().split())
n = 300001
num =2**(300000).bit_length() #num:n以上の最小の2のべき乗
seg=[ide_ele]*2*num
a = [int(input()) for i in range(N)]
dp = [0 for i in range(300001)]
init(dp)

for i in range(N):
    now = query(max(0,a[i]-K),min(300001,a[i]+K+1))+1
    update(a[i],now)

print(query(0,300001))

Measured memory_bytes: 136340
def main():
    a, b, c, d, e= map(int,input().split())
    if a == 0:
        print(1)
    elif b == 0:
        print(2)
    elif c == 0:
        print(3)
    elif d == 0:
        print(4)
    else:
        print(5)
    
    




    
if __name__ == "__main__":
    main()


Measured memory_bytes: 61640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int A,N;
  	cin >> N;
  	cin >> A;
  	if( (N % 500) <= A){
      	cout << "Yes" << endl;
    }else{
     	cout << "No" << endl; 
    }
}


Measured memory_bytes: 256
/**
 *      ABC 93 C
 *      author  : kyomukyomupurin
 *      created : 2018/08/29
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B, C; cin >> A >> B >> C;

    vector<int> v{A, B, C};
    /*for (int i = 0; i < 3; ++i) {
        cout << v[i] << endl;
    }*/

    sort(v.begin(), v.end());
    int a = v[2] - v[1]; int b = v[2] - v[0];

    if (a % 2 == 0 && b % 2 == 0){
        cout << a / 2 + b / 2 << endl;
    }
    else if (a % 2 == 1 && b % 2 == 1){
        cout << a / 2 + b / 2 + 1 << endl;
    }
    else {
        cout << a / 2 + b / 2 + 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    int64_t ans;
    for (int i = 0;i < n;i++){
        int64_t t;
        cin >> t;
        if (i == 0){
            ans = t;
            continue;
        }
        ans = lcm(ans, t);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
# C - 白昼夢
S = input()
S2 = S
W_L = ["dream","dreamer","erase","eraser"]
while True:
    cnt = 0
    for w in W_L:
        if S2.endswith(w):
            S2 = S2[:-(len(w))]
            cnt+=1
    if cnt ==0:
        print('NO')
        exit()
            
    if len(S2)<=7:
        break
    
if S2 ==''or S2 in W_L:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3380
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	vector<ll> dp(n,1000000000000000000);
	dp[0] = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			i+j<n?dp[i+j] = min(dp[i+j],dp[i]+abs(arr[i]-arr[i+j])):true;
		}
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int l, r;
	cin >> l >> r;

	int min_rem = INT_MAX;
	for (int i = l; i <= r; ++i) {
		for (int j = i + 1; j <= r; ++j) {
			int curr = ((long long) i * j) % 2019;
			if (curr == 0) {
				cout << "0\n";
				return 0;
			}

			min_rem = min(min_rem, curr);
		}
	}

	cout << min_rem << "\n";

	return 0;

}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc166/tasks/abc166_c

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 1e5;
const int M_MAX = 1e5;
const int H_I_MAX = 1e9;

int N, M;
vector<int> H;
vector<bool> ps;

int main() {
  cin >> N >> M;
  H = vector<int>(N);
  REP(i, N) cin >> H[i];
  ps = vector<bool>(N, true);
  REP(i, M) {
    int A, B;
    cin >> A >> B;
    A--; B--;
    if (H[A] <= H[B]) ps[A] = false;
    if (H[B] <= H[A]) ps[B] = false;
  }

  int ans = 0;
  REP(i, N) if (ps[i]) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 3696
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	cout<<(n/2)*((n+1)/2);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

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

    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];

    int ans=b[a[0]-1];
    int prev = a[0];

    for(int i=1;i<n;i++){
        ans += b[a[i]-1];
        if(a[i]==prev+1){
            ans += c[a[i]-2];
        }
        prev=a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//Contains functions for implementing a disjoint set union
#include<bits/stdc++.h>
using namespace std;
//#define num 1000000007
#define num 998244353
#define inf 1000000000000000000ll
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pi pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) (a>b)?a:b
//#define min(a,b) (a>b)?b:a
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define fir first
#define sec second
#define mod(a) ((a)>0)?(a):(-(a))
 
 
typedef long long ll;
 
ll parent[200005],size[200005];
void init_parent(ll n)
{
    memset(parent,-1,sizeof(parent[0])*n);
}
void make_set(ll v)
{
    parent[v]=v;
    size[v]=1;
}
ll find_set(ll v)
{
    if(parent[v]==v)
    return v;
    return parent[v]=find_set(parent[v]);
}
void union_sets(ll a,ll b)
{
    a=find_set(a);
    b=find_set(b);
    if(size[a]<size[b])
    {
        swap(a,b);
    }
    parent[b]=a;
    size[a]+=size[b];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w,n;
    cin>>h>>w>>n;
    if(h>w)
    {
        cout<<((n%h==0)?(n/h):(n/h)+1);
    }
    else
    {
        cout<<((n%w==0)?(n/w):(n/w)+1);
    }
    return 0; 
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

class UnionFind {
private:
	vector<int> data;

public:
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	lint size(int x) { return -data[root(x)]; }

	void unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
};


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	UnionFind UF(N);
	int X, Y, Z;
	for (int i = 0; i < M; i++){
		cin >> X >> Y >> Z;

		UF.unify(X - 1, Y - 1);

	}

	vector<int> ans;
	for (size_t i = 0; i < N; i++){
		ans.emplace_back(UF.root(i));
	}
	sort(ans.begin(), ans.end());
	ans.erase(unique(ans.begin(), ans.end()), ans.end());

	cout << ans.size() << "\n";

	return 0;
}

Measured memory_bytes: 1276
n = input()
n = int(n)
a= []
for i in range(n):
	city, score = input().split()
	score = int(score)
	a.append((city, score, i+1))
a.sort(key=lambda k : (k[0], -k[1]))
for i in range(n):
	print(a[i][2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.size())if(s[i] != t[i])ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3736
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep0(i,n) for(i=0;i<(n);i++)
#define repn(i,m,n) for(int i=(m);i<=(n);i++)
#define all(n) n.begin(),n.end()
#define mp make_pair
#define PUTLINE cout<<__LINE__<<endl;

const int INF = 2147483647;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,1,-1,-1,0};
const int dy[]={0,0,1,-1,1,-1,1,-1,0};

double dis[1010];
string res[1010];
vector<vint> e(1010);

class Pos{
public:
	int n;
	double d;
	string s;
	bool operator>(Pos pos)const{return d>pos.d;}
};

int main() {
	int n;
	int b,x[1010],y[1010];
	while(n=in()){
		memset(x,-1,sizeof(x));
		memset(y,-1,sizeof(y));
		rep(i,1010)e[i].clear();
		rep(i,n){
			cin>>b;
			cin>>x[b]>>y[b];
		}
		repn(i,1,1000){
			if(x[i]==-1)continue;
			repn(j,1,1000){
				if(x[j]==-1)continue;
				if(i==j)continue;
				if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])<=2500){
					e[i].push_back(j);
				}
			}
		}
		int m=in();
		rep(i,m){
			rep(i,1010)dis[i]=100100100;
			priority_queue<Pos,vector<Pos>,greater<Pos> > que;
			Pos pos;
			pos.n=in();
			pos.d=0;
			stringstream ss;
			ss<<pos.n;
			pos.s=ss.str();
			que.push(pos);
			while(!que.empty()){
				pos=que.top();
				que.pop();
				if(dis[pos.n]<=pos.d)continue;
				dis[pos.n]=pos.d;
				res[pos.n]=pos.s;
				rep(j,e[pos.n].size()){
					Pos next;
					next.n=e[pos.n][j];
					next.d=pos.d+sqrt((double)((x[pos.n]-x[next.n])*(x[pos.n]-x[next.n])+(y[pos.n]-y[next.n])*(y[pos.n]-y[next.n])));
					ss.str("");
					ss<<next.n;
					next.s=pos.s+" "+ss.str();
					que.push(next);
				}
			}
			int g=in();
			if(dis[g]==100100100)cout<<"NA\n";
			else cout<<res[g]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A_Measure
{
    public class Program

    {
        public static void Main(string[] args)
        {
            string line = ReadSt();

            if (line.Length == 2)
            {
                Console.WriteLine(line);
            }
            else
            {
                Console.WriteLine(line[2].ToString() + line[1].ToString() + line[0].ToString());
            }            
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main(){
    int a,i,n,x,t;
    a=1;
    i=1;
    cin>>n;
    int b[n];
    while(i<=n){
        x=n+1-i;
        cin>>t;
        b[x]=t;
        i+=1;
    }
    while(a<=n){
        if (a==n) cout<<b[a];
        else{
        cout<<b[a]<<" "; 
        }
        a+=1;
    }
    cout<<endl;
}


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

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

    int d, n;
    cin >> d >> n;

    if(n==100)++n;

    cout << n;
    rep(i, d) cout << "00";

    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	for(int i = 1; i < 10; ++i) {
		int j = n / i;
		if(j < 10 and i * j == n) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
count=0
for _ in range(n):
    a=list(map(int,input().split()))
    sum=0
    for i in range(m):
        sum+=a[i]*b[i]
    if sum+c>0:
        count+=1
print(count)

Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#define int long long
#define uint unsigned long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
using namespace std;

int sx[100000];
int sy[100000];

int MOD = 1000000007;
int add(int a, int b)
{
	return (a + b) % MOD;
}
int mul(int a, int b)
{
	return (a * b) % MOD;
}

signed main()
{
	int n, m;
	cin >> n >> m;
	n--; //正方形の数にする
	m--; //
	int prev;
	cin >> prev;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		sx[i] = x - prev;
		prev = x;
	}
	cin >> prev;
	for (int i = 0; i < m; i++)
	{
		int y;
		cin >> y;
		sy[i] = y - prev;
		prev = y;
	}

	int sumx = 0;
	int cnt = n;
	for (int i = 0; i < n; i++)
	{
		int s = mul(sx[i], cnt);
		sumx = add(sumx, s);
		cnt -= (i + 1);
		cnt += (n - (i + 1));
	}

	int sumy = 0;
	cnt = m;
	for (int i = 0; i < m; i++)
	{
		int s = mul(sy[i], cnt);
		sumy = add(sumy, s);
		cnt -= (i + 1);
		cnt += (m - (i + 1));
	}

	cout << mul(sumx, sumy) << endl;
}


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

int main()
{

    string s;
    string t;
    cin>>s>>t;

    int n = s.length();
    int x = t.length();
    int a = n+1;
    int flag = 0;
    if(a==x)
    {
        for (int it=0;it<s.length();it++)
        {
            if(s[it]==t[it])
                continue;
            else
                {
                flag=1;
                break;
                }
        }

        if(flag==0)
        {
            cout<<"Yes"<<endl;
        }
        else
            cout<<"No"<<endl;

	}

	else
      cout<<"No";

      return 0;
}



Measured memory_bytes: 3624
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	static char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		char[] input = sc.next().toCharArray();

		HashMap<Character, Integer> map = new HashMap<Character, Integer>();
		for (int i = 0; i < alphabet.length; i++) {
			map.put(alphabet[i], 0);
		}
		for (char i : input) {
			int value = map.get(i);
			map.put(i, ++value);
		}
		for (int i = 0; i < alphabet.length; i++) {
			if (map.get(alphabet[i]) == 0) {
				System.out.println(alphabet[i]);
				return;
			}
		}
		System.out.println("None");
	}
}


Measured memory_bytes: 26880
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,W,K;
  cin >> H >> W >> K;
  vector<string> G(H);
  for(int i=0; i<H; i++) cin >> G[i];
  int sy,sx;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(G[i][j] == 'S'){
        sy = i;
        sx = j;
      }
    }
  }
  queue<P> que;
  que.emplace(sy,sx);
  vector<vector<int>> dist(H,vector<int>(W,-1));
  dist[sy][sx] = 0;
  auto check = [&](int y,int x){
    return min({y,x,H-1-y,W-1-x});
  };
  int mn = inf;
  while(que.size()){
    int y,x;
    tie(y,x) = que.front();
    chmin(mn,check(y,x));
    que.pop();
    if(dist[y][x] == K) continue;
    for(int k=0; k<4; k++){
      int ny = y + dy[k];
      int nx = x + dx[k];
      if(ny<0 || ny>=H || nx<0 || nx>=W) continue;
      if(dist[ny][nx] != -1) continue;
      if(G[ny][nx] == '#') continue;
      dist[ny][nx] = dist[y][x] + 1;
      que.emplace(ny,nx);
    }
  }
  cout << (mn+K-1)/K + 1 << "\n";
  return 0;
}

Measured memory_bytes: 6840
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String S[] = s.split("");
    for(int i = 0;i < s.length();i++){
      if(i%2 == 0){
        System.out.printf("%s",S[i]);
      }
    }
  }
}


Measured memory_bytes: 60804
N=int(input())
A=list(map(int,input().split()))
ABS=sorted(list(map(abs,A)))
x=1
for a in A:
  if a==0:
    print(sum(ABS))
    exit(0)
  if a<0:
    x*=-1
if x==1:
  print(sum(ABS))
else:
  print(sum(ABS)-2*ABS[0])

Measured memory_bytes: 14412
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

struct Rdata {
	int idx, score;
	string city;
	bool operator<(Rdata r) {
		return (city < r.city) | (city == r.city) & (score > r.score);
	}
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	
	Rdata rtmp;
	vector<Rdata> rst;
	for (int i = 0; i < N; i++){
		cin >> rtmp.city >> rtmp.score;
		rtmp.idx = i + 1;
		rst.emplace_back(rtmp);
	}
	sort(rst.begin(), rst.end());

	for (auto& ele : rst) cout << ele.idx << "\n";

	return 0;	
}

Measured memory_bytes: 256
class Work:
    require = 0
    limit = 0
    def __init__(self, require, limit) -> None:
        self.require = require
        self.limit = limit

def from_list(xs) -> Work: 
    return Work(xs[0], xs[1])

N = int(input())

works = [from_list([int(_) for _ in input().split()]) for i in range(N)]

def solve(works):
    works.sort(key=lambda x: x.limit)
    acc = 0
    for w in works:
        acc += w.require
        if acc > w.limit:
            return "No"
    return "Yes"

print(solve(works))

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll x, y;
  cin >> x >> y;

  ll ans = x + (y/2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()

N = S()
hon = {2,4,5,7,9}
pon = {0,1,6,8}
bon = {3}

n = int(N[-1])
if n in hon:
    print("hon")
elif n in pon:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000


int main(void){
    
    int n, m; cin >> n >> m;
    int p[100010];
    for(int i = 0; i < m; i++){
        cin >> p[i];
    }

    int array[100010] = {};
    //テヲツ?堙ァツ崢エ
    /*for(int i = 0; i < m-1; i++){
        if(p[i] < p[i+1]){
            for(int j = p[i]; j < p[i+1]; j++){
                array[j]++;
            }
        }else{
            for(int j = p[i+1]; j < p[i]; j++){
                array[j]++;
            }
        }
    }*/

    //テ」ツつ、テ」ツδ「テ」ツつケテヲツウツ?
    for(int i = 0; i < m-1; i++){
        if(p[i] < p[i + 1]){
            array[p[i]]++;
            array[p[i + 1]]--;
        }else{
            array[p[i + 1]]++;
            array[p[i]]--;
        }
    }

    for(int i = 1; i < n; i++){
        array[i+1] += array[i];
    }
    
    
    long long ans = 0;

    for(int i = 1; i < n; i++){
        long long a, b, c; cin >> a >> b >> c;
        ans += min(a*array[i], c + b*array[i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr int INF=1e9;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, m, x, c[20], a[20][20];
  cin>>n>>m>>x;
  REP(i, n){
    cin>>c[i];
    REP(j, m){
      cin>>a[i][j];
    }
  }
  int ans=INF;
  REP(i, 1<<n){
    int num[20];
    REP(j, m){
      num[j]=0;
    }
    int tmp=0;
    REP(j, n){
      if(i>>j&1){
        tmp+=c[j];
        REP(k, m){
          num[k]+=a[j][k];
        }
      }
    }
    bool ok=true;
    REP(j, m){
      if(num[j]<x){
        ok=false;
        break;
      }
    }
    if(ok){
      CHMIN(ans, tmp);
    }
  }
  cout<<(ans==INF ? -1 : ans)<<'\n';
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for(int &e : H) cin >> e;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        bool ok = true;
        for(int j = 0; j < i; j++) if(H[j] > H[i]) ok = false;
        ans += ok;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long int ll;

set<pair<ll, ll>> point;

vector<pair<ll, ll>> row(300005), col(300005);

bool compare(pair<ll, ll> first, pair<ll, ll> second)
{
    return first.first > second.first;
}

int main(void)
{
    ll H, W, M;
    cin >> H >> W >> M;
    ll maxNum = 0;

    for (ll i = 0; i < M; i++)
    {
        ll a, b;
        cin >> a >> b;
        row[a].first++;
        row[a].second = a;
        col[b].first++;
        col[b].second = b;

        point.insert(make_pair(a, b));
    }

    sort(row.begin(), row.end(), compare);
    sort(col.begin(), col.end(), compare);

    ll tmpR = 0, tmpC = 0;
    for (ll i = 0; i < M; i++)
    {
        if (tmpR > row[i].first)
            break;

        tmpR = row[i].first;

        for (ll j = 0; j < M; j++)
        {
            if (tmpC > col[j].first)
                break;

            tmpC = col[j].first;

            ll total = tmpR + tmpC;
            if (point.find(make_pair(row[i].second, col[j].second)) != point.end())
            {
                total--;
                maxNum = max(maxNum, total);
            }
            else
            {
                cout << total;
                return 0;
            }
        }
    }

    cout << maxNum;
    return 0;
}


Measured memory_bytes: 31432
import numpy as np

s = list(map(int, input().strip()))
s = np.array(s, dtype=np.bool)
len_s = len(s)

p = 0
count = 0

while p < len_s - 1:
    if s[p] != s[p + 1]:
        count += 2
        if p < len_s - 2:
            s[p:-2] = s[p + 2:]
        if p > 0:
            p -= 1
        else:
            p = 0

        len_s -= 2
    else:
        p += 1

print(count)


Measured memory_bytes: 14536
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b;
    cin>>a>>b;
    double aa=a,bb=b;
    cout<<a/b<<" "<<a%b<<" "<<(double)(aa/bb)<<endl;

}


Measured memory_bytes: 3280
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

typedef long long  ll;
const int MAXN = 111111;
ll dp[111][MAXN];
int w[MAXN], v[MAXN];

int main(){
    faster
    int n, W; cin >> n >> W;
    for(int i = 1;i <= n;i++) cin >> w[i] >> v[i];
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= W;j++){
            dp[i][j] = dp[i - 1][j];
            if(j - w[i] >= 0)
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
        }
    }
    ll ans = 0;
    for(int i = 1;i <= W;i++)ans = max(ans, dp[n][i]);
    cout << ans << "\n";
    return 0;
}

    



Measured memory_bytes: 88704
#include <stdio.h>

int
main(void)
{
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);

	int left = A + B;
	int right = C + D;

	if (left > right)
		puts("Left");
	else if (left < right)
		puts("Right");
	else
		puts("Balanced");
	return (0);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int a, b;
  cin >> a >> b;
  int ans = a * b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

class BST:
    def __init__(self):
        self.root = None
    def insert(self, key):
        x, y = self.root, None
        while x != None: x, y = x.left if key < x.key else x.right, x
        if y == None: self.root = Node(key)
        elif key < y.key: y.left = Node(key)
        else: y.right = Node(key)
    def print_tree(self):
        def inorder(node):
            return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
        def preorder(node):
            return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''
        print(inorder(self.root))
        print(preorder(self.root))

tree = BST()
input()
for e in sys.stdin:
    if e[0] == 'i': tree.insert(int(e[7:]))
    else: tree.print_tree()


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

using namespace std;

long long dp[405][405];
long long pre[405];

int main(){
    int N;
    cin >> N;
    for(int i = 1; i<=N; i++){
        cin >> pre[i];
        pre[i] += pre[i-1];
    }
    for(int len = 2; len <= N; len++){
        for(int l = 0; l+len<=N; l++){
            int r = l+len;
            dp[l][r] = LLONG_MAX/2-5;
            for(int k = l+1; k<r; k++){
                dp[l][r] = min(dp[l][k] + dp[k][r], dp[l][r]);
            }
            dp[l][r] += pre[r] - pre[l];
        }
    }
    cout << dp[0][N] << endl;
}


Measured memory_bytes: 1536
use proconio::input;

fn main() {
    input! {
        n: usize,
        d: [(u64, u64); n],
    }
    let mut l: Vec<u64> = d.iter().map(|(l, _)| *l).collect();
    let mut r: Vec<u64> = d.iter().map(|(_, r)| *r).collect();
    l.sort();
    r.sort();
    if n % 2 == 1 {
        println!("{}", r[n/2] - l[n/2] + 1);
    } else {
        let l2 = l[n/2 - 1] + l[n/2];
        let r2 = r[n/2 - 1] + r[n/2];
        println!("{}", r2 - l2 + 1);
    }
}


Measured memory_bytes: 12828
N,K=map(int,input().split())
mod=10**9+7

def cmb(n,r):
  global mod
  if r<0 or r>n:
    return 0
  return (g1[n]*g2[r]*g2[n-r])%mod

g1=[1,1]
g2=[1,1]
inv=[0,1]
for i in range(2,1000003):
  g1.append((g1[-1]*i)%mod)
  inv.append((-inv[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inv[-1])%mod)
P=0
for i in range(min(N,K+1)):
  P=(P+cmb(N,i)*cmb(N-1,i))%mod
print(P)

Measured memory_bytes: 212976
#include<stdio.h>

#define N 250

void insert(int);
void Hprint(int);

int H[N];
int heapSize;

int main()
{
  int n, i, key;
  heapSize=0;
  scanf("%d", &n);
  for(i=0; i<n; i++)
    {
      scanf("%d", &key);
      insert(key);
    }
  Hprint(n);
  return 0;
}
void insert(int key)
{
  H[heapSize] = key;
  heapSize++;
}
void Hprint(int n)
{
  int i;
  for(i=0; i<n; i++)
    {
      printf("node %d: key = %d, ", i+1, H[i]);
      if((i+1)/2 >= 1)
	printf("parent key = %d, ", H[(i+1)/2 -1]);
      if((i+1)*2 <= heapSize)
	printf("left key = %d, ", H[(i+1)*2 -1]);
      if((i+1)*2 +1 <= heapSize)
	printf("right key = %d, ", H[(i+1)*2]);
      printf("\n");
    }
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void){
	int n;
	char str[105];
	int r = 0, b = 0;
	scanf("%d", &n);
	scanf("%s", str);
	for(int i = 0; i < n; i++){
		if(str[i] == 'R')r++;
		else b++;
	}
	if(r > b)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    rep(i, N) { cin >> P[i]; }
    vector<int> check(N - 1);
    vector<int> cum(N);
    rep(i, N - 1) {
        if(P[i + 1] < P[i])
            check[i] = 1;
    }
    rep(i, N - 1) { cum[i + 1] = cum[i] + check[i]; }

    set<int> se;
    rep(i, K) se.insert(P[i]);
    int res = 0;
    bool is_order = 0;
    if(0 == cum[K - 1])
        is_order = 1;
    else
        res++;
    for(int i = K; i < N; i++) {
        auto rmit = se.find(P[i - K]);
        int mx = *se.rbegin();
        if(cum[i] == cum[i - K + 1]) {
            is_order = 1;
        } else if(rmit == se.begin() && P[i] > mx) {
        } else {
            res++;
        }
        se.erase(rmit);
        se.insert(P[i]);
    }
    cout << res + is_order << endl;
    return 0;
}

Measured memory_bytes: 14836
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


TT = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

S = input()

print(7-TT.index(S))


Measured memory_bytes: 4196