akhauriyash/Code-Regression huggingface dataset:
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	char c;
	cin >> c;
	if(c == 'A')puts("T");
	else if(c == 'T')puts("A");
	else if(c == 'C')puts("G");
	else puts("C");
	return 0;
}



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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    int sum = 0, minv = INT_MAX;
    rep(i, 0, n) {
        int p;
        cin >> p;
        if (minv >= p) {
            minv = p;
            ++sum;
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
/**
*   @author Mustafa Khaled.
*/
#pragma GCC optimize("O3")
#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 REP(i, n) FOR(i, 0, n)
#define FastInputOutput ios_base :: sync_with_stdio( 0 ) ; cin.tie( 0 ) ; cout.tie( 0 ) ;
#define ReadFromFile(x)  freopen( x, "rt" , stdin ) ;
#define WriteToFile(x)  freopen( "in.txt", "wt" , stdout ) ;
#define D(x) scanf("%d",&x);
#define LLD(X) scanf("%lld",&x);
#define in(x,...) scanf(x,__VA_ARGS__)
#define out(x,...) printf(x,__VA_ARGS__)
typedef long long ll;

/// for debugging
string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
#ifndef ONLINE_JUDGE
    #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define dbg(...) {}
#endif

/// start driven program
const int OO = 0x3f3f3f3f , N=1e3;


void seive(){
int lp[1000000+7];
vector<int> pr;
	for (int i=2; i<=1000000+1; ++i) {
			if (lp[i] == 0) {
					lp[i] = i;
					pr.push_back(i);
			}
			for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=1000000; ++j) lp[i * pr[j]] = pr[j];

	}
}

bool ok(int val){
}
int bin_search(){ //max
    int l =0 , h =1000;
    int mid;
    while(l<h){
        mid=(l+h)>>1;
        if( ok(mid) ){
            h=mid;
        }else{
            l=mid+1;
        }
    }
    return h;
}

int main(){
    int  k , x; cin>>k>>x;
    int l = x-(k-1),r = x+(k-1);
    for( ; l <=r ; ++l){
        cout<<l<<" ";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int e,f;
  e = a + b;
  f = c + d;
  if (e > f){
  cout << "Left" << endl;
  }
  else if (e < f){
  cout << "Right" << endl;
  }
  else{
  cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
///****In the name of Allah, most Gracious, most Compassionate****//

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

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

#define NL cout<<"\n";
#define ALL(a) a.begin(), a.end()
#define DBG(a) cout<< #a <<" --> "<<(a)<<endl;
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
    os<<"{"<<p.first<<","<<p.second<<"}";
    return os;
}

const int N=3e5+5;
const int oo=1e9+7;


ll paw(ll x,ll n)
{
    ll ret=1;
    while(n--)
    ret*=x;
    return ret;
}

int32_t main()
{
    FastIO;
    ll n,p;
    cin>>n>>p;
    ll ans=1;
    ll x=0;
    while(p%2==0)
    {
        x++;
        p/=2;
    }
    ans*=paw(2,x/n);
    for(ll i=3;i*i<=p;i+=2)
    {
        x=0;
        while(p%i==0)
        {
            p/=i;
            x++;
        }
        ans*=paw(i,x/n);
    }
    if(p>1)
    {
        ans*=paw(p,1/n);
    }
    cout<<ans<<"\n";;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


int main() {
  int a;
  ll ans=0,n,k,x,y,m,memo=1,sx=1,sy=1,gx,gy;
  string ka,ss;
  map<string,int>mp;
  cin>>x>>y;
  bool foo;
  ans+=ll(x*(x-1)/2);
  ans+=ll(y*(y-1)/2);
  cout<<ans<<endl;
  
  
  //cout<<dp[x-1][y-1]<<endl;

  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

Measured memory_bytes: 256
function Main(s) {
  var s = s.split("\n")[0].split(" ").map(e => e*1);
  ans = 1;
  for (var i = 0; i < s[0]; i++) {
    if(i === 0) {
      ans *= s[1]; 
    } else {
      ans *= (s[1] - 1) % 1000000007;
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	if(S[0]==S[1]) return _P("Bad\n");
	if(S[1]==S[2]) return _P("Bad\n");
	if(S[2]==S[3]) return _P("Bad\n");
	_P("Good\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-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; }

const int MAX = 100010;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll comb(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll s; cin >> s;
    COMinit();

    ll ans = 0;
    ll d = 1; // 桁数
    while (3*d <= s) {
        ll t = s - 3 * d;
        if (d == 1) ans += 1;
        else ans += comb(t+d-1, d-1);
        ans %= MOD;
        if (ans < 0) ans += MOD;
        d++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5984
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

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

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  ll ans=0;
  rep(i,1,n)ans+=i;

  std::cout<<ans;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define FOR(i,l,r) for(int i = l ; i <= r ;++i )
#define inf 1<<30
#define EPS (1e-9)
#define ALL(T)  T.begin(),T.end()
#define lson(i)     i<<1
#define rson(i)     (i<<1|1)
using namespace std;
typedef pair<int,int> pii;
const int maxn = 1e5+10;
int a[maxn];
int n;
int main(){
	cin >> n;
	int sign = 1;
	FOR(i,1,n){
		cin >> a[i];
	}
	FOR(i,1,n-1){
		if(a[i]>a[i+1]){
			if(a[i]-1>a[i+1])
				sign = 0;
			else
				a[i+1]++;
		}
	}
	if(sign)	cout << "Yes" << endl;
	else cout <<"No" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
 int N;cin>>N;
  map<int,int>M;
  for(int i=0;i<100000;i++)
    M[i]=0;
  for(int i=2;i<=150;i++)
    for(int j=2;j<=150;j++)
      for(int k=2;k<=150;k++){
      int sum=i*i+j*j+k*k;
    if(sum%2==0 && (i+j+k)%2==0 && i<((i+j+k)/2)&& j<((i+j+k)/2)&&k<((i+j+k)/2)){
    M.at(sum/2)++;
    }
          }for(int i=1;i<=N;i++)
        cout<<M.at(i)<<endl;
  return 0;
}


Measured memory_bytes: 8224
import numpy as np
N = int(input())
a = np.array([int(input()) for i in range(N)])
MOD =998244353
sum_a = np.sum(a)
dp =  np.zeros((N+1,sum_a+1))
half_dp = np.zeros((N+1,sum_a//2+1))
dp[0][0] = 1
half_dp[0][0] = 1

for i in range(1,N+1):
    dp[i,:] += dp[i-1,:]*2 %MOD
    dp[i,a[i-1]:] +=  dp[i-1, :-a[i-1]]%MOD
    half_dp[i,:] +=  half_dp[i-1,:] %MOD
    half_dp[i,a[i-1]:] += half_dp[i-1,:-a[i-1]]%MOD

all_combination = 3**N %MOD
half_sum_a = sum_a //2 if sum_a %2 == 0 else sum_a//2+1 
bigger_than_half = np.sum(dp[N][half_sum_a:])
half_half = half_dp[N][half_sum_a] if sum_a%2==0 else 0
ans = int(all_combination - 3* bigger_than_half + 3* half_half)%MOD
print(ans)
    


Measured memory_bytes: 328856
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val xs = readLine()!!.split(" ").map { it.toInt() }
  val counts = IntArray(110000)
  for (x in xs) {
    if (x >= 1) counts[x - 1]++
    counts[x]++
    counts[x + 1]++
  }
  println(counts.max())
}


Measured memory_bytes: 50020
from collections import deque

n, q = map(int, input().split())
eg = [[] for _ in range(n + 1)]

for _ in range(n - 1):
    a, b = map(int, input().split())
    eg[a].append(b)
    eg[b].append(a)

cnt = [0] * (n + 1)
for i in range(q):
    p, x = map(int, input().split())
    cnt[p] += x


q = deque()
q.append(1)
seen = {1}
ans = [0] * (n + 1)
ans[1] = cnt[1]
while q:
    v = q.pop()
    for t in eg[v]:
        if t in seen:
            continue
        q.append(t)
        seen.add(t)
        ans[t] = ans[v] + cnt[t]

print(*ans[1:])


Measured memory_bytes: 70968
// EbTech's Rust template. Thanks EbTech!
#![allow(unused_imports)]
use std::cmp::{max, min, Reverse};
use std::collections::{HashMap, HashSet};
use std::io::{self, prelude::*};
use std::str;

/*
5 2
5 -4 4 3 -5
4 3
3 -1

5 -4 4 3 -5 -> 8
5 -4 4 3 3  -> 11
5 -4 4 -1 3 -> 7
*/

struct Scanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitWhitespace<'static>,
}
impl<R: BufRead> Scanner<R> {
    fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_whitespace(),
        }
    }
    fn next<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_whitespace())
            }
        }
    }
}

fn solve<R: BufRead, W: Write>(scan: &mut Scanner<R>, w: &mut W) {
    let s: String = scan.next();
    let t: String = scan.next();
    let n = s.len();
    let m = t.len();
    let s: Vec<char> = s.chars().collect();
    let t: Vec<char> = t.chars().collect();

    let mut res = m;
    for i in 0..n-m+1 {
        let mut cnt = 0;
        for j in 0..m {
            if s[i+j] != t[j] {
                cnt += 1;
            }
        }
        res = min(res, cnt);
    }
    writeln!(w, "{}", res);
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    // let t: u64 = scan.next();
    let t = 1;
    for _ in 0..t {
        solve(&mut scan, &mut out);
    }
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const ll INF = (ll)(1e18);

int main(void){
  ll n;
  cin >> n;
  vector<vector<ll>> A(n, vector<ll>(n));
  REP(i, n) REP(j, n) cin >> A[i][j];
  vector<vector<ll>> d(A);
  REP(k, n) REP(i, n) REP(j, n){
    if(k == i || k == j || i == j) continue;
    if(d[i][k]+d[k][j] > A[i][j]) continue;
    if(d[i][k]+d[k][j] < A[i][j]){
      cout << -1 << endl;
      return 0;
    }
    d[i][j] = INF;
  }
  ll ans = 0;
  REP(i, n) FOR(j, i+1, n) ans += (d[i][j] != INF) ? d[i][j] : 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 100100;
const ll oo = 1e18;

int x,y,a,b,c;
ll sum=oo;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("in.txt","r",stdin);
    cin>>a>>b>>c>>x>>y;
    for (int ti = 0;ti<=max(x,y);ti++) sum = min(sum,1ll*max(0,x-ti)*a + 1ll*max(0,y-ti)*b + 2ll*ti*c);
    cout<<sum;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

string s;
set<int> st;
bool vis[1000];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    st.insert(s[0]);
    vis[s[0]] = true;
    for (int i = 1; i < 4; i++) {
        if (st.count(s[i])) {
            st.erase(s[i]);
        }
        else {
            if (vis[s[i]]) {
                cout << "No\n";
                return 0;
            }
            st.insert(s[i]);
            vis[s[i]] = true;
        }
    }
    if (st.empty()) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

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

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

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int sim(vector<vector<int>> &field, vector<int> c, int H, int W) {
    vector<vector<int>> v(H+2, vector<int>(W+2));
    queue<pair<int, int>> que;
    v[1][1] = 1;
    int dx[] = {0, 1, 0, -1};
    int dy[] = {-1, 0, 1, 0};
    for (int k = 0; k <= 5; k++) {
        for (int y = 1; y <= H; y++) {
            for (int x = 1; x <= W; x++) {
                if (v[y][x] == 1) {
                    que.push({y, x});
                }
            }
        }
        while (!que.empty()) {
            pair<int, int> crt = que.front();
            que.pop();
            for (int i = 0; i < 4; i++) {
                int nx = crt.second + dx[i];
                int ny = crt.first + dy[i];
                if (field[ny][nx] == c[k] && v[ny][nx] == 0) {
                    v[ny][nx] = 1;
                    que.push({ny, nx});
                }
            }
        }
    }

    int ret = 0;
    for (int y = 1; y <= H; y++) {
        for (int x = 1; x <= W; x++) {
            if (v[y][x] == 1) {
                ret++;
            }
        }
    }
    return ret;
}

int solve(int H, int W, int C) {
    vector<vector<int>> field(H+2, vector<int>(W+2));
    for (int y = 1; y <= H; y++) {
        for (int x = 1; x <= W; x++) {
            cin >> field[y][x];
        }
    }
    vector<int> c(6);
    c[0] = field[1][1];
    c[5] = C;
    int ret = -1;
    for (c[1] = 1; c[1] <= 6; c[1]++) {
        for (c[2] = 1; c[2] <= 6; c[2]++) {
            for (c[3] = 1; c[3] <= 6; c[3]++) {
                for (c[4] = 1; c[4] <= 6; c[4]++) {
                    ret = max(sim(field, c, H, W), ret);
                }
            }
        }
    }
    return ret;
}

int main(void) {
    int H, W, C;
    vector<int> ans;
    while (1) {
        cin >> H >> W >> C;
        if (!H && !W && !C) break;
        ans.push_back(solve(H, W, C));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
}


Measured memory_bytes: 3140
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {

	solve();
    }

    static void solve(){
	int p = kbd.nextInt();
	for(int i=2; i>0; i--){
	    int pp = kbd.nextInt();
	    if(p>pp) p=pp;
	}

	int j = kbd.nextInt();
	int j2 = kbd.nextInt();
	if(j>j2) j=j2;


	System.out.println(j+p-50);
    }
}

Measured memory_bytes: 17324
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int D;
  cin >> D;
  if (D==22) {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  else {
    if (D==23) {
      cout << "Christmas Eve Eve" << endl;
    }
    else {
      if (D==24) {
        cout << "Christmas Eve" << endl;
      }
      else {
        cout << "Christmas" << endl;
      }
    }
  }
}

Measured memory_bytes: 3592
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

struct edge {
    int from, to;
    ll cost;
};

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int N, Q, K;

vector<edge> G[MAX_N + 1], T[MAX_N + 1];
int X[MAX_N], Y[MAX_N];
ll lgh[MAX_N + 1];

void getLength(int s, int prev, ll l);

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

    cin >> N;

    for (int i = 1; i < N; i++) {
        int s, t;
        ll c;
        cin >> s >> t >> c;
        edge es = { s, t, c };
        G[s].push_back(es);
        edge et = { t, s, c };
        G[t].push_back(et);
    }

    cin >> Q >> K;
    for (int i = 0; i < Q; i++) {
        int x, y;
        cin >> x >> y;
        X[i] = x;
        Y[i] = y;
    }

    getLength(K, -1, 0);

    for (int i = 0; i < Q; i++) {
        cout << lgh[X[i]] + lgh[Y[i]] << "\n";
    }

    return 0;
}

void getLength(int s, int prev, ll l)
{
    for (int i = 0; i < G[s].size(); i++) {
        edge e = G[s][i];
        if (e.to != prev) {
            lgh[e.to] = l + e.cost;
            getLength(e.to, s, l + e.cost);
        }
    }
    return;
}

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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

long long H, W;
vector<vector<long long>> cost_map(1000+1, vector<long long>(1000+1, 0));

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int N;
  cin >> N;
  vector<long long> T(N);
  for(int i = 0; i < N; ++i) {
    cin >> T[i];
  }

  if(N > 1) {
    long long num = lcm(T[0], T[1]);
    for(int i = 2; i < N; i++) {
      num = lcm(num, T[i]);
    }
    cout << num << endl;
  }
  else {
    cout << T[0] << endl;
  }

  return 0;
}


Measured memory_bytes: 11440
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define int long long
#define REP(i,l,r) for(int i=l;i<r;i++)
using namespace std;
typedef pair<int,int> P;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
struct edge{
    int to,cost;
};
class dijkstra{
    int V;
    int d[100002];
    priority_queue<P,vector<P>,greater<P>>que;
    void update(int s,vector<edge> G[]){
        fill(d,d+V+1,100000000000ll);
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            rep(i,G[v].size()){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
public:
    dijkstra(int v,int s,vector<edge> G[]){
        V=v;
        update(s,G);
    }
    int find(int e){
        return d[e];
;    }
};
class Union_Find{
private:
    vector<int> t,s;
public:
    Union_Find(int max_length){
        rep(i,max_length+1){
            t.push_back(i);
            s.push_back(1);
        }
    }
    void Union(int x,int y){
        if(same(x,y))return;
        int tx=Find(x),ty=Find(y);
        if(s[tx]<s[ty]){
            s[ty]+=s[tx];
            t[tx]=ty;
        }
        else if(s[tx]>s[ty]){
            s[tx]+=s[ty];
            t[ty]=tx;
        }
        else if(tx>ty){
            t[tx]=ty;
            s[ty]+=s[tx];
        }
        else{
            t[ty]=tx;
            s[tx]+=s[ty];
        }
    }
    int Find(int n){
        if(t[n]==n)return n;
        else return t[n]=Find(t[n]);
    }
    bool same(int x,int y){
        return Find(x)==Find(y);
    }
    int get_Size(int a){
        return s[a];
    }
};
signed main(){
    int n,memo[200011];
    string s;
    cin>>n>>s;
    int ans=LLONG_MAX;
    memo[0]=0;
    rep(i,n){
        if(s[i]=='.')memo[i+1]=memo[i]+1;
        else memo[i+1]=memo[i];
    }
    if(memo[n]==0)cout<<0<<endl;
    else{
    rep(i,n+1){
        int cnt=i-memo[i]+(memo[n]-memo[i]);
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    }
}

Measured memory_bytes: 2180
N, M = gets.split(" ").map{|v|
	v.to_i
}

student = []
N.times do
	a, b = gets.split(" ").map{|v|
		v.to_i
	}
	student << [a, b]
end

cp = []
M.times do
	a, b = gets.split(" ").map{|v|
		v.to_i
	}
	cp << [a, b]
end

student.each do |s|
	min = 10 ** 9
	j = 1
	index = -1
	cp.each do |c|
		dist = (s[0]-c[0]).abs + (s[1]-c[1]).abs
		if dist < min then
			min = dist
			index = j
		end
		j += 1
	end
	puts index
end

 	

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

ll dp[2001][2001], sum[2001][2001];

int main(){	
	long long N;
	long long M;
	scanf("%lld",&N);
	vector<long long> S(N-1+1);
	scanf("%lld",&M);
	vector<long long> T(M-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&S[i]);
	}
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&T[i]);
	}
	rep(i,N+1) {
		dp[i][0] = 0;
		sum[i][0] = 0;
	}
	rep(i,M+1) {
		dp[0][i] = 0;
		sum[0][i] = 0;
	}
	repn(i,N) {
		repn(j,M) {
			if (S[i-1] == T[j-1]) dp[i][j] = (sum[i-1][j-1] + 1)%mod; else dp[i][j] = 0;
			sum[i][j] = (sum[i-1][j] + sum[i][j-1] + (mod - sum[i-1][j-1]) + dp[i][j])%mod;
		}
	}
	cout << sum[N][M]+1 << endl;

	return 0;
}



Measured memory_bytes: 62848
#include <iostream>

using namespace std;


int n, N, i, j, k, a[20], x[20][20], y[20][20], v[(1 << 15) + 10], nr;
bool ok;

int main() {
    N = (1 << 15);
    for (i = 1; i < N; ++i) {
        v[i] = v[i >> 1] + (i & 1);
    }
    cin >> n;
    for (i = 1; i <= n; ++i) {
        cin >> a[i];
        for (j = 1; j <= a[i]; ++j) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    N = (1 << n);
    for (k = 1; k < N; ++k) {
        ok = 1;
        for (i = 1; i <= n; ++i) {
            if( !(k & (1 << (i - 1))) ) {
                continue;
            }
            for (j = 1; j <= a[i]; ++j) {
                if (((k >> (x[i][j] - 1)) & 1) ^ y[i][j]) {
                    ok = 0;
                }
            }
        }
        if(ok) {
            nr = max(nr, v[k]);
        }
    }
    cout << nr << "\n";
    return 0;
}


Measured memory_bytes: 384
a = (input()).split()
for i in range(len(a)):
    a[i] = int(a[i])

for x in a:
    if x % 2 == 0:
        print("0")
        quit()

res = 10 ** 18
for i in range(len(a)):
    sub = 1
    for j in range(len(a)):
        if(j == i):
            continue
        sub *= a[j]
    res = min(res, sub)

print(res)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        try(Scanner sc = new Scanner(System.in)){
            while(true){
                int max=0,min=0,sum=0,ave=0;
                int a = sc.nextInt();
                if(a==0) break;
                int[] s = new int[100];
                for(int i=0;i<a;i++){
                    s[i]=sc.nextInt();
                    sum+=s[i];
                    if(i==0){
                        max=s[0];
                        min=s[0];
                    }else if(max<s[i]){
                        max=s[i];
                    }else if(min>s[i]){
                        min=s[i];
                    }
                }
                ave=(sum-max-min)/(a-2);
                System.out.println(ave);
            }
        }
    }
}


Measured memory_bytes: 28748
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
    int n, m;
    long long int money = 0;
    cin >> n >> m;
    long long int a[n];
    int b[n];
    map<long long int, int> shopList;

    // initialization
    shopList.insert(make_pair(0, 0));
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        if (shopList.count(a[i]) > 0) {
            shopList[a[i]] += b[i];
            a[i] = b[i] = 0;
        }
        else
            shopList.insert(make_pair(a[i], b[i]));
    }
    sort(a, a+n);
    for (int i = 0; i < n && m > 0; i++) {
        money += a[i] * min(shopList.at(a[i]), m);
        m -= min(shopList.at(a[i]), m);
    }
    cout << money << endl;
}

Measured memory_bytes: 7680
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }
        Arrays.sort(d);
        int sum = d[n / 2] - d[n / 2 - 1];
        System.out.println(sum);
    }
}




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

  string s;
  cin >> s;
  int num = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '+') {
      num++;
    } else {
      num--;
    }
  }
  cout << num << endl;


  return 0;
}


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



