akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int n, m;

int ta[100];
int ha[100];


void solve() {
  int sumTa, sumHa;
  sumTa= sumHa = 0;
  for(int i = 0; i < n; ++i) sumTa += ta[i];
  for(int i = 0; i < m; ++i) sumHa += ha[i];
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < m; ++j) {
      sumTa -= ta[i];
      sumHa += ta[i];
      sumHa -= ha[j];
      sumTa += ha[j];
      if(sumTa == sumHa) {
	cout << ta[i] << " " << ha[j] << endl;
	return;
      }
      sumTa += ta[i];
      sumHa -= ta[i];
      sumHa += ha[j];
      sumTa -= ha[j];
    }
  }
  cout << -1 << endl;
}

main() {
  while((cin >> n >> m) && (n || m)) {
    for(int i = 0; i < n; ++i) {
      cin >> ta[i];
    }
    for(int i = 0; i < m; ++i) {
      cin >> ha[i];
    }
    solve();
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P);
int min(int,int);
P dequeue();

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
 P x = Q[head];
 head = (head+1)%LEN;
 return x;
}

int min(int a,int b){
  return a<b ? a:b;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n+1;

  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}

Measured memory_bytes: 10756
#include<cstdio>
int n,a,b,k=0,t=1,s,d;
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for(;t<=n;t++)
	{
    	s=0,d=t;
    	while(d)
    	{
        	s+=d%10,d/=10;
    	}
    	if(s>=a&&s<=b)
		{
        	k+=t;
    	}
	}
	printf("%d",k);
}

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

using namespace std;

int main(){
  string x;

  while(cin>>x,(x!="0")){
    int n=0;

    for(int i=0; i<(int)x.size(); i++){
      n+=(x[i]-'0');
    }
    cout <<n<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3196
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

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

int main()
{
    int n;
    int r;
    int tmp1[15000] = {};
    int tmp2[15000] = {};
    while (scanf("%d", &n))
    {
        if (n == 0)
            break;
        cin.ignore();
        for (int i = 0; i < n; i++)
        {
            scanf(" %d", &r);
            tmp1[i] = r;
        }
        int m = 0;
        int f = 1;
        while (f)
        {
            int chk = 0;
            for (int i=0; i < n; i++)
            {
                int cnt = 0;
                for (int j=0; j < n; j++)
                    if (tmp1[j] == tmp1[i])
                        cnt++;
                // printf("%d ",cnt);
                tmp2[i] = cnt;
                if (tmp2[i] != tmp1[i])
                    chk++;
                // printf("HOGE");
            }
            if (chk == 0)
            {
                printf("%d\n", m);
                for (int i=0; i < n - 1; i++)
                    printf("%d ", tmp2[i]);
                printf("%d\n", tmp2[n - 1]);
                f = 0;
                break;
            }
            else
            {
                m++;
                for (int i=0; i < n; i++)
                    tmp1[i] = tmp2[i];
            }
        }
    }
    return 0;
}


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

using namespace std;

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

	long long answer = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			answer += d[i] * d[j];
		}
	}

	cout << answer << endl;
}

Measured memory_bytes: 256
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll                          long long
#define ld                          long double
 
#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second
 
#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define  MN                           INT_MIN
#define  MX                           INT_MAX
#define int long long
bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int dp[100001];
int32_t main()
{
	int n;
	cin >> n;
	int a[n+1],b[n];
	for(int i = 0;i<n+1;i++)
		cin >> a[i];
	for(int i = 0;i<n;i++)
		cin >> b[i];
	int ans = 0;
	for(int i = 0;i<n;i++)
	{
		ans += min(a[i],b[i]);
		b[i] -= min(a[i],b[i]);
		ans+= min(a[i+1], b[i]);
		a[i+1] -= min(a[i+1],b[i]);
	}
	cout << ans << endl;
}

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

using namespace std;

