akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
//long long…2^64-1 = 9223372036854775807まで

void _main() {
	string ans = "Yes";

	ll N;
	cin >> N;
	
	vector<ll> H(N);
	rep(i, 0, N) cin >> H[i];

	ll Height = H[N-1];//数値以下にできないならNoの基準＆j=N-1の分
	if (N - 2 >= 0) {
		rrep(j, N - 2, 0) {
			//大きく、数値以下にできない場合・不可能
			if (Height < H[j] - 1) ans = "No";
			//大きいが、1引けば同じ数値にできる場合・変更なし
			//数値以下の場合・変更なし
			
			//数値より低い場合・H[j]にする
			if (Height > H[j]) Height = H[j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

int main(void)
{
	int l;
	scanf("%d", &l);

	printf("%lf", ((double)l * (double)l * (double)l) / 27.0);
	return 0;
}


Measured memory_bytes: 128
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF = (1LL << 31) - 1;
const double EPS = 1e-9;

struct SegmentTree {
    const int INF = (1LL << 31) - 1;
    vector<int> node;
    int n;
    SegmentTree(vector<int> a) {
        int n_ = a.size();
        n = 1;
        while(n < n_) n <<= 1;
        node.resize(2 * n - 1, INF);
        for(int i = 0; i < n_; i++) {
            node[n - 1 + i] = a[i];
        }
        for(int i = n - 2; i >= 0; i--) {
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
        }
    }
    void update(int i, int x) {
        i = n - 1 + i;
        node[i] = x;
        while(1) {
            if (i == 0) break;
            i = (i - 1) / 2;
            node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
        }
    }
    int find(int a, int b, int k = 0, int l = 0, int r = 0) {
        if (l >= r) r = n;
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return node[k];

        int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N, INF);
    SegmentTree seg(A);
    for (int q = 0; q < Q; q++) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            seg.update(x, y);
        } else {
            cout << seg.find(x, y + 1) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4708
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

    int n,k;
    cin>>n>>k;
    vi h(n);
    rep(i,n){
        cin>>h[i];
    }
    sort(all(h));

    int ans=0;
    rep(i,n-k){
        ans+=h[i];
    }

    cout<<ans<<endl;


}

Measured memory_bytes: 1792
I=lambda:map(int,input().split())
N,X=I()
w=[0]
for i in I():w+=[w[-1]+i]
print(min(5*w[N]+k*X+sum(2*w[j]for j in range(N-k*2,0,-k))for k in range(1,N+1))+N*X)

Measured memory_bytes: 27244
#include<bits/stdc++.h>
using namespace std;
#define int long long
const double Pi=acos(-1.0);
const int N=1000005;
double a,b,x;
signed main(){
	scanf("%lf%lf%lf",&a,&b,&x);
	if (x>=a*a*b/2){
		double x1=(a*a*b-x)/a*2/a;
		if (!x1)puts("0");
		else printf("%.10lf\n",90-atan(a/x1)*180/Pi);
	}
	else {
		double x1=2*x/a/b;
		printf("%.10lf\n",90-atan(x1/b)*180/Pi);
	}
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    private static int f(String i, String j, int n) {
        int r = 0;
        for (int k = 1; k <= n; k++) {
            String s = Integer.toString(k);
            if (s.substring(0, 1).compareTo(i) == 0 && s.substring(s.length() - 1).compareTo(j) == 0)
                r++;
        }
        return r;
    }

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = Integer.parseInt(scanner.next());
            int r = 0;
            for (int i = 0; i < 10; i++) {
                String is = Integer.toString(i);
                for (int j = 0; j < 10; j++) {
                    String js = Integer.toString(j);
                    r += f(is, js, n) * f(js, is, n);
                }
            }
            System.out.println(r);
        }
    }

}


Measured memory_bytes: 345348
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define nl '\n'

#define PI 3.14159265

using namespace std;

string s;
int x;

int main(){
    cin >> s;
    vector<int> v;
    for(int i = 0; i < s.length(); i++){
        v.push_back(s[i]);
    }

    x = ((s[5]-'0') * 10) + (s[6]-'0');

    if(x > 4){
        cout << "TBD";
    }else{
        cout << "Heisei";
    }

    





}

//g++ -std=c++14 comp.cpp -o b; ./b.exe


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


ll dp[202020][2];

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

	int N;
	cin >> N;
	vector<ll>A(N);
	for (int i = 0; i < N; i++)cin >> A[i];

	dp[1][0] = -inf;
	dp[1][1] = A[0];
	dp[2][0] = A[1];
	dp[3][0] = A[2];
	dp[3][1] = A[0] + A[2];
	for (int i = 4; i <= N; i++) {
		if (i % 2 == 0) {
			ll pre2 = dp[i-2][0];
			ll pre3 = dp[i-3][1];
			dp[i][0] = max(pre2,pre3) + A[i-1];
		}
		else {
			ll pre2_0 = dp[i-2][0];
			ll pre3_0 = dp[i-3][0];
			ll pre4_0 = dp[i-4][1];
			dp[i][0] = max(pre2_0,max(pre3_0,pre4_0)) + A[i - 1];
			dp[i][1] = dp[i-2][1] + A[i - 1];
		}
	}

	if (N % 2 == 0) {
		puts(max(dp[N][0],dp[N-1][1]));
	}
	else {
		puts(max(dp[N][0],max(dp[N-1][0],dp[N-2][1])));
	}

	return 0;
}

Measured memory_bytes: 7916
n = int(input())
a = list(map(int,input().split()))
flag = False
for i in range (n):
    if (a[i] % 2 == 0):
        if (a[i] % 3 == 0 or a[i] % 5 == 0):
            flag = False
        else:
            flag = True
            break
print ("DENIED" if flag else "APPROVED")

Measured memory_bytes: 3060
def solve():
    H,W,A,B=map(int,input().split())
    data=[[0]*W for i in range(H)]
    for i in range(B):
        for j in range(A):
            data[i][j]=1
    for i in range(B,H):
        for j in range(A,W):
            data[i][j]=1
    return data

data=solve()
for i in data:
    print(''.join(map(str,i)))

Measured memory_bytes: 12916
import java.util.Scanner;

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

		String str;

		while(sc.hasNext()){
			str = sc.next();
			char[] ch = str.toCharArray();

			for(int i = 0; i < ch.length; i++){
				if(ch[i] == '@'){
					for(int j = 0; j < ch[i + 1] - '0'; j++)
						System.out.print(ch[i + 2]);
					i += 2;
				}else{
					System.out.print(ch[i]);
				}
			}
			System.out.println();
		}
		sc.close();
	}
}

