akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    string l;
    cin >> l;
    vector<vector<int>> dp(2, vector<int>(l.size()));
    dp[0][0] = 1;
    dp[1][0] = 2;
    for(int i = 1; i < l.size(); ++i){
        dp[0][i] = ((ll)3 * dp[0][i-1] + dp[1][i-1] * (l[i] == '1')) % MOD;
        dp[1][i] = (ll)dp[1][i-1] * (l[i]-'0' + 1) % MOD;
    }
    cout << ((ll)dp[0][l.size()-1] + dp[1][l.size()-1]) % MOD << "\n";
    return 0;
}

Measured memory_bytes: 1616
#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()
{
    ll h;
    cin >> h;
    ll cnt = 0, depth=1;
    while(h>0){
        cnt += depth;
        depth *= 2;
        h = floor(h/2);
    }
    cout << cnt << endl;
    return 0;
}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

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 (a>b) { a=b; return 1; } return 0; }

int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    rep (i, n) rep (j, d) cin >> x[i][j];
    
    int ans = 0;
    rep (i, n-1) rep (j, i+1, n) {
        int dist = 0;
        rep (k, d) dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
        //cout << i << ", " << j << ", " << dist << endl;
        rep (k, 128) if (k * k == dist) ans++;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <functional>
using namespace std;

int main() {
	long long N; cin >> N;
	cout << ((N + 110) / 111) * 111 << endl;
	return 0;
}

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

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int main() {
  int n,m;
  S2(n,m);
  int tot = 1900 * m + 100 * (n - m);
  printf("%d\n",(1<<m) * tot);
  return 0;
}


Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str;
        Random random = new Random();
        int j,i,h,a,b,c;
        int[] x = new int[6];
        int[] y = new int[6];
        str = scan.nextLine();
        String[] num = str.split(" ", 0);
        for(i = 0; i < 6; i++){
            x[i] = Integer.valueOf(num[i]);
            y[i] = x[i];
        }
        str = scan.nextLine();
        a = Integer.valueOf(str);
        for(i=0;i<a;i++){
            str = scan.nextLine();
            num = str.split(" ", 0);
            b = Integer.valueOf(num[0]);
            c = Integer.valueOf(num[1]);
            while(x[0] != b||x[1] != c){
                turn(x,random.nextInt(4));
            }
            System.out.println(x[2]);
        }
        scan.close();
    }

    static void set(int[] x,int a,int b,int c,int d,int e,int f){
        x[0] = a;
        x[1] = b;
        x[2] = c;
        x[3] = d;
        x[4] = e;
        x[5] = f;
    }
    static void turn(int[] x,int i){
        switch (i){
            case 0:
                set(x,x[4],x[0],x[2],x[3],x[5],x[1]);
                break;
            case 1:
                set(x,x[3],x[1],x[0],x[5],x[4],x[2]);
                break;
            case 2:
                set(x,x[2],x[1],x[5],x[0],x[4],x[3]);
                break;
            case 3:
                set(x,x[1],x[5],x[2],x[3],x[0],x[4]);
                break;
        }
    }
}




