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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n), idxs(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        idxs[i] = i;
    }
    sort(idxs.begin(), idxs.end(), [&](const int& i1, const int& i2){return a[i1] < a[i2];});

    set<int> s;
    int hoge = n - k + 1;
    ll ans = 2000000000;
    for (int i = 0; i < n; i++) {
        if (hoge < q) {
            break;
        }
        int prv = 0, tar = a[idxs[i]];
        priority_queue<int> pq;
        for (int j : s) {
            priority_queue<int> pq2;
            for (int ii = prv; ii < j; ii++) {
                pq2.push(-a[ii]);
            }

            int num = max(j - prv - k + 1, 0);
            for (int ii = 0; ii < num; ii++) {
                pq.push(pq2.top());
                pq2.pop();
            }

            prv = j + 1;
        }

        priority_queue<int> pq2;
        for (int ii = prv; ii < n; ii++) {
            pq2.push(-a[ii]);
        }

        int num = max(n - prv - k + 1, 0);
        for (int ii = 0; ii < num; ii++) {
            pq.push(pq2.top());
            pq2.pop();
        }
        
        for (int ii = 0; ii < q; ii++) {
            tar = max(tar, -pq.top());
            pq.pop();
        }
        ans = min(ans, (ll)tar - a[idxs[i]]);

        auto itr = s.upper_bound(idxs[i]);
        int r2;
        if (itr == s.end()) {
            r2 = n - 1;
        } else {
            r2 = *itr - 1;
        }
        int l2;
        if (itr == s.begin()) {
            l2 = 0;
        } else {
            itr--;
            l2 = *itr + 1;
        }
        hoge -= max(r2 - l2 + 1 - k + 1, 0);
        hoge += max(idxs[i] - l2 - k + 1, 0) + max(r2 - idxs[i] - k + 1, 0);
        s.insert(idxs[i]);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
#define endl "\n"
//cout << fixed << setprecision(2);


int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    if(n % 1000 == 0){
        cout << 0 << endl;
    }
    else{
        cout << 1000 - (n % 1000) << endl;
    }
}


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

using namespace std;

int main(void)
{
    int n; cin >> n;
    vector<int> a(n),rain(n);
    int sum = 0;
    for(int i = 0; i < n; i++) 
    {
        cin >> a.at(i);
        sum += a.at(i);
    }
    
    int s = 0;
    for(int i = 0; 2 * i + 1 < n; i++)  s += a.at(2 * i + 1);
    
    rain.at(0) = sum - 2 * s;

    cout << rain.at(0) << " ";

    for(int i = 1; i < n; i++)
    {
        rain.at(i) = 2 * a.at(i-1) - rain.at(i-1);
        cout << rain.at(i) << " ";
    }
}

Measured memory_bytes: 2048
// https://atcoder.jp/contests/abc064/tasks/abc064_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int m;

  vector<int> a;

  cin >> m;

  REP(i, m)
  {
    int ai;
    cin >> ai;
    a.push_back(ai);
  }

  sort(ALL(a));

  cout << a.back() - a.front() << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
int dp[100000], dp2[100000], v[100000];
int main()
{
	int n, k;
	while (scanf("%d%d", &n, &k), n|k) {
		int w = 0;
		for (int i=0; i<k; ++i) {
			int t;
			scanf("%d", &t);
			if (t == 0)
				w = 1;
			else
				v[i-w] = t;
		}
		std::sort(v, v+k-w);
		dp[0] = 1;
		for (int i=1; i<k-w; ++i)
			dp[i] = v[i]-v[i-1]==1 ? dp[i-1]+1 : 1;
		bool used = false;
		if (w) {
			dp2[0] = 1, dp2[k-w] = 1000011;
			for (int i=1; i<k-w; ++i) {
				if (v[i] - v[i-1] == 1) {
					dp2[i] = dp2[i-1]+1;
				}
				else {
					if (v[i] - v[i-1] == 2) {
						dp2[i] = dp[i-1] + 2;
						used = true;
					}
					else {
						dp2[i] = 1;
					}
				}
			}
		}
		printf("%d\n", std::max(*std::max_element(dp, dp+k-w), *std::max_element(dp2, dp2+k-w)+!used));
	}
	return 0;
}