int a, b, c;

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

    cin >> a >> b >> c;

    if (a <= c && c <= b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;
	char t[105];

	rep(i, n) cin >> t[i];

	s = "Three";
	rep(i, n){
		if(t[i] == 'Y'){
			s = "Four";
			break;
		}
	}

	cout << s;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <regex>

/*
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;



using ll = long long;
using ull = unsigned long long;
constexpr ll N = 2e5;

constexpr ull max_num = 1e18;
ull a[N];
*/

using ull = unsigned long long;
using ll = long long;

using namespace std;




int main() {
   
	int n, k;
	cin >> n >> k;
	auto a = vector<int>(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}

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

	int sum = 0;
	for (int i = 0; i < k; i++)
	{
		sum += a[i];
	}
	cout << sum;
	
	return 0;
	
}


Measured memory_bytes: 3252
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int A,B,C,N;
        cin>>A>>B>>C;
        if(A==0&&B==0&&C==0)break;
        cin>>N;
        int lis[1000][4];
        for(int i=0;i<N;i++)cin>>lis[i][0]>>lis[i][1]>>lis[i][2]>>lis[i][3];
        int che[301];
        for(int i=1;i<=300;i++)che[i]=2;

        for(int i=0;i<N;i++){
            if(lis[i][3]==1)che[lis[i][0]]=1,che[lis[i][1]]=1,che[lis[i][2]]=1;
        }
        for(int i=0;i<N;i++){
            if(che[lis[i][0]]==1&&che[lis[i][1]]==1&&lis[i][3]==0)che[lis[i][2]]=0;
            if(che[lis[i][0]]==1&&che[lis[i][2]]==1&&lis[i][3]==0)che[lis[i][1]]=0;
            if(che[lis[i][1]]==1&&che[lis[i][2]]==1&&lis[i][3]==0)che[lis[i][0]]=0;
        }
        for(int i=1;i<=A+B+C;i++)cout<<che[i]<<endl;
    }
    return 0;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
double ret = 0;
vector<ll> v;

void input() {
  IN(N);
  ll tmp;
  REP(i, N) {
    IN(tmp);
    v.pb(tmp);
  }
}

void solve() {
  sort(ALL(v));
  ret = v[0];
  FOR(i, 1, N) {
    ret = (ret + (double)v[i])/2.0;
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
ans, tmp = 0, 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
ans = max(ans, tmp)
print(ans)

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    int n;
    cin >> n;
    vector <ll> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    int ans = 0, c = 0;
    for (int i = n-2; i >= 0; i--) {
        if (h[i] >= h[i+1]) c++;
        else c = 0;
        ans = max(ans, c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main()
{
  long t,x;
  cin>>t;
  float sum=0.0;
  for(int i=1;i<=t;i++)
  {
    cin>>x;
    sum+=1.0/x;
  }
  cout<<fixed<<setprecision(10)<<1.0/sum<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		System.out.println((int) (l - Math.ceil(Math.max((double) a/c, (double) b/d))));
	}
}

Measured memory_bytes: 26224
#include<bits/stdc++.h>
#define ll long long int 
using namespace std; 
int dp[100005];
int solve(int a[],int n)
{
  if(n<=1)
    return 0;
    int ans1=INT_MAX;

    if(dp[n]!=-1)
      return dp[n];
   if(n>1)
   {
     ans1=abs(a[n-1]-a[n])+solve(a,n-1);
   } 
   int ans2=INT_MAX;
   if(n>2)
   {
     ans2=abs(a[n-2]-a[n])+solve(a,n-2);
   } 

   return dp[n]=min(ans1,ans2);
}
int main() 
{
  int t=1;
  //cin>>t;
  while (t--)
  {
    memset(dp,-1,sizeof(dp));
      int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
      cin>>a[i];
    }
    cout<<solve(a,n)<<endl;
  }
  

  
} 


Measured memory_bytes: 12148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);


	int x, y;
	cin >> x >> y;

	for(int i = 0; i <= x; i++){
		int j = x - i;
		if(i * 2 + j * 4 == y){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};

//--global--//

class UnionFind{
    public:
        vector<ll> par; // 親
        vector<ll> rank; // 木の深さ
        ll numComponent; // 木の数
        void init(ll n){
            par.resize(n);
            rank.assign(n, 1LL);
            for(ll i=0; i<n; ++i) par[i] = i;
            numComponent = n;
        }

        ll findRoot(ll x){
            if(par[x] == x) return x;
            else return par[x] = findRoot(par[x]);
        }

        void unite(ll x, ll y){
            x = findRoot(x);
            y = findRoot(y);
            if(x == y) return;
            if(rank[x] < rank[y]) swap(x, y);
            rank[x] += rank[y];
            par[y] = x;
            numComponent--;
            return;
        }

        bool same(ll x, ll y){
            return findRoot(x) == findRoot(y);
        }

        ll size(ll x){
            return rank[findRoot(x)];
        }
};

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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n, m;
    cin >> n >> m;
    UnionFind unionFind;
    unionFind.init(n);
    vector<pair<ll, ll> > v;
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        v.push_back(make_pair(a, b));
    }
    reverse(ALL(v));

    vector<ll> ans;

    ll tmp = unionFind.numComponent * (unionFind.numComponent-1) / 2;
    rep(i, v.size()){
        //cout << unionFind.numComponent << endl;
        ans.push_back(tmp);
        pair<ll, ll> f = v[i];
        if(!unionFind.same(f.first, f.second))
            tmp -= unionFind.size(f.first) * unionFind.size(f.second);
        unionFind.unite(f.first, f.second);
    }
    
    reverse(ALL(ans));

    rep(i, ans.size()){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 6256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  vector<P> xy(N);
  REP(i, N) {
    ll x, y;
    cin >> x >> y;
    xy[i].first = x;
    xy[i].second = y;
  }
  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }
  map<P, int> mp;
  REP(i, N) REP(j, N) {
    if (i == j) continue;
    ll p = xy[j].first - xy[i].first;
    ll q = xy[j].second - xy[i].second;
    mp[P(p, q)]++;
  }
  int res = N;
  for (auto a : mp) {
    res = min(res, N - a.second);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}


Measured memory_bytes: 2124
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
// Begin Template IO/Utility
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &V){
	os<<'[';
	for(int i=0;i<(int)V.size();i++)
		os<<V[i]<<",]"[i==(int)V.size()-1];
	return os;
}
template<typename T> istream& operator>>(istream &is, vector<T> &V){
	for(T &x:V)
		is>>x;
	return is;
}
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T,U> &p){
	os<<'{'<<p.first<<','<<p.second<<'}';
	return os;
}
template<typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){
	is>>p.first>>p.second;
	return is;
}
// End Template IO/Utility
void solve(){
	int N, M;
	cin>>N>>M;
	vector<vector<int>> g(N+1);
	for(int i=0;i<M;i++){
		int from, to;
		cin>>from>>to;
		g[from].push_back(to);
		g[to].push_back(from);
	}
	vector<bool> vis(N+1);
	queue<int> q;
	q.push(1);
	vis[1]=1;
	vector<int> ans(N+1,-1);
	while(!q.empty()){
		int node=q.front();
		q.pop();
		for(auto near:g[node]){
			if(!vis[near]){
				vis[near]=true;
				ans[near]=node;
				q.push(near);
			}
		}
	}
	for(int i=2;i<=N;i++)
		if(ans[i]==-1){
			cout<<"No";
			return;
		}
	cout<<"Yes\n";
	for(int i=2;i<=N;i++){
		cout<<ans[i]<<"\n";
	}
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int T=1;
	while(T--){
		solve();
	}
}


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

