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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	auto N=in(),S=in();
	vector<ll> A=vecin<ll>(N);
	vector<ll> B(N+1,0);
	REP(i,N){
		B[i+1] = B[i]+A[i];
	}

	int LW=N,SW=1;
	if(B[LW]-B[SW-1]<S){
		out(0);
		return 0;
	}
	while(LW-SW>0){
		int MW = (LW+SW)/2;
		bool flag = false;
		for(int i=1;i<=N-MW+1;i++){
			if(B[i+MW-1]-B[i-1]>=S){
				flag = true;
				break;
			}
		}
		if(flag){
			LW = MW;
		}
		else{
			SW = MW+1;
		}
	}

	out(LW);
	return 0;
}



Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
// dijstra's algo
void solve(){
	int dx[4] = {-1,1,0,0},dy[4] = {0,0,-1,1};
	int h,w,k; cin >> h >> w >> k;
	int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
	--sx;--sy;--tx;--ty;
	vector<string> s(h);
	forn(i,0,h) cin >> s[i];
	
	queue<pair<int,pair<int,int>>> q;
	q.push({0,{sx,sy}});
	int dist[h][w];
	memset(dist,inf,sizeof(dist));
	dist[sx][sy] = 0;
	while(q.size() > 0){
		auto temp = q.front();
		q.pop();
		int cost = temp.first;
		int x = temp.second.first, y = temp.second.second;
		forn(i,0,4){
			forn(j,1,k+1){
				int nx = x + dx[i]*j, ny = y + dy[i]*j;
				if(nx < 0 || ny < 0 || nx >= h || ny >= w) break;
				int cur_cost = cost + 1;
				if(s[nx][ny] == '@') break;
				if(dist[nx][ny] > cur_cost){
					dist[nx][ny] = cur_cost;
					q.push({cur_cost,{nx,ny}});
				}
				if(dist[nx][ny] < cur_cost) break;
			}
		}
	}
	cout << (dist[tx][ty] == inf ? -1 : dist[tx][ty]);
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 9636
import sys
from bisect import bisect_left, bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *L = map(int, read().split())

    L.sort()

    ans = 0
    for i in range(N):
        a = L[i]
        for j in range(i + 1, N):
            b = L[j]
            left = bisect_left(L, b, lo=j + 1)
            right = bisect_left(L, a + b)
            ans += right - left

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74096
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}


//深さ優先探索
void dfs(vector<string> &m,vector<vector<bool>> &seen, ll x, ll y, ll h, ll w){

	seen[y][x]=true;

	
	for(ll i=0;i<4;i++){
		ll nx=x,ny=y;
		if(i==0){ //up
			ny=y-1;
		}
		else if(i==1){ //down
			ny=y+1;
		}
		else if(i==2){ //right
			nx=x+1;
		}
		else{ //left
			nx=x-1;
		}

		if(nx<0 || nx>=w || ny<0 || ny>=h){
			continue;
		}
		if(seen[ny][nx]){
			continue;
		}
		
		if(m[ny][nx]=='#'){
			continue;
		}

		dfs(m,seen,nx,ny,h,w);
	}
}

const ll MOD=1000000007;