Measured memory_bytes: 17332
#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a;
    b=a%100;
    a/=100;
    bool A=(1<=a&&a<=12),B=(1<=b&&b<=12);
    if(A&&B) cout<<"AMBIGUOUS"<<endl;
    if(A&&!B) cout<<"MMYY"<<endl;
    if(!A&&B) cout<<"YYMM"<<endl;
    if(!A&&!B) cout<<"NA"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 2050

struct Info{
	bool operator<(const struct Info& arg) const{
		return loc < arg.loc;
	}
	bool can_warp;
	int loc,diff,need_time,next_node;
};

struct State{

	State(int arg_node_id,int arg_sum_dist){
		node_id = arg_node_id;
		sum_dist = arg_sum_dist;
	}
	bool operator<(const struct State &arg) const{
		return sum_dist > arg.sum_dist;
	}
	int node_id,sum_dist;
};

int L;
int N;
Info info[NUM];
int min_dist[NUM];
map<int,bool> first_MAP; //first_MAP[位置] = その位置にノードがある
map<int,int> MAP; //MAP[位置] = インデックス

int main(){

	scanf("%d %d",&L,&N);

	first_MAP[L] = true;
	bool is_zero = false;

	for(int i = 0; i < N; i++){

		scanf("%d %d %d",&info[i].loc,&info[i].diff,&info[i].need_time);
		first_MAP[info[i].loc] = true;
		info[i].can_warp = true;

		if(info[i].loc == 0){
			is_zero = true;
		}
	}
	info[N].can_warp = false;
	info[N].loc = L;

	int index;

	if(is_zero){

		index = N+1;

	}else{

		info[N+1].can_warp = false;
		info[N+1].loc = 0;
		index = N+2;
	}

	int warp_loc;

	//ワープ先が既存ノードか調べる
	for(int i = 0; i < N; i++){

		warp_loc = info[i].loc+info[i].diff;

		auto at = first_MAP.find(warp_loc);

		if(at == first_MAP.end()){ //存在しないノードを増やす

			first_MAP[warp_loc] = true;
			info[index].can_warp = false;
			info[index].loc = warp_loc;
			index++;
		}
	}
	sort(info,info+index);

	for(int i = 0; i < index; i++){

		MAP[info[i].loc] = i;
	}

	//エッジを張る
	for(int i = 0; i < index; i++){

		if(info[i].can_warp){

			warp_loc = info[i].loc+info[i].diff;
			info[i].next_node = MAP[warp_loc];

		}
	}

	min_dist[0] = 0;
	for(int i = 1; i < index; i++){
		min_dist[i] = BIG_NUM;
	}

	priority_queue<State> Q;
	Q.push(State(0,0));

	int next_node,next_dist;

	while(!Q.empty()){

		if(Q.top().sum_dist > min_dist[Q.top().node_id]){

			Q.pop();
		}else if(Q.top().node_id == index-1){

			printf("%d\n",Q.top().sum_dist);
			return 0;

		}else{

			//そのまま進む
			if(min_dist[Q.top().node_id+1] > Q.top().sum_dist+(info[Q.top().node_id+1].loc-info[Q.top().node_id].loc)){
				min_dist[Q.top().node_id+1] = Q.top().sum_dist+(info[Q.top().node_id+1].loc-info[Q.top().node_id].loc);
				Q.push(State(Q.top().node_id+1,min_dist[Q.top().node_id+1]));
			}
			if(info[Q.top().node_id].can_warp == true){
				next_node = info[Q.top().node_id].next_node;
				if(min_dist[next_node] > Q.top().sum_dist+info[Q.top().node_id].need_time){
					min_dist[next_node] = Q.top().sum_dist+info[Q.top().node_id].need_time;
					Q.push(State(next_node,min_dist[next_node]));
				}
			}

			Q.pop();
		}
	}

	return 0;
}



Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define long long long // for codeforces