Measured memory_bytes: 0
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
P g(LL d,LL r){
	if(d+r>=10){
		return P(2,(d+r)%10+1);
	}
	return P(1,d+r);
}
P f(LL d,LL c){
	if(c==1){
		return P(0,d);
	}
	P u=f(d,c/2);
	P v=g(u.second,u.second);
	if(c%2){
		P w=g(v.second,d);
		return P(2*u.first+v.first+w.first,w.second);
	}
	return P(2*u.first+v.first,v.second);
}
int main() {
	int M;
	cin >> M;
	LL r=0;
	LL ret=0;
	for(int i=0;i<M;i++){
		LL c,d;
		cin >> d >> c;
		P u=f(d,c);
		ret+=u.first;
		if(i){
			P v=g(u.second,r);
			ret+=v.first;
			r=v.second;
		}
		else{
			r=u.second;
		}
	}
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <math.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define vll vector<ll> 
#define nl cout << endl
#define fr(a,b) for(auto i=a;i<b;i++)
#define pll pair<ll,ll>
#define f first
#define s second
#define vpll vector<pll>
#define ump unordered_map
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define IN(a,b) ((a).find(b)!=(a).end())
#define pb push_back
#define mkp make_pair
#define PI M_PI
#define INF 1e18
#define deb(x) if(ON) cout << #x <<" : " << x << endl
#define fast ios_base::sync_with_stdio(false)
#define io cin.tie(NULL),cout.tie(NULL)
#define ON !false
ll dx[]={0,-1,0,1};
ll dy[]={1,0,-1,0};
const ll mod=1e9+7;
ll i,j;
ll add(ll a,ll b){
    return  ((a%mod)+(b%mod)+mod)%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod)+mod)%mod;
}
void pause(ll id){
    cout << "Waiting " << id << endl;
    cin >> id;
}

const int mxn=1e5+10;
ll n,t;