void solve(){
	
	ll k,a,b;
	cin>>k>>a>>b;

	ll n=b/k;
	if(n*k>=a){
		cout<<"OK"<<endl;
	}
	else{
		cout<<"NG"<<endl;
	}


}


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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
static const int INF = 2000000000;
static const int NIL = -1;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);
    if(a>b){
        printf("0\n");
        return 0;
    } else if(a==b){
        printf("1\n");
        return 0;
    } else {
        ll ans = (b*(n-1)+a)-(a*(n-1)+b)+1;
        printf("%lld\n",(ans > 0) ? ans : 0);
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstdio>
using namespace std;
typedef long long int ll;
int main()
{
    int n,i,j;
    scanf("%d",&n);
    ll a[100009],pre=0;
    int ok=0;
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(i=2;i<=n;i++)
    {
        if(a[i]<a[i-1])
        {
            a[i-1]--;
            if(a[i-1]>a[i])
                ok=1;
            else if(a[i-1]==a[i])
            {
                 j=i+1;
                while(j<=n)
                {
                    if(a[j]!=a[i])
                    {
                        if(a[j]<a[i])
                            ok=1;
                        break;
                    }
                    j++;
                }
            }
        }
        if(ok==1)
            break;
    }
    if(ok==1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict
N, = map(int, input().split())

dd = defaultdict(int)
cc = dict()
norm = dict()
ss = []
for _ in range(N):
    xs = list(map(int, input().split()))
    cnd = [tuple(xs[j:] + xs[:j]) for j in range(1, 5)]
    x = min(cnd)
    for item in cnd:
        norm[item] = x
    dd[x] += 1
    cc[x] = (4 if x[0] == x[1] else 2)if x[0] == x[2] and x[1] == x[3] else 1
    ss.append(x)

def f(ff, gg):
    a,b,c,d=ff
    e,h,g,f=gg
    tl = [(a,e,f,b), (b,f,g,c), (c,g,h,d), (d,h,e,a)]
    for i in range(4):
        if tl[i] not in norm:
            return 0
        tl[i] = norm[tl[i]]
    r = 1
    for cp in tl:
        r *= dd[cp]*cc[cp]
        dd[cp] -= 1
    for cp in tl:
        dd[cp] += 1
    return r

r = 0
for i in range(N):
    ff = ss[i]
    dd[ff]-=1
    for j in range(i+1, N):
        sl = ss[j]
        x, y, z, w = sl
        dd[sl]-=1
        sls = [(x,y,z,w), (y,z,w,x), (z,w,x,y), (w,x,y,z)]
        for s in sls:
            r += f(ff, s)
        dd[sl]+=1
    dd[ff]+=1
print(r//3)


Measured memory_bytes: 50548
n, m = map(int, input().split())
ab = sorted([tuple(map(int, input().split())) for i in range(n)])
i, ans = 0, 0
while ab[i][1] < m:
    m -= ab[i][1]
    ans += ab[i][1] * ab[i][0]
    i += 1
ans += ab[i][0] * m
print(ans)

Measured memory_bytes: 89324
/*
* @Author: dnhirapara
* @Date: 2020-04-30 22:24
* @Name: dp_g
*/
#include <bits/stdc++.h>

using namespace std;

/************defination************/

#define endl "\n"
#define log(x) cerr << __LINE__ << ": " << #x << " -> " << (x) << endl;
#define ll long long int
#define ull unsigned long long int

void in_out_file(){
    #ifdef _DEBUG
        freopen("F:/Coding/CompetitiveProg/static/input.txt", "r", stdin);
        freopen("F:/Coding/CompetitiveProg/static/output.txt", "w", stdout);
        freopen("F:/Coding/CompetitiveProg/static/debug.txt", "w", stderr);
    #endif
}

ll dp[100005] = {0};
bool vis[100005] = {0};
// int dfs(int n, vector<ll> graph[],vector<bool> &visited,vector<ll> &dist){
//     visited[n] = true;
//     int cnt = 0;
//     for(auto i : graph[n]){
//             log(i)
//             if(dist[i]!=-1)return dist[i];
//             cnt  = max(dist[i],dist[n]+1);
//             ans = max(dist[i],ans);
//             dfs(i, graph, visited, dist);
//     }
//     return dist[n] = cnt;
// }

ll dfs(ll n, std::vector<ll> g[]){
    if(vis[n])return dp[n];
    vis[n] = true;
    ll best = 0;
    for(auto i:g[n]){
        best = max(best, dfs(i,g)+1);
    }
    return dp[n] = best;
}

//@time comp :
//@space comp :
int main(){
    // cin.ignore(); must be there when using getline(cin, s)
    #ifndef AUTO
        in_out_file();
    #endif
    ll n, m;
    ll x, y;
    cin>>n>>m;
    std::vector<ll> graph[n+1];
    std::vector<ll> vertax(n+1);
    for(ll i=1;i<=m;i++){
        cin>>x>>y;
        graph[x].push_back(y);
    }
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        ans = max(ans, dfs(i, graph));
    }
    cout<<ans<<endl;
    // for(ll i=1;i<=n;i++){
    //     cout<<i<<" -> ";
    //     for(auto j: graph[i]){
    //         cout<<j<<" ";
    //     }
    //     cout<<"\n";
    // }
    // std::vector<bool> visited(n+1);
    // for(ll i=0;i<n+1;i++){
    //     visited[i] = false;
    //     vertax[i] = -1;
    // }
    // for(ll i=1;i<n+1;i++){
    //     dfs(i, graph, visited, vertax);
    // }
    // for(ll i=1;i<=n;i++){
    //     log(vertax[i])
    // }
    // cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9472
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

string re(string s) {
	REP(i, s.length() / 2)
		swap(s[i], s[s.length() - 1 - i]);
	return s;
}
int main() {
	int n;
	cin >> n;
	while (n--) {
		string s;
		cin >> s;
		set<string> ss;
		FOR(i, 1, s.length()) {
			ss.insert(s.substr(0, i) + s.substr(i, s.length() - i));
			ss.insert(re(s.substr(0, i)) + s.substr(i, s.length() - i));
			ss.insert(s.substr(0, i) + re(s.substr(i, s.length() - i)));
			ss.insert(re(s.substr(0, i)) + re(s.substr(i, s.length() - i)));
			ss.insert(s.substr(i, s.length() - i) +s.substr(0, i) );
			ss.insert(s.substr(i, s.length() - i) +re(s.substr(0, i)) );
			ss.insert(re(s.substr(i, s.length() - i)) +s.substr(0, i) );
			ss.insert(re(s.substr(i, s.length() - i)) +re(s.substr(0, i)));
		}
		cout << ss.size() << endl;
	}
}

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

int main(void)
{
   int i, x=0;
   char s[200001], t[200001];

   scanf("%s%s",s,t);

   for(i=0;i<strlen(s);i++)
      if(s[i]!=t[i])
         x++;

   printf("%d\n",x);
   return 0;
}

Measured memory_bytes: 2096
#include <stdio.h>

int main()
{
	int n, i, j, isprime[51000], primes[5500], matches;

	/* pre-processing */
	for(i = 0; i < 51000; i++) isprime[i] = 1;
	isprime[0] = 0;
	isprime[1] = 0;
	for(i = 2; i < 51000; i++) if(isprime[i]) for(j = 2; i * j < 51000; j++) isprime[i * j] = 0;

	while(1) {
		matches = 0;
		scanf("%d", &n);
		if(n == 0) break;
		for(i = 0; i < n; i++) {
			if(isprime[i] && isprime[n - i]) {
				matches++;
				if(i == n - i) matches++;
			}
		}
		printf("%d\n", matches / 2);
	}
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<"//"<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
ll dp[500005][6],sc[500005][6];
//bool check[5005];
//char s[500005],t[500005];
bool flag,dame;

ll  fact[400005];
ll rfact[400005];
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<400000; i++){
        fact[i] = (fact[i-1]*i) % mod;
        rfact[i] = rui(fact[i],mod - 2);
    }
}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;
}

int main(){
	cin >> n;
	num = -INF;
	for(i=0;i<n;i++){
		cin >> x[i];
		if(x[i] >= num)ans++;
		num = max(num,x[i]);
	}
	p(ans);
	return 0;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

bool check(vector<int> A){
	bool ok = true;
	REP(i,A.size()){
		if(A[i] % 2 == 1) ok = false;
	}

	return ok;

}

int main(void){

	int N; cin >> N;
	vector<int> A(N);
	REP(i,N) cin >> A[i];

	int ans = 0;
	while(check(A)){
		REP(i,N) A[i] /= 2;
		ans++;
	}

	cout << ans << endl;



	return 0;

}


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

using namespace std;
#define pb push_back
#define ll long long
#define fast std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
 
 //string ans="";
/*ll solve(ll n )
 {
     if(n<12)
        return n;
     if(mp[n]==0)
            mp[n]=max(solve(n/2)+solve(n/3)+solve(n/4),n);
     return mp[n];
        
 }
*/
int main(){
   fast;
   ll n;
   cin>>n;
   ll r=0,ans=0;
   string s;cin>>s;
   for(ll i=0;i<n;i++)
   {
      if(s[i]=='R')
        r++;
   }
   for(ll i=0;i<r;i++)
   {
       if(s[i]!='R')
        ans++;
   }
   cout<<ans;
}

Measured memory_bytes: 3764
#include<stdio.h>
#define N 100

int main()
{
  int n,A[N],i,flag,cnt=0,change,j;
  
  scanf("%d",&n);

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



  flag = 1;
  i=0;
  while(flag)
    {
      flag = 0;
      for(j=n-1;j>=i+1;j--)
	{
	  if(A[j] < A[j-1])
	    {
	      change = A[j];
	      A[j] = A[j-1];
	      A[j-1] = change;
	      flag = 1;
	      cnt++;
	    }
	 
	}
      i++;
    }


  for(j=0;j<n;j++)
    {
      printf("%d",A[j]);
      if(j !=n-1)printf(" ");
    }
  printf("\n%d\n",cnt);
  
  return 0;
}





Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
const int mod = 1000000007;
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
int h,n,sum=0;
std::vector<int> a;
int main(){
  cin >> h >> n;
  a.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  cout << (h <= sum ? "Yes" : "No") << endl; 
}


Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#define N 10000
int isprime(int);
int main(){
  int a,i,c,count=0,b[N];

  scanf("%d",&a);

  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }

  for(i=0;i<a;i++){
    c=isprime(b[i]);
    if(c==1)
      count++;
  }
 
  printf("%d\n",count);
  return 0;
}

int isprime(int a){
  int i;
    if(a==2){
      return 1;
    }
    if(a<2||a%2==0){
      return 0;
    }
    
    i=3;
    while(i <= sqrt(a)){
      if(a%i==0){
	return 0;
      }
      i+=2;
    }
    return 1;
}

      

  

Measured memory_bytes: 632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100000 + 100;

int n, a[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 0; i <= n - 1; i++)
		cin >> a[i];
	sort(a, a + n, greater<int>());

	for(int i = 0; i <= n; i++)
		if(i + 1 >= a[i + 1])
		{
			// cerr << i << endl;
			int tmp1 = a[i] - i, tmp2 = 1;
			for(int j = i + 1; j <= n && i < a[j]; j++)
				tmp2++;
			if(tmp1 % 2 == 0 || tmp2 % 2 == 0)
				cout << "First" << endl;
			else
				cout << "Second" << endl;
			break;
		}


	return 0;
}


Measured memory_bytes: 640
N=int(input())
A=[[]for i in range(N)]
for i in range(N):
    a,b,c=map(int,input().split())
    A[i].append(a)
    A[i].append(b)
    A[i].append(c)
A.sort(key=lambda x:x[2],reverse=True)
c=0
h=0
X=0
Y=0
for x in range(101):
    for y in range(101):
        c=0
        for i in range(N):
            H=abs(A[i][0]-x)+abs(A[i][1]-y)+A[i][2]
            if H>=abs(A[i][0]-x)+abs(A[i][1]-y):
                break
        for i in range(N):
            if max(H-abs(A[i][0]-x)-abs(A[i][1]-y),0)!=A[i][2]:
                c=1
                break
        if c==0:
            h=H
            X=x
            Y=y
            break
    if c==0:
        break
print(X,Y,h)


Measured memory_bytes: 3064
S = input()

ans = 'No'
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    ans = 'Yes'
if S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
    ans = 'Yes'
if S[0] == S[3] and S[1] == S[2] and S[0] != S[2]:
    ans = 'Yes'
print(ans)


Measured memory_bytes: 3060
n = int(input())
s = []
for i in range(n):
    s.append(list(map(int, input().split())))

s.sort()

#print(s)

ans = (s[0][0] - 1) + (s[-1][0] - s[0][0] + 1) + (s[-1][1])

print(ans)

Measured memory_bytes: 27948
N = int(input())
prime = [2]
ansans = []
flag = True
counter = 0
now = 3
ans = ""
while len(ansans) != N:
  counter = 0
  flag = True
  while prime[counter] ** 2 <= now:
    if now % prime[counter] == 0:
      flag = False
      break
    counter += 1
  if flag:
    prime.append(now)
    if now % 5 == 1:
      ansans.append(now)
  now += 1
for i in range(N):
  ans += str(ansans[i])
  if i != N - 1:ans += " "
print(ans)

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

#include <atcoder/string>
using namespace atcoder;

void solve(std::string S){
    vector<int> sa = suffix_array(S);
    set<string> st;
    long long answer = (long long)S.size() * (S.size() + 1) / 2;
    for (auto common_height : lcp_array(S, sa)) {
        answer -= common_height;
    }

    cout << answer << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 16076
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n, m = map(int, input().split())

    ab = []
    for _ in range(n):
        a, b = map(int, input().split())
        ab.append((a,b))

    ab.sort(key=lambda x: x[0])
    # print(ab)
    ans = 0
    j = 0
    h = []
    for i in range(1,m+1):
        while j < len(ab) and ab[j][0] <= i:
            heappush(h, (-ab[j][1]))
            j += 1

        if len(h) > 0:
            val = heappop(h)
            # print(val)
            ans -= val

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21848
N = int(input())
txy = [tuple(map(int,input().split())) for _ in range(N)]
t = 0
x = 0
y = 0
for i in range(N):
    nt,nx,ny = txy[i]
    t = nt-t
    x = nx-x
    y = ny-y
    d = abs(x)+abs(y)
    if t < d:
        print("No")
        exit(0)
    elif (t-d)%2 == 1:
        print("No")
        exit(0)
    t,x,y = txy[i]
print("Yes")

Measured memory_bytes: 22596
#include<stdio.h>

int main(void){
  int k;
  scanf("%d", &k);
  if(k%2 == 0){
    printf("%d\n", (k/2)*(k/2));
  }else{
    printf("%d\n", (k/2)*(k/2+1));
  }
  return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
answer = -1, -1, -1

for x in range(n+1):
  for y in range(n-x+1):
    z = n - x - y
    if x * 10000 + y * 5000 + z * 1000 == m:
      answer = (x, y, z)
      break
    else:
      continue
print(*answer)


Measured memory_bytes: 3060
import java.util.Scanner;


public class Main {

	Scanner sc;
	
	class Circle{
		public double r;
		public Vector c;
		
		public Circle(double x, double y, double r){
			this.c=new Vector(x, y);
			this.r=r;
		}
	}
	
	class Line{
		public Vector p1, p2;
		
		public Line(double x1, double y1, double x2, double y2){
			this.p1=new Vector(x1,y1);
			this.p2=new Vector(x2,y2);
		}
		
		public Vector v(){
			return p2.subtract(p1);
		}
	}
	
	class Vector{
		public double x, y;
		
		public Vector(double x, double y){
			this.x=x;
			this.y=y;
		}
		
		public double norm(){
			return Math.hypot(x, y);
		}
		
		public double sqrNorm(){
			return x*x+y*y;
		}
		
		public double ip(Vector v){
			return x*v.x+y*v.y;
		}
		
		public Vector add(Vector v){
			return new Vector(x+v.x, y+v.y);
		}
		
		public Vector subtract(Vector v){
			return new Vector(x-v.x, y-v.y);
		}
		
		public Vector multiply(double a){
			return new Vector(x*a, y*a);
		}
		
		public String toString(){
			return String.format("(%f,%f)", x, y);
		}
	}
	
	boolean cross(Circle circle, Line line){
		Vector v1=line.p1.subtract(circle.c), v2=line.p2.subtract(circle.c);
		Vector x=line.p1.subtract(line.v().multiply(line.v().ip(v1)/line.v().sqrNorm()));
		
		if((v1.norm()<circle.r&&v2.norm()<circle.r)||x.subtract(circle.c).norm()>circle.r) return false;
		else if(x.subtract(line.p1).ip(x.subtract(line.p2))<=0) return true;
		else if(v1.norm()<circle.r||v2.norm()<circle.r) return true;
		else return false;
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	void io(){
		sc=new Scanner(System.in);
		
		int n;
		while((n=ni())!=0){
			Circle[] circle=new Circle[n];
			for(int i=0;i<n;++i){
				circle[i]=new Circle(ni(),ni(),ni());
			}
			
			int m=ni();
			for(int i=0;i<m;++i){
				Line line=new Line(ni(), ni(), ni(), ni());
				
				boolean safe=false;
				for(int j=0;j<n;++j){
					safe|=cross(circle[j],line);
				}
				System.out.println(safe?"Safe":"Danger");
			}
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}
}

Measured memory_bytes: 31588
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$W) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
//$a = array_map('intval',explode(" ",trim(fgets(STDIN))));

$rb = array();
for($i=0;$i<$N;$i++) {
  list($X,$L)= explode(" ",trim(fgets(STDIN)));
  $r=new robo($X,$L);
  $rb[]=$r;
}
usort($rb,'cmp');
$cnt=1;
$prev=0;
for($i=1;$i<$N;$i++) {
  $dup = $rb[$i]->isDup($rb[$prev]);
  //printf("prev [%d %d] %d %d %s\n",$rb[$prev]->s,$rb[$prev]->e,$rb[$i]->s,$rb[$i]->e,$dup);
  if ($dup) continue;
  $cnt++;
  $prev=$i;
}
printf("%d\n",$cnt);
function cmp($a,$b)
{
  if ($a->e == $b->e) return 0;
  return ($a->e < $b->e) ? -1 : 1;

}
Class robo {
  public $s;
  public $e;
  function __construct($x,$l)
  {
    $this->s = $x-$l;
    $this->e = $x+$l;
  }
  public function isDup($robo)
  {
    if ($this->s >= $robo->e) return false;
    if ($this->e <= $robo->s) return false;
    return true;
  }
}


Measured memory_bytes: 21364
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
int n,a; cin>>n>>a;
cout<<(n*n-a);
return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    string S;
    cin >> S;
    bool flag=true;
    for(int i=0;i<3;i++)
    {
        if(S.substr(i,1)==S.substr(i+1,1))
        {
            flag=false;
            break;
        }
    }
    if(flag)cout << "Good" << endl;
    else  cout << "Bad" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

string* bubble_sort(int n, string* array) {
  for (int i = 0; i < n; i++) {
    for (int j = n-1; j > i; j--) {
      if (array[j][1] < array[j-1][1]) {
        string tmp = array[j];
        array[j] = array[j-1];
        array[j-1] = tmp;
      }
    }
  }
  return array;
}

string* selection_sort (int n, string* array) {
  for (int i = 0; i < n; i++) {
    int mini = i;
    for (int j = i+1; j < n; j++) {
      if (array[j][1] < array[mini][1]) {
        mini = j;
      }
    }
    string tmp = array[i];
    array[i] = array[mini];
    array[mini] = tmp;
  }
  return array;
}

void print_array(int n, string* array) {
  cout << array[0];
  for (int i = 1; i < n; i++) {
    cout << " " << array[i];
  }
  cout << endl;
}

int main() {
  int n;
  string* a;
  string* b;

  cin >> n;
  a = new string[n];
  b = new string[n];
  
  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    
    a[i] = tmp;
    b[i] = tmp;
  }

  bubble_sort(n, a);
  print_array(n, a);
  cout << "Stable" << endl;
  
  selection_sort(n, b);
  print_array(n, b);
  bool stable = true;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      stable = false;
      break;
    }
  }

  if (stable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
ll MOD = 1e9 + 7;
vector<int> a;
int n;
int main()
{
  cin >> n;
  a.resize(n);
  REP(i,n){
    cin >> a[i];
  }
  int x, y, z;
  x = y = z = 0;
  ll ans = 1;
  REP(i, n){
    ll mul = 0;
    int id = 0;
    if(a[i] == x){mul ++;id = 1;}
    if(a[i] == y){mul ++;id = 2;}
    if(a[i] == z){mul ++;id = 3;}
    if(mul == 0){
      ans = 0;
      break;
    }
    ans *= mul;
    ans %= MOD;
    if(id == 1){x ++;}
    if(id == 2){y ++;}
    if(id == 3){z ++;}
  }
  cout << ans << endl;
}


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

int main()
{
    int N, x;
    int ans = 0;
    vector<int> d;

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x;
        d.push_back(x);
    }

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

    cout << ans << endl;

    return 0;
}

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

char s[20000];
int w;

int main(){
	scanf("%s",s);
	scanf("%d",&w);
	int l=strlen(s);
	for(int i=0;i<l;i++)
		if(i%w==0) printf("%c",s[i]);
	
	return 0;
}

Measured memory_bytes: 128
N,L = map(int,input().split())
azi = []
for i in range(N):
    azi.append(i+L)
if min(azi) > 0:
    k = min(azi)
elif min(azi) <= 0 and max(azi) >= 0:
    k = 0
elif max(azi) < 0:
    k = max(azi)
azi.remove(k)
print(sum(azi))

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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		List<Integer> list = new ArrayList<>();
		for(int i = 1; i <= b; i++) {
			int num = (a * i) % b;
			list.add(num);
		}
		if (list.contains(c)) out.println("YES");
		else out.println("NO");

		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



Measured memory_bytes: 23380
#include <stdio.h>
#include <string.h>
int main()
{
    char a[1000];
    scanf("%s",a);
    int len=strlen(a);
    for(int i=0;i<=len/2;i++)
    {
        if(a[i]!=a[len-i-1])
        {
            printf("No");
            return 0;
        }

    }
    printf("Yes");
}

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

int main() {
  int n,q;
  cin>>n>>q;
  vector<int> a[n+1];
  rep(i,0,n-1){
    int from,to;
    cin>>from>>to;
    a[from].push_back(to);
    a[to].push_back(from);
  }
  ll b[n+1];
  rep(i,1,n+1) b[i]=0;
  rep(i,0,q){
    int c;
    ll d;
    cin>>c>>d;
    b[c]+=d;
  }
  bool used[n+1];
  rep(i,1,n+1) used[i]=false;
  used[1]=true;
  queue<int> r;
  r.push(1);
  while(r.size()){
    int p=r.front();
    r.pop();
    rep(i,0,a[p].size()){
      if(used[a[p][i]]==false){
        b[a[p][i]]+=b[p];
        used[a[p][i]]=true;
        r.push(a[p][i]);
      }
    }
  }
  rep(i,1,n+1) cout<<b[i]<<endl;
}


Measured memory_bytes: 16500
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c, d := intScanner(), intScanner(), intScanner(), intScanner()
	fmt.Println(smaller(a, b) + smaller(c, d))
}


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



int main(){
    
    int n;cin>>n;
    vv faclist(19, vi (19, 0));
    
    rep(i,n){
        double a;cin>>a;
        ll anum = a*1e9+0.5;
        
        //llとして読み込み, 2と5の冪を計算
        int fac2 = -9, fac5 = -9;
        
        while( fac2<10 && anum%2 == 0 ){
            fac2++;
            anum /= 2;
        }
        
        while( fac5<10 && anum%5 == 0 ){
            fac5++;
            anum /= 5;
        }
        
        faclist[min(18,fac2+9)][min(18,fac5+9)]++;
    }
    
    //個数累積のリストを作る
    vv acclist = faclist;
    
    
    rep(i,19){
        for(int j=17; j>=0; j--){
            acclist[i][j] += acclist[i][j+1];
        }
    }
    rep(j,19){
        for(int i=17; i>=0; i--){
            acclist[i][j] += acclist[i+1][j];
        }
    }
    
    ll ans = 0;
    
    rep(i,19)rep(j,19){
        if(!faclist[i][j])continue;
        
        if(i>8 && j>8)ans += faclist[i][j] * (acclist[18-i][18-j]-1);
        else ans += faclist[i][j] * acclist[18-i][18-j];
    }
    
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
#define rall(x) x.rbegin(),x.rend()
#define all(x) x.begin(),x.end()
using ll = long long;

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(rall(p));
    sort(rall(q));
    vector<int> tmp;
    rep(i,x) tmp.push_back(p[i]);
    rep(i,y) tmp.push_back(q[i]);
    rep(i,c) tmp.push_back(r[i]);
    sort(rall(tmp));
    ll sum = 0;
    rep(i,x+y) sum += tmp[i];
    cout << sum << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#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__)
const long long inf = 1LL << 60;
const int intinf = 1 << 30;
const long long mod = 1e9 + 7;

const double PI = acos(-1);
const double c60 = cos(PI / 3);
const double s60 = sin(PI / 3);

int counts = 0;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end())
            cout << " ";
    }
    cout << endl;
};