int main(){
  int n,t;
  cin>>n>>t;
  vector<int> st(n),at(n);
  vector<string> sn(n),an(n);
  rep(i,n){
    int a,b;
    scanf("%d:%d", &a, &b);
    st[i] = a*60+b;
    cin>>sn[i];
    scanf("%d:%d", &a, &b);
    at[i] = a*60+b;
    cin>>an[i];
  }

  vector<string> as;
  vector<int> ai;
  rep(i,n-1){
    int x = st[i+1]-at[i];
    if(x >= t){
      as.pb(an[i]);
      ai.pb(x);
    }
  }

  cout << ai.size() << endl;
  rep(i,ai.size()) cout << as[i] << " " << ai[i] << "\n";

  return 0;
}

Measured memory_bytes: 3280
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
ll divp(ll a, ll b){
    if(a % b== 0) return (ll)0;
    else return (ll)1;
}
int main(){
    ll N;
    cin >> N;
    ll a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    ll ans = 0;
    ll ta, tb, tc , td, te;
    ta = N/a + divp(N, a);
    tb = N/b + divp(N, b) + 1;
    tc = N/c + divp(N, c) + 2;
    td = N/d + divp(N, d) + 3;
    te = N/e + divp(N, e) + 4;
    ll time[5] = {ta, tb, tc, td, te};
    ans = ta;
    for(int i = 1; i < 5; i++){
        if(ans < time[i]){
        ans = ans +  max(0LL, time[i] - ans);
        }else{
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
public static void main(String[]args){
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int i=1;
int b=0,c=0,d=0,e=0,f=0;
int z=0;
do {
	z=i;
	b=z%10;
	z/=10;
	c=z%10;
	z/=10;
	d=z%10;
	z/=10;
	e=z%10;
	z/=10;
	f=z%10;
	z/=10;
	
	if(i%3==0||b==3||c==3||d==3||e==3||f==3) {System.out.print(" "+i);}
	if(a==i) {break;}
	i++;
}while(true);
System.out.println();
}
}



Measured memory_bytes: 28528
#include <stdio.h>
#include <stdlib.h>

int main() {
  int i = 0;
  char s[7];
  char c;
  long a[100],temp;

  while(scanf("%s ", s) > 0) {
    c = s[0];
    if(c<'0' || c>'9') {
      switch (c) {
      case '+':
	temp = a[i-2] + a[i-1];
	break;
      case '-':
	temp = a[i-2] - a[i-1];
	break;
      case '*':
	temp = a[i-2] * a[i-1];
	break;
      default:
	break;
      }
      a[i-2] = temp;
      i = i-1;
    }else{
      a[i] = atol(s);
      i++;
    }
  }
  printf("%ld\n", a[0]);

  return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int K = 0;
    Scd(K);
    vector<int> E(K,INF);
    vector<bool> t(K,false);

    E[1] = 1;
    t[1] = true;
    deque<int> q;

    q.push_back(1);

    while( !q.empty() ){
        int from = q.front();
        q.pop_front();

        t[from] = true;
        int to;
        // +1
        to = ( from + 1 ) % K;
        if( !t[to] )
        if( E[from]+1 < E[to] ){
            E[to] = E[from]+1;
            q.push_back( to );
        }
        // *10
        to = ( from * 10 ) % K;
        if( !t[to] )
        if( E[from] < E[to] ){
            E[to] = E[from];
            q.push_front( to );
        }
    }

    printf ("%d\n", E[0] );

    return 0;
}



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

using real_number = double;
using point = complex< real_number >;
const real_number eps = 1e-5, pi = acos(-1);

istream &operator>>(istream &is, point &p) {
  real_number a, b;
  is >> a >> b;
  p = point(a, b);
  return is;
}

struct line {
  point a, b;

  line() = default;
  line(point a, point b) : a(a), b(b) {}
};

struct segment : line {
  segment() = default;
  segment(point a, point b) : line(a, b) {}
};

real_number cross(const point &a, const point &b) {
  return a.real() * b.imag() - a.imag() * b.real();
}

real_number dot(const point &a, const point &b) {
  return a.real() * b.real() + a.imag() * b.imag();
}

int ccw(const point &a, point b, point c) {
  b = b - a, c = c - a;
  if (cross(b, c) > eps) return +1;
  return 0; // sabori
}

bool intersect(const segment &s, const point &p) {
  return abs(abs(s.a-p)+abs(s.b-p)-abs(s.a-s.b))<eps;
  //return ccw(s.a, s.b, p) == 0;
}

point projection(const segment &s, const point &p) {
  double t = dot(p - s.a, s.a - s.b) / norm(s.a - s.b);
  return s.a + (s.a - s.b) * t;
}

real_number distance(const segment &s, const point &p) {
  point r = projection(s, p);
  if (intersect(s, r)) return abs(r - p);
  return min(abs(s.a - p), abs(s.b - p));
}

int n;
vector< real_number > r;
vector< point > from, to;

vector< int > dp(1 << 16, -1);

int dfs(int bit) {
  int &res = dp[bit];
  if (res != -1) return res;
  
  res = __builtin_popcount(bit);
  
  for (int i = 0; i < n; ++i) {
    if (bit & (1 << i)) continue;

    bool f = true;
    
    segment s(from[i], to[i]);
    for (int c = 0; c < n; ++c) {
      if (c == i) continue;

      point p;
      if (bit & (1 << c)) p = to[c];
      else p = from[c];
      if (distance(s, p) - (r[i] + r[c]) < -eps) f = false;
    }

    if (f) {
      res = max(res, dfs(bit | (1 << i)));
    }
  }

  return res;
}
int main() {
  cin >> n;

  r.resize(n);
  from.resize(n);
  to.resize(n);

  for (int i = 0; i < n; ++i) {
    cin >> r[i] >> from[i] >> to[i];
  }

  cout << dfs(0) << endl;
}



Measured memory_bytes: 3272
#include <iostream>
#define N_MAX 100
using namespace std;

int N,A,B,i,j,k;
int a[N_MAX];
int num[N_MAX] = {0};
int ans=0;
int r,g,b;

int main(){
  cin >> r >> g >> b;
  ans = r*100 + g*10 + b;
  if (ans % 4 == 0)  cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int fa[200010],ans,n,k;
vector <int> des[200010];
int dfs(int s)
{
	int d=0;
	for (int k=0;k<des[s].size();k++)
		d=max(d,dfs(des[s][k])+1);
	if ((d==k-1)&&(fa[s]!=1)) {ans++;d=-1;}
	return d;
}
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&fa[i]);
		if (i!=1) des[fa[i]].push_back(i);
	}
	ans=(fa[1]!=1);fa[1]=1;
	dfs(1);
	printf("%d\n",ans);
}