int main(){

int x , y ;cin>>x>>y;
if( x==y )cout<<"Draw"<<endl;
else{
    if( x==1 )cout<<"Alice"<<endl;
    else
    if( y==1 )cout<<"Bob"<<endl;
    else
    if( x>y )cout<<"Alice"<<endl;
    else
    if( x<y )cout<<"Bob"<<endl;
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    vector<int> count(1e5+1, 0);

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if ( a > 1e5 ) {
            ans++;
        } else {
            count[a]++;
        }
    }

    for (int i = 0; i < 1e5 + 1; i++) {
        if ( count[i] > i ) {
            ans += count[i] - i;
        } else if ( count[i] < i ) {
            ans += count[i];
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

a=int(input())
x=0
for i in range(1,a+1):
    for j in range(1,a+1):
        for k in range(1,a+1):
            x+=gcd(i,j,k)

print(x)

Measured memory_bytes: 69832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void){
	int N; cin >> N;
	ll ans = 3;
	rep(i, N) ans = ans * 2 + 1;
	printf("%lld\n", ans - 1);
	return 0;
}

Measured memory_bytes: 256
N,Y = map(int, input().split())


a = Y//10000
b = Y//5000

flag = False

for i in range(a+1):
    if flag == True:
        break
    for j in range(b+1):
        if N-i-j<0:
            break
        if i*10000+j*5000+(N-i-j)*1000 == Y:
            flag = True
            s = i
            t = j
            u = N-i-j
            break

if flag == True:
    print(s,t,u)
else:
    print(-1,-1,-1)

Measured memory_bytes: 3064
n=int(input())
#print(n)
otosilist=[]
for nth in range(n):
    okane=input().split(' ')
    otosilist.append([okane[0], okane[1]])

#print(otosilist)
money=0

for olist in otosilist:
    if olist[1]=='JPY':
        money+=float(olist[0])
    else:
        money+=float(olist[0])*380000.0

print(money)

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
dp = [0]*N
dp[0] = 1000
for i in range(N-1):
    dp[i+1] = max(dp[i],(dp[i]//A[i])*A[i+1]+dp[i]-(dp[i]//A[i])*A[i])
print(dp[-1])

Measured memory_bytes: 61860
# 解説を見て書いたコード
"""
ある境目を考える。境目より左が全て白、境目より右が全て黒でなくてはいけない。
ゆえに、境目より左の黒の数と境目より右の白の数を数えれば、その境目における「変更が必要な石の数」がわかる。
よって、境目を端から端まで動かしてその中で最小の「変更が必要な石の数」を求めればよい。
"""
N = int(input())
str = input()
minDistance = 0

black = "#"
white = "."
leftblack = 0
rightwhite = 0

for i in range(N):
    if str[i] == white:
        rightwhite += 1

minDistance += rightwhite

for j in range(0, N):
    if str[j] == black:
        leftblack += 1
    else:
        rightwhite -= 1
    if leftblack + rightwhite < minDistance:
        minDistance = leftblack+rightwhite

print("{}".format(minDistance))


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

int main() {
   int S,h,m,s;
   cin>> S >> h >> m >> s;
   h=S/3600;
   m=(S/60)%60;
   s=S%60;

  
   cout<< h <<":" << m << ":" << s <<endl;
  
  
}


Measured memory_bytes: 3120
/*    Isn't it lovely, all alone?              */
/*    Heart made of glass, my mind of stone    */
/*    Tear me to pieces, skin to bone          */
/*    Hello, welcome home                      */

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
ll mod=1000000007;

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

ll t=1;
//cin>>t;
while(t--)
{


ll a,b;
cin>>a>>b;
cout<<a*b<<endl;
}
return 0;
}




















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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    LL N;
    cin >> N;
    if(N%2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    LL res = 0;
    LL p = 10;
    for(;p <= N;) {
        res += N/p;
        p *= 5;
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int n,m,ans,lake[100][100];
int x[4] = {0,1,0,-1},y[4] = {-1,0,1,0};

void func(int i,int j,int c){
	lake[i][j] = 0;
	if(c > ans)ans=c;
	
	for(int k = 0;k < 4; k++)if(lake[i+x[k]][j+y[k]] && i+x[k] >= 0 && i+x[k] < n && j+y[k] >= 0  && j+y[k] < m)	func(i+x[k],j+y[k],c+1);
	lake[i][j] = 1;
}

int main(void){
	while(scanf("%d%d", &m, &n) && n && m){
		for(int i = 0; i < n; i++)for(int j = 0; j < m; j++)scanf("%d", &lake[i][j]);
		for(int i = 0; i < n; i++)for(int j = 0; j < m; j++)if(lake[i][j])func(i,j,1);
		
		ans = !printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
package main

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

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(r io.Reader, w io.Writer) {
	scanner := initScanner(r)
	x := scanInt64(scanner)
	ans := "No"
	if x >= 30 {
		ans = "Yes"
	}
	fmt.Fprintln(w, ans)
}

// utilityメソッド群

const maxCapacity = 512 * 1024 // デフォルト値は64*1024

func initScanner(r io.Reader) *bufio.Scanner {
	scanner := bufio.NewScanner(r)
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)
	scanner.Split(bufio.ScanWords) // スペースごとに読み込む
	return scanner
}

func check(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func scanInt64(scanner *bufio.Scanner) int64 {
	scanner.Scan()
	val, err := strconv.ParseInt(scanner.Text(), 10, 64)
	check(err)
	return val
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x,n;
    cin >> x >> n;
    vector<int> arr;
    for (int i=0;i<=n-1;i++)
    {
        int a;
        cin >> a;
        arr.push_back(a);
    }
    sort(arr.begin(),arr.end());
    int base_val=0;
    int min_diff=INT_MAX;
    for (int i=0;i<=101;i++)
    {
        bool check=binary_search(arr.begin(),arr.end(),i);
        if (!check)
        {
            int diff=abs(i-x);
            if (diff<min_diff)
            {
                min_diff=diff;
                base_val=i;
            }
        }
    }
    cout << base_val << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h,a;
	ll n;
	cin>>h>>n;
	ll sum=0;
	for(ll i=0;i<n;i++){
		ll a;
		cin>>a;
		sum+=a;
	}
	if(sum>=h)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  ll n, m;
  cin >> n >> m;

  vl v(n), w(n);
  rep(i,0,n) cin >> w[i] >> v[i];

  const ll inf = 1e18;
  vl dp(512345, inf);
  dp[0] = 0;

  rep(i,0,n) {
    per(j,0,512345) {
      if (dp[j] < inf) ckmin(dp[j+v[i]], dp[j]+w[i]);
    }
  }

  ll ans = 0;
  rep(i,0,sz(dp)) if (dp[i] <= m) ans = i;
  cout << ans << '\n';
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define M 10001
using namespace std;
long long n,k,t,u,v,l,d,c,x,a;
bool s[M];

int main(){
  cin>>n>>k>>t>>u>>v>>l;
  for(int i=0;i<n;i++)cin>>d,s[d]=true;
  for(int i=0;i<l;i++){
    if(s[i])
      if(!x||k==c)x=v*t;
      else c++;
    else if(!x&&c)c--,x=v*t;
    if(x)a++,x--;
  }
  printf("%.8f\n",a*1.0/v+(l-a)*1.0/u);
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

using namespace std;

#define ll long long int

void Main()
{
	int N;
	cin >> N;
	map<vector<ll>, ll> array_num;
	vector<string> s(N);

	for (int i = 0; i < N; i++) {
		string si;
		cin >> si;
		vector<ll> s_arr(26, 0);
		for (int i = 0; i < si.size(); i++) {
			s_arr[si[i] - 'a']++;
		}
		array_num[s_arr]++;
	}

	ll ans = 0;
	for (auto itr = array_num.begin(); itr != array_num.end(); itr++) {
		ans += itr->second * (itr->second - 1) / 2;
	}

	cout << ans << endl;

}
 
int main()
{
	Main();
	return 0;
}



Measured memory_bytes: 30720
#include <iostream>
#include <string>
using namespace std;
int W[100005];
int A[100005];
int main() {
  ios::sync_with_stdio(false);
  int N, M, p;
  string S;
  cin >> N >> M;
  int P = 0;
  for (int i=0; i<M; i++) {
    cin >> p >> S;
    if (A[p]) continue;
    if (S == "AC") {
      A[p] = 1;
      P++;
    } else {
      W[p]++;
    }
  }
  int D = 0;
  for (int i=1; i<=N; i++) {
    if (A[i]) D += W[i];
  }
  cout << P << ' ' << D << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int N, L,sum,t;
	scanf("%d%d", &N, &L);
	sum = (L + (L+N-1)) * N / 2;
	if (L == 0)
	{
		t = 0;
	}
	if (L + N <= 0)
	{
		t = L+N-1;
	}
	if (L > 0 && L + N > 0)
	{
		t = L;
	}
	if (L < 0 && L + N>0)
	{
		t = 0;
	}
	printf("%d", sum-t);
	return 0;
}

Measured memory_bytes: 128
from collections import deque, Counter


class UnionFind:
    def __init__(self, v):
        self.v = v
        self._tree = list(range(v + 1))
        self._counter = Counter(self._tree)

    def _root(self, a):
        queue = deque()
        while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
        while queue:
            index = queue.popleft()
            self._tree[index] = a
        return a

    def union(self, a, b):
        root_a = self._root(a)
        root_b = self._root(b)
        if root_a == root_b:
            return 0

        self._tree[root_b] = root_a
        ca = self._counter[root_a]
        cb = self._counter[root_b]
        self._counter[root_a] += cb
        self._counter[root_b] = 0
        return ca * cb

    def find(self, a, b):
        return self._root(a) == self._root(b)


N, M = map(int, input().split(' '))
edges = [tuple(map(int, input().split(' '))) for _ in range(M)]

dp = [0] * (M + 1)
dp[-1] = N * (N - 1) // 2
union_find = UnionFind(N)

for i in reversed(range(M)):
    if dp[i + 1] == 0:
        break
    a, b = edges[i]
    minus = union_find.union(a, b)
    dp[i] = dp[i + 1] - minus

for i in range(M):
    print(dp[i + 1])


Measured memory_bytes: 32168
#include <cstdio>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,p[510],a[510],cnt[510],ans[250100];

bool cmp(int x,int y)
{
    return p[x]<p[y];
}

bool solve()
{
    for (int i=1,j=1,k=1; i<=n*n; ++i)
        if (!ans[i])
        {
            for (; j<=n && cnt[a[j]]+1>=a[j]; ++j);
            for (; cnt[a[k]]==n; ++k);
            if (j<=n)
                ++cnt[ans[i]=a[j]];
            else
            {
                if (k==j)
                    return 0;
                ++cnt[ans[i]=a[k]];
            }
        }
        else
            if (++cnt[ans[i]]!=ans[i])
                return 0;
    return 1;
}

int main()
{
    scanf("%d",&n);
    repu(i,1,n)
        scanf("%d",&p[i]),ans[p[i]]=a[i]=i;
    sort(a+1,a+1+n,cmp);
    if (solve())
    {
        puts("Yes");
        repu(i,1,n*n)
            printf("%d ",ans[i]);
    }
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<string>
#include<stdlib.h>
#define ll long long

using namespace std;

const ll N=305;

ll a[N];

int main(){

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

    int n;
    ll X=0,D;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>a[i];
        if(i>1){
            X^=a[i];
        }
    }
    ll S = a[0]+a[1];
    if(S-X<0||(S-X)%2!=0){
        cout<<-1<<endl;
        return 0;
    }else{
        D = (S-X)/2;
    }
    ll ans = D;
    for(int i=60;i>=0;--i){
        ll x = ((X>>i)&1ll),d = ((D>>i)&1ll);
        if(x&&d){
            cout<<-1<<endl;
            return 0;
        }
        if(!d&&x&&(ans|1ll<<i)<=a[0]){
            ans|=1ll<<i;
        }
    }
    if(ans==0||ans>a[0])
        cout<<-1<<endl;
    else
        cout<<a[0]-ans<<endl;

    return 0;
}

Measured memory_bytes: 3624
a = list(map(int, input().split()))
if a[1] >= a[2]:
  b = a[2]
if a[2] >= a[1]:
  b = a[1]

c = (a[1] + a[2]) - a[0] 
if c <= 0:
  c = 0
d = str(b) + " " + str(c)
print(d)



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>v(n+1,1);
	for(int i=2;i<=n;++i){
		for(int j=i;j<=n;j+=i){
			++v.at(j);
		}
	}
	int64_t ans=0;
	for(int i=1;i<=n;++i)ans+=1L*i*v.at(i);
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 42236
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

n=gets.to_i
N=n
ans=[]
2.upto((n**0.5).to_i+1) do|i|
    while (n%i).zero?
      ans.push(i)
      n/=i
    end
end
if n>1
    ans.push(n)
end
puts "#{N}: #{ans.sort.join(" ")}"


Measured memory_bytes: 6920
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template <typename T>
vector<T> divisor(T n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}
template <typename T>
map<T, int> prime_factor(T n) {
    map<T, int> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        res[n]++;
    }
    return res;
}
template <typename T>
T gcd(T a, T b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    auto d = divisor(accumulate(a.begin(),a.end(),0LL));
    reverse(d.begin(), d.end());
    for(ll x : d){
        vector<ll>b(n);
        rep(i,n)b[i] = a[i] % x;
        ll sum = accumulate(b.begin(), b.end(), 0LL);
        if(sum % x)continue;
        ll num = 1LL<<60;
        ll s = 0;
        sort(b.begin(),b.end());
        rep(i,n){
            s += b[i];
            if(s == (n-1-i)*x-(sum - s)){
                num = min(num, s);
                break;
            }
        }
        if(num <= k){
            cout << x << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256