akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,i,x,y,nxt,st,ed;
int a,b;
int main()
{
    //freopen("dijkstra.in","r",stdin);
    //freopen("dijkstra.out","w",stdout);
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>a>>b;
    if(a+b==15)cout<<'+'<<endl;
    else if(a*b==15)cout<<'*'<<endl;
    else cout<<'x'<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, k;

	cin >> n >> k;

	ll ma = 0;

	REP(i, n - 2) {
		ma += i + 1;
	}

	if (k > ma) {
		cout << -1 << endl;
		return 0;
	}

	ll dif = ma - k;
	ll m = n - 1;
	vector<pair<ll, ll>> v;

	REP(i, n - 1) {
		v.push_back(make_pair(1, i + 2));
	}

	vector<pair<ll, ll>> vv;

	FOR(i, 2, n) {
		FOR(j, i + 1, n + 1) {
			vv.push_back(make_pair(i, j));
		}
	}

	REP(i, dif) {
		m++;
		v.push_back(vv[i]);
	}

	cout << m << endl;

	REP(i, m) {
		cout << v[i].first << " " << v[i].second << endl;
	}
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			double x1=sc.nextDouble();
			double y1=sc.nextDouble();
			double x2=sc.nextDouble();
			double y2=sc.nextDouble();
			double x3=sc.nextDouble();
			double y3=sc.nextDouble();
			double x4=sc.nextDouble();
			double y4=sc.nextDouble();	
			System.out.println(x1>x4||x3>x2||y1>y4||y3>y2?"NO":"YES");
		}
	}
}

Measured memory_bytes: 21008
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int arr[100005];

int n;

void solve() {                   
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i) {
		scanf("%d", &arr[i]);
	}

	ll f = n * (n + 1ll) / 2;
	ll sum = 0;

	for (int i = 1; i <= n; ++i) {
		sum += arr[i];
	}

    if (sum % f) {
    	printf("NO\n");
    	return;
    }

    sum /= f;

    for (int i = 1; i <= n; ++i) {
    	int cur = arr[i] - (i > 1 ? arr[i - 1] : arr[n]);

    	if (sum < cur || (sum - cur) % n) {
    		printf("NO\n");
    		return;
    	}
    }

    printf("YES\n");        
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 640
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)
/////////////////////////// ..... ///////////////////////////
#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }
/////////////////////////// ..... ///////////////////////////
#define int ll
#define pb(x) push_back(x)
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////
const int N = 1e5+2;
vector<int> g[N];
int n,m;
int dp[N+1];
int visited[N+1];

void dfs(int u){
	visited[u]=1;
	for(int child : g[u]){
		if(!visited[child]){
			dfs(child);
			dp[u] = max(dp[u],1 + dp[child]);
		}
		else dp[u]=max(dp[u],1+dp[child]);
	}
}
/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	cin >> n >> m;
	For(i,m){
		int u,v; cin >> u >> v;
		g[u].pb(v);
	}
	dp[1] = 0;
	int ans = 0;
	FOR(i,1,n+1){
		if(!visited[i]){
			dfs(i);
		}
		//deb(i,dp[i]);
		ans = max(ans,dp[i]);
	}
	cout << ans <<"\n";

}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("TC", "r", stdin);
		//freopen("output.txt","w",stdout);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    	cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
    #endif
}

Measured memory_bytes: 13316
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  int s = 0, h = 0;
  F0R(i, N) {
    int p;
    cin >> p;
    s += p;
    chmax(h, p);
  }
  s -= h / 2;
  cout << s;
}
#endif


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    string s,t;cin>>s>>t;
    int sum=0;
    rep(i,s.size())if(s[i]!=t[i])sum++;
    cout<<sum<<endl;
}

