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

typedef long long ll;

#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define mn 1000000

using namespace std;

int main()
{
    #if LOCAL_DEBUG
        fstream cin("in.txt");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n,m;

    cin>>n>>m;

    ll niza[n][2];
    ll zbir = 0;

    for (ll i = 0; i<n; i++) {
        cin>>niza[i][0]>>niza[i][1];

        zbir += niza[i][1];
    }

    ll dp[zbir+1];

    for (int i = 0; i<=zbir; i++) dp[i] = LONG_LONG_MAX/2;

    dp[0] = 0;

    for(int i = 0; i<n; i++){
        for(ll j = zbir; j>=niza[i][1]; j--){
            dp[j] = min(dp[j], dp[j - niza[i][1]] + niza[i][0]);
        }
    }

    int res = 0;

    for (int i = 0; i<=zbir; i++) {
        if (dp[i] <= m) res = max(res, i);
    }

    cout<<res<<endl;

    return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 100005;

int dp[3005][3005];

int main(){
	fastio;
	string a,b;
	cin >> a >> b;
	for(int i = 1; i <= sz(a); i++){
		for(int j = 1; j <= sz(b); j++){
			char x = a[i-1], y = b[j-1];
			if(x == y) {
				dp[i][j] = dp[i-1][j-1] + 1;
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	string ans;
	function<void(int, int)> gen = [&](int x, int y){
		if(x == 0 and y == 0)
			return ;
		if(x-1 >= 0 and dp[x-1][y] == dp[x][y]){
			gen(x-1, y);
		} else if (y-1 >= 0 and dp[x][y-1] == dp[x][y]){
			gen(x, y-1);
		} else {
			ans.pb(a[x-1]);
			gen(x-1, y-1);
		}
	};
	gen(sz(a), sz(b));
	reverse(all(ans));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 39400
#include <iostream>
#include <string>
using namespace std;

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

    string O, E;
    cin >> O >> E;

    int sum = O.size() + E.size();
    string ans = "";
    for(int i = 0; i < sum; ++i){
        if(i % 2 == 0){
            ans += O[i / 2];
        }
        else {
            ans += E[i / 2];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld=long double;
 
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int count=1;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1])
        count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    char s;
    cin >> s;

    if (isupper(s))
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }

    return 0;
}

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


using namespace std;
using ll = long long;


int main() {
    int n;
    cin >> n;
    int r = n % 1000;
    if(r == 0) {
        cout << 0 << "\n";
    } else {
        cout << 1000- r << "\n";
    }



    return 0;
}



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

map<vector<int>,int> m[2];
int main() {
  int n;
  cin >> n;
  vector<int> a[2];
  for(int i=0,x; i<n; i++) {
    cin >> x;
    a[0].push_back(x);
    a[1].push_back(i+1);
  }
  for(int k=0; k<2; k++) {
    queue<vector<int> > que;
    m[k][a[k]]=0;
    que.push(a[k]);
    while(!que.empty()) {
      vector<int> b=que.front();que.pop();
      int x=m[k][b];
      if(x>3) continue;
      for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
          vector<int> c=b;
          reverse(c.begin()+i,c.begin()+j+1);
          if(m[k].count(c)) continue;
          m[k][c]=x+1;
          que.push(c);
        }
      }
    }
  }
  int ans=9;
  for(map<vector<int>,int>::iterator it=m[0].begin(); it!=m[0].end(); it++) {
    if(m[1].count(it->first)) ans=min(ans,it->second+m[1][it->first]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 81192
#pragma GCC optimize("O3")
/*{{{*/
#include <bits/stdc++.h>
#ifdef LOCAL
int c_ = 0;
#define cout (c_?cerr:cout)
#define debug(...) \
{if(!c_++)cerr<<"\033[96;1m"; \
__VA_ARGS__; \
if(!--c_)cerr<<"\033[0m";}
#else
#define debug(...) {}
#endif
#define assrt(...) debug(\
if (not (__VA_ARGS__)) \
    exit((cerr << __LINE__ << ": " << #__VA_ARGS__ << '\n', 0));\
)
#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template < typename t > using V = vector< t >;
template < typename t, size_t s > using A = array< t, s >;
void print() {cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":""); print(b...);}
template< typename t > void print_range(t a, const t& b)
{ while (a != b) cout << (*a++) << ' '; cout << '\n';}
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
#define dump_range(...) debug(cerr<<#__VA_ARGS__ << ": "; print_range(__VA_ARGS__))
/*}}}*/

constexpr int nax = 1e3, eax = 3;

using State = array< int, eax >;

int siz[eax], k; ll tab[eax][nax];
set< State > used;
set< pair< ll, State > > Q;
vector< ll > ans;

ll calc(const State& s)
{
    return tab[0][s[0]] + tab[1][s[1]] + tab[2][s[2]];
}

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

    for (int i = 0; i < eax; ++i)
        cin >> siz[i];
    
    cin >> k;
    
    for (int i = 0; i < eax; ++i)
        for (int j = 0; j < siz[i]; ++j)
            cin >> tab[i][j];

    for (int i = 0; i < eax; ++i)
        sort(tab[i], tab[i] + siz[i]), reverse(tab[i], tab[i] + siz[i]);

    State p {0, 0, 0};

    Q.insert({calc(p), p});

    while (ans.size() < k)
    {
        auto p = *Q.rbegin(); Q.erase(prev(Q.end()));
        used.insert(p.nd);
        ans.push_back(p.st);
        for (int i = 0; i < 3; ++i)
            if (p.nd[i] + 1 < siz[i])
            {
                State s = p.nd; ++s[i];
                if (used.find(s) == used.end())
                    Q.insert({calc(s), s});
            }
    }

    for (int i = 0; i < k; ++i)
        print(ans[i]);
}

Measured memory_bytes: 768
using System;

namespace ABC140
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int[] B = new int[N - 1];
            for (int i = 0; i < N - 1; i++)
            {
                B[i] = int.Parse(input[i]);
            }

            int[] A = new int[N];
            A[0] = B[0];
            A[N - 1] = B[N - 2];
            for (int i = 1; i < N - 1; i++)
            {
                A[i] = Math.Min(B[i - 1], B[i]);
            }

            int count = 0;
            for (int i = 0; i < N; i++)
            {
                count += A[i];
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <ctype.h>
using namespace std;
 
 
int main(){
  char a,b;
  cin >>a>>b;
  
  if(a=='D'&&b=='D'||a=='H'&&b=='H')cout<<"H"<<endl;
  else cout<<"D"<<endl;
}

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

ll solve() {
    ll N, a, a0;
    cin >> N;
    int d = 0;
    cin >> a0;
    ll ans = 1;
    for ( int i = 1; i < N; i++ ) {
        cin >> a;
        if ( a > a0 ) {
            if ( d == -1 ) {
                ans++;
                d = 0;
            } else {
                d = 1;
            }
        } else if ( a < a0 ) {
            if ( d == 1 ) {
                ans++;
                d = 0;
            } else {
                d = -1;
            }
        }
        a0 = a;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
string s; int p, k = 1, a[2035], ans;
signed main() {
    cin >> s;
    a[p]++;
    for1(i, s.size()) {
        p = (p + k * (s[s.size() - i] - '0')) % 2019;
        k *= 10; k %= 2019;
        a[p]++;
    }
    for0(i, 2020)ans += a[i] * (a[i] - 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

class UnionFind{
  private:
    vector<int> Parent;
  public:
    UnionFind(int N){
      Parent = vector<int>(N,-1);
    }

    int find(int x){
      if(Parent[x] < 0) return x;
      return Parent[x] = find(Parent[x]);
    }

    int size(int x){
      return -Parent[find(x)];
    }

    bool unite(int x, int y){
      x = find(x);
      y = find(y);
      if(x==y) return false;

      if(size(x)<size(y))swap(x,y);
      Parent[x] += Parent[y];
      Parent[y] = x;
      return true;
    }

    bool same(int x, int y){
      return find(x) == find(y);
    }
};

const int N_MAX = 210;
vector<vector<int> > G(N_MAX);
vector<vector<int> > v(N_MAX,vector<int>(N_MAX));

void warshall_floyd(int N){
  int i,j,k;
  rep(k,N)rep(i,N)rep(j,N){
    if(v[i][j] > v[i][k] + v[k][j]){
      v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
    }
  }
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  rep(y,N)rep(x,N){
    char c;cin >> c;
    v[x][y] = c-'0';
    if(v[x][y]){
      G[x].push_back(y);
      G[y].push_back(x);
    }else v[x][y] = N_MAX;
  }
  UnionFind uni = UnionFind(N);
  rep(i,N)rep(j,N){
    if(v[i][j] == 1){
      repp(k,j+1,N){
        if(v[i][k]==1)uni.unite(j,k);
      }
      if(uni.same(i,j)){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  warshall_floyd(N);
  int d = 0;
  rep(i,N) repp(j,i+1,N) d = max(d,v[i][j]);
  cout << d+1 << endl;
  return 0;
}


Measured memory_bytes: 896
let l = ["SUN";"MON";"TUE";"WED";"THU";"FRI";"SAT";"SUN"]
let s = read_line ()
let f s = match s with
|"MON"-> 6 |"TUE"-> 5 |"WED"-> 4 |"THU"-> 3
|"FRI"-> 2 |"SAT"-> 1 |"SUN"-> 7
let () = print_int (f s)

Measured memory_bytes: 384
#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;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#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));
//priority_queue<int,vector<int>, greater<int> > q2;
	
pii G[60][60];
int N;
VI es;

bool dfs(int now, int go, int pa) {
	VI a;
	//cout << now << " " << go << " " << pa << endl;
	if (now == go) {
		es = a;
		return true;
	}
	REP(i, N) {
		if (G[now][i].first) {
			if (i == pa)continue;

			if (dfs(i, go, now)) {
				es.push_back(G[now][i].second);
				return true;
			}
		}
	}
	return false;
}

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


	cin >> N;

	REP(i, 60)REP(j, 60)G[i][j].first = 0;
	REP(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a][b].first = 1;
		G[b][a].first = 1;
		G[a][b].second = i;
		G[b][a].second = i;
	}
	
	int M;
	cin >> M;
	VI eset(M);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		dfs(a, b, -1);

		for (int e : es) {
			eset[i] |= (1LL << e);
		}
	}
	int ans = 0;
	REP(i, 1 << M) {
		int mask = 0;
		REP(j, M) {
			if (i >> j & 1)mask |= eset[j];
		}
		int white = 0;
		int tmp = mask;
		while (tmp) {
			if (tmp & 1)white++;
			tmp /= 2;
			//cout << tmp << endl;
		}

		int now = 1LL << (N - 1 - white);
		int ttmp = 0;
		tmp = i;
		while (tmp) {
			if (tmp & 1)ttmp++;
			tmp /= 2;
		}
		if (ttmp % 2)ans -= now;
		else ans += now;
	}

	cout << ans << endl;
	
	return 0;
}



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

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 ll = long long;

ll dp[15][15];
bool memo[15][15];
ll f(ll x, ll y){
  if(memo[x][y]) return dp[x][y];
  memo[x][y] = true;
  if(x==9LL) {
    dp[x][y] = f(x,y-1LL) + f(x-1LL,y-1LL);
  }
  else if(x == 0LL) {
    dp[x][y] = f(x,y-1LL) + f(x+1LL, y-1LL);
  }
  else{
    dp[x][y]=f(x+1LL,y-1LL) + f(x,y-1LL) + f(x-1,y-1LL);
  }
  return dp[x][y];
}

int main() {
  ll N;
  cin >> N;
  bool ov = false;
  for(int i = 0; i <=9; i++) {
    memo[i][1] = true;
    dp[i][1]=1LL;
  }
  ll cnt = 0LL;
  ll x=0LL, y=0LL;
  for(ll i = 1LL; i < 15LL; i++) {
    for(ll j = 1LL; j <=9LL ; j++) {
      cnt += f(j,i);
      if(cnt>=N){
        x=j;
        y=i;
        ov=true;
        break;
      }
    }
    if(ov) break;
  }
  vector<ll> v;
  ll a = dp[x][y] - (cnt - N);
  v.push_back(x);
  while(a!=1LL||y!=1){
    y--;
    if(x!=0){
      x--;
    }
    if(dp[x][y]>=a) {
      v.push_back(x);
      continue;
    }
    a -= dp[x][y];
    x++;
    if(dp[x][y]>=a) {
      v.push_back(x);
      continue;
    }
    a -= dp[x][y];
    x++;
    v.push_back(x);
  }
  for(ll s:v){
    cout<<s;
  }
}
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef array<ll,2> pll;
const ll NMAX=100001,MOD=1e9+7;
vector<ll> edg[NMAX];
ll dp[NMAX][2];
bool visited[NMAX];
void dfs(ll node){
    visited[node]=1;
    dp[node][0]=dp[node][1]=1;
    for(auto it : edg[node]){
        if(!visited[it]){
            dfs(it);
            dp[node][1]=(dp[node][1]*dp[it][0])%MOD;
            dp[node][0]=(dp[node][0]*(dp[it][0]+dp[it][1]))%MOD;
        }
    }
}
int main()
{
    ll n;
    cin>>n;
    for(ll i=1;i<n;i++){
        ll a,b;
        cin>>a>>b;
        edg[a].push_back(b);
        edg[b].push_back(a);
    }
    dfs(1);
    cout<<(dp[1][0]+dp[1][1])%MOD;
    return 0;
}

///ABCDEFGHIJKLMNOPQRSTUVWXYZ
///11110111101010100000000000


Measured memory_bytes: 16224
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int N;
	std::cin >> N;

	long result = 0;
	for (int i = 1; i <= N; ++i)
		if ((i % 3 != 0) && (i % 5 != 0))
			result += i;
	std::cout << result << "\n";
}


Measured memory_bytes: 3632
import functools
 
n = int(input())
lst = list(map(int, input().split()))
 
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
    
lst_forward = []
a = lst[0]
for i in lst:
    a = gcd(a, i)
    lst_forward.append(a)

lst_backward = []
a = lst[-1]
for i in lst[::-1]:
    a = gcd(a, i)
    lst_backward.append(a)
lst_backward = list(reversed(lst_backward))

s = max(lst_backward[1], lst_forward[-2])
for i in range(1, n-1):
    s = max(s, gcd(lst_forward[i-1], lst_backward[i+1]))
print(s)

Measured memory_bytes: 14576
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int Mod = 998244353;

const int N = 310;

struct Point{
	int x, y;
}P[N];

int n, Pow[N];
double s[N];

int main(){
	scanf("%d", &n);
	Pow[0] = 1;
	For(i, 1, n) scanf("%d%d", &P[i].x, &P[i].y), Pow[i] = Pow[i - 1] * 2 % Mod;
	int ans = Pow[n] - n;
	For(i, 1, n){
		int c = 0;
		For(j, i + 1, n) s[++c] = P[i].x == P[j].x ? 1e10 : double(P[j].y - P[i].y) / double(P[j].x - P[i].x);
		sort(s + 1, s + c + 1);
		For(j, 1, c){
			int r = j;
			while(r < c && fabs(s[r + 1] - s[j]) < 1e-10) ++r;
			ans = (Mod + ans - Pow[r - j + 1] + 1) % Mod;
			j = r;
		}
	}
	printf("%d\n", (ans + Mod - 1) % Mod);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>

using namespace std;


int main()
{
    int N, L; cin >> N >> L;
    int sum = 0, min = INT_MAX;
    for (int i = 0; i < N; i++) {
        int val = L + i;
        sum += val;
        if (abs(val) < min) {
            min = abs(val);
        }
    }

    if (sum >= 0) {
        sum -= min;
    }  else {
        sum += min;
    }
    cout << sum << endl;
    return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int N;
int L[2020];

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> L[i];
    }
    sort(L, L + N);
    int ans = 0;
    for (int a = 0; a < N - 2; ++a) {
        for (int b = a + 1; b < N - 1; ++b) {
            int ccnt = upper_bound(L, L + N, L[a] + L[b] - 1) - L;
            ccnt -= b + 1;
            ans += ccnt;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
;;;; mod
(let ((p 1000000007))
  (defun mod+ (a b)
    (mod (+ a b) p))
  
  (defun mod* (a b)
    (mod (* a b) p))
  
  (defun mod_expt (a z)
    (loop :with ans := 1
          :with pow := a
          :while (> z 0)
          :do (multiple-value-bind (x y) (floor z 2)
                (setf z x)
                (if (= y 1) (setf ans (mod* ans pow)))
                (setf pow (mod* pow pow)))
          :finally (return ans)))
  
  (defun mod_inv (a)
    ; TODO use Euclidean
    (mod_expt a (- p 2))))

;;;; main
(let* ((x (read))
       (y (read))
       (n (/ (- (* 2 x) y) 3))
       (m (/ (- (* 2 y) x) 3)))
  (if (and (<= 0 n) (<= 0 m) (integerp n) (integerp m))
      (let ((f (make-array (list (+ n m 1))))
            (f-1 (make-array (list (+ n m 1)))))
        (setf (aref f 0) 1)
        (setf (aref f-1 0) 1)
        (setf (aref f 1) 1)
        (setf (aref f-1 1) 1)
        (loop :for i :from 2 :to (+ m n)
              :do (setf (aref f i) (mod* (aref f (1- i)) i))
              :do (setf (aref f-1 i) (mod* (aref f-1 (1- i)) (mod_inv i))))
        (format t "~A~%" (mod* (aref f (+ m n)) (mod* (aref f-1 n) (aref f-1 m)))))
      (format t "0~%")))


Measured memory_bytes: 35032
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
	long long n;
	cin>>n;
	long long s=0;
	for(int i=1;i<=n;i++)
	{
		long long o;
		cin>>o;
		a[o]++;
		s+=o;
	}
	int m;
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		long long x,y;
		cin>>x>>y;
		s+=(y-x)*a[x];
		a[y]+=a[x];
		a[x]=0;
		cout<<s<<endl;
	}
 } 

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


int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i=0; i<n; i++) {
		cin >> a[i];
	}
	int bg = a[(k-1)-(k-1)];
	int idx1 = (k-1)-(k-1);
	for(int i=k; i<n; i++) {
		if(a[i] > bg) {
			cout << "Yes\n";
		}
		else{
			cout << "No\n";
		}
		idx1++;
		bg = a[idx1];
	}
}

Measured memory_bytes: 4404
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
s = input()

for i in s:
    ch = (ord(i) - ord("A") + n)%26 + ord("A")
    print(chr(ch),end="")
print()

Measured memory_bytes: 4468
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

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

    vector<ll> a(n),b(n);

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

    ll need = 0;
    ll ans = 0;
    vector<ll> above;
    for(int i = 0; i < n; i++){
        ll t = b[i] - a[i];
        if(t > 0){
            need += b[i] - a[i];
            ans++;
        }else{
            above.push_back(abs(b[i] - a[i]));
        }
    }

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

    for(int j = above.size()-1; need > 0 && j >= 0; j--){
        ans++;
        need -= above[j];
    }

    if(need > 0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2936
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100001

int table[NUM],a[NUM],c[NUM],d[NUM];

int main(){

	int N;
	scanf("%d",&N);

	for(int i = 1; i <= N; i++)table[i] = 0;

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

	int tmp;
	for(int i = 1; i <= N; i++){
		scanf("%d",&tmp);
		table[tmp]--;
	}

	bool FLG = true;

	for(int i = 1; i <= N; i++){
		if(table[i] > 0){
			FLG = false;
			break;
		}
	}

	if(FLG){
		printf("Yes\n");
		return 0;
	}

	for(int i = 1; i <= N; i++){
		if(table[a[i]] <= 0){
			c[i] = a[1];
			d[i] = a[1];
		}else{
			c[i] = a[1];
			d[i] = a[2];
		}
	}

	printf("No\n");
	printf("%d",c[1]);
	for(int i = 2; i <= N; i++)printf(" %d",c[i]);
	printf("\n");

	printf("%d",d[1]);
	for(int i = 2; i <= N; i++)printf(" %d",d[i]);
	printf("\n");

	return 0;
}



Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 50005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  cout << (n - 2) * 180 << en;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
set<int> s;
int main()
{
    int n;
    cin>>n;
    int x;
    for(int i=1;i<=n;i++)
    {
         cin>>x;
         s.insert(x);
    }
    int sum=s.size();
    int t=n-sum;
    if(t%2==0)
    {
        cout<<sum<<endl;
    }
    else
    {
        cout<<sum-1<<endl;
    }
}


Measured memory_bytes: 4992
// https: //onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/1/ITP2_1_A

#include <iostream>
#include <vector>

int main()
{
    std::vector<int> v;

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++)
    {
        int m;
        std::cin >> m;
        if(m==0)
        {
            int x;
            std::cin >> x;
            v.push_back(x);
        }
        if(m==1)
        {
            int x;
            std::cin >> x;
            std::cout << v[x] << std::endl;
        }
        if(m==2)
        {
            v.pop_back();
        }

        // for(auto& y:v)
        // {
        //     std::cout << y ;
        
        // }
        // std::cout  << std::endl;
    }

    return 0;
}


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

typedef long long ll;

template<typename T>
inline T Read(){
    T s = 0, f = 1; char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) {s = (s << 3) + (s << 1) + ch - '0'; ch = getchar();}
    return s * f;
}

#define read() Read<int>()
#define readl() Read<long long>()

const int mod = 1e9 + 7;
int qp(int a, int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1; 
	}
	return ans;
}

void solve() {
	int n = read();
	if(n == 1) puts("0");
	else if(n == 2) puts("2");
	else printf("%d\n", (((ll)qp(10, n) - 2 * qp(9, n) + qp(8, n)) % mod + mod) % mod);
}

int main()
{
	int T = 1;
	//T = read();
	for(int i = 1; i <= T; ++i) {
		solve();
	}

	return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    ll hoge = 0;
    ll ans = 1e18;
    for (int i = 0; i < n - 1; i++) {
        hoge += a[i];
        ll rest = sum - hoge;
        ans = min(ans, abs(hoge - rest));
    }
    cout << ans << "\n";
    return 0;
}

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

// Problem https://atcoder.jp/contests/abc095/tasks/abc095_b

int solver(int kind,int gP,vector<int> cP){// 種類,与えられた粉,各材料の使用量
    int result;
    /** for(int j=0;j<kind;j++){
        cout << cP.at(j) << ",";
    }
    cout << endl; **/
    int allP=0;
    int minP=1010;
    for(int j=0;j<kind;j++){
        allP = allP + cP.at(j);
        // ついでに最小粉もチェック
        if(cP.at(j) < minP) minP = cP.at(j);
    }
    /** cout << "allUsedPowder is " << allP << endl;
    cout << "minPowser is " << minP << endl; **/
    int rCake; // 全種類に使ったうえで、最小粉を使って作れるケーキの数
    rCake = ( gP - allP ) / minP;
    result = kind + rCake;
    return result;
}

int main(void){
    int N,X,answer;
    cin >> N >> X;
    vector<int> m(N);
    for(int j=0;j <N;j++){
        cin >> m.at(j) ;
    }
    answer = solver(N,X,m);
    cout << answer << endl; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;

bool ch(ll a,ll b)
{
    ll c=(1<<b);
    a/=c;
    return (a&1);
}

int main()
{
    ll a,b,c,d,n,m,i,j,k,t;
    cin>>n>>m>>k;
    ll ans=0;
    string s[n];
    for(i=0;i<n;i++) cin>>s[i];
    for(i=0;i<(1<<n);i++)
    {
        for(j=0;j<(1<<m);j++)
        {
            ll count=0;
            for(a=0;a<n;a++)
            {
                for(b=0;b<m;b++)
                {
                    if(s[a][b]=='#' && !ch(i,a) && !ch(j,b)) 
                        count++;
                }
            }
            if(count==k) ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3632
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let H = read![[i64]];

    let mut count = 1;
    let mut max_h = H[0];
    for i in 1..N {
        if H[i] < max_h {
            continue;
        }

        max_h = max(max_h, H[i]);
        count += 1;
    }

    println!("{}", count)
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	int pt = 0, ph = 0;
	for(int i = 0; i < n; ++i){
		string t, h;
		cin >> t; cin >> h;
		if(t > h) pt += 3;
		else if(t == h){
			++pt; ++ph;
		}else ph += 3;
	}
	cout << pt << " " << ph << endl;
	return 0;
}

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

typedef long long LL;

const int N=100000,mod=1000000007;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n,x[N+9];

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

int inv[N+9];

void Get_inv(){
  inv[1]=1;
  for (int i=2;i<=n;++i) inv[i]=mul(mod-mod/i,inv[mod%i]);
}

int ans;

void Get_ans(){
  int sum=0;
  for (int i=1;i<n;++i){
	sadd(sum,inv[i]);
	sadd(ans,mul(sum,x[i+1]-x[i]));
  }
  for (int i=1;i<n;++i) smul(ans,i);
}

void work(){
  Get_inv();
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    
    int cnt = 0;
    REP(i,n+1) {
        REP(j,m+1) {
            if (i * m + j * n - 2 * i * j == k) cnt++;
        }
    }
    
    if (cnt) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
void PRINT(std::string str) {
	int a, b;
	std::cin >> a >> b;
	str = str.substr(a, b - a + 1);
	std::cout << str << std::endl;
}
void REVERSE(std::string  &str) {
	int a, b;
	std::cin >> a >> b;
	std::string CopySTR = str;
	for (unsigned int i =0 ; i <= b-a; ++i) {
		str[a+i] = CopySTR[b - i];
	}
}
void REPLACE(std::string &str) {
	int a, b;
	std::string q;
	std::cin >> a >> b >> q;
	str = str.erase(a, b - a + 1);
	str = str.insert(a, q);
}
int main(void) {
	std::string str;
	std::cin >> str;
	int NumberCOMAND;
	std::cin >> NumberCOMAND;
	for (int i = 0; i < NumberCOMAND; ++i) {
		std::string COMAND;
		std::cin >> COMAND;
		if (COMAND == "print") {
			PRINT(str);
					}
		else if (COMAND == "reverse") {
			REVERSE(str);
		//	std::cout << str << std::endl;
		}
		else if (COMAND == "replace") {
			REPLACE(str);
			//std::cout << str << std::endl;
		}
	}
		//system("pause");
	return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

ll checkNP(ll A) {
    if (A > 0) {
        return 1; 
    }
    else if (A < 0) {
        return -1;
    }
    else {
        return 0;
    }
}

int main() {
	ll argN;
	cin >> argN;

	vector<ll> argA(argN);
	vector<ll> flip(argN, 0);
	for (ll i = 0; i < argN; ++i) {
		cin >> argA.at(i);
	}
	
	if (argN == 1) {
	    cout << 1 << endl;
	    return 0;
	}

    ll baseDiff = checkNP(argA.at(0) - argA.at(1));
	for (ll i = 1; i < argN - 1; ++i) {
	    if (baseDiff == 0) {
			baseDiff = checkNP(argA.at(i) - argA.at(i + 1));
			continue;
		}
	    
		if (flip.at(i - 1) == 1) {
			baseDiff = checkNP(argA.at(i) - argA.at(i + 1));
			continue;
		}
		
		ll tempDiff = checkNP(argA.at(i) - argA.at(i + 1));
		if (baseDiff * tempDiff < 0) {
			flip.at(i) = 1;
		}
	}

	cout << accumulate(flip.begin(), flip.end(), 0) + 1 << endl;
}

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

int main(){

	string str[8];
	int valid;

	while(cin >> str[0]){
		for(int i=1; i<8; i++){
			cin >> str[i];
		}
		
		valid = 0;
		for(int i=0; i<8 && valid == 0; i++){
			for(int j=0; j<8; j++){
				if(str[i][j] == '1'){
					if(i <= 4 && str[i+3][j] == '1'){
						cout << 'B' << endl;
						valid = 1;
						break;
					}
					if(j <= 4 && str[i][j+3] == '1'){
						cout << 'C' << endl;
						valid = 1;
						break;
					}
					if(j != 0 && i <= 5 && str[i+2][j-1] == '1'){
						cout << 'D' << endl;
						valid = 1;
						break;
					}
					if(j <= 5 && i != 7 && str[i+1][j+2] == '1'){
						cout << 'E' << endl;
						valid = 1;
						break;
					}
					if(j != 7 && i <= 5 && str[i+2][j+1] == '1'){
						cout << 'F' << endl;
						valid = 1;
						break;
					}
					if(j != 0 && i != 7 && str[i+1][j-1] == '1'){
						cout << 'G' << endl;
						valid = 1;
						break;
					}
					cout << 'A' << endl;
					valid = 1;
					break;
				}
			}
		}
	}

	return 0;

}

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

int main() {
    int n;
    cin >> n;
    tuple<string, int, int> s[n];

    int i;
    for(i = 0; i < n; i++){
        cin >> get<0>(s[i]) >> get<1>(s[i]);
        get<2>(s[i]) = i + 1;
    }

    int j;
    for(i = 0; i < n - 1; i++){
        for(j = 0; j < n - 1; j++){
            if (get<0>(s[j]) > get<0>(s[j + 1])) {
                swap(s[j], s[j + 1]);
            }
        }
    }

    for(i = 0; i < n - 1; i++){
        for(j = 0; j < n - 1; j++){
            if (get<0>(s[j]) == get<0>(s[j + 1]) && get<1>(s[j]) < get<1>(s[j + 1])) {
                swap(s[j], s[j + 1]);
            }
        }
    }

    for(i = 0; i < n; i++){
        cout << get<2>(s[i]) << endl;
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>



int main() {
  unsigned long long i, j = 0, k, num = 0,  ans = 0, N = 0;
  scanf("%llu", &N);
  num = N;
  for (i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  }
  printf("%llu", ans);
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e6;
const int Nmax=2e5+1;
const int Nd=61;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;} //最大公約数


int main(){
  int n; cin>>n;
  vector<int> a(n);
  int ans=0;
  rep(i,n){
    cin>>a[i];
    if(i==0)  ans=a[0];
    else ans=gcd(ans,a[i]);
  }
  cout<<ans<<endl;


}


Measured memory_bytes: 3760
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		StringBuilder str = new StringBuilder();

		while (true) {
			int h = scan.nextInt();
			int w = scan.nextInt();

			if (h == 0 && w == 0)
				break;
			
			//上の部分
			for (int i = 0; i < w; i++)
				str.append("#");        
			str.append("\n");           
			
			//中の部分
			for (int i = 0; i < h - 2; i++) {
				str.append("#");
				for (int j = 0; j < w - 2; j++) {
					str.append(".");
				}
				str.append("#\n");
			}
			
			//下の部分
			for (int i = 0; i < w; i++)
				str.append("#");
			str.append("\n");
			
			//1行あける
			str.append("\n");  
		}
		System.out.print(str);
	}
}

Measured memory_bytes: 20368
#include <iostream>
#include <cmath>
#include <complex>
using namespace std;
typedef complex<double> xy_t;

xy_t P[50];

double cross_product(xy_t a, xy_t b){ //外積を求める(A-iB)*(C+iD)=(AC + BD)+i(AD-BC)からconj(a)*bの虚部を返せば良い
    return (conj(a)*b).imag();
}

int main(){
    int num = 0;
    double x, y;
    while(~scanf("%lf,%lf", &x, &y)){ //入力が続く間
        P[num] = xy_t(x, y); //P[num++]と書けば一行で済む
        num++;
    }
    double ans = 0; //面積を足していく
    for(int i = 0; i+2 < num; i++){
        xy_t a = P[0], b = P[i+1], c = P[i+2]; //一点aを固定した状態で和を考える
        ans += cross_product(b-a, c-a)/2; //cross_productは平行四辺形の面積なので2で割って足す
    }
    cout << ans << endl;
}




Measured memory_bytes: 3256
#include<stdio.h>
int main(void)
{
	int N, D, P;
	scanf("%d %d", &N,&D);
	P = N / (1 + D * 2);
	if (N%(1+D*2)==0) {
		printf("%d", P);
	}
	else {
		printf("%d", P+1);
	}
	return 0;




}


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

int main(){
  int h,w,ch,cw,dh,dw;
  cin>>h>>w>>ch>>cw>>dh>>dw;
  ch--;
  cw--;
  dh--;
  dw--;
  vector<string> sij(h);
  for(int i=0;i<h;i++){
    cin>>sij[i];
  }
  vector<vector<int>> dij(h,vector<int>(w,-1));
  deque<int> que;
  que.push_front(cw);
  que.push_front(ch);
  dij[ch][cw]=0;
  int curr_h;
  int curr_w;
  h--;
  w--;
  while(que.size()>0){
    curr_h=que[0];
    curr_w=que[1];
    que.pop_front();
    que.pop_front();
    for(int i=0;i<5;i++){
      for(int j=0;j<5;j++){
        if(curr_h-2+i<=h && curr_h-2+i>=0 && curr_w-2+j<=w && curr_w-2+j>=0){
          if(sij.at(curr_h-2+i).at(curr_w-2+j)=='.'){
            if((i==2 && abs(j-2)==1) || (j==2 && abs(i-2)==1)){
              if(dij.at(curr_h-2+i).at(curr_w-2+j)==-1){
                dij.at(curr_h-2+i).at(curr_w-2+j)=dij.at(curr_h).at(curr_w);
                que.push_front(curr_w-2+j);
                que.push_front(curr_h-2+i);
              }else if(dij.at(curr_h-2+i).at(curr_w-2+j)>dij.at(curr_h).at(curr_w)){
                dij.at(curr_h-2+i).at(curr_w-2+j)=dij.at(curr_h).at(curr_w);
                que.push_front(curr_w-2+j);
                que.push_front(curr_h-2+i);
              }
            }else if(i==2 && j==2){
              continue;
            }else{
              if(dij.at(curr_h-2+i).at(curr_w-2+j)==-1){
                dij.at(curr_h-2+i).at(curr_w-2+j)=dij.at(curr_h).at(curr_w)+1;
                que.push_back(curr_h-2+i);
                que.push_back(curr_w-2+j);
              }else if(dij.at(curr_h-2+i).at(curr_w-2+j)>dij.at(curr_h).at(curr_w)+1){
                dij.at(curr_h-2+i).at(curr_w-2+j)=dij.at(curr_h).at(curr_w)+1;
                que.push_front(curr_h-2+i);
                que.push_front(curr_w-2+j);
              }
            }
          }
        }
      }
    }
  }
  cout<<dij[dh][dw]<<endl;
}

Measured memory_bytes: 9508
#include<iostream>
#include <string>
#include <cstring>
using namespace std;

int main(){
    int X, Y;
    cin>> X>> Y;
    for(int i = 0; i<=X; i++){
      if (2*i + 4*(X-i) ==Y){
        cout<<"Yes"<<endl;
        return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,f,g;
  cin >> a >> b >> c >> d;
  if(b>a){
  e = b-a;
  }
  else{
  e = a-b;
  }
  if(c>b){
  f = c-b;
  }
  else{
  f = b-c;
  }
  if (c>a){
  g = c-a;
  }
  else{
  g = a-c;
  }
  if(d>=g || (d>=e && d>=f)){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}





int main()
{
ll a,b,n;
cin>>a>>b>>n;
ll x;

if(b<=n){
    x=b-1;
}else{
    x=n;
}

cout<<floor(a*x/b)-a*floor(x/b)<<endl;
}



Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n,m;
  cin>>n>>m;
  vi a(n);
  rep(i,n) cin>>a[i];

  vi d;
  vector<pi> p;
  rep(i,m){
    int b,c;
    cin>>b>>c;
    p.pb(make_pair(c,b));
  }
  sort(allr(p));
  int cnt=0;
  for(auto v:p){
    if(cnt>n) break;
    int b=v.second,c=v.first,re=n-cnt;
    rep(i,min(b,re)){
      d.pb(c);
      cnt++;
    }
  }
  sort(all(a));
  sort(all(d));
  int ans=0;
  int k=d.size();
  rep(i,n) ans+=a[i];

  rep(i,min(n,k)){
    int in=d[k-1-i],out=a[i];
    if(in<out)break;
    ans+=in-out;
    // cout<<ans<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4464
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int main() {

    vector< bool > p(1000001, true);
    p[0] = p[1] = false;
    for(int i = 2; i * i < 1000001; i++)
        for(int j = i + i; j < 1000001; j += i)
            p[j] = false;

    int a, d, n;
    while(cin >> a >> d >> n, d) {
        int cnt = 0;
        for(int i = 0; ; i++) {
            if(p[a + d * i]) cnt++;
            if(cnt == n) {
                cout << a + d * i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A[3][3], a1, a2, a3, b1, b2, b3;
  for(int i=0; i<3; ++i){
    for(int j=0; j<3; ++j) cin >> A[i][j];
  }
  for(int i=0; i<=100; ++i){
    a1 = i;
    b1 = A[0][0]-a1;
    b2 = A[0][1]-a1;
    b3 = A[0][2]-a1;
    a2 = A[1][0]-b1;
    a3 = A[2][0]-b1;
    if(A[1][1] == a2+b2 && A[1][2] == a2+b3 && A[2][1] == a3+b2 && A[2][2] == a3+b3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3680
#!/usr/bin/env python3
s = input()
n = len(s)

ans = 0
for b in range(1 << (n - 1)):
    tmp = 0
    for i, x in enumerate(s):
        tmp = 10 * tmp + int(x)
        if b >> i & 1:
            ans += tmp
            tmp = 0
    ans += tmp
print(ans)


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

using namespace std;

typedef long long ll;

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

    int h, a;
    cin >> h >> a;

    if(h%a) cout << h/a+1;
    else cout << h/a << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    int ans = 0; int ma = 0;
    rep(i,n){
        int x; cin >> x;
        if(ma <= x){
            ma = x;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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


bool triangleok(ll a, ll b, ll c)
{
    if(a < b+c && b < c+a && c<a+b)
    {
        return true;
    }
    else 
    {
        return false;
    }
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> L;


    for(ll i = 0; i < N;i++)
    {
        ll temp;
        cin >> temp;
        L.push_back(temp);
    }

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

    ll j;
    ll a,b,c;
    ll num=0;

    for(ll i = 0;i<N-1;i++)
    {
        a = L[i];
        
        for(ll j = i+1;j<N;j++)
        {
            b = L[j];

            ll temp  = a+b;
            for(ll k = j+1;k<N;k++)
            {
                if(temp <= L[k])
                {
                    break;
                }
                else
                {
                    num++;
                }
                
            }
        }
    }

    cout << num << endl;



    return 0;
}



Measured memory_bytes: 256