signed main(){
    fast;
    io;
    if(!true){
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    }
    ll n,k;
    cin >> n >> k;
    vll h(n);
    vll ans(n,0);
    ll i,j;
    for(i=0;i<n;i++){
        cin >> h[i];
    }
    ll mn;
    for(i=1;i<n;i++){
        mn=INF;
        for(j=max(0ll,(i-k));j<i;j++){
            mn=min(mn,abs(h[i]-h[j])+ans[j]);
        }
        ans[i]+=mn;
    }
    cout << ans[n-1] << endl;
   
    return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n, k;
    cin >> n >> k;
    li star_num = (n - 2) * (n - 1) / 2;
    if (k > star_num) {
        puts("-1");
        return 0;
    }

    li num = (n - 1) + (star_num - k);
    cout << num << endl;
    rep(i, n - 1) {
        cout << 1 << " " << i + 2 << endl;
    }
    li cnt = 0;
    li rest = (star_num - k);
    if (rest > 0) {
        repp(i, 2, n + 1) {
            repp(j, i + 1, n + 1) {
                cout << i << " " << j << endl;
                cnt++;
                if (cnt == rest)break;
            }
            if (cnt == rest)break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <map>
#include <cstring>
#include <cassert>
 
using namespace std;

// (y,x) ~ (y+ky-1,x+kx-1) に +1 する
// [0,cell.size()-1] x [0,cell.size()-1] で考える
void add(vector<vector<int> > &cell, int y, int x, int ky, int kx){

    // はみ出す部分
    if(y+ky>cell.size()){
        int d=y+ky-cell.size();
        add(cell,y,x,ky-d,kx);
        add(cell,0,x,d,kx);
        return;
    }
    if(x+kx>cell.size()){
        int d=x+kx-cell.size();
        add(cell,y,x,ky,kx-d);
        add(cell,y,0,ky,d);
        return;
    }

    cell[y][x]++;
    if(x+kx<cell.size()) cell[y][x+kx]--;
    if(y+ky<cell.size()) cell[y+ky][x]--;
    if(x+kx<cell.size() && y+ky<cell.size()) cell[y+ky][x+kx]++;

}

int main(){

    int n,k;
    cin>>n>>k;

    vector<vector<int> > cell(2*k,vector<int>(2*k,0));

    while(n--){
        int x,y;
        string c;
        cin>>x>>y>>c;

        if(c=="W") y+=k;

        x%=(2*k);
        y%=(2*k);

        add(cell,(y-k+1+2*k)%(2*k),(x-k+1+2*k)%(2*k),k,k);
        add(cell,(y+1)%(2*k),(x+1)%(2*k),k,k);
    }

    //show(cell);

    for(int i=0;i<2*k;i++){
        for(int j=0;j<2*k-1;j++){
            cell[i][j+1]+=cell[i][j];
        }
    }

    int res=0;
    for(int i=0;i<2*k-1;i++){
        for(int j=0;j<2*k;j++){
            cell[i+1][j]+=cell[i][j];
            res=max(res,cell[i][j]);
        }
    }
    for(int i=0;i<2*k;i++) res=max(res,cell[2*k-1][i]);


//    for(int i=0;i<2*k;i++){
//      for(int j=0;j<2*k;j++){
//            res=max(res,cell[i][j]);
//        }
//    }
    cout<<res<<endl;


	return 0;
}


Measured memory_bytes: 16000
n=int(input())
s=str(input())

r=set()
g=set()
b=set()
for i in range(n):
    if s[i]=='R':
        r.add(i)
    if s[i]=='G':
        g.add(i)
    if s[i]=='B':
        b.add(i)

d=len(r)*len(g)*len(b)

for ri in r:
    for gi in g:
        dist = abs(ri-gi)
        if ri > gi:
            bi = dist + ri
            if bi in b:
                d -= 1
            bi = gi - dist
            if bi in b:
                d -= 1
        else:
            bi = dist + gi
            if bi in b:
                d -= 1
            bi = ri - dist
            if bi in b:
                d -= 1

        if (ri + gi) % 2 == 0:
            bi = (ri+gi)/2
            if bi in b:
                d -= 1
print(d)

Measured memory_bytes: 9376
using System;
using System.Collections.Generic;
 
class Program
{
    static void Main(string[] args)
    {
        var Box = Console.ReadLine();
        var Each = Box.Split(' ');
        int N, i, point;
        N = int.Parse(Each[0]);
        i = int.Parse(Each[1]);
        point = N - i + 1;
        Console.WriteLine(point);
        Console.ReadLine();
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    int minv = *min_element(begin(A), end(A));
    int sum = 0;
    for (int a : A) sum = (sum + a) % 2;
    if (N % 2) {
        cout << (sum ? "First" : "Second") << endl;
    } else {
        cout << ((minv % 2 || sum) ? "First" : "Second") << endl;
    }
    return 0;
}


Measured memory_bytes: 3564
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  ll n,m; cin >> n >> m;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  ll l=0,r=2e5+1;
  while(r-l!=1){
    ll mid=(r+l)/2;
    ll cnt=0;
    rep(i,n){
      cnt+=a.end()-lower_bound(all(a),mid-a[i]);
    }
    if(cnt<m) r=mid;
    else l=mid;
  }
  int x=l;
  vector<ll> s(n+1);
  s[0]=0;
  rep(i,n) s[i+1]=s[i]+a[i];
  ll ans=0;
  ll cnt=0;
  rep(i,n){
    int j=lower_bound(all(a),x-a[i])-a.begin();
    ans+=(s[n]-s[j])+a[i]*(n-j);
    cnt+=n-j;
  }
  ans-=x*(cnt-m);
  cout << ans << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;

int main(void) {

    ll X, Y;
    cin >> X >> Y;
    if (X % Y == 0) {
        cout << -1 << endl;
        return 0;
    }

    for (ll i = 2; ; i++) {
        ll x = X * i;
        if (x <= 0 || 1e18 < x) {
            cout << -1 << endl;
            return 0;
        } else if (x % Y != 0) {
            cout << x << endl;
            return 0;
        }
    }
}



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

int main(){

	int n;
	cin >> n;

	int digit = log10(n)+1;
	int sum = 0;
	int tmp = 10;
	while(log10(n)+1!=1){
		digit = fmod(log10(n)+1,2);
		if(digit == 1){
			sum++;
		}
		n--;
	}
	cout << sum+1 <<endl;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<int> v(50);
	for (int i = 0; i < 50; i++) {
		if (i <= 1) v.at(i) = 1;
		else v.at(i) = v.at(i - 1) + v.at(i - 2);
	}

	cout << v.at(n) << endl;
}


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

int main(){
  string s1, s2, ans = "";
  int idx1 = 0, idx2 = 0;
  cin >> s1 >> s2;
  for(int i = 0; i < s1.size() + s2.size(); i++){
    ans += i % 2 == 0 ? s1[idx1++] : s2 [idx2++];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "615" ].parse.expand.solve == 1 );
	assert( [ "217" ].parse.expand.solve == 0 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = input.front.to!( long );
	return tuple( x );
}

auto solve( long x )
{
	auto c = x / 100;
	auto m = c * 100 + c * 5;
	return ( x <= m ) ? 1 : 0;
}


Measured memory_bytes: 256
// Problem: B - Substring
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define elif else if
#define VPII vector <PII>
#define y2 y1919810
typedef pair <int, int> PII;
typedef vector <int> VI;
//#define int long long
#define all(x) x.begin(),  x.end()
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
#define RESET(x) memset((x), 0, sizeof(x))
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
string s, t;
string subs(int l, int r) {
  string ret;
  range(i, l, r) ret.pb(s[i]);
  return ret;
}
int dist(string x, string y) {
  int ret = 0;
  if (x.length() != y.length()) return -1;
  rep(i, x.length()) {
    if (x[i] != y[i]) ret++; 
  }
  return ret;
}
void solve() {
  cin >> s >> t;
  int n = s.length(), m = t.length();
  int ans = INF;
  for (int i = 0; i < n && i + m - 1 < n; i++) {
    string r = subs(i, i + m - 1);
    ans = min(ans, dist(r, t));
  }
  cout << ans << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  int T = 1;
  // cin >> T;
  while (T--) 
    solve();
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>

using namespace std;

int main()
{
    int x,y;
    cin >> x >> y;
    if ((x == 1) && (y > 1))
        cout << "Alice";

    else if ((y == 1) && (x > 1 ))
        cout << "Bob";
        
    else if (x < y)
        cout << "Bob";

    else if (x > y)
        cout << "Alice";

    else if (x == y)
        cout << "Draw";


    return 0;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
total = 0
que_list=[]
finish_list=[]


for i in range(n):
    que_list.append(input().split())


while que_list:
    m = que_list.pop(0)
    if int(m[1]) > q:
        total += q
        m[1] = int(m[1]) - q
        que_list.append(m)
    else:
        total+=int(m[1])
        m[1] = total
        finish_list.append(m)
        
for i in range(len(finish_list)):
    print(finish_list[i][0],finish_list[i][1])



Measured memory_bytes: 18640
// In the name of God

#include <bits/stdc++.h>

using namespace std;

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

	int n;
	cin >> n;

	long long ans = 0;
	
	for(int i = 1; i <= n; i++) {
		if(i % 3 == 0 || i % 5 == 0) continue;
		ans += i;
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 3628
INF = 10**10
n,m = map(int,input().split())
ab=[]
cd=[]

for _ in range(n):
  ab.append(list(map(int,input().split())))

for _ in range(m):
  cd.append(list(map(int,input().split())))         

for abi in ab:
  dist = INF
  nearest = -1
  for i,cdi in enumerate(cd):
    tmp = abs(abi[0]-cdi[0]) + abs(abi[1]-cdi[1])
    if tmp<dist:
      dist = tmp
      nearest = i+1
    dist = min(tmp,dist)
    
  print(nearest)

Measured memory_bytes: 3064
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

dp = [0] * (N+1)

t = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

for i in range(1, N+1):
    for a in A:
        if 0 <= i-t[a]:     
            if dp[i-t[a]] == 0 and i-t[a] > 0: continue
            dp[i] = max(dp[i], dp[i-t[a]]*10+a)
print(dp[N])

Measured memory_bytes: 14388
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin>>N;
    vll A(N);
    bool zero = false;
    ll ans=1;
    for (size_t i = 0; i < N; i++)
    {
        cin>>A[i];
        if(A[i]==0)
        {
            cout<<0;
            return 0;
        }
    }
    
    long double keta=0;
    for (size_t i = 0; i < N; i++)
    {
        keta += log10(A[i]);
        if(keta > 18)
        {
            cout<<-1;
            return 0;
        }
    }
    for (size_t i = 0; i < N; i++)
    {
        ans *= A[i];
        if(ans > 1000000000000000000)
        {
            cout<<-1;
            return 0;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4116
S = str(input())
ans = "Yes"
if S != S[::-1]:
    ans = "No"
elif S[:int((len(S)-1)/2)] != S[:int((len(S)-1)/2)][::-1]:
    ans = "No"
elif S[int((len(S)+3)/2)-1:] != S[int((len(S)+3)/2)-1:][::-1]:
    ans = "No"
else:
    pass
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
#define inf 1000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back

int n, a[101010], ans= 0, m[101001];

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

cin >> n;
rep(i, 1, n){
    cin >> a[i];
    m[a[i]]++;
}

rep(i, 1, n){
if(m[a[i]]>1){
        ans+= m[a[i]]-1;
        m[a[i]]=1;
}
}

if(ans%2==0)cout << n-ans << endl;

else cout << n-ans-1 << endl;


return 0;}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MAXN=110;
int n,a[MAXN],ans;
int main () {
	ans=1e9;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {scanf("%d",&a[i]);}
	for (int i=1;i<=100;i++) {
		int tmp=0;
		for (int j=1;j<=n;j++) {tmp+=(a[j]-i)*(a[j]-i);}
		ans=min(ans,tmp);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int A = sc.nextInt();
	        int B = sc.nextInt();
	        int M = sc.nextInt();
	        long amin=200000;
	        long bmin=200000;
	        long[] a = new long[A];
	        for (int i=0 ; i<A; i++) {
	            a[i] = Long.parseLong(sc.next());
	            amin=Math.min(amin, a[i]);
	        }
	        long[] b = new long[B];
	        for (int i=0 ; i<B; i++) {
	            b[i] = Long.parseLong(sc.next());
	            bmin=Math.min(bmin, b[i]);
	        }
	        int[] x = new int[M];
	        int[] y = new int[M];
	        long[] c = new long[M];
	        long min=amin+bmin;
	        for (int i=0 ; i<M; i++) {
	            x[i] = Integer.parseInt(sc.next());
	            y[i] = Integer.parseInt(sc.next());
	            c[i] = Long.parseLong(sc.next());
	            min=Math.min(min, a[x[i]-1]+b[y[i]-1]-c[i]);
	        }
	        
	        
	        System.out.println(min);
	 }
}


Measured memory_bytes: 68284
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;  
typedef unsigned long long ull;         
typedef vector < pii > vpii;                                   	
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;
 
 
const int inf = 1e9, maxn = 1e6 + 48, mod = 1e9 + 7, N = 5e4 + 24;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n;
main () {
	cin >> n;
	int c = n % 10;
	if (c == 2 || c == 4 || c == 5 || c == 7 || c == 9)
		cout << "hon";
	else if (c == 3)	
		cout << "bon";
	else
		cout << "pon";
}

Measured memory_bytes: 3592
import math

n = int(input())

div_min = math.floor(100*(n/108))
div_max = math.ceil(100*(n/108))

if int(div_min * 1.08) == n:
    print(str(div_min))
elif int(div_max * 1.08) == n:
    print(str(div_max))
else:
    print(':(')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
int expression(string,int&);
int term(string,int&);
int factor(string,int&);
int number(string,int&);

bool f;

int expression(string s,int& p){
  int res=term(s,p);
  while(p<(int)s.size()){
    if(s[p]=='+'){
      p++;
      res+=term(s,p);
      continue;
    }
    if(s[p]=='-'){
      p++;
      res-=term(s,p);
      continue;
    }
    break;
  }
  return res;
}

int term(string s,int& p){
  int res=factor(s,p);
  while(p<(int)s.size()){
    if(s[p]=='*'){
      p++;
      res*=factor(s,p);
      continue;
    }
    if(s[p]=='/'){
      p++;
      int tmp=factor(s,p);
      if(tmp==0){
	f=1;
	break;
      }
      res/=tmp;
      continue;
    }
    break;
  }
  return res;
}

int factor(string s,int& p){
  int res;
  if(s[p]=='('){
    p++;
    res=expression(s,p);
    p++;
  }else{
    res=number(s,p);
  }
  return res;
}

int number(string s,int& p){
  int res=0;
  while(p<(int)s.size()&&isdigit(s[p]))
    res=res*10+s[p++]-'0';
  return res;
}

signed main(){
  int n;
  cin>>n;
  while(n--){
    string s;
    int p=0;
    cin>>s;s.pop_back();
    cout<<expression(s,p)<<endl;
  }
  return 0;
}

/*
verified on 2017/04/26
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?lang=jp&id=0109
*/

Measured memory_bytes: 3056
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include<map>
#include <utility>
#include <math.h>
#include <queue>
# define INF 1000000000
using namespace std;
int gcd(int a, int b) {
	int d;
	if (a > b) {
		int t = b;
		b = a;
		a = t;
	}
	while ((d = b % a) != 0) {
		b = a;
		a = d;
	}
	return a;
}
int counto[200100] = { 0 };
int main(){
	int a = 0,b=0;
	int N,K;
	cin >> N>>K ;
	
	for (int i = 0; i < N; i++) {
		cin >> a;
		b=max(b, a);
		counto[a-1]++;
	}
	int c = 0;
	sort(counto, counto + b,greater<int>());
	for (int i = 0; i < K; i++) {
		c += counto[i];
		//cout << c << endl;
		
	}
	cout << N - c << endl;
	return 0;
}

	



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// RootCount; 始点(0,0)から終点(h-1,w-1)まで{右,下}方向の移動のみで到達可能なパターン数を計算する。
long long RootCount(const vector<string> &a, long long h, long long w, char WALL = '#', long long MOD = MODV){
    vector<vector<long long>> dp(h, vector<long long>(w, 0)); dp[0][0] = 1;
    for(long long i=0; i<h; i++){
        for(long long j=0; j<w; j++){
            if(j<w-1 && a[i][j+1] != WALL) dp[i][j+1] = (dp[i][j+1]+dp[i][j])%MOD;
            if(i<h-1 && a[i+1][j] != WALL) dp[i+1][j] = (dp[i+1][j]+dp[i][j])%MOD;
        }
    }
    return dp[h-1][w-1];
}

int main(){
    Init();
    ll h, w; cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a[i];
    cout << RootCount(a, h, w) << endl;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

void solve(){
    //abc96c
    int h,w;
    cin>>h>>w;
    string board[60];
    rep(i,h)cin>>board[i];
    int dx[]={1,0,-1,0};
    int dy[]={0,1,0,-1};
    bool f;
    
    rep(i,h){
        rep(j,w){
            if(board[i][j]=='#'){
              int cnt=0;
                rep(k,4){
                    
                    int x=i+dx[k];
                    int y=j+dy[k];
                    if(x>=0&&x<h&&y>=0&&y<w&&board[x][y]=='#')f=1;
                    else cnt++;
                }
                if(cnt==4){
                    f=0;
                    break;
                }
            }
        }
        if(f==0)break;
    }
    if(h==1&&w==1&&board[0][0]=='#'){
        cout<<"Yes"<<endl;
        return;
    }
    cout<<(f?"Yes":"No")<<endl;
}

int main(){
    cout<<std::fixed<<std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <complex>

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

Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#define ll long long
#define ull unsigned long long
#define LLMax LLONG_MAX
#define LLMin LLONG_MIN
#define Max INT_MAX
#define Min INT_MIN
#define FOR1(i,a,b) for(int i=(a);i<(b);i++)
#define FOR2(i,a,b) for(int i=(a);i<=(b);i++)
#define DWN(j,b,a) for(int j=(b);j>=(a);j--) 
#define SET0(a) memset(a,0,sizeof(a))
#define SETN1(a) memset(a,-1,sizeof(a))
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define int long long
const int INF=0x3f3f3f3f;
const int NINF=-INF-1;
const double PI=acos(-1); 
const int mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
signed main() {
	//IOS;
	int n,k;
	cin>>n>>k;
	int ans=0;
	FOR2(i,k,n+1) {
		int cnt=(n+n-i+1)*i/2-(0+i-1)*i/2+1;
		ans=(ans+cnt%mod)%mod;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<n; ++i)
#define FOR(i, a, b) for(int i=a; i<b; ++i)
#define FORR(i, a, b) for(int i=b-1; i>=a; --i)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r, g;
	cin>>r>>g;
	cout<<r+(g-r)*2<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#pragma warning(disable:4996)

int main() {
	int n = 0, x = 0, y = 0, d = 0;
	int anser = 0;
	double jug = 0,X = 0;

	scanf("%d %d",&n ,&d);

	for (int i = 0; i < n; i++) {
		jug = 0;
		scanf("%d %d", &x, &y);
		X = ((double)x * (double)x )+( (double)y * (double)y);
		jug = sqrt(X);
		if(jug <= (double)d){
			anser++;
		}
	}
	printf("%d", anser);

}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
ll MOD = 1e9+7;
 
map<ll, int> PrimeFact(ll N){
    map<ll, int> mp;
 
    while(N != 1){
        bool found = false;
        for(ll i = 2; i * i <= N; i++){
            if(N % i == 0){
                mp[i]++;
                N /= i;
                found = true;
                break;
            }
        }
 
        if(!found){
            mp[N]++;
            break;
        }
    }
 
    return mp;
}
 
ll powmod(ll a, int cnt){
    if(cnt == 0) return 1;
    else if(cnt % 2 == 0){
        ll tmp = powmod(a, cnt / 2);
        return tmp * tmp % MOD;
    }
    else {
        return a * powmod(a, cnt - 1) % MOD;
    }
}
 
ll revmod(ll a){
    //a^(MOD - 2)
 
    return powmod(a, MOD - 2);
}
 
 
int main(){
    int N;
    cin >> N;
    ll a[N];
    for(int i = 0; i < N; i++) cin >> a[i];
 
    map<ll, int> lcm;
    for(int i = 0; i < N; i++){
        //cout << "hoge" << endl;
        map<ll, int> mp = PrimeFact(a[i]);
        for(auto it = mp.begin(); it != mp.end(); it++){
            ll num = it -> first;
            int cnt = it -> second;
            lcm[num] = max(lcm[num], cnt);
        }
    }
 
 
 
    ll lcmmod = 1;
    for(auto it = lcm.begin(); it != lcm.end(); it++){
        //cout << it -> first << " " << it -> second << endl;
        lcmmod *= powmod(it -> first, it -> second);
        lcmmod %= MOD;
    }
 
    //cout << lcmmod << endl;
 
    ll ans = 0;
    for(int i = 0; i < N; i++){
        ans += revmod(a[i]);
        ans %= MOD;
    }
 
    ans *= lcmmod;
    ans %= MOD;
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int a=read(),b=read(),c=read(),d=read();

int main(){
if (abs(a-b)<=d&&abs(b-c)<=d||abs(a-c)<=d) puts("Yes");
else puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <functional>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	ll rem = 0;
	for (int i = 0; i < s.size(); i++)
	{
		rem += (s[i] - '0');
	}
	if (rem % 9 == 0) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3768
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ff first 
#define ss second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define testcase(t) int t;cin>>t;while(t--)
#define mp(x,y) make_pair(x,y)
#define in(x) insert(x)
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,a,b)  for (__typeof((b)) i=(b);i>=(a);i--)
#define PI 3.14159265358979323846
#define SP(x) setprecision(x)
#define reflex ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define M 998244853
#define sz(a) (int)a.size()
#define endl "\n"
#define all(v) v.begin(), v.end()
#define mem(arr,val) memset(arr,val,sizeof(arr)) //For "0" and "-1"                  
#define inp0(a,n) rep(i,0,n-1) cin>>a[i];
#define inp1(a,n) rep(i,1,n) cin>>a[i]; 
#define prll(x) printf("%lld",x)
#define nth_ele(v,n) nth_element(v.begin(), v.begin()+n ,v.end())//O(N)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll gcd(ll n1, ll n2){if(n2!=0) return gcd(n2, n1%n2);else return n1;}
ll powerM(ll a,ll b){if(b==0) return 1;  if(b==1) return a%M; ll x=powerM(a,b/2)%M; if(b&1){return ((((a%M)*(x%M))%M)*(x%M))%M;}return ((x%M)*(x%M))%M;}
ll power(ll a,ll b){if(b==0) return 1;  if(b==1) return a; ll x=power(a,b/2); if(b&1){return ((((a)*(x)))*(x));}return ((x)*(x));}
 

const ll INF=1e18; 
const int SIZE = 100005;
const int SSIZE = 1000005;

ll solve(string s){
    ll cnt = 0;
    int n = sz(s);
    rep(i,0,n-1){
        if(i==0){
            if(n>1 && s[0]=='R' && s[1]=='R') cnt++;
        }
        else if(i==n-1){
            if(n>1 && s[n-2]=='L' && s[n-1]=='L') cnt++;
        }
        else{
            if(s[i]==s[i-1] && s[i]=='L') cnt++;
            if(s[i]==s[i+1] && s[i]=='R') cnt++;
        }
    }
    return cnt;
}

int main(){
    ll n,k,k1;
    cin>>n>>k1;
    string s;
    cin>>s;
    string s1 = s, s2 = s;
    k = k1;
    rep(i,0,n-1){
        if(s[i]=='L'){
            while(i<n && s[i]=='L'){
                s1[i]='R';
                i++;
            }
            k--;
            if(k==0) break;
        }
    }
    if(k!=0 && s1[0]=='L'){
        s1[0]='R';
    }
    ll ans = solve(s1);
    k = k1;
    rep(i,0,n-1){
         if(s[i]=='R'){
            while(i<n && s[i]=='R'){
                s2[i]='L';
                i++;
            }
            k--;
            if(k==0) break;
        }
    }
    if(k!=0 && s2[0]=='L'){
        s2[0]='R';
    }
    ans = max(ans, solve(s2));
    cout<<ans<<endl;
}



Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    vi h(N);
    REP(i,N) cin >> h[i];

    vi ans(N,0);
    REP(i,N-1) {
        if (h[i] >= h[i+1]) ans[i+1] = ans[i] + 1;
    }

    cout << *max_element(ALL(ans)) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

void bfs(pair<ll, ll> next, ll current, const vector<vector<char>>& field, vector<vector<ll>>& result) {
    result[next.first][next.second] = current;
}


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

    ll h, w, n;
    cin >> h >> w >> n;

    ll ans1 = n % w == 0 ? n / w : n / w + 1;
    ll ans2 = n % h == 0 ? n / h : n / h + 1;

    cout << min(ans1, ans2) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    ll n,w;
    cin>>n>>w;
    
    vector<vector<ll>> vec(4,vector<ll>());
    ll w1,v1;
    cin>>w1>>v1;
    vec[0].push_back(v1);
    rep(i,0,n-1){
        ll a,b;
        cin>>a>>b;
        vec[a-w1].push_back(b);
    }
    
    rep(i,0,4)  sort(all(vec[i]),greater<ll>());
    int p=vec[0].size();
    int q=vec[1].size();
    int r=vec[2].size();
    int s=vec[3].size();
    
    vector<ll> vec0(p+1),vec1(q+1),vec2(r+1),vec3(s+1);
    rep(i,0,p) vec0[i+1]=vec0[i]+vec[0][i];
    rep(i,0,q) vec1[i+1]=vec1[i]+vec[1][i];
    rep(i,0,r) vec2[i+1]=vec2[i]+vec[2][i];
    rep(i,0,s) vec3[i+1]=vec3[i]+vec[3][i];
    
    ll ans=0;
    rep(i,0,p+1){
        rep(j,0,q+1){
            rep(k,0,r+1){
                rep(l,0,s+1){
                    ll weight=w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l;
                    ll value=vec0[i]+vec1[j]+vec2[k]+vec3[l];
                    
                    if(weight>w) continue;
                    ans=max(ans,value);
                }
            }
        }
    }
    
    cout<<ans<<endl;
    
}



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

using namespace std;

using int64 = long long;


int W, H;
char mas[500][500];
int min_cost[500][500];

int bfs(int sx, int sy, char c)
{
  const int vx[] = {0, 1, 0, -1}, vy[] = {1, 0, -1, 0};
  memset(min_cost, -1, sizeof(min_cost));

  queue< pair< int, int > > que;
  que.emplace(sx, sy);
  min_cost[sx][sy] = 0;

  while(!que.empty()) {
    auto p = que.front();
    que.pop();
    if(mas[p.second][p.first] == c) return (min_cost[p.first][p.second]);
    for(int i = 0; i < 4; i++) {
      int nx = p.first + vx[i], ny = p.second + vy[i];
      if(nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
      if(min_cost[nx][ny] != -1) continue;
      if(mas[ny][nx] == '#') continue;
      min_cost[nx][ny] = min_cost[p.first][p.second] + 1;
      que.emplace(nx, ny);
    }
  }
  return (-1);
}

int main()
{
  cin >> H >> W;
  int proc = 0;
  for(int i = 0; i < H; i++) {

    cin >> mas[i];
    for(int j = 0; j < W; j++) {
      if(mas[i][j] == '#') ++proc;
    }
  }
  mas[H - 1][W - 1] = 'G';
  auto s = bfs(0, 0, 'G');
  if(s == -1) cout << -1 << endl;
  else cout << H * W - s - proc - 1 << endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll a,b,h,m;cin>>a>>b>>h>>m;
    ld mdeg=m*6;
    ld hdeg=h*30+mdeg/12;
    ld angle=abs(hdeg-mdeg);
    ld c=sqrt(a*a+b*b-2*a*b*cos(angle*(pi/180)));
    cout<<setprecision(20)<<c;
    return 0;  
} 





Measured memory_bytes: 4180
N, M = map(int, input().split())
X = sorted(map(int, input().split()))

dis = [0]*(M-1)

for i in range(M-1):
  dis[i] = X[i+1] - X[i]

dis.sort()

if N < M:
  print(sum(dis[:M-N]))
else:
  print(0)

Measured memory_bytes: 20448
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

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

    int n;
    cin >> n;
    vector<int> wr(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        x--;
        wr[x] = i;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int r = i;
        while (r + 1 < n && wr[r] < wr[r + 1]) {
            r++;
        }
        ans = max(ans, r - i + 1);
        i = r;
    }
    cout << n - ans << endl;
}   

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

int main(){
  vector<int> haiku(3);
  cin >> haiku[0] >> haiku[1] >> haiku[2];
  sort(haiku.begin(), haiku.end());
  if(haiku[0] == 5 && haiku[1] == 5 && haiku[2] == 7 ){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

  
  


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	ll n; cin >> n;
	ll a[200005];
	map<ll, ll> m;
	for(ll i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a, a+n);
	const ll h = 1000006;
	for(ll i=0;i<n;i++){
		m[a[i]]++;
		if(m[a[i]]==1){
			for(ll j=a[i]*2;j<h;j+=a[i]){
				m[j]++;
			}
		}
	}
	ll ans = 0;
	for(int i=0;i<n;i++){
		if(m[a[i]]==1) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll R;
  cin >> R;

  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800)
    cout << "ARC" << endl;
  else {
    cout << "AGC" << endl;
  }

  return 0;
}


Measured memory_bytes: 256