Measured memory_bytes: 13184
#include <stdio.h>


int main(void){
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h){
		printf("Yes");
	}else{
		printf("No");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define mst(a) memset(a,0,sizeof a)
int h,w,k;
string s[10];
int main(){
	cin>>h>>w>>k;
	for(int i=0;i<h;i++) cin>>s[i];
	int p=1<<h-1,ans=1e9;
	for(int q=0;q<p;q++)
	{
		int r[15]={},cnt=__builtin_popcount(q),flag=0;
		for(int j=0;j<w;j++)
		{
			int id=0,jg=0;
			for(int i=0;i<h;i++)
			{
				r[id]+=s[i][j]=='1';
				if(r[id]>k) jg=1;
				if(q>>i&1) id++;
			}
			if(jg){
				cnt++;
				mst(r),id=0;
				for(int i=0;i<h;i++)
				{
					r[id]+=s[i][j]=='1';
					if(r[id]>k) flag=1;
					if(q>>i&1) id++;
				}
			}
		}
		if(!flag) ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0; 
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  char b;
  cin >> b;
  switch(b){
    case 'A':
      cout << 'T' << endl;
      break;
    case 'C':
      cout << 'G'<< endl;
      break;
    case 'G':
      cout << 'C'<< endl;
      break;
    case 'T':
      cout << 'A'<< endl;
      break;
    default:
      break;      
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, m, x;
    cin >> n >> m >> x;

    vs32 c(n);
    vector< vs32 > a(n, vs32(m));
    rep (i, n)
    {
        cin >> c[i];
        rep (j, m)
        {
            cin >> a[i][j];
        }
    }

    int ans = 1e9;
    rep (i, 1 << n)
    {
        vs32 b(m, 0);
        int cost = 0;
        rep (j, n)
        {
            if ((i >> j) & 1)
            {
                cost += c[j];
                rep (k, m) b[k] += a[j][k];
            }
        }
        bool flag = true;
        rep (j, m)
        {
            if (b[j] < x) flag = false;
        }
        if (flag) ans = min(ans, cost);
    }

    if (ans == 1e9) ans = -1;
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3660
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(void) {
	int n,a[3003];
	//dp[i][j]:a[i]~a[j]まで残ってる状態からのX-Y
	long dp[3003][3003] = {0};
	scanf("%d",&n);
	for (int i=0;i<n;i++) scanf("%d",&a[i]);
	for (int i=n-1;i>=0;i--){
	    for (int j=i;j<n;j++){
	        if ((n-i-j-1)%2==0){
	            //次の手が太郎
	            dp[i][j] = max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
	        }else{
	            //次の手が次郎
	            dp[i][j] = min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
	        }
	    }
	}
	
	printf("%lld\n",dp[0][n-1]);
	return 0;
}

Measured memory_bytes: 70656
use std::io::Read;
use std::io::*;
use std::str::FromStr;
     
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")
}
    
fn main() {
    let _a: String = read();
    let _b: String = read();
    let mut iter_a = _a.split_whitespace();
    let mut iter_b = _b.split_whitespace();
    let a: i32 = iter_a.next().unwrap().parse().unwrap();
    let b: i32 = iter_b.next().unwrap().parse().unwrap();

    if a < b {
        for _ in 0..b {
            print!("{}", a);
        }
    } else {
        for _ in 0..a {
            print!("{}", b);
        }
    }
}

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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  
  int x[N], y[N], a[N];
  for(int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> a[i];
  }
  
  int map[H][W];
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      map[i][j] = 1;
    }
  }
  
  for(int i = 0; i < N; i++) {
    switch(a[i]) {
      case 1 :
        for(int j = 0; j < H; j++) {
          for(int k = 0; k < x[i]; k++) {
            map[j][k] = 0;
          }
        }
        break;
      case 2 :
        for(int j = 0; j < H; j++) {
          for(int k = x[i]; k < W; k++) {
            map[j][k] = 0;
          }
        }
        break;
      case 3 :
        for(int j = 0; j < W; j++) {
          for(int k = 0; k < y[i]; k++) {
            map[k][j] = 0;
          }
        }
        break;
      case 4 :
        for(int j = 0; j < W; j++) {
          for(int k = y[i]; k < H; k++) {
            map[k][j] = 0;
          }
        }
        break;
    }
  }
    
  int count = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(map[i][j] == 1) {
        ++count;
      }
    }
  }
    
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
num = input()

