akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

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

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	string S; cin >> S;
	ll ans = 0, max = 0;
	for (int i = 0;i < S.size();i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			max++;
		}
		else {
			if (ans < max)ans = max;
			max = 0;
		}
	}
	if (ans > max)cout << ans << endl;
	else cout << max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll N, D;
  cin >> N >> D;
  vector<ll> X(N), Y(N);
  rep(i,N) cin >> X[i] >> Y[i];
  int ans = 0;
  rep(i,N) {
    if (X[i] * X[i] + Y[i] * Y[i] <= D*D) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5988
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class AtCoderr
    {
        static double wator;
        static void Main(string[] args)
        {
            double[] s = ReadLine().Split(' ').Select(double.Parse).ToArray();
            double a = s[0];
            double b = s[1];
            double x = s[2];
            wator = x/a;
            //θを二分探索する
            var left = 0D;
            var right = PI/2;
            if (2 * x >= a*a*b)
            {
                while (right - left > 1E-8)
                {
                    var mid = (left + right) / 2.0;
                    if (Pow(a,3) * Tan(mid) > 2 * (a*a*b-x))
                    {
                        right = mid;
                    }
                    else
                    {
                        left = mid;
                    }
                }
            }
            else
            {
                while (right - left > 1E-8)
                {
                    var mid = (left + right) / 2D;
                    if (a * Pow(b,2) > 2 * Tan(mid)*x)
                    {
                        left = mid;
                    }
                    else
                    {
                        right = mid;
                    }
                }
            }
            
            WriteLine(
                ((left+right) /2) * 180/PI
                );
        }
    }
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N; cin >> N;
    ll ans = 1;
    REPS(i, N)
    {
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3544
#include <iostream>

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int c=0;
    if(m>=2){
        c=(m*(m-1))/2;
        c+=(n*(n-1))/2;
    }else{
        c=(n*(n-1))/2;
    }
    cout<<c<<endl;
}

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

int main(){
    int N, answer = 1;
    cin >> N;

    vector<int> mochi(N);
    for (int i = 0; i < N; i++){
        cin >> mochi.at(i);
    }

    sort(mochi.begin(), mochi.end());
    reverse(mochi.begin(), mochi.end());

    for (int i = 0; i < N-1; i++){
        if (mochi.at(i) == mochi.at(i+1)){
            continue;
        }
        else{
            answer++;
        }
    }
    cout << answer << endl;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, m = MI()

    print("Yes" if n == m else "No")


main()


Measured memory_bytes: 64920
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let n: f64 = read();
    let m: f64 = read();
    println!("{}",n/m);
}


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

int main() {
    int n; cin >> n;
    vector<pair<int, int>> gs(n);
    for (int i=0; i<n; ++i) {
        int x, l; cin >> x >> l;
        int g = x+l;
        int s = x-l;
        gs[i] = make_pair(g, s);
    }
    sort(gs.begin(), gs.end());
    int ans = 1;
    int now = gs[0].first;
    for (int i=1; i<n; ++i) {
        if (now > gs[i].second) continue;
        else {
            ans++;
            now = gs[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<string.h>
#include<queue>
#include<math.h>
#include<set>
#include<unordered_set>
#include<limits.h>
using namespace std;

typedef unsigned long long ll;

vector<vector<int> >vec;
vector<bool>visited;
ll ans=0;
void dfs(int a){
    visited[a]=true;
    bool ok=1;
    for(int i=0;i<visited.size();i++){
        if(visited[i]==false){
            ok=0;
        }
    }
    if(ok){
        ans++;
    }
    for(int i=0;i<vec[a].size();i++){
        if(!visited[vec[a][i]]){
            dfs(vec[a][i]);
        }
    }
    visited[a]=false;
}



int main(){
    int n,m;
    cin>>n>>m;
    vec.resize(n);
    visited.resize(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    dfs(0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main()
{
	cin>>n>>a>>b;
	if(a>b)
		cout<<0<<endl;
	else if(n==1&&a!=b)
		cout<<0<<endl;
	else
		cout<<(n-2)*(b-a)+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


// 素因数分解O(√n)--------------------------------------------
template<class T> void prime_factor(T n, map<int,T> &res){
  for (ll i=2; i*i<=n; i++){ while (n%i==0){ res[i]++; n/=i; } }
  if (n!=1) res[n]+=1;
}

int main() {
  ll N; cin >>N;
  map<int,ll> pris;
  prime_factor(N, pris);
  ll res = 0;
  for (auto p : pris){
    ll v = p.second;
    for (int i=1;; i++){
      if (v < i) break;
      v -= i;
      res++;
    }
  }
  cout <<res <<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e9;
auto p = vector<int>();
auto c = vector<int>();
int d,g;
	
int main(){
	ll n;
	cin >> n;
  	auto used = map<int,int>();
	ll sum = 0;
	for(ll i=1;i<n;i++){
      if(used[i] == 1 && used[n-i] == 1) continue;
      if(i == n-i)continue;
      used[i]=1;
      used[n-i]=1;
      sum++;
	}

	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 47104
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 2333333
ll n;
int m,q,a[SZ];
bool cov[SZ];
int ff[SZ];
int gf(int x) {return (ff[x]==-1)?x:ff[x]=gf(ff[x]);}
void uni(int a,int b)
{int ga=gf(a),gb=gf(b);if(ga^gb)ff[ga]=gb;}
int main()
{
	scanf("%lld%d%d",&n,&m,&q);
	for(int i=1;i<=q;i++)
	scanf("%d",a+i),cov[a[i]]=1;
	#define TJ(r,ans)\
	memset(ff,-1,sizeof(ff));\
	for(int i=0;i<r;i++)\
	{\
		if(cov[i%m])continue;\
		if(i+7<r&&!cov[(i+7)%m]) uni(i,i+7);\
		if(i%7!=6&&i+1<r&&!cov[(i+1)%m]) uni(i,i+1);\
	}\
	for(int i=0;i<r;i++)\
		if(!cov[i%m]) ans+=gf(i)==i;
	int ans1=0; TJ(m*7,ans1)
	int ans2=0; TJ(m*14,ans2)
	ll rd=7*n/m,zg=rd/7,bf=rd%7,ans=0;
	if(zg) ans=ans1+(ans2-ans1)*(zg-1);
	int ans3=0; TJ(m*bf,ans3)
	int ans4=0; TJ(m*bf+m*7,ans4)
	if(zg) ans+=ans4-ans1; else ans+=ans3;
	printf("%lld\n",ans);
}


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

int main()
{
    ll w, h, x, y;
    double ans;

    cin >> w >> h >> x >> y;

    ans = (double)(w * h) / 2;
    cout << fixed << setprecision(10) << ans;
    if ((double)x== (double)w/2.0 && (double)y== (double)h/2.0)
        cout << " 1" << endl;
    else
        cout << " 0" << endl;

    return 0;
}


Measured memory_bytes: 3756
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int a,b;

  cin >> a >> b;

  if(a==1) a+= 100;
  if(b==1) b+= 100;

  if(a > b){
    puts("Alice");
  }else if(a == b){
    puts("Draw");
  }else{
    puts("Bob");
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define N 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x,i,y;
    cin>>x;
    y = x/100;
    x = x%100;
    if(y*5 >= x)
        cout<<1;
    else
        cout<<0;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;

int main(){
  ll N;
  cin>>N;
  for(ll h=1;h<=3500;h++){
	for(ll n=1;n<=3500;n++){
	  if(4*h*n-N*h-N*n<=0)continue;
	  if((N*n*h)%(4*h*n-N*h-N*n))continue;
	  cout<<h<<" "<<n<<" "<<(N*n*h)/(4*h*n-N*h-N*n)<<endl;
	  return 0;
	}
  }
}


Measured memory_bytes: 768
#include <iostream>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int main() {
  int T;
  cin >> T;
  for (int i = 0; i < T; ++i) {
    long long n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << floor_sum(n, m, a, b) << endl;
  }
  return 0;
}

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

int main(void)
{
    int price=700;
    string S;

    cin >> S;

    for(int i=0; i<3; i++)
    {
        if(S.at(i) == 'o')
        {
            price += 100;
        }
    }

    cout << price << endl;

    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();


        int[] roadSum = new int[N];

        for (int i = 0; i < M; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;

            //a < b とする処理
            if (a > b) {
                int tmp = b;
                b = a;
                a = tmp;
            }
            roadSum[a]++;
            roadSum[b]++;

        }
        for (int i = 0; i < N; i++) {
            System.out.println(roadSum[i]);
        }
    }
}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  cin>>n;
  vll A(n);
  ll all=0;
  FOR(i,0,n){
    cin>>A[i];
    all+=A[i];
  }
  ll ans=0;
  FOR(i,0,n){
    ans+=(all-A[i])*A[i];
  }
  co(ans/2)
}

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

#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

int main() {
    fastio;
    int n;
    cin>>n;
    int a[n],count=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]%2!=0 && i%2!=0)
            count++;
    }
    cout<<count<<"\n";
    return 0;   
}

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

int main(){
	ll N, M = 1e9 + 7; cin >> N;
        vector<ll> heights(N), minCost(N);
        for(ll &ele : heights) cin >> ele;
        minCost[0] = 0;
        for(ll place = 1; place < N; ++place){
            ll prevMin = M;
            if(place - 2 >= 0){
                prevMin = min(prevMin,
        		  minCost[place - 2] + abs(heights[place - 2] - heights[place]));
            }
            prevMin = min(prevMin,
            	      minCost[place - 1] + abs(heights[place - 1] - heights[place]));
	    minCost[place] = prevMin;            
        }
        cout << minCost[N - 1] << endl;
    	return 0;
}

Measured memory_bytes: 1792
//swing
//iroha_loves_strings

//atcoder_beginner_042_b

#include <bits/stdc++.h>

using namespace std;

int main(){
	int n,l;
	cin>>n>>l;
	vector <string> s(n);
	for(int i=0;i<n;i++){
			cin>>s[i];
	}
	sort(s.begin(),s.end());
	for(int i=0;i<n;i++){
		cout<<s[i];
	}
	
}



Measured memory_bytes: 256
/*input
100000 5
*/
#include "bits/stdc++.h"
using namespace std;
long long n,k;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>n>>k;

	long double ans = 0.0;
	for(int now=1;now<=n;++now){
		long double sum = 1.0/n;
		for(int j=now;j<k;j*=2) 
			sum *= 0.5;
		ans += sum;
	}
	cout<<fixed<<setprecision(16)<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve() {
    LL q,t,a,b;
    cin >> q;
    priority_queue<LL,VLL,less<LL>> ql;
    priority_queue<LL,VLL,greater<LL>> qr;
    LL suma = 0, sumb = 0;
    REP(qq,0,q) {
        cin >> t;
        if (t == 1) {
            cin >> a >> b;
            sumb += b;
            
            if (ql.size() == 0) {
                ql.push(a);
                suma -= a;
            } else if (ql.top() < a) {
                qr.push(a);
                suma += a;
            } else {
                ql.push(a);
                suma -= a;
            }

            if (ql.size() - qr.size() == 2) {
                suma += 2 * ql.top();
                qr.push(ql.top());
                ql.pop();
            } else if (qr.size() > ql.size()) {
                suma -= 2 * qr.top();
                ql.push(qr.top());
                qr.pop();
            }
        } else if (t == 2) {
            cout << ql.top() << " ";
            LL add = 0;
            if (ql.size() - qr.size() == 1) add += ql.top();
            cout << suma + sumb + add << endl;
        }
    }
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3828
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <map>

using namespace std;

typedef long long ll;

const ll INF = 1e18;
ll T;
ll n, a, b, c, d;
map<ll, ll> mp;

ll dfs(ll x) {
	if (mp.count(x)) return mp[x];
	if (x == 0) return mp[0] = 0;
	if (x == 1) return mp[1] = d;

	ll res = INF;
	if (x <= n / d) res = min(res, x*d);
	res = min(res, dfs(x / 2) + a + x % 2 * d);
	res = min(res, dfs((x + 1) / 2) + a + (2 - x % 2)*d);
	res = min(res, dfs(x / 3) + b + x % 3 * d);
	res = min(res, dfs((x + 2) / 3) + b + (3 - x % 3)*d);
	res = min(res, dfs(x / 5) + c + x % 5 * d);
	res = min(res, dfs((x + 4) / 5) + c + (5 - x % 5)*d);
	return mp[x] = res;
}

int main() {
	cin >> T;
	while (T--) {
		cin >> n >> a >> b >> c >> d;
		mp.clear();
		cout << dfs(n) << endl;
	}

	return 0;
}

Measured memory_bytes: 4372
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int A = Integer.parseInt(scn.next());
		String op = scn.next();
		int B = Integer.parseInt(scn.next());

		if (op.equals("+")) {
			System.out.println(A + B);
		} else if (op.equals("-")) {
			System.out.println(A - B);
		}
	}
}

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

 int main()
 {
     int n,x,t,T,l,m;

     cin>>n>>x>>t;

     if(n<x){
        cout<<t<<endl;
     }
     else{
        l = n/x;
        m = n%x;
        T = l*t;
        if(m<=x && m!=0){
            T = T+t;
        }
        cout<<T<<endl;
     }
     return 0;
 }


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

int main() {
  int l,r,d;
  int ans=0;

  cin >> l >> r >> d;

  for(int i=l;i<=r;i++) {
    if(i%d==0) {ans++;}
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int n;
	scanf("%d",&n);
	printf("%d\n",a[n]);
	return 0;
}

Measured memory_bytes: 256
X = gets.to_i

i = case X
  when (400...600); 8
  when (600...800); 7
  when (800...1000); 6
  when (1000...1200); 5
  when (1200...1400); 4
  when (1400...1600); 3
  when (1600...1800); 2
  when (1800...2000); 1
  end

puts i

Measured memory_bytes: 14292
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, n);
	vector<LL> a(n);
	cin >> a;
	sort(RALL(a));
	LL sum = 0;
	inc1(i, n - 1) { sum += a[i / 2]; }
	OUT(sum);
}


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

typedef long long ll;

int main(){
  ll n;
  cin >> n;
  
  ll t,a;
  
  ll t_num = 1;
  ll a_num = 1;
  
  for(ll i=0; i<n; i++){
    cin >> t >> a;
    
    ll q = max(t_num / t + (t_num % t != 0), a_num / a + (a_num % a != 0));
    t_num = t * q;
    a_num = a * q;
  }
  
  cout << t_num + a_num << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,x,i,j,k,t_cases,sum,ans,flag;
	int C[12],A[12][12],level[12];
	cin >> n >> m >> x;
	for(i=0;i<n;i++)
	{
		cin >> C[i];
		for(j=0;j<m;j++)
			cin >> A[i][j];
	}
	ans = INT_MAX;
	t_cases = 1<<n;
	for(i=0;i<t_cases;i++)
	{
		sum =0;
		memset(level,0,12*sizeof(int));
		for(j=0;j<n;j++)
		{
			if(i>>j & 1)
			{
				sum += C[j];
				for(k=0;k<m;k++)
					level[k] += A[j][k];
			}
		}
		flag=1;
		for(j=0;j<m;j++)
		{
			if(level[j]<x)
				flag=0;
		}
		if(flag==1 and sum<ans)
			ans = sum;
	}
	if(ans==INT_MAX)
		cout << "-1\n";
	else
		cout << ans << endl;
	return 0;
}

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

int main(){

int n;
cin >> n;
int cntr=0;
vector<char> c(200010);
for(int i=0; i<n; i++){
    cin >> c[i];
    if(c[i]=='R') cntr++;
}
int r=0;
for(int i=0; i<cntr; i++){
    if(c[i]=='R') r++;
}
cout << cntr-r << endl;

}

Measured memory_bytes: 3612
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(){
	string days[7] = {"thu", "fri", "sat", "sun", "mon", "tue", "wed"};
	int X;
	cin >> X;
	cout << days[X%7] << "\n";
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "D"
int n;
int a[300001];
ll l[300001];
ll r[300001];
ll s[300001];
multiset <int> s1, s2;
multiset <int, greater<int> > s3, s4;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    FOR(i, 1, 3*n){
        read(a[i]);
        s[i]=s[i-1]+a[i];
    }
    FOR(i, 1, n) s2.insert(a[i]);
    ll now=0;
    FOR(i, n+1, 2*n){
        s2.insert(a[i]);
        while(s1.size()<i-n){
            s1.insert(*s2.begin());
            now+=*s2.begin();
            s2.erase(s2.begin());
        }
        while(*s2.begin()<*s1.rbegin()){
            now-=*s1.rbegin();
            s1.erase(--s1.end());
            s1.insert(*s2.begin());
            now+=*s2.begin();
            s2.erase(s2.begin());
        }
        l[i]=now;
    }
    DFOR(i, 3*n, 2*n+1) s4.insert(a[i]);
    now=0;
    DFOR(i, 2*n, n+1){
        s4.insert(a[i]);
        while(s3.size()<2*n+1-i){
            s3.insert(*s4.begin());
            now+=*s4.begin();
            s4.erase(s4.begin());
        }
        while(*s4.begin()>*s3.rbegin()){
            now-=*s3.rbegin();
            s3.erase(--s3.end());
            s3.insert(*s4.begin());
            now+=*s4.begin();
            s4.erase(s4.begin());
        }
        r[i]=now;
    }
    ll ans=-(1LL<<60);
    FOR(i, n, 2*n) ans=max(ans, (s[i]-l[i])-(s[3*n]-s[i]-r[i+1]));
    writeln(ans);
}

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

int main() {
    string ans = "No";
    int n;
    cin >> n;
    for (int i=0; i<30; i++) {
        for (int j=0; j<15; j++) {
            int place = i*4 + j*7;
            if (place == n) {
                ans = "Yes";
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

typedef pair<ll, ll> P;

bool check(vector<int> &tracks, int mid, int k) {
    int now_sum = 0;
    int c = 0;
    for (int i = 0; i < tracks.size(); i++) {
        int traffic = tracks[i];
        if (traffic > mid) return false;
        if (now_sum + traffic > mid) {
            c++;
            now_sum = traffic;
        } else {
            now_sum += traffic;
        }
    }
    return c < k;
}

int main() {

    int n, k;
    cin >> n >> k;
    vector<int> tracks(n);
    rep(i, n) cin >> tracks[i];

    int floor = 0, ceil = INF;

    while (floor + 1 < ceil) {
        int mid = (floor + ceil) / 2;
        bool b = check(tracks, mid, k);
        if (b) {
            ceil = mid;
        } else {
            floor = mid;
        }
    }

    cout << ceil << endl;
}



Measured memory_bytes: 3124
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static Scanner scanner = new Scanner();
    static int mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            if ((int)(i * 1.08) == n) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(":(");
    }

    public static void main(String[]$) {
        try {
            new Main().solve();
            System.out.flush();
        } catch (Throwable t) {
            System.out.flush();
            t.printStackTrace();
        }
    }
}

class System {
    static PrintWriter out = new PrintWriter(java.lang.System.out);

    static void exit() {
        java.lang.System.exit(0);
    }
}

class Scanner {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n, ans = 0;
    cin >> n;
    int i;
    for (i = 1; i <= n; i++) {
        string s;
        s = to_string(i);
        if (s.length() % 2 == 1)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char=小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define str string
#define please return
#define AC 0
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	int a, b, c;
	cin >> a >> b >> c;

	cout << (a - c) / (b + c) << rt;

	please AC;
}

Measured memory_bytes: 256
def main():
    INF = float("inf")

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

    dp = [INF] * (2 ** N)
    dp[0] = 0

    for _ in range(M):
        a, b = map(int, input().split())
        C = [int(i) for i in input().split()]
        mask = sum(1 << (c - 1) for c in C)
        for i, dpi in enumerate(dp):
            if dp[i | mask] > dpi + a:
                dp[i | mask] = dpi + a

    ans = dp[-1]
    print(-1 if ans == INF else ans)


if __name__ == '__main__':
    main()


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

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

void Main() {
	string str; cin >> str;
	int q; cin >> q;
	REP(i, q) {
		string cmd; cin >> cmd;
		int a, b;
		cin >> a >> b;
		if (cmd == "reverse") {
			string r_str = str.substr(a, b - a + 1);
			reverse(ALL(r_str));
			str = str.substr(0, a) + r_str + str.substr(b + 1, str.size() - b);
		} else if (cmd == "print") {
			cout << str.substr(a, b - a + 1) << endl;
		} else {
			string p;
			cin >> p;
			str = str.substr(0, a) + p + str.substr(b + 1, str.size() - b);
		}
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3228
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cassert>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

const int MAXN=1E3+5;
const int MAXM=2E3+5;

struct __edge{
    int nxt,v;
}Edge[MAXM];

int head[MAXN],cnt_e,siz[MAXN],n;
int f[MAXN][MAXN*5],t[MAXN*5],val[MAXN];

inline void add(int u,int v)
{
    Edge[++cnt_e].v=v;
    Edge[cnt_e].nxt=head[u];
    head[u]=cnt_e;
}

int dfs(int x,int fa)
{
    f[x][0]=0;
    for(int i=head[x];i;i=Edge[i].nxt)
    {
        if(Edge[i].v==fa) continue;
        int v=Edge[i].v,w=dfs(v,x);
        memcpy(t,f[x],sizeof t);memset(f[x],0x3f,sizeof f[x]);
        for(int j=0;j<=val[x];j++)
        {
            if(j+val[v]<=val[x]) f[x][j+val[v]]=min(f[x][j+val[v]],t[j]+w);
            if(j+w<=val[x]) f[x][j+w]=min(f[x][j+w],t[j]+val[v]);
        }
    }
    int ret=0x3f3f3f3f;
    for(int j=0;j<=val[x];j++) ret=min(ret,f[x][j]);
    return ret;
}

int main()
{
    scanf("%d",&n);
    for(int i=2,x;i<=n;i++) scanf("%d",&x),add(x,i),add(i,x);
    for(int i=1;i<=n;i++) scanf("%d",&val[i]);
    int ans=dfs(1,0);
    puts(ans==0x3f3f3f3f?"IMPOSSIBLE":"POSSIBLE");
    #ifdef LOCAL
        system("pause");
    #endif
}

Measured memory_bytes: 19456
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        
        while(scan.hasNext())
        {    
            int[][] areaArray = new int[21][21];
            int n = scan.nextInt();
            if(n==0)
                break;
            //宝石の場所
            for(int i=0;i<n;i++)
            {
                int x1 = scan.nextInt();
                int y1 = scan.nextInt();
                areaArray[y1][x1]=1;
            }
            int total = n;
            int getCount = 0;
            
            //ロボットの初期位置
            int x2 = 10;
            int y2 = 10;
            //ロボットにする命令
            int m = scan.nextInt();
            for(int i=0;i<m;i++)
            {
                String direct = scan.next();
                int kyori = scan.nextInt();

                //北に進む
                if(direct.equals("N"))
                {
                    for(int j=0;j<kyori;j++)
                    {
                        y2++;
                        if(areaArray[y2][x2]==1)   
                        {
                            getCount++;
                            areaArray[y2][x2]=0;
                        }
                    }
                }
                //東に進む
                else if(direct.equals("E"))
                {
                    for(int j=0;j<kyori;j++)
                    {
                        x2++;
                        if(areaArray[y2][x2]==1)   
                        {
                            getCount++;
                            areaArray[y2][x2]=0;
                        }
                    }
                }
                //南に進む
                else if(direct.equals("S"))
                {
                    for(int j=0;j<kyori;j++)
                    {
                        y2--;
                        if(areaArray[y2][x2]==1)   
                        {
                            getCount++;
                            areaArray[y2][x2]=0;
                        }
                    }
                }
                //西に進む
                else if(direct.equals("W"))
                {
                    for(int j=0;j<kyori;j++)
                    {
                        x2--;
                        if(areaArray[y2][x2]==1)   
                        {
                            getCount++;
                            areaArray[y2][x2]=0;
                        }
                    }
                }
            }
            if(total==getCount)
                System.out.println("Yes");
            else
                System.out.println("No");
            
        }
    }
}

Measured memory_bytes: 35168
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_set>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  vector<ll>a(x+1),b(y+1),c(z+1);
  rep(i,x)cin>>a[i];
  rep(i,y)cin>>b[i];
  rep(i,z)cin>>c[i];
  a[x]=(-(ll)1e17);
  b[y]=(-(ll)1e17);
  c[z]=(-(ll)1e17);
  sort(all(a),greater<ll>());
  sort(all(b),greater<ll>());
  sort(all(c),greater<ll>());
  priority_queue<pair<ll,int>>q;
  set<int> ma;
  q.push({a[0]+b[0]+c[0],0});
  rep(i,k)
  {
    auto tq=q.top();q.pop();
    int x[3]={tq.second&1023,tq.second>>10&1023,tq.second>>20&1023};
    int ts;
    rep(j,3)
    {
      x[j]++;
      if(!ma.count(ts=tq.second+(1<<(10*j)))){ma.insert(ts);q.push({a[x[2]]+b[x[1]]+c[x[0]],ts});};
      x[j]--;
    }
    cout<<tq.first<<"\n";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 768
// AtCoder Regular Contest 065
// D - 連結 / Connectivity

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> PII;


class UnionFind {
    public:
        vector<int> data;
        void init(int size) {
            data = vector<int>(size, -1);
        }
        bool unite(int x, int y) {
            x = root(x); y = root(y);
            if (x == y) {
                return false;
            }
            if (data[y] < data[x]) {
                swap(x, y);
            }
            data[x] += data[y];
            data[y] = x;

            return true;
        }
        bool same(int x, int y) {
            return root(x) == root(y);
        }
        int root(int x) {
            return data[x] < 0 ? x : data[x] = root(data[x]);
        }
        int size(int x) {
            return -data[root(x)];
        }
};


int N, KL[2];
UnionFind uf[2];
map<PII, int> mp;

int main() {

    PII p;
    int a, b;

    scanf("%d%d%d", &N, &KL[0], &KL[1]);
    for (int j = 0; j < 2; j++) {
        uf[j].init(N);
        for (int i = 0; i < KL[j]; i++) {
            scanf("%d%d", &a, &b);
            uf[j].unite(a - 1, b - 1);
        }
    }

    for (int i = 0; i < N; i++) {
        p = PII(uf[0].root(i), uf[1].root(i));
        mp[p] = mp[p] + 1;
    }

    for (int i = 0; i < N; i++) {
        p = PII(uf[0].root(i), uf[1].root(i));
        printf("%d%c", mp[p], i == N - 1 ? '\n' : ' ');
    }

    return 0;

}





Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n,a,b; cin >> n;
  if (n == 2) {
    int a,b;
    cin>>a>>b;
    COUT(a+b);
  } else COUT("Hello World");
  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 SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int n,m;
	string s,t;
	cin >> n;
	map<string, int> mp;
	REP(i,n){
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	REP(i,m){
		cin >> t;
		mp[t]--;
	}
	int ans = 0;
	for(auto a : mp) ans = max(ans,a.second);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define INF 100000000

const int MOD = 1e9+7;
typedef long long ll;
using namespace std;
const ll M = 998244353;


int main(void) {
	string s;
	cin >> s;
	if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3628
import java.util.*

fun main(args: Array<String>) {
	val scan = Scanner(System.`in`)
	val a = scan.nextInt()
	val b = scan.nextInt()
	val c = scan.nextInt()

	var num = 0
	for (i in a..b) {
		if (c % i == 0) num++
	}
	println(num)
}


Measured memory_bytes: 25640