class Coor {
  public:
    double x;
    double y;
    Coor() {}
    Coor(double xx, double yy) {
        x = xx;
        y = yy;
    }

    void print() { printf("%lf %lf\n", x, y); }
};

void koch(int n, Coor p1, Coor p2) {
    if(n == 0)
        return;

    Coor s((2 * p1.x + 1 * p2.x) / 3, (2 * p1.y + 1 * p2.y) / 3);
    Coor t((1 * p1.x + 2 * p2.x) / 3, (1 * p1.y + 2 * p2.y) / 3);
    Coor u;
    u.x = s.x + (t.x - s.x) * c60 - (t.y - s.y) * s60;
    u.y = s.y + (t.x - s.x) * s60 + (t.y - s.y) * c60;

    koch(n - 1, p1, s);
    s.print();
    koch(n - 1, s, u);
    u.print();
    koch(n - 1, u, t);
    t.print();
    koch(n - 1, t, p2);
}

int main() {
    int n;
    cin >> n;
    Coor p1(0.0, 0.0), p2(100.0, 0.0);
    p1.print();
    koch(n, p1, p2);
    p2.print();
}



Measured memory_bytes: 3204
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//do {
//    print(v);
//  } while (std::next_permutation(v.begin(), v.end()));


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

	ll A, B, Q;
	cin >> A >> B >> Q;
	VI s(A);
	VI t(B);
	REP(i, A)cin >> s[i];
	REP(i, B)cin >> t[i];;
	SORT(s);
	SORT(t);

	REP(i, Q) {
		ll a;
		cin >> a;
		ll ans = LLINF;
		ll S = UB(s, a) - s.begin();
		int T = UB(t, a) - t.begin();
		if (S < A && T < B) {
			ans = min(ans, s[S] - a + abs(s[S] - t[T]));
			ans = min(ans, t[T] - a + abs(s[S] - t[T]));//right only
		}
		if (S - 1 >= 0 && T - 1 >= 0) {
			ans = min(ans, a - s[S-1] + abs(s[S-1] - t[T-1]));
			ans = min(ans, a - t[T-1] + abs(s[S-1] - t[T-1]));//left only
		}
		if (T - 1 >= 0 && S < A) {
			ans = min(ans, s[S] - a + abs(s[S] - t[T - 1]));
		}
		if (T < B &&S - 1 >= 0) {
			ans = min(ans, t[T] - a + abs(t[T] - s[S - 1]));
		}
		if (S - 1 >= 0 && T < A) {
			ans = min(ans, a - s[S - 1] + abs(t[T] - s[S - 1]));
		}
		if(T-1>=0 && S<A){
			ans = min(ans, a - t[T - 1] + abs(t[T - 1] - s[S]));//both
		}
		//if (i == 0)cout << a - s[S - 1] + abs(t[T] - s[S - 1]) << endl;
		cout << ans << endl;
		cout << endl;
	}
	return 0;
}




















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