counter = 0
lol = True

for i in range(1, len(num)):
    if int(num[i]) != 9:
        lol = False

if lol:
    counter += int(num[0])
else:
    counter += int(num[0]) - 1

counter += 9 * (len(num)-1)
print(counter)

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

int main(void)
{
	int islandCount = 0;

	std::string s;
	std::cin >> s;
	char lastCh = '\0';
	for (std::string::iterator it = s.begin(); it != s.end(); it++) {
		if (lastCh != *it) {
			lastCh = *it;
			islandCount++;
		}
	}
	std::cout << islandCount - 1;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 

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

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

    int i, j, k, n, m, l;
    cin>>n>>m>>l;

    vector<vector<ll>> mat1(n, vector<ll>(m));
    vector<vector<ll>> mat2(m, vector<ll>(l));
    rep(i, n) {
        rep(j, m) {
            cin>>mat1[i][j];
        }
    }
    rep(i, m) {
        rep(j, l) {
            cin>>mat2[i][j];
        }
    }

    vector<vector<ll>> res(n, vector<ll>(l));
    rep(i, n) {
        rep(j, l) {
            rep(k, m) {
                res[i][j] += mat1[i][k] * mat2[k][j];
            }
        }
    }

    rep(i, n) {
        rep(j, l-1) {
            cout<<res[i][j]<<" ";
        }
        cout<<res[i][l-1]<<endl;
    }
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,a,b,i,p=0;
cin>>n;
string s;
cin>>s;
for(i=0;i<n-1;i++){
    if(s[i]==s[i+1])
    s[i]='0';
}for(i=0;i<n;i++){
    if(s[i]!='0')
    p++;
}cout<<p;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

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

    int N;
    cin >> N;

    vector<long long> x(N), y(N), h(N);

    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> h[i];
    }

    long long h_init = 0;
    bool wrong_pair = false;
    long long ans_x, ans_y, ans_h;

    int si = -1;
    for(int i = 0; i < N; i++){
        if(h[i] > 0){
            si = i;
            break;
        }
    }
    
    for(long long ix = 0; ix <= 100; ix++){
        for(long long iy = 0; iy <= 100; iy++){
            wrong_pair = false;
            h_init = abs(ix - x[si]) + abs(iy - y[si]) + h[si];
            for(int i =0 ; i < N; i++){
                if(h[i] > 0){       
                    if(h_init != (abs(ix - x[i]) + abs(iy - y[i]) + h[i])){
                        wrong_pair = true; 
                    }
                
                }else{
                    if(h_init > abs(ix - x[i]) + abs(iy - y[i])){
                        wrong_pair = true;
                    }
                }
                
            }
            if(!wrong_pair){
                    ans_x = ix;
                    ans_y = iy;
                    ans_h = h_init;
                    break;
                }
        }
    }

    cout << ans_x << " " <<  ans_y << " " << ans_h << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;const int N=2e2+7;