Measured memory_bytes: 26212
#include<bits/stdc++.h>
using namespace std;
double h[1919];
int main() {
	double t, a;
	int n;
	double s = 100000000;
	cin >> n >> t >> a;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 0; i < n; i++) {
		h[i] = abs(a - (t - h[i] * 0.006));
	}
	for (int i = 0; i < n; i++) {
		if (h[i] < s) { s = h[i]; }
	}
	for (int i = 0; i < n; i++) {
		if (h[i] == s) { cout << i + 1 << endl; return 0; }
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	string a;
	cin >> a;
	int x=0,y=0;
	for(int i=0;i<a.size();i++)
		x+=(a[i]^i)&1^1,y+=(a[i]^i)&1;
	cout << min(x,y); 
	return 0;
}

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

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> cnt(200001);
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    cnt[a]++;
  }
  int ans = 0;
  sort(cnt.begin(), cnt.end(), greater<int>());
  for (int i = k; i < n + 1; i++)
    ans += cnt[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
# coding:utf-8
s = input()
t = input()
ans = len(t)

for i in range(len(s) - len(t) + 1):
    count = 0
    for j in range(0, len(t)):
        if s[i + j] != t[j]:
            count += 1
    ans = min(ans, count)

print(ans)


Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
 
int main(){
 
  int n, x;
  cin >> n >> x;
  if (n*500 >= x) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 3564
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007
#define PI acos(-1)

void solve() {
    int x;
    cin >> x;
    if(x == 0) {
        cout << 1;
    } else {
        cout << 0;
    }
}

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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int int64_t

signed main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,ans,i;
    string str;
    cin>>str;


    for(int i=0;i<str.size();i++)
    {
        n=str[i]-'0';
        ans+=n;

        ans%=9;
    }

    cout<<(ans ? "No" : "Yes")<<endl;
    

    return 0;
}




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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    int arr[3] = {a, b, c};

    int cnt_5 = 0;
    int cnt_7 = 0;

    for (int i : arr) {
        if (i == 5) {
            cnt_5++;
        } else if (i == 7) {
            cnt_7++;
        }
    }

    if (cnt_5 == 2 && cnt_7 == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int s[6];
  int p[6][6] = {{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
  int a,b,n;

  for(int i=0;i<6;i++) cin>>s[i];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    for(int j=0;j<6;j++){
      if(a==s[j]) a=j;
      if(b==s[j]) b=j;
    }
    cout<<s[p[a][b]-1]<<endl;
  }
  return 0;
}

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

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

int main()
{
	int n;
	string s;
	cin >> n;
	cin >> s;

	bool ans = true;
	rep(i, n/2)
	{
		if(s[i] != s[i+(n/2)]) ans = false;
	}
	if(n % 2 == 1) cout << "No" << endl;
	else if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << n / 2 - 1 << endl;
    } else {
        cout << (n - 1) / 2 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>void amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>void amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_

ll dp[2001][2001],sum[2001][2001];
int TLE_TERROR()
{
 	ll n;
 	cin>>n;
 	// ll dp[n+1][n+1],sum[n+1][n+1];
 	// mem0(dp);mem0(sum);
 	for(ll i=3;i<=n;i++)
 	{
 		dp[1][i]=1;
 		sum[1][i]=1;
 		sum[1][i]+=sum[1][i-1];
 		sum[1][i]%=M;
 	}
 	// for(ll i=1;i<=n;i++)
 	// {
 	// 	for(ll j=1;j<=n;j++)
 	// 	{
 	// 		cout<<dp[i][j]<<" ";
 	// 	}
 	// 	cout<<endl;
 	// }
 	// cout<<endl;
 	for(ll i=1;i<=n;i++)
 	{
 		for(ll j=3;j<=n;j++)
 		{
 			dp[i][j]+=sum[i-1][j-3];
 			dp[i][j]%=M;
 			sum[i][j]=dp[i][j];
 			sum[i][j]%=M;
 			sum[i][j]+=sum[i][j-1];
 			sum[i][j]%=M;
 			dp[i][j]+=dp[i-1][j];
 			dp[i][j]%=M;
 			sum[i][j]%=M;
 		}
 	}
 	// for(ll i=1;i<=n;i++)
 	// {
 	// 	for(ll j=1;j<=n;j++)
 	// 	{
 	// 		cout<<dp[i][j]<<" ";
 	// 	}
 	// 	cout<<endl;
 	// }
 	// cout<<endl;
 	// for(ll i=1;i<=n;i++)
 	// {
 	// 	for(ll j=1;j<=n;j++)
 	// 	{
 	// 		cout<<sum[i][j]<<" ";
 	// 	}
 	// 	cout<<endl;
 	// }
 	cout<<dp[n][n];
 	return 0;   
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TESTS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

Measured memory_bytes: 65976
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var rl = RL();
            var sprlst = spr(rl);
            var intlist = sprlst.Select(x => c2i(x)).ToList();
            //var ret = false;
            string ret = intlist[2] + " " + intlist[0]+" "+intlist[1];
            Console.WriteLine(ret);
            
            Console.ReadLine();


        }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static int c2i(string c) { return int.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair

#define debug(...) cerr << "[" << (#__VA_ARGS__) << "] : "; _debug(__VA_ARGS__);

template<class T, class S>
ostream& operator <<(ostream& out, pair<T, S> p) {
	out << "(" << p.first << ", " << p.second << ")" << endl;
	return out;
}

template<class T>
ostream& operator <<(ostream& out, vector<T>& v) {
	out << "[";
	if (v.size() > 0) out << v[0];
	for (auto it = next(v.begin()); it != v.end(); it++)
		cout << ", " << *it;
	out << "]";
	return out;
}
template<typename Arg, typename ...Args>
void _debug(Arg&& arg, Args && ...args) {
	using expander = int[];
	cerr << "{";
	cerr << arg; 
	(void)expander{0, ((void)(cerr << ", " << args), 0)...};
	cerr << "}" << endl;
}

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;

const int N = 405;
int dp[N][N];
//dp[i][j] = the min total cost of combining interval [i, j] into one vertex

int32_t main() {
	FAST_IO;
	int n;
	cin >> n;
	vi a(n);
	for (int& x: a) cin >> x;
	
	auto sum = [&](int L, int R) {
		int s = 0;
		for (int i = L; i <= R; ++i) {
			s += a[i];
		}
		return s;
	};
	
	for (int L = n-1; L >= 0; --L) {
		for (int R = L; R < n; ++R) {
			if (L == R) {
				dp[L][R] = 0;
			} else {
				dp[L][R] = INF;
				for (int i = L; i <= R-1; ++i) {
					dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + sum(L, R));
				}
			}
		}
	}
	
	cout << dp[0][n-1] << endl;
//	freopen("in.txt", "r", stdin);
	
	
	
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17


Measured memory_bytes: 1536
/*input
-1000000000 0 -1000000000 0
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll mx=a*c;
    MXTO(mx,a*d);
    MXTO(mx,b*c);
    MXTO(mx,b*d);
    cout<<mx;
}

Measured memory_bytes: 3648
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))

one, two, three = 0, 0, 0
for i in p:
	if i <= a:
		one += 1
	elif a < i <= b:
		two += 1
	else:
		three += 1
print(min(one, two, three))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <random>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int K; string S; cin >> K >> S;
	if (S.size() <= K) cout << S << '\n';
	else {
		for (int i = 0; i < K; i++) cout << S[i];
		cout << "...\n";
	}
	return 0;
}




Measured memory_bytes: 3672
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

//--------------------------

int main() {

  int n; cin >> n;
  int a[n][3]; rep(i, n) cin >> a[i][0] >> a[i][1] >> a[i][2];

  int t = a[0][0], x = a[0][1], y = a[0][2];

  if(t<x+y) {
    cout << "No" << endl;
    return 0;
  }else {
    if((t+x+y)%2==1) {
      cout << "No" << endl;
      return 0;
    }
  }

  rep(i, n-1) {
    t = a[i+1][0] - a[i][0];
    x = a[i+1][1] - a[i][1];
    y = a[i+1][2] - a[i][2];
    if(t<x+y) {
      cout << "No" << endl;
      return 0;
    }else {
      if((t+x+y)%2==1) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (int)(s); i < (int)(e); ++i)
#define per(i,s,e) for(int i = (int)(s)-1; i >= (int)(e); --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  double a,b,x;  cin >> a >> b >> x;
  bool f = false;
  if(a*a*b/2 > x){x = a*a*b-x;f = true;}
  double ans = 0;
  if(!f)ans = atan(2.0*(a*a*b-x)/(a*a*a));
  else ans = atan(2.0*(a*a*b-x)/(a*b*b));
  if(f)ans = (M_PI*0.5) - ans;
  ans *= (180.0/M_PI);
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr long long int MOD = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin >> n;
    string s;
    cin >> s;

    int res = 0;
    for(int i=2; i < n; i++){
        if(s[i] == 'C' && s[i-1] == 'B' && s[i-2] == 'A'){
            res++;
        }
    }
    cout << res << endl;



    return 0;
};


Measured memory_bytes: 256
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll n,m,d,dd=0;
    cin>>n>>m;;
    ll k = sqrt(m)+1;
    for(ll i=1;i<=min(k,divup(m,n));i++){
        if(m%i==0){
            d=i;
            if(i>=n){
                dd=m/i;
                break;
            }
        }
    }
    if(d>=n) cout<<max(d,dd)<<endl;
    else cout<<d<<endl;
}


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

using i64 = int64_t;

int main(){
    int n, m;
    cin >> n >> m;
    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        v.push_back(a);
    }
    vector<pair<i64, i64>> op;
    for(int i=0;i<m;++i){
        i64 b, c;
        cin >> b >> c;
        op.emplace_back(b, c);
    }
    sort(v.begin(), v.end());
    sort(op.begin(), op.end(), [](const pair<i64, i64> &a, const pair<i64, i64> &b){
        return a.second > b.second;
    });

    i64 ans = 0;
    int idx = 0;
    for(int i=0;i<m;++i){
        int cnt = 0;
        for(int j=0;j<op[i].first;++j){
            if(idx + j >= n)break;
            if(v[idx+j] > op[i].second)break;
            ans += op[i].second;
            cnt++;
        }
        idx += cnt;
    }
    while(idx < n)ans += v[idx++];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.buffer.readline
def inp():
    return map(int,input().split())
n, q = [int(i) for i in input().split()]
e = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = inp()
    e[a-1].append(b-1)
    e[b-1].append(a-1)

p = [0] * n
for _ in range(q):
    pp, x = inp()
    p[pp - 1] += x


def dfs(i=0, r=-1):
    for j in e[i]:
        if j != r:
            p[j] += p[i]
            dfs(j, i)
dfs()

print(*p)


Measured memory_bytes: 268392
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll aN,bN,m;
  cin >> aN >> bN >> m;
  ll a[aN];
  ll b[bN];
  ll x,y,c;
  for(int i=0;i<aN;i++) cin >> a[i];
  for(int i=0;i<bN;i++) cin >> b[i];
  ll ans = MOD;
  for(int i=0;i<m;i++){
    cin >> x >> y >> c;
    ans = min(ans,a[x-1]+b[y-1]-c);
  }
  sort(a,a+aN);
  sort(b,b+bN);
  ans = min(ans,a[0]+b[0]);
  cout << ans << endl;
  return 0;
}


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

int main() {

  long A,B,r;
  long A_org,B_org;
  cin >> A >> B;
  A_org = A;
  B_org = B;
  r = A % B;
  while(r!=0){
    A = B;
    B = r;
    r = A % B;
  }
  //cout << A << B << r << endl;
  cout << (A_org * B_org / B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

const ll INF = (1LL << 58LL);
const int MAX_N = 100002;
int A[MAX_N], B[MAX_N], C[MAX_N];

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;

    int N = X + Y + Z;
    vector<P> ab;
    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i] >> C[i];
        ab.emplace_back(B[i] - A[i], i);
    }
    sort(ab.begin(), ab.end());

    vector<ll> max_total(N, 0);

    {
        priority_queue<P> que;
        ll x_total = 0;
        ll z_total = 0;
        for(int i=0;i<X+Z;i++){
            int k_in = ab[i].second;
            que.emplace(C[k_in] - A[k_in], k_in);
            x_total += A[k_in];
            if(que.size() > X){
                int k_out = que.top().second;
                x_total -= A[k_out];
                z_total += C[k_out];
                que.pop();
            }
            if(que.size() == X){
                max_total[i] = x_total + z_total;
            }else{
                max_total[i] = -INF;
            }
        }
    }
    {
        priority_queue<P> que;
        ll y_total = 0;
        ll z_total = 0;
        for(int i=0;i<Y+Z;i++){
            int k_in = ab[N-1-i].second;
            que.emplace(C[k_in] - B[k_in], k_in);
            y_total += B[k_in];
            if(que.size() > Y){
                int k_out = que.top().second;
                y_total -= B[k_out];
                z_total += C[k_out];
                que.pop();
            }
            if(que.size() == Y){
                max_total[N-1-i-1] += y_total + z_total;
            }else{
                max_total[N-1-i-1] += -INF;
            }
        }
    }

    ll ans = 0;
    for(int i=0;i<N;i++){
        ans = max(ans, max_total[i]);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

#define let auto
#define conr auto const&

int const N = 100 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;

int n;
int a[N];
ll f[N];

ll bp(ll x, ll e) {
  ll y = 1;
  for(; e; e >>= 1) {
    if(e&1) y = y * x % M;
    x = x * x % M;
  }
  return y;
}

ll ncr(int n, int r) {
  if(n < r)
    return 0;
  return f[n] * bp(f[n-r] * f[r] % M, M-2) % M;
}

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

  cin >> n;
  n++;

  f[0] = 1;
  for(int i = 1; i <= n; ++i)
    f[i] = i * f[i-1] % M;

  int m;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;

    if(a[x])
      m = n-(i-a[x]+2);
    a[x] = i+1;
  }

  for(int i = 1; i <= n; ++i) {
    ll x = ncr(n, i);
    if(m >= i-1) {
      x -= ncr(m, i-1);
      x += M;
      x %= M;
    }
    cout << x << '\n';
  }

  cout << flush;
}

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

int main() {

  int n;
  cin >> n;
  bool test = true;
  
  vector<int> v(n);
  for(int i=0; i<n; i++)
    cin >> v.at(i);
  
  for(int i=0; i<n; i++){
    if(v.at(i) % 2 == 0 && v.at(i) % 3 != 0 && v.at(i) % 5 != 0)
      test = false;
  }
  
  if(test == false)
    cout << "DENIED" << endl;
  if(test == true)
    cout << "APPROVED" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


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

signed main(){
    int X;
    cin >>X;
    vector <bool > expo(X+1);
    expo[1] = 1;
    for(int b=2;b<=X;b++){
        int v = b*b;
        while(v<=X){
        expo[v] = 1;
        v *= b;
        }
    }
    for(int i=X;i>=1;i--){
        if(expo[i]){
        Out(i);
          break;
        }
    }
}

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

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

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


int main() {
  int N;
  int A[SIZE], As[SIZE];

  scanf("%d", &N);

  for (int i=0; i<N; i++) {
    scanf("%d", A+i);
    As[i] = A[i];
  }

  sort(As, As+N);

  for (int i=0; i<N; i++) {
    if (As[N-1] == A[i])
      printf("%d\n", As[N-2]);
    else
      printf("%d\n", As[N-1]);
  }

  return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

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

		int n = Integer.parseInt(sc.nextLine());
		int k = Integer.parseInt(sc.nextLine());
		int x = Integer.parseInt(sc.nextLine());
		int y = Integer.parseInt(sc.nextLine());
		
		if(n<k)k=n;
		
		System.out.println(x*k + y*(n-k));
	}

}


Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


print(1 - a_int())


Measured memory_bytes: 68712
n, y = map(int, input().split())
y /= 1000
for q in range(n + 1):
    for w in range(n - q + 1):
        if 10 * q + 5 * w + 1 * (n - q - w) == y:
            print(q, w, (n - q - w))
            exit(0)
print("-1 -1 -1")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n, 0), b(n, 0);
    rep1(i, n){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end(), greater<ll>());
    rep1(i, n){
        if (a[i] == b[0]) cout << b[1] << endl;
        else cout << b[0] << endl;
    }
    
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll ans = 0;
  while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
    ll na = b / 2 + c / 2;
    ll nb = c / 2 + a / 2;
    ll nc = a / 2 + b / 2;
    a = na;
    b = nb;
    c = nc;
    ans++;
    if(a == b && b == c) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
require 'prime'

n, p = gets.split.map(&:to_i)
if p == 1
  puts 1
elsif n == 1
  puts p
else
  h = Prime.prime_division(p).to_h
  ans = 1
  h.each do |k, v|
    while v >= n
      ans *= k
      v -= n
    end
  end
  puts ans
end

Measured memory_bytes: 3964
#include <iostream>
#include <algorithm>

using namespace std;

int64_t dp[101][101][301];
int64_t w[100];
int64_t v[100];

int main()
{
    int N;
    int64_t W;

    cin >> N >> W;
    for (int i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }

    int64_t w0 = w[0];
    for (int i = 0; i < N; i++)
    {
        w[i] -= w0;
    }

    for (int i = 0; i <= N; i++)
    {
        for (int k = 0; k <= N; k++)
        {
            for (int64_t weight = 0; weight <= 300; weight++)
            {
                if (i == 0 || k == 0)
                {
                    dp[i][k][weight] = k == 0 ? 0 : -1;
                    continue;
                }
                int64_t cand = -1;

                if (dp[i - 1][k][weight] >= 0)
                {
                    cand = max(cand, dp[i - 1][k][weight]);
                }
                if (weight - w[i - 1] >= 0 && dp[i - 1][k - 1][weight - w[i - 1]] >= 0)
                {
                    cand = max(cand, dp[i - 1][k - 1][weight - w[i - 1]] + v[i - 1]);
                }

                dp[i][k][weight] = cand;
            }
        }
    }

    int64_t result = 0;
    for (int k = 0; k <= N; k++)
    {
        for (int64_t weight = 0; weight <= 300; weight++)
        {
            if (W >= w0 * k + weight)
            {
                result = max(result, dp[N][k][weight]);
            }
        }
    }

    cout << result << endl;
    return 0;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = max(max(a * c, a * d), max(b * c, b * d));
	cout << ans << endl;
	return 0;
}

//!

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

int main()
{
	bool f = true;
	int N;
	cin >> N;
	vector<vector<char>> a(N, vector<char>(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				f = false;
			}
		}
	}
	if (f) {
		cout << -1 << endl;
		return 0;
	}
	int lm = 0, r = 0;
	for (int i = 0; i < N; i++) {
		int cnt = 0;
		for (int j = 0; j < N; j++) {
			if (a[i][j] == '#') {
				cnt++;
			}
		}
		lm = max(lm, cnt);
	}
	for (int j = 0; j < N; j++) {
		bool flag = true;
		for (int i = 0; i < N; i++) {
			if (a[i][j] == '.') {
				flag = false;
				break;
			}
		}
		if (flag) {
			r++;
		}
	}
	if (lm == N) {
		cout << N - r << endl;
		return 0;
	}
	vector<int> ex(N);
	for (int j = 0; j < N; j++) {
		for (int i = 0; i < N; i++) {
			if (a[i][j] == '#') {
				ex[j] = 1;
				break;
			}
		}
	}
	int res = N;
	vector<int> need(N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (a[i][j] == '.') {
				need[i]++;
			}
		}
		need[i] += 1 - ex[i];
		res = min(res, need[i]);
	}
	cout << res + N - r << endl;
	return 0;
}


Measured memory_bytes: 512
p = 10**9+7
N = int(input())
S1 = input().strip()
S2 = input().strip()
cnt = 1
i = 0
if S1[0]==S2[0]:
    cnt = (cnt*3)%p
    flag = 1
    i += 1
else:
    cnt = (cnt*6)%p
    flag = 2
    i += 2
while i<N:
    if S1[i]==S2[i]:
        if flag==1:
            cnt = (cnt*2)%p
        flag = 1
        i += 1
    else:
        if flag==1:
            cnt = (cnt*2)%p
        else:
            cnt = (cnt*3)%p
        flag = 2
        i += 2
print(cnt)

Measured memory_bytes: 38396
#include <bits/stdc++.h>
#define int long long
#define maxc 20005
#define maxn 1005
using namespace std;
struct Pt {
    int w, s, v;
    void RD() {
        cin >> w >> s >> v;
    }
    bool operator < (const Pt &a) const {
        return w + s < a.w + a.s;
    }
};

int dp[maxc] = {};
Pt arr[maxn];
int n;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        arr[i].RD();
    }
    sort(arr + 1, arr + n + 1);
    for(int i = 1; i <= n; i++) {
        int mx = arr[i].s + arr[i].w;
        for(int j = mx; j >= arr[i].w; j--) {
            dp[j] = max(dp[j], dp[j - arr[i].w] + arr[i].v);
        }

    }
    cout << *max_element(dp, dp + maxc) << '\n';
    return 0;
}


Measured memory_bytes: 3744
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int x, y, a, b, c;

	while(scanf("%d%d%d%d%d", &x, &y, &a, &b, &c)==5)
	{
		vi p(a), q(b), r(c);

		for(int i=0;i<a;i++) scanf("%d", &p[i]);
		for(int i=0;i<b;i++) scanf("%d", &q[i]);
		for(int i=0;i<c;i++) scanf("%d", &r[i]);

		sort(p.rbegin(), p.rend());
		sort(q.rbegin(), q.rend());
		sort(r.rbegin(), r.rend());

		vi eat;

		copy(p.begin(), p.begin()+x, back_inserter(eat));
		copy(q.begin(), q.begin()+y, back_inserter(eat));
		sort(eat.begin(), eat.end());

		for(int i=0;i<c && i<x+y;i++)
		{
			if(eat[i]<r[i]) eat[i]=r[i];
		}

		ll ans=0LL;
		for(int me:eat) ans+=me;

		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2552
N=int(input())
listP = [[0,0,0]]
while True:
    try:
        listP.append(list(map(int,input().split())))
    except:
        break;

output = "Yes"

dxy=[0,0,0]
for t in range(N):
    for i in range(3):
        dxy[i] = listP[t+1][i]-listP[t][i]
    if (dxy[0] >= abs(dxy[1])+abs(dxy[2])) and ((dxy[0]-dxy[1]-dxy[2])%2 == 0) :
        continue
    else:
        output = "No"
        break

print(output)

Measured memory_bytes: 27400
import java.io.*;
import java.util.*;

public class Main {
  static int MOD = 1000000007;
  static double EPS = 1e-9;

  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(in.readLine());

    int N = Integer.parseInt(st.nextToken());
    int L = Integer.parseInt(st.nextToken());

    String[] s = new String[N];

    for (int i = 0; i < N; i++) {
      s[i] = in.readLine();
    }
    Arrays.sort(s);

    String res = "";

    for (int i = 0; i < N; i++) {
      res += s[i];
    }

    System.out.println(res);

    in.close();
  }
}

Measured memory_bytes: 25300
#include <iostream>
#include <algorithm>
#include<string>

using namespace std;

template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }


void solve(string S)
 {

int N=S.size();
  int res=1e5,i;
 for(i=0;i<N-2;i++) {
    int x=100*(S[i]-'0')+10*(S[i+1]-'0')+1*(S[i+2]-'0');
    SMIN(res,abs(x-753));
  }
  cout<<res<<endl;
}

int main() {

 // cin.tie(0);
 string S;

  cin>>S;

  solve(S);

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
using namespace std;
typedef long long int ll;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

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


int main() {
  int N;
  cin >> N;
  ll sum = 0;
  for(int a=1;a<=N;a++){
      for(int b=1;b<=N;b++){
          for(int c=1;c<=N;c++){
              sum += gcd(a,gcd(b,c));
          }

      }

  }

    cout << sum << endl;

}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

long long gcd(long long a, long long b) {
    if(a < b)
        swap(a,b);
    while(a%b != 0) {
        long long c = b;
        b = a%b;
        a = c;
    }
    return b;
}

int main(){
    long long a,b,c,d; cin >> a >> b >> c >> d;
    long long ans = b - a + 1;

    long long cc = b/c - a/c;
    if(a%c == 0)
        cc++;
    long long dd = b/d - a/d;
    if(a%d == 0)
        dd++;
    long long x = c*d/gcd(c,d);
    long long cd = b/x - a/x;
    if(a%x == 0)
        cd++;
    // cout << cc << " " << dd << " " << cd << endl;
    cout << ans - cc - dd + cd << endl;
}


Measured memory_bytes: 256
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\s/);

const A = +input[0], const B = +input[1], const X = +input[2];
const ans = X < A
  ? 'NO'
  : X - A > B
    ? 'NO'
    : 'YES';
console.log(ans);

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define pi pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;
inline int read(){
	int x=0;char c=getchar();bool p=1;
	for(;!isdigit(c);c=getchar())if(c=='-')p=0;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return p?x:-x;
}
const int N=100005;
map<pi,int> p;
queue<pi> q;
set<int> s[N];
int n,x,y,t,fa[N];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main(){
	n=read();
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<n*2-1;i++){
		x=read();y=read();
		s[x].insert(y);s[y].insert(x);
		p[mp(x,y)]++;p[mp(y,x)]++;
		if(p[mp(x,y)]==2)q.push(mp(x,y));
	}
	set<int>::iterator it;
	while(!q.empty()){
		pi u=q.front();q.pop();
		x=find(u.first);y=find(u.second);
		s[x].erase(y);s[y].erase(x);
		if(s[x].size()<s[y].size())swap(x,y);
		for(it=s[y].begin();it!=s[y].end();it++){
			t=*it;
			p[mp(t,y)]=p[mp(y,t)]=0;
			s[t].erase(y);s[t].insert(x);
			p[mp(t,x)]++;p[mp(x,t)]++;
			if(p[mp(t,x)]==2)q.push(mp(t,x));
			s[x].insert(t);
		}
		fa[y]=x;
		s[y].clear();
	}
	int s=0;
	for(int i=1;i<=n;i++)s+=fa[i]==i;
	if(s==1)puts("YES");else puts("NO");
	return 0;
}

Measured memory_bytes: 56192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class BombsChain
    {
        struct Point { internal int x, y; }

        readonly int[] moveX = new int[] { -1, 0, 1, 0 };
        readonly int[] moveY = new int[] { 0, -1, 0, 1 };

        char[][] map;

        public BombsChain()
        {
            map = new char[8][];
        }

        public void MakeMap(string source, int i)
        {
            map[i] = source.ToCharArray();
        }

        public void Solve(int x, int y)
        {
            Stack<Point> stk = new Stack<Point>();

            Point willPush;
            willPush.x = x - 1;
            willPush.y = y - 1;
            stk.Push(willPush);

            while (stk.Count > 0)
            {
                Point cur = stk.Pop();

                map[cur.y][cur.x] = '0';

                for (int i = 0; i < 4; i++)
                {
                    for (int j = 1; j < 4; j++)
                    {
                        willPush.x = cur.x + moveX[i] * j;
                        willPush.y = cur.y + moveY[i] * j;

                        if (!IsValid(willPush.x, willPush.y)) continue;

                        if (map[willPush.y][willPush.x] == '1')
                        {
                            stk.Push(willPush);
                        }
                    }
                }
            }
        }

        public void Print(int n)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Data " + n + ":");

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    sb.Append(map[i][j]);
                }
                sb.Append("\n");
            }
            Console.Write(sb);
        }

        private bool IsValid(int x, int y)
        {
            if (x < 0) return false;
            if (x > 7) return false;
            if (y < 0) return false;
            if (y > 7) return false;
            return true;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                Console.ReadLine();

                BombsChain BC = new BombsChain();

                for (int j = 0; j < 8; j++)
                {
                    string input = Console.ReadLine();

                    BC.MakeMap(input, j);
                }

                int x = int.Parse(Console.ReadLine());
                int y = int.Parse(Console.ReadLine());

                BC.Solve(x, y);
                BC.Print(i);
            }
        }
    }
}

Measured memory_bytes: 10216