using namespace std;

#define int long long

const int N = 2e5 + 5;
int n, h[N], a[N], dp[N];

struct Bit {
    int maxx[N];
    void update (int pos, int val) {
        for (; pos < N; pos += pos & -pos) maxx[pos] = max(maxx[pos], val);
    }
    int get (int pos) {
        int ret = 0;
        for (; pos > 0; pos -= pos & -pos) ret = max(ret, maxx[pos]);
        return ret;
    }
} bit;

int32_t main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> h[i];
    for (int i = 1; i <= n; ++i) cin >> a[i];

    for (int i = 1; i <= n; ++i) {
        dp[i] = a[i] + bit.get(h[i]);
        bit.update(h[i], dp[i]);
    }

int ans = 0;
for (int i = 1; i <= n; ++i) ans = max(ans, dp[i]);
cout << ans;

    return 0;
}


Measured memory_bytes: 6528
program main
  implicit none
  integer :: n, m, c, i, num = 0
  integer, allocatable :: b(:), a(:)

  read *, n, m, c
  allocate (a(m), b(m))
  read *, b(:)

  do i = 1, n
    read *, a(:)
    if (dot_product(a, b) > -c) then
      num = num + 1
    end if
  enddo

  print '(i0)', num

end

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;
		
ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}

int main() {
	ll tttt; 
	//cin>>tttt;
	tttt = 1;
    while(tttt--) { 	
		ll a,b,c,d; cin>>a>>b>>c>>d;
		ll ans = a*c;
		ans = max(ans,a*d);
		ans = max(ans,b*d);
		ans = max(ans,b*c);
		cout<<ans;
    } 
    return 0; 
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int64_t mod=1000000007;
int64_t pw(int64_t x,int64_t y){
  int64_t z;
  if (y==0) return 1;
  else{
    z=pw(x,y/2)*pw(x,y/2)%mod;
    if(y%2==1) z=z*x%mod;
    return z;
  }
}
int main(){
  int64_t n,i,ans=0;
  cin>>n;
  vector<int64_t> c(n);
  for(i=0;i<n;i++) cin>>c.at(i);
  sort(c.begin(),c.end());
  for(i=0;i<n;i++) ans=(ans+(n+1-i)*c.at(i)%mod)%mod;
  ans=ans*pw(4,n-1)%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
using Graph = vector<vector<int>>;

int main(){
    ll K;
    string S;
    cin >> K >> S;
    if(S.size() > K){
        cout << S.substr(0,K)+"..." << endl;
    }else{
        cout << S << endl;
    }
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;

typedef pair<int,int> pii;

class node{
public:
	pii p;
	vector <node*> ch;
	node() {
		p = pii(0,0);
	}
	node (int x, int y){
		p = pii(x, y);
	}
	bool operator < (const node &a) const {
		return p < a.p;
	}
};

int tree[2][804040], n;
map <int, int> pos;

void build (int i, int ind, int l, int r, int x, int v) {
	if (l == r) {
		tree[i][ind] = v;
		return;
	}
	int mid = (l+r)/2;
	if (x <= mid) {
		build(i, ind*2, l, mid, x, v);
	} else {
		build(i, ind*2+1, mid+1, r, x, v);
	}
	tree[i][ind] = min(tree[i][ind*2], tree[i][ind*2+1]);
}

int query (int i, int ind, int l, int r, int x, int y) {
	if (l == x && r == y) {
		return tree[i][ind];
	}
	if (l > y || r < x || x > y) {
		return 1<<30;
	}
	int mid = (l+r)/2;
	return min(query(i, ind*2, l, mid, x, min(mid, y)), query(i, ind*2+1, mid+1, r, max(mid+1, x), y));
}

node* sol (int l, int r) {
	if (l >= r) {
		return NULL;
	}

	int x, y;
	x = query(l%2, 1, 0, n-1, l, r);
	y = query(1-(l%2), 1, 0, n-1, pos[x]+1, r);
	node *new_node = new node(x, y);
	new_node->ch.push_back(sol(pos[x]+1, pos[y]-1));
	new_node->ch.push_back(sol(l, pos[x]-1));
	new_node->ch.push_back(sol(pos[y]+1, r));

	return new_node;
}

int main () {
	int a;
	scanf ("%d", &n);

	for (int i=0;i<2;i++) {
		for (int j=0;j<n*4;j++) {
			tree[i][j] = 1<<30;
		}
	}

	for (int i=0;i<n;i++) {
		scanf ("%d", &a);
		build(i%2, 1, 0, n-1, i, a);
		pos[a] = i;
	}

	set <node> s;
	node cur;

	s.insert(*sol(0, n-1));

	while (s.size() != 0) {
		cur = *s.begin();
		cout << cur.p.first << " " << cur.p.second << " ";
		for (int i=0;i<cur.ch.size();i++) {
			if (cur.ch[i] != NULL) {
				s.insert(*cur.ch[i]);
			}
		}
		s.erase(cur);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 39040
#include <iostream>
#include <vector>
using namespace std;
struct NODE{
	vector<int> child;
};
int main(int argc, char* argv[])
{
	int N,M;
	cin>>N>>M;

	vector<NODE> Node(N);
	int i;
	int a,b;
	for (i=0;i<M;i++){
		cin>>a>>b;
		a--;
		b--;
		Node[a].child.push_back(b);
		Node[b].child.push_back(a);
	}
	for (i=0;i<N;i++){
		cout<<Node[i].child.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    ll ans=0;
    for(ll i=1;i<n;i++){
        if(a[i-1]>a[i]){
            ll dx=a[i-1]-a[i];
            ans+=dx;
            a[i]+=dx;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840