struct data{int to,next;}e[N*N*2];int head[N],col[N],cnt,h[N],flag,ans,t,w,n,m,i,j,k,q[N];char ch;
void ins(int u,int v){e[++cnt].to=v;e[cnt].next=head[u];head[u]=cnt;}
void dfs(int x){
	if(flag)return;
	for(int i=head[x];i;i=e[i].next)if(!col[e[i].to]){
		col[e[i].to]=-col[x];dfs(e[i].to);
	}else if(col[e[i].to]==col[x])flag=1;
} 
void bfs(int S){
	memset(h,-1,sizeof(h));t=0;w=1;q[0]=S;h[S]=0;
	while(t!=w){
		int x=q[t++];ans=max(ans,h[x]);
		for(i=head[x];i;i=e[i].next)if(h[e[i].to]==-1)h[e[i].to]=h[x]+1,q[w++]=e[i].to;
	}
}
int main(){
	for(scanf("%d",&n),i=1;i<=n;++i)for(j=1;j<=n;++j){
		scanf(" %c",&ch);k=ch-'0';if(k)ins(i,j);
	}col[1]=1;dfs(1);if(flag)puts("-1");
	else{for(int i=1;i<=n;++i)bfs(i);printf("%d\n",ans+1);}
}

Measured memory_bytes: 512
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        int[] ans = solve2(N, A);
        for (int i=0; i<N; i++) {
            if (i != 0) {
                System.out.print(" ");
            }
            System.out.print(ans[i]);
        }
        System.out.println();
    }

    private static int[] solve2(int N, int[] A) {
        int[] ans = assume(N, A, 0);
        int value = valid(N, A, ans);

        if (value != 0) {
            ans = assume(N, A, -value);
        }

        return ans;
    }

    private static int[] assume(int N, int[] A, int a) {
        int[] ans = new int[N];
        ans[0] = a;
        for (int i=1; i<N; i++) {
            ans[i] = (A[i-1] - ans[i-1]/2)*2;
        }

        return ans;
    }

    private static int valid(int N, int[] A, int[] ans) {
        return ans[0]/2 + ans[N-1]/2 - A[N-1];
    }

}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var lList = new LinkedList<int>();

            foreach (var x in Enumerable.Range(1, n))
            {
                var t = Console.ReadLine().Split();
                if (t[0] == "insert") lList.AddFirst(int.Parse(t[1]));
                else if (t[0] == "delete") lList.Remove(int.Parse(t[1]));
                else if (t[0] == "deleteFirst") lList.RemoveFirst();
                else lList.RemoveLast();
            }

            Console.WriteLine(string.Join(" ", lList));
        }
    }
}



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

bool solve(vector<int> v, bool turn, int k, vector<int> &dp) {
	if(dp[k]!=-1) {
		return dp[k];
	}
	bool answer = false;
	for(int i=0;i<v.size();i++) {
		if(k>=v[i]) {
			answer = answer | !solve(v,!turn,k-v[i], dp);
		}
	}
	dp[k]=answer;
	return dp[k];
}

int main() {
	int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++) {
    	cin>>v[i];
    }
    vector<int> dp(k+1, -1);
    bool answer = solve(v,true,k, dp);
    if(answer) {
    	cout<<"First"<<endl;
    } else {
    	cout<<"Second"<<endl;
    }
    
	return 0;
}


Measured memory_bytes: 53760
import math


def main():
    S = int(input())
    a = math.ceil(math.sqrt(S))
    if a * a == S:
        print(0, 0, a, 0, 0, a)
        return
    if a ** 2 - S <= int(1e9):
        d = a
        b = 1
        c = a**2 - S
    else:
        d = a - 1
        b = 1
        c = a*d - S
    print(0, 0, a, b, c, d)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
#include <iostream>

using namespace std;