int main(){
    int n=0;
    string S;
    cin >> S;
    if(S == "SAT")n = 1;
    else if(S == "FRI")n = 2;
    else if(S == "THU")n = 3;
    else if(S == "WED")n = 4;
    else if(S == "TUE")n = 5;
    else if(S == "MON")n = 6;
    else n = 7;
    cout << n << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#define ll long long
const int N=1005,mo=1e9+7;
int n,m,i,j,cnt,tot1,tot2,tot,vk;
ll nk;char s[N];
bool a[N][N],flag1,flag2;
int Pow(int x,ll n){
	int k=1;
	for (;n;n>>=1,x=(ll)x*x%mo)
		if (n&1) k=(ll)k*x%mo;
	return k;
}
int main(){
	scanf("%d%d%lld",&n,&m,&nk);
	if (nk<2){printf("%d",nk);return 0;}
	nk--;
	for (i=1;i<=n;i++){
		scanf("%s",s+1);
		for (j=1;j<=m;j++)
			if (s[j]=='#') a[i][j]=1,cnt++;
	}
	for (i=1;i<=m;i++) if (a[1][i]&&a[n][i])
		tot1++,flag1=1;
	for (i=1;i<=n;i++) if (a[i][1]&&a[i][m])
		tot2++,flag2=1;
	if (flag1&&flag2){puts("1");return 0;}
	if (!flag1&&!flag2){
		printf("%d",Pow(cnt,nk));return 0;
	}
	if (flag1){
		for (tot=tot1,i=1;i<n;i++) for (j=1;j<=m;j++)
			if (a[i][j]&&a[i+1][j]) vk++;
	}
	else{
		for (tot=tot2,i=1;i<=n;i++) for (j=1;j<m;j++)
			if (a[i][j]&&a[i][j+1]) vk++;
	}
	int v=(ll)tot*Pow(cnt,mo-2)%mo;
	v=(ll)Pow(cnt,nk-1)*(Pow(v,nk)-1)%mo*Pow(v-1,mo-2)%mo;
	int ans=(Pow(cnt,nk)-(ll)vk*v)%mo;
	printf("%d",(ans+mo)%mo);
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		for (int i = 0; i < s.length(); i += 2) {
			System.out.print(s.charAt(i));
		}
	}
}


