akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;


namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            int n = int.Parse(Console.ReadLine());
            var A = cin.SplitReader();

            List<Pair<int>> ans = new List<Pair<int>>();
            for(var i = 0; i < n; i++)
            {
                ans.Add(new Pair<int>(A[i], i + 1));
            }

            ans.Sort();
            foreach(var p in ans)
            {
                Console.Write($"{p.index} ");
            }
            
            
            //Console.Out.Flush();
        }

        struct Edge
        {
            public int _to;
            public long _distance;

            public Edge(int t, long d)
            {
                _to = t;
                _distance = d;
            }
        }


    }
    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

   public static class Tool
        {
            static public void Initialize<T>(ref T[] array, T initialvalue)
            {
                for (var i = 0; i < array.Length; i++)
                {
                    array[i] = initialvalue;
                }
            }
            static public long ModuloP(long value, long mod)
            {
                long r = value % mod;

                if (r * mod < 0)
                {
                    r += mod;
                }
                return r;
            }

        }

   struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
   {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
   }

    


}






Measured memory_bytes: 29652
#ifndef _WIN32
#include<iostream>
#endif 

#include<cmath>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

#define FOR(i,bg,ed) for(int i = (bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
struct cww {
	cww() {
		ios::sync_with_stdio(false);
		cin.tie(0);
	}
}star;
template<typename T>
istream & operator>> (istream &is, vector<T>&v) {
	for (auto &it : v)is>> it;
	return is;
}
char f(char c) {
	if (c == 'a')return 'Z';
	if (c == 'A')return 'z';
	return c - 1;
}
int main() {
	int n;
	while (cin >> n, n) {
		vector<int> k(n);
		cin >> k;
		string s;
		cin >> s;
		int id = 0;
		for (auto &c : s) {
			REP(i,k[id]) {
				c = f(c);
			}
			id++;
			id %= n;

		}
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 3156
var perm=[];
var flag=[];
for(var i=0;i<4;i++)flag[i]=false;
var cnt=0;
for(var i=0;i<4;i++){flag[i]=true;
for(var ii=0;ii<4;ii++){if(flag[ii])continue;flag[ii]=true;
for(var iii=0;iii<4;iii++){if(flag[iii])continue;flag[iii]=true;
for(var iiii=0;iiii<4;iiii++){if(flag[iiii])continue;
perm[cnt]=[i,ii,iii,iiii];
cnt++;
}flag[iii]=false;
}flag[ii]=false;
}flag[i]=false;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');

var Arr=(input.trim()).split("\n");
while(true){
var abcd=Arr.shift();
if(abcd=="0 0 0 0")break;
var ary=abcd.split(" ").map(Number);
var ans=0;
var s=["+","-","*"];
for(var i=0;i<3;i++){
for(var j=0;j<3;j++){
for(var k=0;k<3;k++){
perm.forEach(function(v){
var a=ary[v[0]];
var b=ary[v[1]];
var c=ary[v[2]];
var d=ary[v[3]];
if(ans==0 && eval(a+s[i]+b+s[j]+c+s[k]+d)==10)ans=a+s[i]+b+s[j]+c+s[k]+d;
if(ans==0 && eval("("+a+s[i]+b+s[j]+c+")"+s[k]+d)==10)ans="("+a+s[i]+b+s[j]+c+")"+s[k]+d;
if(ans==0 && eval("("+a+s[i]+b+")"+s[j]+"("+c+s[k]+d+")")==10)ans="("+a+s[i]+b+")"+s[j]+"("+c+s[k]+d+")";
if(ans==0 && eval("("+"("+a+s[i]+b+")"+s[j]+c+")"+s[k]+d)==10)ans="("+"("+a+s[i]+b+")"+s[j]+c+")"+s[k]+d;
});
}
}
}

if(ans!=0)ans="("+ans+")";
console.log(ans);
}

Measured memory_bytes: 26820
#include <iostream>
#include <cmath>

int main(int argc, char const* argv[]) {
    std::ios::sync_with_stdio(false);
    long N;
    std::cin >> N;
    int len = std::log10(N) + 1;
    std::cout << (len - 1) * 9 + (N+1) / (long)(std::pow(10, len-1)) - 1 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <locale>
#include <iostream>
using namespace std;
int main(void){
 
    string a,b,c;
    cin>>a>>b>>c;
    int d,e;
    d=a.size();
    e=b.size();
    if(a[d-1]==b[0]&&b[e-1]==c[0]){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    
}
    // 

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	int weight[]={2,3,5,10,12,15};
	int price[]={380,550,850,1520,1870,2244};
	
	vi dp(51,1<<29);
	rep(i,6)
		dp[weight[i]]=price[i];
	rep(i,6)
		repi(j,weight[i],51)
			dp[j]=min(dp[j],dp[j-weight[i]]+price[i]);
	
	for(int n;cin>>n,n;)
		cout<<dp[n/100]<<endl;
	
	return 0;
}

Measured memory_bytes: 0
#B - Exponential
import math
X = int(input())
def expo(x):
    ans = 1
    for i in reversed(range(1,x+1)):
        for j in range(int(math.sqrt(x))+1):
            for k in range(2,int(math.sqrt(x))):
                if i == j**k:
                    ans = i
                    return ans
    return ans
print(expo(X))

Measured memory_bytes: 9116
#include <stdio.h>
int max1(int z,int m,int n);
int main(int argc, char *argv[])
{
	int a,b,m,n,x,max;
	scanf("%d%d",&a,&b); 
	m=a+b;
	n=a-b;
	x=a*b;
	max1(m,n,x);
	return 0;
} 
int max1(int z,int m,int n)
{
	int max;
	max=z;
	if(max<m||max<n)
	{
		if(m>n)max=m;
		else max=n;
	}
	printf("%d\n",max);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string N;
    cin >> N;
    int l = N.length();
    int k[l];
    for (int i = 0; i < l; i++) {
        k[i] = N[i] - '0';
    }
    int d[l][2]{};
    d[0][0] = k[0];
    d[0][1] = 10 - k[0] + 1;
    
    for (int i = 1; i < l; i++) {
        d[i][0] = min(d[i - 1][0] + k[i], d[i - 1][1] + k[i]);
        d[i][1] = min(d[i - 1][0] + 10 - k[i] + 1, d[i - 1][1] + 10 - k[i] - 1);
    }
    cout << min(d[l - 1][0], d[l - 1][1]) << "\n";
    for (int i = 0; i < l; i++) {
        // printf("%d %d\n", d[i][0], d[i][1] + 1);
    }
    return 0;
}

Measured memory_bytes: 13060
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	multiset<int>a;
	int sum = 0,co=0;
	for (int z = 0; z < m; z++) {
		int b, c;
		cin >> b >> c;
		if (b >= n)
			co++;
		else {
			a.insert(n - b);
		}
	}
	set<int>::iterator it=a.begin();
	while (co < m - 1) {
		sum += (*it);
		it++;
		co++;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int n;
	int a[200];
	int i;
	cin >> n;
	rep(i, n)
		cin >> a[i];
	int count = 0;
	bool f = true;
	while(f) {
		rep(i, n) {
			if (a[i] % 2 == 1 || a[i] == 0) {
				f = false;
				break;
			}
			a[i] = a[i] / 2;
		}
		if (f)
			count++;
	}
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    cout << z << " " << x << " " << y << endl;
 }



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

int main(){
    long n;
    cin >> n;
    for(long i = n;i < 10000000000;i += n){
        if((i%2 == 0) && (i%n == 0)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int m=2000000;
    vector<int> a(m);
    int n;cin>>n;
    rep(i,n){
        int t;cin>>t;a[t]++;
    }

    int ans=0;
    for(int i=1;i<=m;i++){
        if(a[i]==0) continue;
        for(int j=i+i;j<m;j+=i) a[j]=0;
        if(a[i]==1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	long long  n,i,cur,ans,res,tot;
	cin >> n;
	vector<long long> a(n+1);
	deque<long long> dq;
	//input
	tot=0;
	for(i=0; i<=n; i++){
		cin >> a[i];
		tot+=a[i];
	}
	
	//corner
	if(n==0){
		if(a[0]==1){
			cout << 1 << endl;
		}else{
			cout << -1 << endl;
		}
		return 0;
	}
	
	/*
	//judge
	cur=1; ans=0;
	for(i=0; i<=n; i++){
		if(cur<a[i]){
			cout << -1 << endl; return 0;
		}else{
			cur-=a[i];
			cur*=2;
		}
	}
	*/
	//count
	ans=0; res=1; 
	for(i=0; i<=n; i++){
		ans+=res;
		tot-=a[i]; res-=a[i];
		res=min(res*2,tot);
		if(res<0){
			cout << -1 << endl; return 0;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  lol a[n + 5];
  rep(i, n){
    cin >> a[i];
  }
  for(int i = k;i < n;i ++){
    //cout << a[i - k] << " ";
    if(a[i] > a[i - k]){
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
  return 0;
}


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

using namespace std;

int frog(vector<int>& cost,int k){
    int n=cost.size();
    vector<int> dp(cost.size(),INT_MAX);
    dp[cost.size()-1]=0;
    dp[cost.size()-2]=abs(cost[cost.size()-1]-cost[cost.size()-2]);
    for(int i=cost.size()-3;i>=0;i--){
        for(int j=i+1;j<=min(n-1,i+k);j++){
            dp[i]=min(dp[i],dp[j]+abs(cost[i]-cost[j]));
        }
    }
    return dp[0];
}

void atcoder(){
  int n,k;
  cin>>n>>k;
  vector<int> arr(n);
  for(int i=0;i<n;i++) {
      cin>>arr[i];
  }
  cout<<frog(arr,k);    
}

int main(){
    atcoder();
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ins insert
#define Pq priority_queue
#define u_set unordered_set
#define MOD 1000000007
#define MAXN 100001
#define set_val(arr,v) memset(arr, v, sizeof(arr))
#define FOR(i,from,to) for(int i=from; i<to; i++)
#define FOL(i,from,to) for(int i=from; i>=to; i--)
#define B() begin()
#define E() end()
#define F first
#define S second


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

	vector<int> r;
	FOR(i,0,k) {
		r.pb(s);
	}
	FOR(i,k,n) {
		r.pb(rand()%MOD);
	}
	for(auto x : r) cout << x << " ";
	cout << endl;
	return 0; 
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  int N = 0,M = 0,a = 0, b = 0;
  cin >> N;
  a = N / 500;
  M = N % 500;
  b = M / 5;
  cout << a * 1000 + b * 5;
}

Measured memory_bytes: 256
#


def main():
    n, m = map(int, input().split(" "))
    count = 0
    if n > 1:
        count += (n * (n - 1) // 2)
    if m > 1:
        count += (m * (m - 1) // 2)
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include<bits/stdc++.h>
#include<unordered_map>
#include<vector>
#define ll long long
using namespace std;
int main(){
   ll n;
   cin>>n;
   ll q=n/1000;
   ll r=n%1000;
   if(r==0)
    cout<<0<<endl;
  else
   cout<<(q+1)*1000-n<<endl;
   
   return 0;
    
}


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

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

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; }

ll n,x,t;
string s;
int main() {
    INIT();

    cin >> s;
    for(auto&& c : s) {
        n += c - '0';
    }
    if(n % 9 == 0) {
        cout << "Yes";
    } else {
        cout << "No";
        
    }
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

int x,y;

void solve(){
    scanf("%d %d", &x, &y);
    if(y&1){
        printf("No\n");
        return;
    }
    if((y-2*x)/2<0 || (y-2*x)/2 > x){
        printf("No\n");
    }    
    else printf("Yes\n");
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 3732
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	cin >> N;
	vector<ll> A(N+2);
	A[0] = A[N+1] = 0;
	for(int i=0;i<N;i++) cin >> A[i + 1];
	
	ll tot = 0;
	for(int i=0;i<N+1;i++) tot += abs(A[i] - A[i+1]);
	
	for(int i=1;i<=N;i++){
		cout << tot - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1]) << endl;
	}
	
	
	
	
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=true;
// const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x,y;
    cin>>n>>x>>y;
    x--;y--;
    ll lim = 1e+15;
    vector<vector<ll>> mat(n,vector<ll>(n,lim));
    vector<vector<ll>> nbs(n,vector<ll>());
    rep(i,n) {
        mat[i][i] = 0;
        if (i<n-1) {
            nbs[i].push_back(i+1);
            nbs[i+1].push_back(i);
            mat[i][i+1] = 1;
            mat[i+1][i] = 1;
        }
    }
    mat[x][y] = mat[y][x] = 1;
    nbs[x].push_back(y);
    nbs[y].push_back(x);
    vector<ll> cnt(n+2,0);
    rep(i,n) {
        vector<ll> dist(n,lim);
        dist[i] = 0;
        priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> pq;
        pq.emplace(0,i);
        while(!pq.empty()) {
            auto now = pq.top();
            pq.pop();
            if (now.first>dist[now.second]) {continue;}
            for(auto x: nbs[now.second]) {
                if (dist[x]>now.first + mat[x][now.second]) {
                    dist[x] = now.first + mat[x][now.second];
                    pq.emplace(dist[x], x);
                }
            }
        } 
        rep(i,n) {
            cnt[dist[i]]++;
        }
    }
    rep(i,n-1) {
        cout << cnt[i+1]/2 << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> img(N);
  vector<string> tmp(M);
  for (int i = 0; i < N; ++i) cin >> img[i];
  for (int i = 0; i < M; ++i) cin >> tmp[i];
  string res = "No";
  for (int i = 0; i < N - M + 1; ++i) {
    for (int j = 0; j < N - M + 1; ++j) {
      int diff = 0;
      for (int y = 0; y < M; ++y) {
        for (int x = 0; x < M; ++x) {
          if (img[i + y][j + x] != tmp[y][x]) diff++;
        }
      }
      if (diff == 0) res = "Yes";
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <functional>
#include <map>
#include <numeric>
#include <random>
#include <vector>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	int n, k;
	cin >> n >> k;
	
	long double ans = 0;
	for (int i = 1; i <= n; ++i) {
		long double tmp = 1.0 / n;
		int now = i;
		while (now < k) {
			now *= 2;
			tmp /= 2;
		}
		ans += tmp;
	}
	cout << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
Q, H, S, D = map(int, input().split(" "))
N = int(input())

A = [Q, H, S, D]
B = [0.25, 0.5, 1, 2]
M = [Q*4, H*2, S, D/2]

result = 0
for i in range(4):
    m = min(M)
    j = M.index(m)
    M.remove(m)
    b = B[j]
    n = N%B[j]
    if b == 0.25:
        result += N*4*A[j]
    elif b == 0.5:
        result += N*2*A[j]
    else:
        result += N//B[j]*A[j]
    if n == 0:
        break
    N = n

print(result)


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

int main() {
    ll n;
    cin >> n;

    ll ans = 0;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) ans = i;
    }

    cout << ans + n / ans - 2 << endl;
    return 0;
}


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

main() {
  int A,B,C;
  cin >>A>>B>>C;
  for(int i=1;i<=B;++i){
    if(i*A%B==C){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var m = int.Parse(_[1]);
            var a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            var total = a.Sum();
            if((n - total) >= 0){
                Console.WriteLine(n - total);
            }else{
                Console.WriteLine(-1);
            }
        }
    }
}


Measured memory_bytes: 29104
#include <cstdio>

int K, N;
int A;
int g, b;
int main()
{
    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; i++){
      scanf("%d",&A);
    }

    int ans = 0;

    if(K == N){
      ans = 1;
    }
    else if(N / 2 < K && K < N){
      ans = 2;
    }
    else{
      int i = 1;
      while(i*(K - 1) + 1 < N){
        i++;
      }
      ans = i;
    }

    printf("%d", ans);

}


Measured memory_bytes: 128
a , b ,c ,d ,e = map(int, input().strip().split())
 
list = []
list.append(a)
list.append(b)
list.append(c)
list.append(d)
list.append(e)
count = 0
for i in range(0, len(list)):
    if list[i]==0:
        count = i+1
        break
print(count)

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<numeric>

#define REP(i, a) for(int i=0;i<(int)a;++i)
#define INF 1145141919;
typedef long long ll;
typedef long double ld;
using namespace std;

int H, W;
vector<ll> a;

void solver() {
    while (cin >> H >> W) {
        if (H == 0 && W == 0)break;
        REP(h, H) {
            REP(w, W) {
                printf("%c", ((w + h) & 1) ? '.' : '#');
            }
            printf("\n");
        }
        printf("\n");
    }
}

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

Measured memory_bytes: 3048
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  double ans = 0;
  for(int i = 0; i < n - 1; i++) {
    ans = (a[0] + a[1]) / 2.0;
    a.erase(a.begin());
    a.erase(a.begin());
    a.push_back(ans);

    sort(a.begin(), a.end());
  }
  //cout << ans << endl;
  printf("%.10f\n", a[0]);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;




int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  int l[Q], r[Q];
  for (int i = 0; i < Q; i++) {
    cin >> l[i] >> r[i];
  }
  
  int count[N];
  count[0]= 0;
  int idx = 1;
  while( idx < N){
    if(S[idx-1]=='A'&&S[idx]=='C'){
      count[idx] = count[idx-1]+1;
    } else {
      count[idx] = count[idx-1];
    }
    idx++;
  }

  for (int i = 0; i < Q; i++) {
    cout << count[r[i]-1] - count[l[i]-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 4904
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    string s;
    cin>>n>>a>>b;
    cin>>s;
    int i,pass=0,orank=0;
    for(i=0;i<n;i++){
        if(s[i]=='c')
        {cout<<"No"<<endl;
        }
        else if(s[i]=='a')
        {   if(pass<(a+b))
            {cout<<"Yes"<<endl;
            pass++;
            }
         else 
        cout<<"No"<<endl;
        }
        else if(s[i]=='b')
        {
            if(pass<(a+b) && (orank<b))
            {cout<<"Yes"<<endl;
            pass++;
            orank++;
            }
        else 
        cout<<"No"<<endl;  
        }
        
    }
}

Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	bool c[8] = {};
	ll N; cin >> N;
	ll o = 0;

	rep(i, 0, N) {
		ll a; cin >> a;
		if (a < 400) c[0] = true;
		else if (a < 800) c[1] = true;
		else if (a < 1200) c[2] = true;
		else if (a < 1600) c[3] = true;
		else if (a < 2000) c[4] = true;
		else if (a < 2400) c[5] = true;
		else if (a < 2800) c[6] = true;
		else if (a < 3200) c[7] = true;
		else if (a >= 3200) o++;
	}

	ll cnt = 0;
	rep(i, 0, 8) {
		if (c[i])cnt++;
	}

	if (cnt == 0) {
		cout << 1 << " ";
	}
	else {
		cout << cnt << " ";
	}

	cout << cnt + o << endl;
	//cout << min((cnt + o), (ll)8) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll m1; ll d1;
    ll m2; ll d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (m1 == m2){
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
 * Aizu Online Judge
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 *
 * @author yoshkur
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			InputData inputData = new InputData(br);
			Processing processing = new Processing(inputData);
			System.out.println(processing.getResult());

		} catch (IOException | NumberFormatException e) {
			System.err.println(e.getLocalizedMessage());
		}
	}
}

class InputData {

	private Integer W;
	private Integer H;
	private Integer x;
	private Integer y;
	private Integer r;

	public InputData(BufferedReader br) throws IOException {
		String line = br.readLine().trim();
		String[] values = line.split(" ");
		this.W = Integer.valueOf(values[0]);
		this.H = Integer.valueOf(values[1]);
		this.x = Integer.valueOf(values[2]);
		this.y = Integer.valueOf(values[3]);
		this.r = Integer.valueOf(values[4]);
	}

	public Integer getW() {
		return W;
	}

	public void setW(Integer W) {
		this.W = W;
	}

	public Integer getH() {
		return H;
	}

	public void setH(Integer H) {
		this.H = H;
	}

	public Integer getX() {
		return x;
	}

	public void setX(Integer x) {
		this.x = x;
	}

	public Integer getY() {
		return y;
	}

	public void setY(Integer y) {
		this.y = y;
	}

	public Integer getR() {
		return r;
	}

	public void setR(Integer r) {
		this.r = r;
	}

}

class Processing {

	private InputData inputData;

	public Processing(InputData inputData) {
		this.inputData = inputData;
	}

	public String getResult() {
		String result = null;
		if (this.inputData.getR() > this.inputData.getX() 
				|| this.inputData.getR() > this.inputData.getY() 
				|| this.inputData.getR() + this.inputData.getX() > this.inputData.getW() 
				|| this.inputData.getR() + this.inputData.getY()> this.inputData.getH()) {
			result = "No";
		} else {
			result = "Yes";
		}
		
		return result;
	}
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

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

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M)  //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) {           //bit計算
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) {   //素数判定
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

signed main() {
    string s;
    cin >> s;
    for (int i = 1; i < s.length(); i++) {
        if (i > 0 && s[i] == 'C' && s[i - 1] == 'B') {
            s.replace(i - 1, 2, "D");
            i -= 1;
        }
    }
    int count = 0;
    int ans = 0;
    for (int i = s.length() - 1; i >= 0; i--) {
        if (s[i] == 'D') {
            count++;
        } else if (s[i] == 'A') {
            ans += count;
        } else {
            count = 0;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 644
d = int(input())
l = []
c = 0
flag = False
for i in range(d):
  a,b = list(map(int,input().split()))
  l.append([a,b])
for i in range(d):
  if l[i][0] == l[i][1]:
    c += 1
    if c >= 3:
      flag = True
  else:
    c = 0
if flag == True:
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	deque<ll> a;
	ll n;
	cin >> n;
	FOR(i,0,n){
		ll k;
		cin >> k;
		if(i%2){
			a.push_back(k);
		}else{
			a.push_front(k);
		}
	}
	if(n%2==0)REV(a);
	for(auto x:a){
		cout << x << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3840
#include<stdio.h>

int main(){
	int num[100],i=0,count,same[100]={0},max=0,max_name[100]={0},j=0,k,key;
	
	while(scanf("%d",&num[i])!=EOF){i++;}
	count=i;
	
	for(i=0;i<count;i++){
		for(j=0;j<count;j++){
			if(num[i]==num[j])same[i]++;
		}
	}
	
	j=0;
	
	for(i=0;i<count;i++){
		if(max<same[i]){
			max=same[i];
		}
	}
	
	for(i=0;i<count;i++){
		if(max==same[i]){
			max_name[j]=num[i];
			++j;
		}
	}
	
	for(i=0;i<j;i++){
		for(k=i+1;k<j;k++){
			if(max_name[i]==max_name[k])max_name[k]=0;
		}
	}
	
	for(i=0;i<j;++i){
		for(k=0;k<(j-i);++k){
			if(num[k]>=max_name[k+1]){
				key=max_name[k];
				max_name[k]=max_name[k+1];
				max_name[k+1]=key;
			}
		}
	}
	
	for(i=0;i<=j;i++){
		if(max_name[i]!=0)printf("%d\n",max_name[i]);
	}
	
return 0;
}

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

int main() {
  int a,b;
  cin >> a>>b;
  if (a==1) a=14;
  if (b==1) b=14;
  if (a>b) cout<<"Alice"<<endl;
  else if (b>a) cout << "Bob" << endl;
  else cout<<"Draw"<<endl;
}

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

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  if (S.size() + 1 == T.size() && S == T.substr(0, S.size())) {
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  } 
  
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
struct bisai{
    int begin;
    int end;
};
bisai a[1000005];
struct rule1{
    bool operator()(const bisai &s1,const bisai &s2){
        return s1.end<s2.end;
    }
};
int main(){
    int n,i,t=-2147483647,count=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i].begin>>a[i].end;
        a[i].begin-=a[i].end; 
        a[i].end=a[i].begin+(a[i].end<<1);
    }
    sort(a,a+n,rule1());
    for(i=0;i<n;i++){
        if(a[i].begin>=t){ 
            count++;
            t=a[i].end;
        }
    }
    cout<<count;
} 

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


ll memo[2020][2020];
int meke_comb(){
  for(int i = 0; i < 2020; i++){
    for(int j = 0; j < i+1; j++){
      if(j == 0 || j == i) memo[i][j] = 1;
      else{
	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
      }
    }
  }
  return 0;
}

ll comb(int n, int k){
  return memo[n][k];
}


int main(){
  meke_comb();
  int N,K;
  cin >> N >> K;
  for(int i = 1; i <= K; i++){
    int ans = (comb(N-K+1,i)*comb(K-1,i-1))%mod;
    cout << ans << endl;
  }
}



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

int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i,n) cin >> d[i];
	sort(d.begin(),d.end());
	int ans = 1;
	rep(i,n-1){
		if(d[i] != d[i+1]) ans++;
	}
	cout << ans << endl;
    return 0;
}



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

int main() {
  int n,m,l;
  cin >> n >> m >> l;
  vector<vector<int>> a(n,vector<int>(m));
  vector<vector<int>> b(m,vector<int>(l));
  vector<vector<ll>> c(n,vector<ll>(l));
  rep(i,n) {
    rep(j,m) {
      cin >> a[i][j];
    }
  }
  rep(i,m) {
    rep(j,l) {
      cin >> b[i][j];
    }
  }

  rep(i,n) {
    rep(j,l) {
      rep(k,m) {
        c[i][j] += a[i][k]*b[k][j];
      }
    }
  }
  rep(i,n) {
    rep(j,l) {
      if(j!=l-1) cout << c[i][j] << ' ';
      else cout << c[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
  int n, k;

  cin >> n >> k;

  vector<int> iv;
  int ans = 0;

  // vectorの初期化
  for (int i = 0; i <= n; i++) iv.push_back(0);

  for (int i = 1; i <= n; i++) {
    int x; cin >> x;
    iv[x] += 1;
  }

  // // ivの出力
  // cout << endl;
  // for (int i = 1; i <= n; i++) {
  //   cout << iv[i] << endl;
  // }

  sort(iv.begin(), iv.end());

  // // ivの出力
  // cout << "after sort" << endl;
  // for (int i = 1; i <= n; i++) {
  //   cout << iv[i] << endl;
  // }

  int start;

  // 0ではないivの要素の先頭のindexを探す
  for (int i = 1; i <= n; i++) {
    if (iv[i] != 0) {
      start = i;
      break;
    }
  }

  // cout << "start: " << start << endl;
  //
  // cout << iv[start] << endl;
  //
  if ((n - start + 1) > k) {
    for (int i = start; i < n + 1 - k; i++) {
      ans += iv[i];
    }
  }

  cout << ans << endl;

  return 0;
}


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

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

const int MAXN = 2e5;
const ll MOD = 1e9+7;

int N, K;
ll ans;

int main()
{
	int i, j;
	scanf("%d%d", &N, &K);

	ll a=0, b=0;
	for(i=0; i<=N; i++)
	{
		a+=i, b+=N-i;
		if(K-1<=i) ans=((ans+b-a+1)%MOD+MOD)%MOD;
	}
	printf("%lld\n", ans);
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
    // get values from input
    cin.tie(0);
    ios::sync_with_stdio(false);

    int S, W;
    cin >> S >> W;
    
    // main procedure

    // output
    WRITE_N(W >= S ? "unsafe" : "safe");

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprllf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(ll x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ll((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

struct STree { // example: range sum with range addition
	vector<ll> st,lazy;ll n;
	STree(ll n): st(4*n+5,0), lazy(4*n+5,0), n(n) {}
	void push(ll k, ll s, ll e){
		if(!lazy[k])return; // if neutral, nothing to do
		st[k]+=lazy[k]; // update st according to lazy
		if(s+1<e){ // propagate to children
			lazy[2*k]+=lazy[k];
			lazy[2*k+1]+=lazy[k];
		}
		lazy[k]=0; // clear node lazy
	}
	void upd(ll k, ll s, ll e, ll a, ll b, ll v){
		push(k,s,e);
		if(s>=b||e<=a)return;
		if(s>=a&&e<=b){
			lazy[k]+=v; // accumulate lazy
			push(k,s,e);return;
		}
		ll m=(s+e)/2;
		upd(2*k,s,m,a,b,v);upd(2*k+1,m,e,a,b,v);
		st[k]=max(st[2*k],st[2*k+1]); // operation
	}
	ll query(ll k, ll s, ll e, ll a, ll b){
		if(s>=b||e<=a)return -(1LL<<60); // operation neutral
		push(k,s,e);
		if(s>=a&&e<=b)return st[k];
		ll m=(s+e)/2;
		return max(query(2*k,s,m,a,b),query(2*k+1,m,e,a,b));
	}
	void upd(ll a, ll b, ll v){upd(1,0,n,a,b,v);}
	ll query(ll a, ll b){return query(1,0,n,a,b);}
}; // usage: STree rmq(n);rmq.init(x);rmq.upd(s,e,v);rmq.query(s,e);

const ll N=2e5+5;
ll n,m;
vector<pair<ll,ll> > g[N];
ll dp[N];

int main(){FIN;
	cin>>n>>m;
	STree st(n+1);
	fore(x,0,m){
		ll l,r;ll v;cin>>l>>r>>v;
		g[l].pb({r,v});
	}
	for(auto p:g[n])st.upd(n,p.fst+1,p.snd);
	for(ll x=n-1; x>=0; x--){
		dp[x] = st.query(x,n+1);
		st.upd(x,x+1,dp[x]);
		for(auto p:g[x])st.upd(x,p.fst+1,p.snd);
	}
	cout << dp[0] << "\n";
}

Measured memory_bytes: 25472
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int k = scan.nextInt();
		int[] a = new int[n];
		int[] b = new int[m];
		for(int i = 0;i < n; ++i){
			a[i] = scan.nextInt();
		}

		for(int i = 0;i < m; ++i){
			b[i] = scan.nextInt();
		}

		long time = 0;//be needed time to read all of A
		for(int i = 0;i < n;++i){
			time += a[i];
		}

		int index_a = n;
		int ans = 0;
		for(int i = 0;i < m+1; ++i){
			while(index_a > 0 && time > k){
				--index_a;
				time -= a[index_a];
			}
			if(time > k)break;
			ans = Math.max(ans, index_a + i);
			if(i == m)break;
			time += b[i];
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 61744
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,W=map(int,input().split())
    w0,v=map(int,input().split())
    V=[[] for _ in range(4)]
    V[0].append(v)
    for _ in range(n-1):
        w,v=map(int,input().split())
        V[w-w0].append(v)
    for i in range(4):
        V[i].sort(reverse=1)
        V[i].insert(0,0)
        for j in range(len(V[i])-1):
            V[i][j+1]+=V[i][j]

    ans=0
    from itertools import product
    for a,b,c,d in product(range(len(V[0])),range(len(V[1])),range(len(V[2])),range(len(V[3]))):
        v=V[0][a]+V[1][b]+V[2][c]+V[3][d]
        if(a*w0+b*(w0+1)+c*(w0+2)+d*(w0+3)<=W): ans=max(ans,v)
    print(ans)
resolve()

Measured memory_bytes: 41324
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int snuke[110];

int main(){
    int n, k;
    cin >> n >> k;
    rep(i, k){
        int d;
        cin >> d;
        rep(j, d){
            int a;
            cin >> a;
            snuke[a] ++;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(snuke[i] == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    N -= 1;
    string ans;

    while (N >= 0)
    {    
        ans.push_back((N % 26) + 'a');
        N /= 26;
        N -= 1;
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

template <typename T>
T MODpow(T x, T n, T MOD = 1000000007) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * x;
        x = x * x;
        n >>= 1;
    }
    return res;
}

signed main(){
    ll n;
    cin >> n;
    if(n % 2 == 1) cout << 0 << endl;
    else{
        ll ans = 0;
        for(ll i = 1; i <= 30; i++){
            if(MODpow<ll>(5, i, MOD) > LINF) break;
            ans += n / (2 * MODpow<ll>(5, i, MOD));
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  double a,b,x,h,ans;
  cin >> a >> b >> x;
  if(2*x/(a*a)-b > 0){
    h = 2*x/(a*a)-b;
    ans = atan((b-h)/a);
  }
  else{
    h = 2*x/(a*b);
    ans = atan(b/h);
  }
  cout << fixed;
  cout << setprecision(9) << ans*180/M_PI << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){

	int N;
	cin>>N;
	
	vector<vector<int>> A(N,vector<int>(N));
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cin>>A[i][j];
		}
	}
	
	long long ans = 0;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			bool f = false;
			for(int k=0;k<N;k++){
				if(i==j||j==k||k==i)continue;
				if(A[i][k] + A[k][j] < A[i][j]){
					cout<<-1<<endl;
					return 0;
				}
				if(A[i][k] + A[k][j] == A[i][j])f=true;
			}
			if(!f){
				ans += (long long)A[i][j];
			}
			
		}
	}
	
	cout<<ans/2<<endl;
	
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;

int n, h[100500], dp[100500];

void solve() {       
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout << dp[n];
}           
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>


using namespace std;


int main() {

	string w;

	cin >> w;

	for (int i = 0; i < w.size(); i++) {
		int cnt = 0;
		for (int k = 0; k < w.size(); k++) {
			if (w[i] == w[k]) {
				cnt++;
			}
		}
		if (cnt % 2 != 0) {
			cout << "No" << endl;
			return 0;

		}
	}
	
	cout << "Yes" << endl;
	return 0;

}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int D, G;
  int p[11];
  i64 c[11];

  cin >> D >> G;
  G /= 100;

  for (int i = 1; i <= D; ++i) {
    cin >> p[i] >> c[i];
    c[i] /= 100;
  }

  vector<int> n(D);
  for (int i = 0; i < D; ++i) n[i] = i+1;

  int minv = INF;

  do {
    int tmp = G;
    int ans = 0;
    for (int i : n) {
      const int take = min((tmp + i - 1) / i, p[i]);
      tmp -= i * take + (take >= p[i] ? c[i] : 0);
      ans += take;
      if (tmp <= 0) break;
    }
    chmin(minv, ans);
  } while(next_permutation(ALL(n)));

  cout << minv << endl;

  return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll N; cin >> N;
	map<ll, ll> m;
	for (ll i = 0; i < N; ++i)
	{
		ll a; cin >> a;
		++m[a];
	}

	ll res{0};
	for (auto &p : m)
	{
		if (p.second > p.first)
			res += p.second - p.first;
		else if (p.second < p.first)
			res += p.second;
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;

vector<int>A, B;

void CountingSort(vector<int>& A, vector<int>& B, int k)
{
    vector<int> C(k+1);

    for (auto a: A) {
        C[a]++;
    }

    for (int i = 1; i <= k; i++) {
        C[i] += C[i - 1];
    }

    for (int i = A.size() - 1; i >= 0; i--) {
        B[C[A[i]]-1] = A[i];
        C[A[i]]--;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    A.resize(n), B.resize(n);
    int k = 0;
    rep(i, n)
    { 
        cin >> A[i]; 
        k = max(A[i], k);
    }
    CountingSort(A, B, k);
    rep(i, n)
    {
        if (i != 0) {
            cout << " ";
        }
        cout << B[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 18236
#include<bits/stdc++.h>
using namespace std;
#define int long long int
// #include"Template.cpp"

void solve() {
    int n; cin >> n;
    if(n>=30) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612