int main(void) {
	int num, ans = 1;
	double t, a, dis, buf;
	cin >> num >> t >> a >> buf;
	dis = a - (t - buf * 0.006);
	if (dis < 0)
		dis *= -1.0;
	for (int i = 2; i <= num; i++) {
		cin >> buf;
		buf = a - (t - buf * 0.006);
		if (buf < 0)
			buf *= -1.0;
		if (dis > buf) {
			dis = buf;
			ans = i;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int N;
int L[100];
 
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> L[i];
  
  int Lmax, S = 0;
  for (int i = 0; i < N; ++i) {
    if (L[i] >= Lmax) Lmax = L[i];
    S += L[i];
  }
  
  if (Lmax < S - Lmax) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

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



ll N;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
	cin>>N;
  string s;
  cin>>s;

  for(ll i = 0 ; i<s.length() ; i++){
  	ll val = (int)s[i] - 65;
  	val +=N;

  	if(val>25)
  		val -= 26;

  	s[i] = (char)(val+65);
  }

 
 cout<<s<<'\n';
   

}



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

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, ans = N;
char s[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(char c = 'a'; c <= 'z'; c++){
		int son = 0, mx = 0;
		s[n + 1] = c;
		for(int i = 1; i <= n + 1; i++)
			if(s[i] == c){
				mx = max(mx, i - son - 1);
				son = i;
			}
		// cout << mx << endl;
		ans = min(ans, mx);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <set>
//#include
#include <numeric>
#define pb push_back
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

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

int findGCD(vector<int> arr, int n)
{
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

void solve(){
    long long n; cin >> n;
//    long long i = 1;
    long long su = 0;
    vector <int> l(3);
    for (int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            for(int k = 1; k<=n; k++){
                l[0] = i;
                l[1] = j;
                l[2] = k;
                su += findGCD(l, 3);
            }
        }
    }
//    while ( i <= n){
//        if (i%3 != 0 &&  i%5 != 0){
//            su += i;
//        }
//        i++;
//    }
    cout << su << "\n";
}

// Drive program
int main()
{
    solve();

    return 0;
}



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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    for (ll i = 0; i <= 50000; i++) {
        if((ll)(i * 1.08) == N){
            cout << i << endl;
            exit(0);
        }
    }
    cout << ":(" << endl;
}

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

class ufds {

public:
	// this function initializes the UFDS
	ufds(int n) {
		par.resize(n);
		sz.resize(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			sz[i] = 1;
		}
	}

	//  this function returns the representative of the group that item x is in
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			// path compression: link x -> representative of the group directly
			// recursively follow the arrows up to the representative
			par[x] = find(par[x]);
			return par[x];
		}
	}

	// this function combines the groups items x and y are in
	void merge(int x, int y) {
		// find the representatives of the two groups
		x = find(x);
		y = find(y);
		if (x == y) {
			return;
		}
		par[x] = y; // x -> y
		sz[y] += sz[x]; // number of items in group y has increased by the number of items in group x
		return;
	}

	// this function returns the size of the group item x is in
	int get_size(int x) {
		return sz[find(x)];
	}

	// this function returns true if items x and y are in the same set
	bool same_set(int x, int y) {
		return find(x) == find(y);
	}

private:
	vector<int> par;
	// par[i] is the 'parent' of item i
	// i -> par[i]
	vector<int> sz;
	// sz[i] stores the number of items in group i
};

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

	int n, m;
	cin >> n >> m;
	ufds data = ufds(n+m);

	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int x;
			cin >> x;
			x--;
			data.merge(i+m, x);
		}
	}
	int common_parent = data.find(m);
	for (int i = m+1; i < n+m; i++) {
		if (data.find(i) != common_parent) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
}

Measured memory_bytes: 5432
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"

const int inf = (int)1e18 + 10;

double dp[3005][3005] = {{0}};
double p[3005];
signed main(){
  fast;
  

   int n;
   cin >> n;
   for(int i = 1 ; i <= n;  i++)
   	  cin >> p[i];

    dp[0][0] = 1.00;
   	for(int i = 1 ; i <= n ; i++){
           for(int h = 0 ; h <= i ; h++){
           	     dp[i][h] = p[i] * dp[i-1][h-1] + dp[i-1][h] * (1.00 - p[i]);
           }
   	}

 double ans = 0.0;
   	for(int i = 1 ; i<= n ; i++){
   		if(i > n-i)
   			ans += dp[n][i];
   	}


   	cout << fixed << setprecision(12) <<  ans << endl;
  
}	

Measured memory_bytes: 69120
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN3(a,b,c);
  IN(x);
  Yes((abs(c-a)<=x || (abs(a-b)<=x && abs(b-c)<=x)));
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long ll;

const ll MOD = 1000000000+7;

int main() {
    ll N, K;
    ll before, after, ans;
    after = 0;
    before = 0;
    ans = 0;
    cin >> N >> K;
    vector<ll>A(N);

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

    for (ll i = 0; i < N-1; i++) {
        for (ll j = i+1; j < N; j++) {
            if (A[i] == A[j]) continue;
            if (A[i] > A[j]) ans = (ans+(K+1)*K/2)%MOD;
            else ans = (ans+(K-1)*K/2)%MOD;
        }
    }
    cout << ans << endl;
}


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

int frog(int i , int*a ,int n, int k,int *dp)
{
  if(i==n-1)
    return 0;
  int maxi = INT_MAX;
  if(dp[i]!=-1)
  return dp[i];
  for(int j=1;j<=k;j++)
  {
    if(i+j>=n)
      break;
    maxi = min(maxi, int(abs(a[i]-a[i+j])) + frog(i+j, a ,n,k,dp));
  }
  return dp[i] = maxi;
}
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n],dp[n+1];
    for(int i=0;i<=n;i++)
    dp[i]=-1;
    for(int i=0;i<n;i++)
    cin>>a[i];

   cout<<frog(0,a,n,k,dp);
}


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

typedef long long ll;
int n;
char s[40];
map<pair<string, string>, ll> mp;