Measured memory_bytes: 33416
#include <iostream>
#include <climits>
#define MAXN 200000
using namespace std;
long long mymax(long long a, long long b){
	const long long lb = LLONG_MIN + INT_MAX, ub = LLONG_MAX - INT_MAX;
	if(a < lb || a > ub)
		a = LLONG_MIN;
	if(b < lb || b > ub)
		b = LLONG_MIN;
	return max(a, b);
}
int main(){
	int N, a[MAXN];
	long long dp[MAXN][4] = {0}; // 0, 12, 13, 22
	cin >> N;
	for(int i=0; i<N; i++)
		cin >> a[i];
	dp[0][0] = a[0], dp[0][1] = LLONG_MIN, dp[0][2] = LLONG_MIN, dp[0][3] = LLONG_MIN;
	dp[1][0] = LLONG_MIN, dp[1][1] = a[1], dp[1][2] = LLONG_MIN, dp[1][3] = LLONG_MIN;
	dp[2][0] = a[0]+a[2], dp[2][1] = LLONG_MIN, dp[2][2] = a[2], dp[2][3] = LLONG_MIN;
	dp[3][0] = LLONG_MIN, dp[3][1] = max(a[0], a[1])+a[3], dp[3][2] = LLONG_MIN, dp[3][3] = LLONG_MIN;
	//cout << a[2] << " " << 
	for(int i=4; i<N; i++){
		dp[i][0] = mymax(dp[i-2][0] + a[i], LLONG_MIN);
		dp[i][1] = mymax(dp[i-3][0] + a[i], dp[i-2][1] + a[i]);
		dp[i][2] = mymax(dp[i-4][0] + a[i], dp[i-2][2] + a[i]);
		dp[i][3] = mymax(dp[i-3][1] + a[i], dp[i-2][3] + a[i]);
	}
	//for(int i=0; i<N; i++)
		//cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << " " << dp[i][3] << endl;
	if(N % 2)
		cout << max(max(dp[N-3][0], dp[N-2][1]), max(dp[N-1][2], dp[N-1][3])) << endl;
	else
		cout << max(dp[N-1][1], dp[N-2][0]) << endl;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n, m, xin, yin, zin;
  cin >> n >> m;
  vector<tuple<ll, ll, ll>> cake(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> xin >> yin >> zin;
    cake[i] = make_tuple(xin, yin, zin);
  }

  ll ans = 0;
  for(int xp = 0; xp <= 1; xp++)
  {
    for(int yp = 0; yp <= 1; yp++)
    {
      for(int zp = 0; zp <= 1; zp++)
      {
        vector<ll> points;

        for(int i = 0; i < n; ++i)
        {
          ll x, y, z;
          tie(x, y, z) = cake[i];
  
          ll point = 0;
          point += xp ? x : -x;
          point += yp ? y : -y;
          point += zp ? z : -z;
          points.emplace_back(point);
        }

        sort(points.rbegin(), points.rend());
        auto st = points.begin();
        auto de = next( points.begin(), m);
        ans = max( ans, accumulate(st, de, 0LL) );
      }
    }    
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
  	int j=0;
    cin >> n >> k;
  	vector<int> weight(n); 
  	
  	for(int i=0; i<n ;i++){
      cin >> weight.at(i);
    }
  	for(int i=0; i<n ;i++){
      if(k<=weight.at(i)){
        j++;
      }
    }
  	cout << j;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 1e9 + 7
digit = 1
for i in range(60):
  one = 0
  for aa in a:
    if (aa >> i) & 1:
      one += 1
  ans += (one * (n - one) * digit) % mod
  ans %= mod
  digit *= 2

print(int(ans))


Measured memory_bytes: 122808
import sys 

count = 0
list_ = []
N = 0

for i in sys.stdin:
    if count == 0:
        N = int(i.split()[0])
        count += 1
    else:
        list1 = []
        count += 1
        if count%2 == 0:
            pass
        else:
            list1 = list(map(int, i.split()))
            for j in list1:
                list_.append(j)

lista = list(set(list_))
x = 0
for k in range(1, N+1):
    if not(k in lista):
        x += 1
print(x)




Measured memory_bytes: 9204
import java.util.Scanner;
import java.util.TreeSet;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
       String a=sc.nextLine();
       for(int i=0;i<a.length();i++){
           char x=a.charAt(i);
           if('a'<=x&&x<='z'){
               x-=32;
               System.out.print(x);
           }else if('A'<=x&&x<='Z'){
               x+=32;
               System.out.print(x);
           }else System.out.print(x);
       }
       System.out.println();
}

}



Measured memory_bytes: 26988
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  int N, L;
  cin >> N >> L;
  
  int Sum = 0;
  for( int i=0; i<N; i++ ) Sum += ( L+i );
  
  vector<int> taste(N);
  for( int i=0; i<N; i++ ) taste.at(i) = Sum - ( L+i );
  
  int ans = Sum - L;
  for( int i=0; i<N; i++ ){
    if( abs( L+i ) < abs( Sum - ans ) ) ans = taste.at(i);
  }
  
  cout << ans;
  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

vector<vector<int32>> adj(100005*2);
vector<bool> visited(100005*2,false);