Measured memory_bytes: 3872
c = [[int(v) for v in input().split()] for _ in range(3)]
b1 = c[0][1]
b2 = c[0][2]
a1 = c[1][0] - c[0][0]
a2 = c[2][0] - c[0][0]
print('Yes' if c[1][1]==a1+b1 and c[1][2]==a1+b2 and c[2][1]==a2+b1 and c[2][2]==a2+b2 else 'No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int cost, sum = 0;
    int coin[4], change[4], yen[4] = {10, 50, 100, 500}; // coinは支払う硬貨の数, changeは最適なおつり
    while(cin >> cost && cost){
        if(sum){//ループ2回目以降は必ずsum!=0となる
            cout << endl; //ループ2回目以降は改行を入れる
        }
        memset(change, 0, sizeof(change));
        sum = 0;
        for(int i = 0; i < 4; i++){ //入力
            cin >> coin[i];
            sum += coin[i] * yen[i]; //所持金を計算
        }
        //所持金全てを支払うことを基本とする
       for(int i = 3; i >= 0; i--){
            while(sum - cost >= yen[i]){ //最適なおつりを計算する
                change[i]++;
                sum -= yen[i];
            }
            if(coin[i] && change[i]){ //無駄な支払いを除外(10円支払って10円貰うなど)
                    coin[i] -= min(coin[i], change[i]);
            }
        }
        for(int i = 0; i < 4; i++){//出力
            if(coin[i]){
                cout << yen[i] << " " << coin[i] << endl;
            }
        }
    }
    return 0;
}



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

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

    string s;
    cin >> s;

    vector<int> A(3);
    for(int i = 0; i < s.size(); i++){
        A[(int)(s[i]-'a')]++;
    }

    int mi = 1e9;
    for(auto x : A){
        mi = min(mi, x);
    }

    for(auto x : A){
        int h = x - mi;
        if(h >= 2){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s,t; cin >> s >> t;
	int a,b; cin >> a >> b;
	string u; cin >> u;
	if(u==s)a--;
	else b--;
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
	char str[105];
	char std[105];
	scanf("%s",str);getchar();
	scanf("%s",std);
	int len = strlen(str);
	int len2 = strlen(std);
//	printf("<%d>\n",len);
	bool flag = true;
	if(len != len2) goto label;
	for(int i=0; i<len; i++){
		int temp = str[len-1];
		for(int j=len-2; j>=0; j--){
			str[j+1] = str[j];
		}
		str[0] = temp;
//		printf(">>%s %s\n",str,std);
		if(strcmp(str,std) == 0){
			puts("Yes");
			flag = false;
			break;
		}
	}
	label:
	if(flag){
		puts("No");
	}
	
	return 0;
}

Measured memory_bytes: 128
program main
  implicit none
  integer i,A,B,C,K,ans
  read(*, *) A,B,C
  read(*, *) K
  !read(*, *) (L(i), i = 1,N)
  do
    if (A-B > -1) then
      K = K-1
      B = B*2
    else
      exit
    end if
  end do
  do
    if (B-C > -1) then
      K = K-1
      C = C*2
    else
      exit
    end if
  end do
  if (K < 0) then
    write(*, *) 'No'
  else
    write(*, *) 'Yes'
  end if
end program main


Measured memory_bytes: 2792
#include <iostream>
#include <string>
#include <cstring>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#define int long long
using namespace std;
signed main(){
    int n,m;
    cin>>n>>m;
    int a[114514];
    for(int i=0;i<n;i++)cin>>a[i];
    vector<pair<int,int> > b(m);
    for(int i=0;i<m;i++){
        int k,l;
        cin>>k>>l;
        b[i]=make_pair(l, k);
    }
    sort(a,a+n);
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    int c=0;
    while(1){
        int i=0;
        bool fin=false;
        while(1){
            if(b[i].second>0)break;
            else if(b[m-1].second==0){
                fin=true;
                break;
            }else{
                i++;
            }
        }
        if(fin==true)break;
        if(a[c]>=b[i].first)break;
        else a[c]=b[i].first;
        b[i].second--;
        c++;
        
    }
    int ans=0;
    for(int i=0;i<n;i++)ans+=a[i];
    cout<<ans<<endl;
    return 0;
}


















Measured memory_bytes: 2688
n = int(input())
a = list(map(int,input().split()))
max_num = a[0]
if n==1:
  print('Yes')
  
else:
  flag = True
  for i in range(1,n):
    max_num = max(max_num,a[i])
    if max_num-a[i]>=2:
      print('No')
      flag = False
      break
    else:
      pass
  if flag == True:
    print('Yes')

Measured memory_bytes: 20668
import java.util.*;

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

        if(a+b >=c){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 23252
import sys

def main():
    N, M = map(int, input().split())
    LR = [tuple(map(int, input().split())) for _ in range(M)]
    RL = sorted([(R, L) for L, R in LR])

    now = 0
    ans = 0
    for R, L in RL:
        if L > now:
            now = R-1
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 24936
#include <iostream>
#include <string> 
using namespace std;
 int main(){
 string n;
 while(1){
 cin >> n; 
if (n == "0") break;
 int a=0,b=0,i;
 for(i=0 ;i < n.length(); ++i){
 a=n[i]-'0';
 b=b+a;
 } 
cout << b << endl;
 }
 return 0;
 } 

  

 



 

 



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

int N;
const int MAX_N = 1.0e5 + 100;
int A[MAX_N];
const int MOD = 1.0e9 + 7;

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

    sort(A, A+N);

    bool f = true;
    ll ans = 0;
    if (N % 2 == 0) {
        for (int i = 0; i < N/2; i++) {
            if (A[2*i] != 2*i+1 || A[2*i+1] != 2*i+1) {
                f = false;
                break;
            }
        }

        if (f) {
            ans = 1;
            for (int i = 1; i <= N/2; i++) {
                ans = (2 * ans) % MOD;
            }
        }
    }
    else {
        for (int i = 0; i < N/2; i++) {
            if (A[0] != 0) {
                f = false;
                break;
            }

            if (A[2*i+1] != 2*i+2|| A[2*i+2] != 2*i+2) {
                f = false;
                break;
            }
        }

        if (f) {
            ans = 1;
            for (int i = 1; i <= N/2; i++) {
                ans = (2 * ans) % MOD;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
// AtCoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <math.h>

using namespace std;

int main() {
    unsigned long long n;
    cin >> n;
    unsigned long long ans = 0;
    for(unsigned long long i = 1; i <= n; i++){
        if( (i %3 == 0 && i % 5 == 0) || i %3 == 0 || i %5 == 0 )continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    long long N, T;
    cin >> N >> T;

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

    long long ans = T;
    for (int i = 0; i < N - 1; i++)
    {
        ans += min(T, t[i + 1] - t[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MP(x,y) make_pair(x,y)
#define X first
#define Y second

using namespace std;
const int MAX=30000;
typedef pair<int,int> PII;
typedef pair<PII,int> PIII;

int memo[1024][1024]; // 最低何回の移動でそこにこれるか


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

int used[200000];

int main(void){
  int n,m;
  int a,b;
  cin >> n >> m;
  rep(i,m){
    cin >> a >> b;
    a--;b--;
    used[a]++;
    used[b]++;
  }

  for(int i = 0; i < n; i++){
    if(used[i] %2){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 768
n = int(input())

kekka = ["AC","WA","TLE","RE"]
ans = [0]*4

for _ in range(n):
    s = input()

    if s == kekka[0]:
        ans[0] += 1
    elif s == kekka[1]:
        ans[1] += 1
    elif s == kekka[2]:
        ans[2] += 1
    elif s == kekka[3]:
        ans[3] += 1

for i in range(4):
    print(kekka[i]+" x ",end="")
    print(ans[i])


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

int main (){
 string s; cin >> s; list<char> ans;
 rep(i,s.size())ans.push_back(s[i]);
 int q; cin >> q;
 int cnt=0;
 rep(i,q){
   int a;
   cin >> a;
   if(a==1)cnt++;
   if(a==2){
     int p; char c; cin >> p >> c;
     if(p==1){
       if(cnt%2==0)ans.push_front(c);
       else ans.push_back(c);
     }
      else{
        if(cnt%2==0)ans.push_back(c);
        else ans.push_front(c);
      }
   }
 }
 std::list<char>::iterator itr;
 if(cnt%2==0){
   for (itr = ans.begin(); itr != ans.end(); itr++) {
         std::cout << *itr ;
     }
}
else{
  auto def=ans.end();
  def--;
  auto des=ans.begin();
  des--;
  for (itr = def; itr != des; itr--) {
        std::cout << *itr ;
    }
}
}


Measured memory_bytes: 9984
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n,x,t;
    cin>>n>>x>>t;
    int times;
    if(n%x==0) times=n/x;
    else times=n/x+1;

    cout<<t*times<<endl;;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair
typedef int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll maxn=2e5+10, maxm=5e3+10, lg=20, mod=998244353, inf=1e18;

ll n,X,Y,par[maxn],h[maxn],ans=0;
vector<ll> g[maxn],ex[maxn];
bool bad[maxn],mk[maxn];
void dfs(ll v){for(auto u:g[v])if(u!=par[v])par[u]=v,h[u]=h[v]+1,dfs(u);}
void df2(ll v,ll d=0){
	mk[v]=1;
	ans=max(ans,2*h[v]);
	if(h[v]<=d) return;
	if(bad[v]){cout<<-1;exit(0);}
	for(auto u:ex[v])if(!mk[u]) df2(u,d+1);
}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n>>X>>Y;
	vector<pll> E;
	for(int i=1;i<n;i++){
		ll v,u; cin>>v>>u;
		E.pb({v,u});
	}
	for(int i=1;i<n;i++){
		ll v,u; cin>>v>>u;
		g[v].pb(u), g[u].pb(v);
	}
	dfs(Y);
	for(auto e:E){
		ll v=e.F, u=e.S;
		if(par[par[v]]==u || par[v]==u || par[par[u]]==v || par[u]==v || par[v]==par[u]) ex[v].pb(u), ex[u].pb(v);
		else bad[v]=bad[u]=1;
	}
	df2(X);
	cout<<ans;
	
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    string s; cin >> s;
    int cnt0 = 0, cnt1 = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0') cnt0++;
        else cnt1++;
    }

    cout << min(cnt0, cnt1) * 2 << endl;
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    double n; cin >> n;
    double odd_number = ceil(n / 2);
    cout << odd_number / n;
}


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

#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;


int32_t main()
{
    int n=in();
    string s; cin>>s;
    int ans=0;
    for(int i=0; i+2<n; i++) if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
    cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


inline LL calcMinCost(LL i, VVI& c) {
    VI x;
    REP(j, 10) {
        if (j != 1 && j != i) x.PB(j);
    }
    LL min_cost = c[i][1];
    do {
        FOR(j, 1, SZ(x) + 1) {
            LL cost = 0;
            LL prev = i;
            REP(k, j) {
                cost += c[prev][x[k]];
                if (cost >= min_cost) continue;
                prev = x[k];
            }
            if (cost >= min_cost) continue;
            cost += c[prev][1];
            if (cost < min_cost) min_cost = cost;
        }
    } while (next_permutation(ALL(x)));
    return min_cost;
}


int main() {
    LL H, W;
    cin >> H >> W;
    VVI c(10, VI(10));
    VVI A(H, VI(W));
    REP(i, 10) {
        REP(j, 10) {
            cin >> c[i][j];
        }
    }
    REP(i, H) {
        REP(j, W) {
            cin >> A[i][j];
        }
    }
    VI m(10);
    REP(i, 10) {
        m[i] = i == 1 ? 0 : calcMinCost(i, c);
    }
    LL ans = 0;
    REP(i, H) {
        REP(j, W) {
            if (A[i][j] != -1) {
                ans += m[A[i][j]];
            }
        }
    }
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 512
from copy import deepcopy

# 多次元配列を作成する
def make_multi_list(initial, degree):
    ans = [initial for _ in range(degree[-1])]
    for d in reversed(degree[:-1]):
        ans = [deepcopy(ans) for _ in range(d)]
    return ans


N, T = map(int, input().split())
AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))
AB.sort()

ans = 0
dp = make_multi_list(0, [3005, 3005])
for i in range(N):
    a, b = AB[i]
    for j in range(T):
        # iを使わないパターン
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
        # iを使うパターン
        nj = j + a
        if nj < T:
            dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j] + b)
    now = dp[i][T - 1] + b
    ans = max(ans, now)

print(ans)


Measured memory_bytes: 121052
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    int n, mx = 0; cin >> n;
    bool okay = true;
    REP(i, n){
        int h; cin >> h;
        if(h < mx-1) okay = false;
        mx = max(mx, h);
    }
    cout << (okay ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <ctime>
#include <vector>
#include <cstdlib>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a,b,c,d;
    d = n%10;
    n = (n-d)/10.0;
    c = n%10;
    n = (n-c)/10.0;
    b = n%10;
    n = (n-b)/10.0;
    a = n%10;
    if ((a == b && b==c ) || (b == c && c==d )){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }


 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    set<string> se;
    rep(i,n){
        string s;
        cin >> s;
        se.insert(s);
    }
    cout << se.size() << endl;
}

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

int a;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a;
    cout << a + a*a + a*a*a << '\n';
    return 0;
}

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


int main(){
    int a,b; cin >> a >> b;
    
    for(int i= 10;i<1300;i++){
        if(floor(i*0.08)==a){
            if(floor(i*0.1) == b){
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
template<class T> inline T pow2_L(T a){
  return a*a;
}
int main(){
  int R;
  rd(R);
  wt_L(pow2_L(R));
  wt_L('\n');
  return 0;
}
// cLay varsion 20191111-2

// --- original code ---
// {
//   int R;
//   rd(R);
//   wt(R**2);
// }


Measured memory_bytes: 256
#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 POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#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
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
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 pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 2003;


ll a,b;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a;
	if(a>=2800)pri("AGC");
	else if(a>=1200)pri("ARC");
	else pri("ABC");
}

Measured memory_bytes: 256
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

// conversion
inline int
toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

int main()
{
    LL W, H, x, y;
    cin >> W >> H >> x >> y;
    printf("%.10Lf %d\n", (long double)(W) * (long double)(H) / 2.0, 2 * x == W && 2 * y == H);
}

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

using ll = long long;
using P = pair<ll,ll>;
const ll INF =ll(1e18)+5;

void solve(long long A, long long B, long long Q, std::vector<long long> s, std::vector<long long> t, std::vector<long long> x){
    s.push_back(INF);s.push_back(-INF);
    t.push_back(INF);t.push_back(-INF);
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    for(ll q:x){
        auto itr1 = lower_bound(s.begin(),s.end(),q);
        auto itr2 = lower_bound(t.begin(),t.end(),q);
        ll ans = INF;
        ll s1 = (*itr1)-q; ll s2 =q- (*(itr1-1));
        ll t1 = (*itr2)-q; ll t2 =q-(*(itr2-1));
        ans= min(ans,max(s1,t1));
        ans=min(ans,max(s2,t2));
        ans = min(ans,min(s1*2+t2,s1+t2*2));
        ans = min(ans,min(s2*2+t1,s2+t1*2));
        cout << ans << endl;

    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> s(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&s[i]);
    }
    std::vector<long long> t(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&t[i]);
    }
    std::vector<long long> x(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&x[i]);
    }
    solve(A, B, Q, std::move(s), std::move(t), std::move(x));
    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int n;
    cin >> n;
    vector<int> a(n);
    REP (i, 0, n) cin >> a[i];
    vector<int> ans(n);
    int sign = 1;
    int pos = n / 2;
    REP (i, 0, n) {
        ans[pos] = a[i];
        sign *= -1;
        pos += sign * (i + 1);
    }

    if (n % 2) {
        reverse(ans.begin(), ans.end());
    }
    REP (i, 0, n) {
        cout << ans[i] << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <math.h>
using namespace std;
 
int main()
{
	int N;
  	cin>>N;
  	int cost[N], height[N];
  
  	for(int i=0; i<N; i++)
    {
		cin>>height[i];
      	if (i == 0)
          cost[i] = 0;
      	else
      	  cost[i] = 2147483627;
    }
  
  	for (int i=0; i<N; i++)
    {
 		  if (i+1<N)
            cost[i+1] = min(cost[i+1], cost[i]+abs(height[i] - height[i+1]));
      	  if (i+2<N)
            cost[i+2] = min(cost[i+2], cost[i]+abs(height[i] - height[i+2]));
    }
    cout<<cost[N-1]<<endl;
 
  return 0;
}

Measured memory_bytes: 1024
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
const int MAXN = 1e6+10 ; 
int cnt[MAXN] ; 
int main(){
	int s ;
	cin >> s ; 
	cnt[s]++; 
	for(int i=2;;i++){
		if ( s % 2 == 0 ) s = s/2 ; 
		else s = 3*s+1 ;  
		cnt[s]++ ; 
		debug() << imie(cnt[s]);
		if ( cnt[s] > 1 ) {
			cout << i << endl;
			break;
		}
	}
    return 0 ;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

ll beki(ll A,ll B){ //A^B
    ll C=1;
    if(B==0){
        return 1;
    }
    else{
        for (ll i = 0; i < B; i++){
        C *= A;
        }
    }
    return C;
}

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

    ll N;
    string S;
    cin >> N;

    ll N_tmp = N;

    ll count = 0;
    ll i = 1;
    while (count < N)
    {
        count += beki(26, i);
        if(count<N){
            i++;
        }
    }

    //cout << count << endl;

    //cout << "i" << i << endl;

    vector<ll> vec(i);

    //N -= beki(26, i - 1);

    bool flag = true;

    REP(j,i){
        ll tmp = N / 26;
        ll tmp2 = (N % 26);
        if(tmp2==0){
            tmp2 = 26;
            N = tmp - 1;
        }
        else{
            flag = false;
            N = tmp;
        }
        vec.at(j) = tmp2;
        
    }

    if(count==N_tmp){
        REP(j,i){
            cout << 'z';
        }
    }


    else{
        RREP(j, i)
        {
            cout << (char)(vec.at(j) + 96);
        }
    }

    /*REP(j, i)
    {
        cout << vec.at(j) << endl;
    }*/

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;


int n, m, a[300000];
vector<int> rem;

bool run(int q, int c, bool use_rem = false) {
    rem.clear();
    int j = 2 * n - c - 1;
    for (int i = j + 1; i < 2 * n; i ++) {
        bool found = false;
        while (j >= 0) {
            int temp = a[j] + a[i];
            if ((temp >= m && temp <= m + q) || temp <= q) {
                j --;
                found = true;
                break;
            }
            else {
                if (use_rem) rem.emplace_back(a[j]);
                j --;
            }
        }
        if (!found) return false;
    }
    if (use_rem) while (j >= 0) rem.emplace_back(a[j --]);
    return true;
}

bool check(int q) {
    int l = 0, r = n;
    while (l < r) {
        int mid = (l + r) / 2 + 1;
        if (run(q, mid)) l = mid;
        else r = mid - 1;
    }
    run(q, l, true);
    for (int x = 0, y = rem.size() - 1; x < y; x ++, y --) 
        if (rem[x] + rem[y] > q)
            return false;
    return true;
}


int main() {
    cin >> n >> m;
    for (int i = 0; i < 2 * n; i ++) {
        cin >> a[i];
    }

    sort(a, a + n * 2);

    int l = 0, r = m;
    while (l < r) {
        int mid = (l + r) / 2;
        if (!check(mid)) l = mid + 1;
        else r = mid;
    }
    cout << r << endl;

    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    double w,h,x,y;
    cin >>w>>h>>x>>y;
    double s=w*h/2;
    bool flg=false;
    if(x*2==w&&y*2==h)flg=true;
    cout <<s<<endl;
    if(flg)cout <<1<<endl;
    else cout <<0<<endl;
    return 0;
}



Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        w: usize,
        mut weval: [(usize, usize); n],
    }

    const V_MAX: usize = 100_001;

    weval.insert(0, (0, 0));
    let mut dp = vec![vec![1_000_000_001; V_MAX]; n+1];

    dp[0][0] = 0;

    for i in 1..=n {
        for j in 0..V_MAX {
            if weval[i].1 <= j {
                dp[i][j] = dp[i-1][j].min(dp[i-1][j-weval[i].1] + weval[i].0);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    let mut ans = n;
    let mut count = 0;
    for i in dp[n].iter() {
        if i <= &w {
            ans = count;
        }
        count += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 81248
#include <stdio.h>

int main()
{
  int i, n, m, a;
  char broken[100001];
  long ans[100001];
  scanf("%d%d", &n, &m);
  for (i = 0; i <= n; i++) broken[i] = 0;
  for (i = 0; i < m; i++) {
    scanf("%d", &a);
    broken[a] = 1;
  }
  if (n == 1) {
    printf("%d\n", 1);
    return 0;
  }
  ans[0] = 1;
  if (broken[1]) ans[1] = 0; else ans[1] = 1;
  for (i = 2; i <= n; i++) {
    if (broken[i]) ans[i] = 0;
    else ans[i] = (ans[i - 2] + ans[i - 1]) % 1000000007;
  }
  printf("%d\n", ans[n]);
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){

    unsigned int w, h, r;
    int x, y;
    int left, right, top, bottom;

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

    left = x - r;
    right = x + r;
    top = y + r;
    bottom = y - r;

    if(left < 0){
        cout << "No" << endl;
    }else if(right > w){
        cout << "No" << endl;
    }else if(top > h){
        cout << "No" << endl;
    }else if(bottom < 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;

}


Measured memory_bytes: 3100
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	int sum = 0;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '-')
			sum--;
		else sum++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int main() {
    ll N;
    cin >> N;
    vector<int> e;
    int a = 0;
    for (ll v = N; v > 0; v /= 10) {
        e.push_back(v % 10);
        a += v % 10;
    }
    reverse(begin(e), end(e));

    int len = e.size();
    int acc = 0;
    for (int j = 0; j < e.size(); ++j) {
        acc += e[j];
        if (e[j] > 0) {
            a = max(a, acc - 1 + 9 * (len - j - 1));
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
t=list(input())

if t[0]=="?":
    if len(t)<=2:
        t[0]="D"

    elif t[1]=="P":
        t[0]="D"
    
    else:
        t[0]="P"
for i in range(1,len(t)):
    if t[i]=="?":
        if i+1==len(t):
            t[i]="D"
            break
        if t[i-1]=="P":
            t[i]="D"
        else:
            if t[i+1]=="P":
                t[i]="D"
            else:
                t[i]="P"
b=""
for i in range(len(t)):
    b+=t[i]
print(b)
    


Measured memory_bytes: 10868
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  string s;cin >>s;
  int n=s.size();
  s.push_back('B');
  string t;
  for(int i = 0; i < n; ++i){
    if(s[i]=='B'&& s[i+1]=='C'){
      t+='D';
      ++i;
    }
    else t+=s[i];
  }
  int m = t.size();
  ll ans=0, count=0;
  for(int i = 0; i < m; ++i){
    if(t[i]=='A'){
      ++count;
    }
    else if(t[i]=='D'){
      ans+=count;
    }
    else{
      count=0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 776
import java.util.*;
public class Main {
  public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     while(sc.hasNext()){
       String S = sc.next();
       String list = S.substring(0,5);
       String list2 = S.substring(6,13);
       String list3 = S.substring(14);
       System.out.println(list + " " + list2 + " " + list3);
     }
  }
}

Measured memory_bytes: 23508
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			int[] a = new int[10];
			for (int i = 0; i < n; i++) {
				a[sc.nextInt()]++;
			}
			for (int i = 0; i < 10; i++) {
				if (a[i] == 0) System.out.println("-");
				else {
					for (int j = 0; j < a[i]; j++) {
						System.out.print("*");
					}
					System.out.println();
				}
			}
		}
	}
}

Measured memory_bytes: 54092
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main()
{
    int n {0}, w {0};
    cin >> n >> w;
    int N {0};
    vector < pair <int, int> > p (n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i].first >> p[i].second;
        N += p[i].second;
    }
    // cout << N + 1 << endl;
    vector <long long int> dp (N + 1);
    for (int i = 0; i <= N; i++)
    {
        dp[i] = 1e18L;
    }
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = N - p[i].second; j >= 0; j--)
        {
            dp[j + p[i].second] = min(dp[j + p[i].second], dp[j] + p[i].first);
        }
    }
    int ans {0};
    for (int i = 0; i < N + 1; i++)
    {
        if (dp[i] <= w)
        {
            ans = max(ans, i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4040
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: f32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: f32 = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = ((a + b) / 2f32).ceil();
    println!("{}", ans);
}


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

using namespace std;

int main() {
    int n; cin >> n;
    string seven = "No";
    while (n > 0) {
        if (n % 10 == 7) {
            seven = "Yes";
            break;
        }
        n /= 10;
    }
    cout << seven << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main()
{
    std::string S;
    std::cin >> S;

    const char c[] = { 'A','T','C','G' };

    int high = 0;
    int cnt = 0;
    for (int i = 0; i < S.length(); i++)
    {
        bool flag = false;
        for (int j = 0; j < 4; j++)
        {
            if (S[i] == c[j])
            {
                flag = true;
                cnt++;
                break;
            }
        }
        if (!flag)
        {
            high = std::max(high, cnt);
            cnt = 0;
        }
    }
    high = std::max(high, cnt);

    std::cout << high << std::endl;

    return 0;
}

Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    cout << T + S;
    return 0;
}

Measured memory_bytes: 3100