int main() {
    scanf("%d %s", &n, s);
    for (int i = 0; i < 1 << n; i++) {
        string a, b;
        for (int j = 0; j < n; j++) {
            if (i >> j & 1) a.push_back(s[j]);
            else b.push_back(s[j]);
        }
        mp[{a, b}]++;
    }
    ll ans = 0;
    for (int i = 0; i < 1 << n; i++) {
        string a, b;
        for (int j = 0; j < n; j++) {
            if (i >> j & 1) a.push_back(s[2 * n - 1 - j]);
            else b.push_back(s[2 * n - 1 - j]);
        }
        ans += mp[{a, b}];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 91904
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
int N, K;

int main(int argc, char ** argv) {
	scanf("%d%d", &N, &K); K *= 2; K++;
	printf("%d\n", N/K + (N%K != 0));
	return 0;
}



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

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	set<int> s;
	for(int i=0;i<3;i++){
		int n;
		cin>>n;
		s.insert(n);
	}
	int co=0;
	set<int>::iterator it;
	for(it=s.begin();it!=s.end();it++){
		co++;
	}
	cout<<co<<endl;
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d", $n, $x);
for($i = 0; $i < $n; $i++){
    $m[$i] = trim(fgets(STDIN));    
}

$flour = $x - array_sum($m);
$etc = floor($flour / min($m));

echo ($n + $etc)."\n";
?>

Measured memory_bytes: 4604
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;

int main() 
{
    int N;
    cin >> N;
    vector<int>A(N);
    vector<int>B(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    for(int i = 0; i < N; i++){
        B.at(A.at(i)-1) = i+1;
    }
    for (int i = 0; i < N; i++) {
        cout << B.at(i) << endl;
    }
}

Measured memory_bytes: 1664
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
for i in range(n):
  if a[i]<b[i]:
    if a[i+1]<b[i]-a[i]:
      a[i+1]=0
    else:
      a[i+1]=a[i+1]-b[i]+a[i]
    a[i]=0
  else:
    a[i]-=b[i]
f=sum(a)
print(s-f)

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

int main(){
  int n,m; cin>>n>>m;
  vector<pii> a(n),c(m);
  rep(i,n)cin>>a.at(i).first>>a.at(i).second;
  rep(i,m)cin>>c.at(i).first>>c.at(i).second;
  int x,y;
  rep(i,n){   
    rep(j,m){    
    int x_ =
      max(a.at(i).first-c.at(j).first
        ,c.at(j).first-a.at(i).first)+
      max(a.at(i).second-c.at(j).second
        ,c.at(j).second-a.at(i).second);
      //cout<<x_<<" ";
    if(j==0){x=x_;y=1;}
    else if(x>x_){x=x_;y=j+1;}
    }
    cout<<y<<endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
#define N 100010
int main(){
    string a,b;cin>>a>>b;
    int num = stoi(b)+stoi(a)*pow(10, b.size());
    if(floor(sqrt(num))==sqrt(num))co("Yes");else co("No");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			char[] c = s.toCharArray();

			for(int i = 0 ; i < 1 << c.length ; i++) {
				StringBuilder sb = new StringBuilder();
				int result = Integer.parseInt(String.valueOf(c[0]));
				sb.append(c[0]);
				for(int j = 1 ; j < c.length ; j++) {
					if((1 & i >> j) == 1) {
						sb.append("+");
						result += Integer.parseInt(String.valueOf(c[j]));
					} else {
						sb.append("-");
						result -= Integer.parseInt(String.valueOf(c[j]));
					}
					sb.append(c[j]);
				}
				if(result == 7) {
					sb.append("=7");
					System.out.println(sb.toString());
					return;
				}
			}

			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>

int main(void)
{
	int i, n, x[1000] = { 0 }, y[1000] = { 0 };
	double p1 = 0, pi = 0, p2 = 0, p3 = 0;

	scanf("%d", &n);

	for ( i = 0; i < n; i++)
	{
		scanf("%d", &x[i]);
	}
	
	for (i = 0; i < n; i++)
	{
		scanf("%d", &y[i]);
	}

	for (i = 0; i < n; i++)
	{
		if (x[i] - y[i] < 0)
		{
			p1 = p1 + y[i] - x[i];
		}
		else
		{
			p1 = p1 + x[i] - y[i];
		}
	}

	for (i = 0; i < n; i++)
	{
		p2 = p2 + (x[i] - y[i])*(x[i] - y[i]);
	}

	for (i = 0; i < n; i++)
	{
		if (x[i] - y[i] < 0)
		{
			p3 = p3 - (x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]);
		}
		else
		{
			p3 = p3 + (x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]);
		}
	}

	for (i = 0; i < n; i++)
	{
		if (x[i] - y[i]>0)
		{
			if (pi < x[i] - y[i])
			{
				pi= x[i] - y[i];
			}
		}
		else
		{
			if (pi < y[i] - x[i])
			{
				pi = y[i] - x[i];
			}
		}
	}

	printf("%f\n%f\n%f\n%f\n", p1, sqrt(p2), pow(p3,1.0/3.0), pi);

	return 0;
}


Measured memory_bytes: 2048