vector<int64> cnt;

void dfs(int32 v){
  if(visited[v])return;
  visited[v] = true;
  for(auto u : adj[v])dfs(u);
  if(v <= 100005)cnt[0]++;
  else cnt[1]++;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  set<int32> xst;
  REP(i,n){
    int32 x,y;
    cin >> x >> y;
    y += 100005;
    adj[x].emplace_back(y);
    adj[y].emplace_back(x);
  }
  int64 ans = -n;
  REP(i,100005*2){
    if(visited[i])continue;
    cnt = vector<int32>(2,0);
    dfs(i);
    ans += cnt[0] * cnt[1];
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 10112
// <--sbhmsh-- Shubham Jaiswal-->//

  #include <bits/stdc++.h>
  #define FASTIO std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  using namespace std;
  #define endl '\n'
  #define deb cout<<"sab_badhiya"<<endl;
  typedef long long int ll;
  // const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
  const long INF = 2000 * 1000 * 1000 + 7;
  vector<pair<int,int>> a;
  int main() {
    FASTIO
    int n,m;
    cin >> n >> m;
    cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2 << endl;
  }


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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


int main(){
    ll n, k;
    cin >> n >> k;
    if(2 * k > n + 1){
        cout << -1 << endl;
        return 0;
    }

    const ll s = (n + 1) / 2;

    vector<ll> a(n), b(n), c(n);
    REP(i, n){
        c.at(i) = k + 2 * n + i;
    }

    for(ll i = 0; i < s; ++i){
        a.at(i) = k + 2 * i;
        b.at(i) = k + s + n - i - 1;
    }
    for(ll i = 0; i < n - s; ++i){
        a.at(s + i) = k + 2 * i + 1;
        b.at(s + i) = k + 2 * n - 1 - i;
    }

    REP(i, n){
        cout << a.at(i) << ' ' << b.at(i) << ' ' << c.at(i) << endl;
    }
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s; cin >> s;
	unordered_set<char> c;
	for (auto i : s) {
		c.insert(i);
	}
	if (c.size() == 1) {cout << "No";}
	else {cout << "Yes";}
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
// #define int long long

signed main() {

	string s;
	cin >> s;
	
	
	int n = s.size();
	s = ' ' + s;
	
	for (int i=1, j=n; i<j; i++, j--) {
		if (s[i] != s[j]) {
			cout << "No" << endl;
			exit(0);
		}
	}
	
	for (int i=1, j=(n-1)/2; i<j; i++, j--) {
		if (s[i] != s[j]) {
			cout << "No" << endl;
			exit(0);
		}
	}
	
	for (int i=(n+3)/2, j=n; i<j; i++, j--) {
		if (s[i] != s[j]) {
			cout << "No" << endl;
			exit(0);
		}
	}
	
	cout << "Yes" << endl;
	
}




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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 ll INF = 1LL << 60;


int main(void){
  char a;
  cin >> a;
  if(a<'a')cout << 'A' << endl;
  else cout << 'a' << endl;
  return 0;
}

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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define  endl 			"\n"
#define  FOR(i, a, n)   for (ll i = a; i < n; i++)
#define  ROF(i, a, n)   for (ll i = a; i >= n; i--)
#define  all(x)         (x).begin(), (x).end()
#define  mset(x, val)   memset(x,val,sizeof(x))
#define  dline          cout<<"///REACHED///\n";

typedef long long ll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  4e+5+7;



// void solve(){
// 	ll n,m,k,ans=0;
// 	cin>>n>>m>>k;
// 	if(m>n/k){
// 		ll p1 =n/k;
// 		ll remjokers=m-n/k;
// 		if(remjokers > k-1){
// 			ans=remjokers/(k-1);
// 		}
// 		else{
// 			cout<<abs(p1-1)<<endl;
// 			return;
// 		}
// 		cout<<abs(p1-(ans+ans*(k-1)))<<endl;
// 		return;
// 	}
// 	if(m<n/k){
// 		cout<<m<<endl;
// 		return;
// 	}


// }

vector<ll> arr;
ll n;
ll findlcm() 
{ 
	// Initialize result 
	ll ans = arr[0]; 

	// ans contains LCM of arr[0], ..arr[i] 
	// after i'th iteration, 
	for (int i = 1; i < n; i++) 
		ans = (((arr[i] * ans)) / 
				(__gcd(arr[i], ans))); 

	return ans; 
} 
ll f(ll num){
	ll temp=0;
	FOR(i,0,n){
		temp+=num%arr[i];
	}
	return temp;
}
void solve(){
	cin>>n;
	arr.resize(n);
	for(ll&x:arr) {cin>>x;}
	
	ll lcm = findlcm();
	lcm--;
	ll ans = f(lcm);
	cout<<ans;

}



int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	string s1,s2;
	cin>>s1>>s2;
	int pos;
	for(int i=0;i<s2.length();i++){
		if(s1[0]==s2[i]){
			pos=i;
			for(int i=0;i<s2.length();i++){
				if(s1[i]!=s2[(i+pos)%s2.length()]){
					// debug(s1[i],s2[(i+pos)%s1.length()]);
					break;
				}
				if(i==s2.length()-1) {
					cout << "Yes" << endl;;
					return 0;
				}		
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


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

int main() {
    int k, pre = 0;
    short t, temp;
    vector<short> a;
    
    cin >> k;
    cin >> t;

    for(int i = 0; i < t; i++){
        cin >> temp;
        a.push_back(temp);
    }
    
    sort(a.begin(), a.end(), std::greater<short>());
    
    if(a.size() > 1){
        while(a[1] != 0){
            for(vector<short>::iterator i = a.begin(); i != a.end(); ++i){
                if(pre == *i){
                    pre = 0;
                    continue;
                }
                else{
                    (*i)--;
                    pre = *i;
                    break;
                }
            }

            sort(a.begin(), a.end(), std::greater<short>());
        }
        
        if(a[0] != 0){
            a[0]--;
        }
    }
    else{
        a[0]--;
    }
    
    
    
    cout << a[0] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

ll res[1223456], test[1234567];
signed main() {
	ll n, x, l, q; cin >> n;
    vector<vector<ll>> table(71, vector<ll>(n + 2));
	for (int h = 0; h < n; h++) { cin >> test[h]; }
	cin >> l >> q;
	ll mae = -1, ato = 0;
	while (true) {
		if (mae == n - 2) { break; }
		mae++;
		while (true) {
			if (ato != n - 1 && test[ato + 1] - test[mae] <= l) { ato++; }
			else { break; }
		}
		//cout << ' ' << mae + 1 << ' ' << ato + 1 << endl;
		table[0][mae + 1] = ato + 1;
	}
    for (int i = 1; i < 70; i++) {
        for (int j = 0; j < n; j++) {
            table[i][j] = table[i - 1][table[i - 1][j]];
			//cout << i << ' ' << j << ' ' << table[i][j] << endl;
        }
    }
    for (int h = 0; h < q; h++) {
		ll a, b, ans = 0; cin >> a >> b; 
		if (a > b) { swap(a, b); } ll cnt = a;
		while (true) {
			if (cnt >= b) { break; }
			ll ok = 0, ng = 70, mid = (ok + ng) / 2;
			while (ng - ok > 1) {
				if (table[mid][cnt] != 0 && table[mid][cnt] <= b) { ok = mid; }
				else { ng = mid; }
				mid = (ok + ng) / 2;
				//cout << table[mid][cnt] << endl;
			}
			ans += pow(2, ok); cnt = table[ok][cnt];
		}
		cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 59960
#include<iostream>
#include<string.h>
using namespace std;

struct node{
	int item;
	node *next;
	node *pre;
};

node *root = NULL;
node *tail = NULL;

void insert(int item){
	if(root==NULL){
		root = new node();
		root->item = item;
		root->next = NULL;
		root->pre = NULL;
		tail = root;
		return ;
	}
	node *newnode = new node();
	newnode->item = item;
	newnode->next = root;
	root->pre = newnode;
	newnode->pre = NULL;
	root = newnode;
}

void deleteNode(int item,char cmd){
	if(root==NULL)return;
	if(cmd=='f'){
		node *n = root;
		if(root->next!=NULL){
			root->next->pre = NULL;
		}
		root = root->next;
		delete n;
	}
	else if(cmd == 'l'){
		node *temp = tail;
		if(tail==NULL)return;

		if(tail->pre ==NULL){
			tail = NULL;
			root = NULL;
		}
		else {
			tail = tail->pre;
			tail->next = NULL;
			delete  temp;
		}
		
		
		
	}
	else{
		node *current1 = root;
		
		if(root==NULL)return;

		while(current1!=NULL){
			if(current1->item == item){
				if(current1 == root){
					node *temp = current1;
					current1 = current1->next;
					root = current1;
					if(root!=NULL)root->pre = NULL;
					delete temp;
			
				}
				else if(current1 == tail){
					node *temp = current1;
					current1 = current1->pre;
					tail = current1;
					tail->next = NULL;
					delete temp;
				}
				else{
					node *temp = current1;
					current1->next->pre = current1->pre;
					current1->pre->next = current1->next;
					delete temp;
				}
				return;
			}
			current1 = current1->next;			
}

}

}





void printlist(){
	node *current = root;
	while(current!=NULL){
		if(current->next == NULL){
			printf("%d\n",current->item);
			return;
		}
		printf("%d ",current->item);
		current = current->next;

	}
	
}
char cmd[20];
int main(){

	int n; cin >> n;

	while(n--){
		scanf("%s",cmd);

		if(strcmp(cmd,"insert")==0){
			int item; scanf("%d",&item);
			insert(item);
		}
		else if(strcmp(cmd,"delete")==0){
			int item; scanf("%d",&item);
			deleteNode(item,'c');
		}
		else if(strcmp(cmd,"deleteFirst")==0){
			deleteNode(-1,'f');
		}
		else if(strcmp(cmd,"deleteLast")==0){
			deleteNode(-1,'l');
		}
	}
	printlist();


	return 0;
}


Measured memory_bytes: 34380
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<double,double> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
    vector<pii>v;
    rep(i,n){
        pii ujimatsu; int gotiusa;
        cin>>gotiusa>>ujimatsu.first>>ujimatsu.second;
        v.push_back(pii(abs(22-(((double)ujimatsu.second/(pow((double)ujimatsu.first/100,2))))),gotiusa));
    }
    sort(all(v));
    cout<<v[0].second<<endl;}
}

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

#define PI 3.14159265358979323846
#define int long long int
#define ff first
#define ss second
#define pb push_back

#define N 1010
#define MOD 1000000007

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n;
    cin >> n;

    string s;
    cin >> s;

    int f[1000] = {};

    for (int i = 0; i < 10; ++i)
    {
    	for (int j = 0; j < 10; ++j)
    	{
    		for (int k = 0; k < 10; ++k)
    		{
    			string t;
    			t += i + '0';
    			t += j + '0';
    			t += k + '0';

    			int pos = 0;
    			for (int l = 0; l < n && pos < 3; ++l)
    			{
    				if(s[l] == t[pos])
    				{
    					pos++;
    				}
    			}
    			if(pos == 3)
    				f[i * 100 + j * 10 + k]++;
    		}
    	}
    }

    int ans = 0;
    for (int i = 0; i < 1000; ++i)
    {
    	if(f[i]) ans++;
    }
    cout << ans;
   	return 0;	
   		
}

Measured memory_bytes: 384
#include <stdio.h>

int main(int argc, char const *argv[]) {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if ((r <= x && x <= W-r) && (r <= y && y <= H-r)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2088
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=1e4+5;
int h,n,w[maxn],v[maxn];
int dp[2*maxn];
const int INF=0x3f3f3f3f;
int main() {
	cin>>h>>n;
	for(int i=1;i<=n;i++) {
		cin>>w[i]>>v[i];
	}
	for(int i=1;i<=2*h;i++) dp[i]=INF;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<w[i];j++) {
			dp[j]=min(dp[j],v[i]);
		}
		for(int j=w[i];j<=h;j++) {
			dp[j]=min(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	cout<<dp[h]; 
//	int minn=INF;
//	for(int j=h;j<=2*h;j++) {
//		if(dp[j]) minn=min(dp[j],minn);
//	}
//	cout<<minn;
}

Measured memory_bytes: 640
#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>;
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 double PI = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	m += h * 60;
	double A = PI / 360 * m;
	double B = PI / 30 * m;
	double ax = a*sin(A);
	double ay = a * cos(A);
	double bx = b * sin(B);
	double by = b * cos(B);
	double ans = sqrt((ax-bx)*(ax-bx) + (ay-by)*(ay-by));
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}

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

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

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int N, M, Q;
vector<int> a, b, c, d;
vector<int> A(11, 0);
int ans = 0;

int get_score()
{
    int score = 0;
    for (int i = 0; i < Q; i++) {
        if (A[b[i]] - A[a[i]] == c[i]) {
            score += d[i];
        }
    }
    return score;
}

void dfs(int cnt)
{
    if (cnt == N) {
        ans = max(ans, get_score());
        return;
    }

    for (int i = min(A[cnt], M); i <= M; ++i) {
        A[cnt+1] = i;
        dfs(cnt+1);
    }
}

int main()
{
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    A[0] = 1;
    dfs(0);
    cout << ans << endl;
}


Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int max=0;


        if( K < A){
            max = K;
            K=0;
        }else{
            for(int i=0; i<A; i++){
                max++;
                K--;
            }
        }
        if(K > 0){
            K-=B;
        }
        if(K > 0){
            while(K > 0){
                K--;
                max--;
            }
        }
        A=C-1;

        System.out.println(max);

        sc.close();
    }
    
}

Measured memory_bytes: 35660
#include<string>//...........................
#include<cstdio>//....../%/........./%/......
#include<iostream>//.../%/........./%/.......
#include<algorithm>//./%/........./%/........
#include<cmath>//..../%/........./%/.........
#include<cstring>//./%/_______../%/_______...
#include<queue>//../=========/./=========/...
#include<set>//.....................½ñ¤¬×î¸ß£¡
#define mem(s,t) memset(s,t,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define MAXINT 0x7fffffff
#define INF 0x3f3f3f3f
typedef long long LL;
using namespace std;
//define begin
const int MAXN=100010;
const int MAXM=200010;


//define end
//function begin

LL x[MAXN],v[MAXN],amax[MAXN],bmax[MAXN],a[MAXN],b[MAXN];

//function end

int main()
{
    int n,i;
    LL maxx,t,m;
    LL c;maxx=0;
    scanf("%d%lld",&n,&c);
    for(i=0;i<n;i++){
        scanf("%lld%lld",&x[i],&v[i]);
    }
    a[0]=v[0]-x[0];amax[0]=a[0];
    for(i=1;i<n;i++)a[i]=a[i-1]+v[i]-(x[i]-x[i-1]),amax[i]=max(amax[i-1],a[i]);
    b[n-1]=v[n-1]-(c-x[n-1]);bmax[n-1]=b[n-1];
    for(i=n-2;i>=0;i--)b[i]=b[i+1]+v[i]-(x[i+1]-x[i]),bmax[i]=max(bmax[i+1],b[i]);

    maxx=max(amax[n-1],bmax[0]);
    if(maxx<0)maxx=0;


    for(i=0;i<n;i++){
        if(i-1<0)m=0;
        else m=amax[i-1];
        t=max(a[i]-x[i]+bmax[i+1],b[i]-(c-x[i])+m);
        maxx=max(maxx,t);
        //if(i==n-1)printf("%lld %lld\n",a[i]-x[i]+bmax[i+1],b[i]-(c-x[i])+m);
    }
    printf("%lld",maxx);


    return 0;
}
















/* ¦Ì'sic forever! */


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
import sys

def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))
    

    A_list.sort(key=lambda x: -abs(x))
    A_plus = []
    A_minus = []
    mod = 10**9 + 7

    for val in A_list:
        if val >= 0:
            A_plus.append(val)
        else:
            A_minus.append(val)
    

    ans = 1
    cnt = 0
    i_p = 0  # index of A_plus
    i_m = 0  # index of A_minus


    while (cnt < K):
        if (K - cnt) == 1:
            if i_p < len(A_plus):
                ans *= A_plus[i_p]
                ans %= mod
                cnt += 1
                i_p += 1
                break
            
            else:
                ans2 = 1

                for i in range( len(A_list)-K, len(A_list) ):
                    ans2 *= A_list[i]
                    ans2 %= mod

                print(ans2)
                return


        if (i_m + 1) < len(A_minus):
            if (i_p + 1) < len(A_plus):
                if abs( A_plus[i_p] * A_plus[i_p + 1] ) > abs( A_minus[i_m] * A_minus[i_m + 1] ):
                    ans *= A_plus[i_p]
                    cnt += 1
                    i_p += 1
                else:
                    ans *= (A_minus[i_m] * A_minus[i_m + 1])
                    cnt += 2
                    i_m += 2

            else:
                ans *= (A_minus[i_m] * A_minus[i_m + 1])
                cnt += 2
                i_m += 2
            
        else:
            ans *= A_plus[i_p]
            cnt += 1
            i_p += 1
        

        ans %= mod
    
    
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 31680
def main():
    N = int(input())
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())
    min_v = min([A, B, C, D, E])
    if N % min_v != 0:
        print(4 + N // min_v + 1)
    else:
        print(4 + N // min_v)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61916
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main() {
    long long int n, d;
    int count = 0;
    long double x[200000];
    long double y[200000];
    scanf("%lld%lld", &n, &d);
    for (int i = 1; i <= n; i++) {
        scanf("%Lf", &x[i]);
        scanf("%Lf", &y[i]);
    }

    for (int i = 1; i <= n; i++) {
        if (sqrt(x[i] * x[i] + y[i] * y[i]) <= d) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    map<int, int> mp;
    int a;
    for(int i = 0; i < n; i++)
        cin >> a, mp[a]++;

    int ans = 0;
    for(auto i: mp){
        if(i.Y > i.X)
            ans += i.Y - i.X;
        if(i.Y < i.X)
            ans += i.Y;
    }

    cout << ans << '\n';
    return 0;
}


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

const int MAXN = 1e2 + 5;

int N;
int occ[MAXN][30];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < 3; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < N; j++)
			occ[j][s[j] - 'a']++;
	}
	
	int ans = 0;
	for (int i = 0; i < N; i++)
		ans += 3 - *max_element(occ[i], occ[i] + 26);
	
	printf("%d\n", ans);
	
	return 0;
}

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

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

  int k, s;
  cin >> k >> s;

  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int l = s - i - j;
      if (0 <= l && l <= k) cnt++;
    }
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256