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

typedef double type_n;
typedef complex<type_n> point;

int main()
{
    point a, b, c, z, h;
    int i, q;
    type_n a1, a2, b1, b2, z1, z2;
    scanf("%lf %lf %lf %lf", &a1, &a2, &b1, &b2);
    a.real(a1), a.imag(a2), b.real(b1), b.imag(b2);
    c = b - a;

    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%lf %lf", &z1, &z2);
        z.real(z1), z.imag(z2);
        h = a + c * (((z - a) / c).real());
        printf("%.12f %.12f\n", h.real(), h.imag());
    }
    return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int a, b, c;
	int i;
	int count = 0;

	scanf("%d%d%d", &a, &b, &c);

	for (i = a; i <= b; i++) {
		if (c % i == 0) count++;
	}

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

Measured memory_bytes: 1188
#include<stdio.h>
#define MAX 100000

int n,k;
long long T[MAX];

int check(long long P){
	int i=0;
	for(int j=0;j<k;j++){
		long long s=0;
		while(s+T[i]<=P){
			s+=T[i];
			i++;
			if(i==n)return n;
		}
	}
	return i;
}

int solve(){
	long long left=0;
	long long right=100000*10000;
	long long mid;
	while(right-left>1){
		mid=(left+right)/2;
		int v=check(mid);
		if(v>=n){right=mid;}
		else{left=mid;}
	}
	
	return right;
}

int main(void){
	scanf("%d",&n);
	scanf("%d",&k);
	
	for(int i=0;i<n;i++){scanf("%d",&T[i]);}
	long long ans=solve();
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 2624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  string s, t;
  cin >> s >> t;

  int l = s.size();

  map<char, int> c, d;

  for(char i = 'a'; i <= 'z'; i++){
    c[i] = 0;
    d[i] = 0;
  }

  REP(i, l){
    c[s[i]]++;
    d[t[i]]++;
  }

  int ks = 0, kt = 0, st = 0, cnt = 0;

  vector<int> ss, tt;

  for(char i = 'a'; i <= 'z'; i++){
    if(c[i]){
      ks++;
      ss.pb(c[i]);
    }
    if(d[i]){
      kt++;
      tt.pb(d[i]);
    }
  }

  VSORT(ss);
  VSORT(tt);

  int ans = 0;

  if(ks == kt){
    REP(i, ks){
      if(ss[i] != tt[i]){
        cout << "No";
        return 0;
      }
    }
    cout << "Yes";
    return 0;
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int K;
	cin >> K;
	
	int odd=0;
	int even=0;
	for(int i=1;i<=K;i++)
	{
		if(i%2==0)
			even++;
		else 
			odd++;
	}
	
	cout << odd*even << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
//#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

//namespace mp = boost::multiprecision;

//using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

string abc(string s) {
	string t;
	t += "A" + s + "B" + s + "C";
	return t;
}
int main() {
	int x;
	cin >> x;
	int n = 0;
	while (1) {
		n++;
		if (n*(n + 1) / 2 >= x) {
			break;
		}
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
#define maxv 100001
#define che 1LL<<32
#define mod 1000000007
bool comp(pair<ll,ll> &p,pair<ll,ll> &q)
{
    return p.second<q.second;
}
int main()
{
    ll n,i,j;
    cin>>n;
    vector< pair<ll,ll> > v(n);
    set<ll> s;
    for(i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        v[i]=mp(x,y);
        s.insert(y);
    }
    sort(v.begin(),v.end(),comp);
    ll time,sum=0;
    for(i=0;i<n;i++)
    {
        sum+=v[i].first;
        if(sum>v[i].second)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;
void YN(bool x){
  if(x) cout<<"Yes";
  else cout<<"No";
}
int main() {
  bool finish=true;
  int N,M; cin>>N>>M;
  vector<int> S(N,-1);
  rep(i,M){
    int a,b; cin>>a>>b;
    a--;
    if(S[a]==-1) S[a]=b;
    else if(S[a]!=b) finish=false;
  }
  if(N!=1 &&S[0]==0) finish=false;
  if(!finish) cout<<-1;
  else{
    if(N==1 &&S[0]==-1) S[0]=0;
    else if(S[0]==-1) S[0]=1;
    rep(i,N){
      if(S[i]==-1) cout<<0;
      else cout<<S[i];
    }
  }   
}


Measured memory_bytes: 3632
Result=[]
pair=[]
ans='No'

N=int(input())

for _ in range(N):
    pair=list(map(int,input().split()))
    Result.append(pair)

for i in range(N-2):
    if Result[i][0]==Result[i][1]:
        if Result[i+1][0]==Result[i+1][1]:
            if Result[i+2][0]==Result[i+2][1]:
                ans='Yes'

print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <sstream>
#include <fstream>
#include <numeric>
#include <tuple>

using namespace std;

#define fori(t) for(int i = 0; i < t; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define fork(n) for(int k = 0; k < n; ++k)
#define forai(a) for(auto& i : a)
#define foraj(a) for(auto& j : a)
#define forak(a) for(auto& k : a)
#define forp(s, n, d) for(int p = s; p < n; p += d)
#define fast cin.tie(0); cout.tie(0); std::ios_base::sync_with_stdio(0);
#define pb(a) push_back(a);
#define pob(a) pop_back(a);
#define sorti(a) sort(a.begin(), a.end());
#define sortm(a, n) sort(a, a + n);
#define reversi(a) reverse(a.begin(), a.end());
#define fi first
#define se second
#define yes cout << "Yes\n";
#define no cout << "No\n";
#define ans(a) cout << a << '\n';
#define res(a, n) a.resize(n);
#define read(a, n) a.resize(n); fori(n) cin >> a[i];
//#define int long long
//#define double long double

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<long long, long long> llll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<int, pair<int, int>>> viii;
typedef pair<int, pair<int, int>> iii;
typedef vector<pair<long long, long long>> vllll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef pair<char, char> cc;
typedef pair<pair<char, char>, char> ccc;
typedef vector<char> vc;
typedef pair<int, char> ic;
typedef pair<ii, char> iic;
typedef vector<bool> vb;
typedef set<int> si;
typedef set<ii> sii;
typedef unsigned long long ull;
typedef pair<ull, ull> ullll;
typedef pair<double, double> dd;
typedef vector<dd> vdd;
typedef vector<pair<ull, ull>> vullll;
typedef pair<bool, bool> bb;
typedef vector<bb> vbb;
typedef vector<vector<ii>> vvii;
typedef vector<vector<iii>> vviii;

const int INF = 2147483647;
const ll LONGINF = 9223372036854775807;
const ll MOD = 1e9 + 7;

void solve()
{
    int n, x, t;
    cin >> n >> x >> t;
    ans((n + x - 1) / x * t)
}

signed main()
{
    fast
    bool mult = false;
    if (mult)
    {
        int t;
        cin >> t;
        while (t--) solve();
    }
    else solve();
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <vector>
#include <utility>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;    // <dist, v>

const int MAX_N = 100001;
const ll INF = 1e18;

struct edge { int to, cost; };
vector<edge> G[2][MAX_N];       // [A/B][N]
ll dist[2][MAX_N];              // [from S/from T]
ll ans[MAX_N];

void dijkstra(vector<edge>* g, ll* d, int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d+MAX_N, INF);
    d[s] = 0;
    que.push({0, s});

    int cost, v;
    while (!que.empty()) {
        tie(cost, v) = que.top();
        que.pop();
        if (d[v] < cost) continue;
        for (const edge& e: g[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push({d[e.to], e.to});
            }
        }
    }
}

int main() {
    int n, m, s, t;
    int u, v, a, b;
    scanf("%d %d %d %d", &n, &m, &s, &t);
    for (int i = 0; i < m; i++) {
        scanf("%d %d %d %d", &u, &v, &a, &b);
        G[0][u].push_back({v, a});
        G[0][v].push_back({u, a});
        G[1][u].push_back({v, b});
        G[1][v].push_back({u, b});
    }
    dijkstra(G[0], dist[0], s);
    dijkstra(G[1], dist[1], t);
    for (int i = 1; i <= n; i++)
        ans[i-1] = dist[0][i] + dist[1][i];
    for (int i = n-2; i >= 0; i--)
        ans[i] = min(ans[i], ans[i+1]);
    for (int i = 0; i < n; i++)
        printf("%lld\n", (ll)1e15 - ans[i]);
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 a,b,c;
    cin >> a >> b >> c;
    if(a + b + c >= 22){
        cout << "bust\n";
    }else{
        cout << "win\n";
    }
    return 0;
}

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

int main()
{
	cin>>s;
	int a=s.size(),cnt=0;
	for(int i=0;i<a;i++){
		if((i+1)%2==0){
			if(s[i]=='L'||s[i]=='U'||s[i]=='D') cnt++;
		}
		if((i+1)%2==1){
			if(s[i]=='R'||s[i]=='U'||s[i]=='D') cnt++;
		}
	}
//	cout<<cnt<<" "<<a<<endl;
	if(cnt==a) cout<<"Yes";
	else cout<<"No";
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N, C[500], S[500], F[500], i, j, t;
	scanf("%d",&N);
	for (i=0;i<N-1;i++) {scanf("%d %d %d",&C[i],&S[i],&F[i]);}
	for (i=0;i<N;i++){
		t = 0;
		for (j=i;j<N-1;j++){
			if (t<S[j]) t=S[j];
			else if (t%F[j] == 0);
			else t=t+F[j]-t%F[j];
			t+=C[j];
		}
		printf("%d\n",t);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 310;

int dis[N][N], dis2[N][N];
int n, m, len;

void init(){

   for (int i = 0; i <= n; ++i)
   {
      for (int j = 0; j <= n; ++j)
      {
         dis[i][j] = inf;
      }
      dis[i][i] = 0;
   }
}

void build(int dis[][N]){
   for (int k = 1; k <=n ; ++k)
      for (int i = 1; i <= n; ++i)
         for (int j = 1; j <= n ; ++j)
            dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
}

int32_t main(){_

   cin>>n>>m>>len;

   init();

   for (int i = 0; i < m; ++i)
   {
      int x, y, z;
      cin >> x >> y >> z;
      if(z > len)continue;
      dis[x][y] = z;
      dis[y][x] = z;
   }

   build(dis);

   for (int i = 1; i <= n; ++i)
   {
      for (int j = 1; j <= n; ++j)
      {
         dis2[i][j] = inf;
      }
      dis2[i][i] = 0;
   }

   for (int i = 1; i <= n; ++i)
   {
      for (int j = 1; j <= n; ++j)
      {
         if((dis[i][j] <= len))
            smin(dis2[i][j], 1LL);
      }
   }

   build(dis2);

   int q;
   cin >> q;

   for (int i = 0; i < q; ++i)
   {
      int s, t;
      cin >> s >> t;
      int tt = dis2[s][t];
      --tt;
      if(tt >= inf / 2)tt = -1;
      cout<<tt;
      cout<<endl;
   }


   return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

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

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

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

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

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

struct LR{
  int l,r;
  LR(int l, int r):l(l),r(r){};
  LR(){}
  friend bool operator<(const LR&a, const LR&b){
    if(a.l == b.l) return a.r < b.r;
    return a.l < b.l;
  }
};

int main(){
  int n; cin >> n;
  vector<LR> v(n);
  int maxL = -1, minR = 1001001001, maxLi=0, minRi=0;
  for(int i = 0; i < n; ++i){
    int l, r; cin >> l >> r;r++;
    v[i] = {l,r};
    if(ChangeMax(maxL, l))maxLi = i;
    if(ChangeMin(minR, r))minRi = i;
  }
  if(n == 2){
    cout << v[0].r - v[0].l + v[1].r - v[1].l << endl;
    return 0;
  }
  
  int maxLR = 0;
  for(int i = 0; i < n; ++i) ChangeMax(maxLR, v[i].r - v[i].l);
  maxLR += max(0,minR - maxL);
  if(maxLi == minRi){
    cout << maxLR << endl;
    return 0;
  }

  vector<LR> w;
  for(int i = 0; i < n; ++i){
    if(i != maxLi && i != minRi) w.push_back(v[i]);    
  }

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

  vector<int> minRlist(n-2), maxLlist(n-2);
  for(int i = 0; i < n-2; ++i){
    if(i == 0)maxLlist[i] = w[i].l;
    else maxLlist[i] = max(maxLlist[i-1], w[i].l);
  }
  for(int i = n-3; i >= 0; --i){
    if(i == n-3)minRlist[i] = w[i].r;
    else minRlist[i] = min(minRlist[i+1], w[i].r);
  }
  debug(minR);
  debug(maxL);  
  for(int i = -1; i < n-2; ++i){
    int l1=0,r1=minR,l2=maxL,r2=0;
    if(i == -1)l1 = v[minRi].l;
    else l1 = maxLlist[i];
    if(i == n-3)r2 = v[maxLi].r;
    else r2 = minRlist[i+1];
    debug(i);
    debug(l1);
    debug(r1);
    debug(l2);
    debug(r2);
    ChangeMax(maxLR, max(r1-l1,0)+max(r2-l2,0));
  }

  cout << maxLR << endl;
  
  return 0;
}


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

int main()
{
	int n;
	while (std::cin >> n) {
		if (n==0) break;
		int* A = new int[n];
		for (int i=0; i<n; i++) std::cin >> A[i];
		std::sort(A, A+n);
		unsigned long long sum = 0;
		for (int i=0; i<n-1; i++) sum += (unsigned long long)((n-i-1) * A[i]);
		std::cout << sum << std::endl;
		delete[] A;
	}
	
	return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    int A[N]; for (int i = 0; i < N; ++i) cin >> A[i];
    int B[N]; for (int i = 0; i < N; ++i) cin >> B[i];

    int sumA[N]; sumA[0] = A[0];
    for (int i = 1; i < N; ++i) sumA[i] = sumA[i-1] + A[i];

    int sumB[N]; sumB[0] = B[0];
    for (int i = 1; i < N; ++i) sumB[i] = sumB[i-1] + B[i];

    int res = 0;
    for (int i = 0; i < N; ++i) {
        if (i == 0) res = max(res, sumA[i] + sumB[N-1]);
        else res = max(res, sumA[i] + (sumB[N-1] - sumB[i-1]));
    }

    cout << res << endl;
}


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

#define ll long long

signed main()
{
  int n; cin >> n;
  int a=0,w=0,t=0,r=0;
  string ans;
  for(int i=0; i<n; ++i)
  {
    cin >> ans;
    if(ans=="AC") ++a;
    else if(ans=="WA") ++w;
    else if(ans=="TLE") ++t;
    else if(ans=="RE") ++r;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
}

Measured memory_bytes: 3628
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
    cin.tie(0);
       ios::sync_with_stdio(false);
 
    int x;
    unsigned long long y = 1;
    int z = -1;
    unsigned long long p = 1000000000000000000;
    cin >> x;
    vector<unsigned long long> vec(x);
    for(int i=0; i<x;i++){
      cin >> vec.at(i);
    }
    for(int i=0; i<x;i++){
      if(vec.at(i)==0){
        cout << 0;
        return 0;
      }else if(vec.at(i)>p){
        cout << z;
        return 0;
      }
    }
    for(int i=0; i<x;i++){
     
      if(y>p/vec.at(i)){
        cout << z;
        return 0;
      }

y = y*vec.at(i);

    }
  
    
    if(y > p){
      cout << z;
    }else{
      cout << y;
    }
  
   return 0;
  
}


Measured memory_bytes: 3988
#include <iostream>
#include <stdio.h>
#include <vector>
#include<algorithm>
using namespace std;

int main()
{
	long A, B, C, D,E;

	cin >> A >> B;
	C = A;
	D = B;
	while (1) {
		if (A > B) {
			A = A - B;
		}
			if (A < B) {
				B = B - A;
			}
		if(A == B){
			E = C * D / A;
			cout << E;
			return 0;
		}
	}




}


Measured memory_bytes: 256
# At Beginner Contest 042 B (200)
n, l = map(int, input().split())
S = []
for _ in range(n):
    S.append(input())

out = []
min_ = float("inf")
min_idxs = list(range(len(S)))
pos = 0
while S:
    new_min = []
    for i in min_idxs:
        s = S[i]
        ch = ord(s[pos])
        if ch < min_:
            min_ = ord(s[pos])
            new_min = [ i ]
        elif ch == min_:
            new_min.append(i)
    if len(new_min) == 1 or pos == l - 1:
        for i in range(len(new_min)):
            out.append(S[new_min[i]])
        for i in range(len(new_min) - 1, -1, -1):
            del S[new_min[i]]
        min_idxs = list(range(len(S)))
        pos = 0
    else:
        pos += 1
        min_idxs = new_min
    min_ = float("inf")

r = "".join(out)
print(r)


Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9+7;
 
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; }
    return true;
}
 
int main() {
	ll X;
  	cin >> X;
  	vi A(100000);
  	for(int i = 1;i <100000; i++){
    	A[i] = A[i-1]+i;
    }
  	rep(i,100000){
    	if(X<=A[i]){
        	cout << i <<endl;
          	break;
        }
    }
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include "random"
#include <unistd.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; ++i)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int Uniform_Random(int a, int b){ // (a <= x <= b)

  random_device rd;
  mt19937 mt(rd());
  
  uniform_int_distribution<int> rv1(a, b);
  return rv1(mt);
  
}
 
void solve(){

  int n; cin >> n;
  vi v(n, 0);
  int maxv = 0, minv = 100;
  ll ans = linf;

  for (int i = 0; i < n; i++)
  {
    cin >> v[i];
    chmax(maxv, v[i]);
    chmin(minv, v[i]);
  }
  

  for (int P = minv; P <= maxv; P++){
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
      sum += pow(v[i] - P, 2);
    }
    chmin(ans, sum);
  }
  cout << ans << endl;

}

int main(){
  
  solve();

  return 0; 
}

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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int A[100005];
int C[100005];
int main()
{
	int N, T;
	cin >> N >> T;
	REP(i, N)
	{
		cin >> A[i];
	}
	int max = A[N - 1];
	IREP(i, N - 1)
	{
		max = std::max(A[i], max);
		C[i] = max - A[i];
	}

	sort(C, C + N, [](int a, int b) {return a > b; });
	int ans = 0;
	REP(i, N)
	{
		if (C[0] != C[i])break;
		ans++;
	}

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

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919810893;
const ll MOD = 1000000007;
const ll NUM = 101010;

ll N;
ll A[20], B[20];

ll ans = INF;

int main(){

    cin >> N;
    rep(i, N)cin >> A[i];
    rep(i, N)cin >> B[i];
        
    ll EV = (N + 1) / 2;
    ll OD = N / 2;
    rep(i, 1 << N){
        ll e = 0, o = 0;
        V v(N), f(N, 0);
        vector<P>w(N);
        for(ll j = 0; j < N; j++){
            if(i & (1 << j)){
                o++;
                f[j] = 1;
                if(j % 2 == 0)v[j] = B[j];
                if(j % 2 == 1)v[j] = A[j];
            }
            else{
                e++;
                f[j] = 0;
                if(j % 2 == 0)v[j] = A[j];
                if(j % 2 == 1)v[j] = B[j];
            }
        }
        if(EV != e || OD != o)continue;
        // cout << endl;
        // rep(j, N)cout << f[j];
        // cout << endl;
        // rep(j, N)cout << v[j] << " ";
        // cout << endl;
        
        ll cnt = 0;
        rep(j, N){
            ll val = INF, idx = -1;
            rep(k, N)if(v[k] < val && f[k] == j % 2){
                val = v[k];
                idx = k;
            }
            w[idx].first = j;
            w[idx].second = v[idx];
            v[idx] = INF;
        }
        // rep(j, N)cout << w[j].first;
        // cout << endl;
        rep(j, N)rep(k, N - 1)if(w[k] > w[k+1]){
            swap(w[k], w[k + 1]);
            cnt++;
        }
        rep(j, N - 1)if(w[j].second > w[j + 1].second)cnt = INF;
        // cout << cnt << endl;
        chmin(ans, cnt);
    }

    if(ans == INF)cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

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

const int MOD = 1e9+7;


string s;
int K;
vector<int>f(1e4+1);
vector<vector<int>>eq(1e4+1,vector<int>(1e2+3,0));
vector<vector<int>>lt(1e4+1,vector<int>(1e2+3,0));

int mod(int a,int b){
    a %= b;
    if(a < 0) a += b;
    return a;
}

int mod(int a){
    return mod(a,MOD);
}


signed main(void){
    cin >> s >> K;
    for(int i=0;i<s.length();i++) f[i] = s[i] - '0';
    // １番目のけたを見て，eqとltを更新
    for(int i=0;i<=9;i++){
        if(f[0]==i) eq[0][mod(i,K)] += 1;
        if(i < f[0]) lt[0][mod(i,K)] += 1;
    }

    // i番目のけたを見てとりうる値（k）を考える，足してjになるような個数をカウント
    for(int i=1;i<s.size();i++){
        for(int j=0;j<K;j++){
            // cout << i << ' ' << j << ' ' << f[i]-j << ' ' << K << ' ' <<mod(f[i]-j,K) << endl;;
            eq[i][j] = eq[i-1][mod(j-f[i],K)];
            for(int k=0;k<=9;k++){
                // cout << mod(j-k,K) << endl;
                lt[i][j] = mod(lt[i][j]+lt[i-1][mod(j-k,K)],MOD);
            }
            for(int k=0;k<f[i];k++){
                lt[i][j] = mod(lt[i][j]+eq[i-1][mod(j-k,K)],MOD);
            }
        }
    }

    // for(int i=0;i<5;i++){
    //     for(int j=0;j<10;j++){
    //         cout << lt[i][j] << ' ';
    //     }cout << endl;
    // }

    // lt[s.size()-1][0]，eq[s.size()-1][0]:最後の桁まで見て総和がdの倍数となる個数．ただし０がカウントされているので−１する
    cout << mod(lt[s.size()-1][0] + eq[s.size()-1][0] - 1,MOD) << endl;;
    return 0;
}

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

int f[1000010];

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

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

  for (int i = 0; i < N; i++) {
    f[A[i]]++;
    if (f[A[i]] > 1) continue;
    for (int j = 2; j * A[i] <= 1000000; j++) f[j * A[i]]++;
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (f[A[i]] == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7988
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int a;
string b;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>a>>b;
	if (a<3200)
		cout<<"red";
	else 
		cout<<b;
	return 0;
}

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

using namespace std;

#define int long long

const int MOD = 998244353;
const int N = 2e5 + 111;

int n, m;
int cnt[N], unco;
int a[N];
int cnt2[N];

void add_element(int x)
{
    if (x < 0) return;
    cnt2[x]++;
    if (cnt2[x] == 1) unco--;
}

void del_element(int x)
{
    if (x < 0) return;
    cnt2[x]--;
    if (cnt2[x] == 0) unco++;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    unco = n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
        add_element(a[i] - cnt[a[i]]);
    }
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        x--;
        del_element(a[x] - cnt[a[x]]);
        cnt[a[x]]--;
        a[x] = y;
        cnt[a[x]]++;
        add_element(a[x] - cnt[a[x]]);
        cout << unco << "\n";
    }
}


Measured memory_bytes: 6144
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main(){
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int a,b,c,d; cin >>a>>b>>c>>d;

    int res = min(b,d) - max(a,c);

    if (res > 0) {
        cout << res << endl;
    } else {
        cout << 0 << endl;
    } 

    return 0;
}



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 unsigned long long int ull;
// PB-DS 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define ff first
#define ss second
#define pb push_back
#define Inf  1000000000000000000
#define inf -1000000000000000000
#define mod 1000000007

ll mulmod(ll x,ll y){
  return (x%mod*y%mod)%mod;
}
 
ll addmod(ll x,ll y){
  return (x%mod+y%mod)%mod;
}
 
long long  power(long long  x,long long  y) { 
    long long  res = 1;      
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x;  
        y = y>>1;  
        x = x*x;  
    } 
    return res; 
}

void testcases(int Case){
  int X,Y;
  cin >> X >> Y;
  bool flag = false;
  for(int i = 1; i<=Y;i++){
    int tmp1 = i;
    int tmp2 = Y - i;
    if(tmp1%2==0&&tmp2%4==0){
      if((tmp1/2+tmp2/4)==X)
        flag = true;
    }
    if(tmp1%4==0&&tmp2%2==0){
      if((tmp2/2+tmp1/4)==X)
        flag = true;
    }
  }
  if(flag){
    cout << "Yes" << "\n";
  }
  else{
    cout << "No" << "\n";
  }
}

  
int main()
{
 // sieve();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    ll t;
    t = 1;
    //cin >> t;
    ll Case =1 ;
    while(t--)
    {
      testcases(Case++);
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <LL, LL> pLL;
typedef pair <int, int> pii;

inline LL Read()
{
	LL x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int n = 90;
const int mod = 1e9 + 7;

vector <pLL> a[n];
LL fib[n];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	fib[0] = fib[1] = 1;
	for (int i = 2; i < n; i ++)
		fib[i] = fib[i - 2] + fib[i - 1];
	a[1].pb(mp(1, 2)), a[1].pb(mp(1, 3));
	for (int i = 2; i + 2 < n; i ++)
		for (auto j : a[i - 1])
			for (LL x = j.yy, y = x + j.xx; y <= fib[i + 2] + fib[i - 1]; y += j.yy)
				a[i].pb(mp(x, y));
	int Q = Read();
	while (Q --)
	{
		LL x = Read(), y = Read();
		if (x > y)
			swap(x, y);
		if (x == 1)
			printf("1 %d\n", y % mod);
		else if (y == 2)
			puts("1 4");
		else
		{
			int cur = 0, ret = 0;
			while (fib[cur + 1] <= x && fib[cur + 2] <= y)
				cur ++;
			printf("%d ", cur);
			for (auto i : a[cur - 1])
			{
				if (i.yy <= x)
					ret = ((y - i.xx) / i.yy + ret) % mod;
				if (i.yy <= y)
					ret = ((x - i.xx) / i.yy + ret) % mod;
			}
			printf("%d\n", ret);
		}
	}
}


Measured memory_bytes: 4096
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<time.h>
typedef unsigned int uint;
typedef long long ll;

int main()
{
    char s[10];
    scanf("%s", s);
    if (s[0] == 'S'&&s[1]=='u'&&s[2]=='n'&&s[3]=='n'&&s[4]=='y')
    {
        printf("Cloudy");
    }
    if (s[0] == 'C'&&s[1]=='l'&&s[2]=='o'&&s[3]=='u'&&s[4]=='d'&&s[5]=='y')
    {
        printf("Rainy");
    }
    if (s[0] == 'R'&&s[1]=='a'&&s[2]=='i'&&s[3]=='n'&&s[4]=='y')
    {
        printf("Sunny");
    }
        return 0;
}

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

int main(void){

    string S; cin>>S;
    int maximum = 0;
    int n = S.length();
    char A='A',B='T',C='G',D='C';
    int count=0;
    bool ok = true;
    for (int i = 0; i < n; ++i) {
        if(S[i]==A||S[i]==B||S[i]==C||S[i]==D){
            count++;
            if(maximum < count){
                maximum = count;
            }
        }else{
            count = 0;
        }

    }
    cout<<maximum<<endl;

    return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

typedef long long ll;

using namespace std;

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

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("snuke"),alphh("ABCDEFGHIJK"),s;

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


   cin >> n >> m >> a;
   rep(i,n+1){
       rep(j,m+1){
           if(i*(m-j)+j*(n-i)==a){
               Cout("Yes");
               return 0;
           }
       }
   }
   Cout("No");
return 0;
}


Measured memory_bytes: 256
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextInt64() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}


func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func (io *Io) PrintBool(b bool, trueS, falseS string) {
	if b {
		io.PrintLn(trueS)
	} else {
		io.PrintLn(falseS)
	}
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func absi(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

type Int64s []int64
func (f Int64s) Len() int {
	return len(f)
}
func (f Int64s) Less(i, j int) bool {
	return f[i] < f[j]
}

func (f Int64s) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}


func abcInt(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func gcdInt(a, b int) int {
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

func solve(io *Io) {
	n := io.NextInt()
	x := io.NextInt()

	ans := 0
	for i := 0; i < n; i++ {
		c := io.NextInt()
		ans = gcdInt(ans, abcInt(x - c))
	}

	io.PrintLn(ans)
}

func main() {
	io := NewIo()
	defer io.Flush()

	solve(io)
}


Measured memory_bytes: 6912
#include <iostream>
//imoutoidすこ
using namespace std;
#define ll long long
int main(){
    int n;
    cin >> n;
    if(n/10==9 || n%10==9){
        cout <<"Yes"<<endl;
    }else{
         cout <<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public void output(){
		for(int a=1;a<=9;a++){
			for(int i=1;i<=9;i++){
				System.out.println(a+"x"+i+"="+a*i);
			}
		}
	}
	public static void main(String[] args){
		Main obj = new Main();
		obj.output();
	}
}

Measured memory_bytes: 16844
while True:
  n = int(input())
  if n == 0:
    break
  ls = [0 for i in range(50)]
  ls[0] = 1
  for i in range(30):
    ls[i+1] += ls[i]
    ls[i+2] += ls[i]
    ls[i+3] += ls[i]
  print( (ls[n] // 3650) + (ls[n] % 3650 != 0) )

Measured memory_bytes: 7676
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m, a[20000] = {}, b, x, y, z, k, in[20000] = {}, ax[20000] = {}, d = 1, w, h, typ = 0;
	long long dp[200005] = {}, memo[200005] = {},res;
	string str, str2;
	cin >> n >> z >> w;
	
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << abs(w - a[n]);
		return 0;
	}
	in[n - 1] = a[n];
	ax[n - 1] = a[n];
	res = max(abs(w-a[n]),abs(a[n]-a[n-1]));
	for (int i = n-2; i>=0; i--) {
		in[i] = min(in[i + 1], a[i]);
		ax[i] = max(in[i + 1], a[i]);
	}
	cout << res;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N1=stdIn.nextInt();
		int N2=stdIn.nextInt();
		int N3=stdIn.nextInt();
		int N4=stdIn.nextInt();
		int h1=0,h2=0,h3=0,h4=0;
		if(N1==1)
			h1++;
		if(N2==1)
			h1++;
		if(N3==1)
			h1++;
		if(N4==1)
			h1++;
		if(h1==0||h1>1)
			System.out.println("NO");
		else{
			if(N1==9)
				h2++;
			if(N2==9)
				h2++;
			if(N3==9)
				h2++;
			if(N4==9)
				h2++;
			if(h2==0||h2>1)
				System.out.println("NO");
			else{
				if(N1==7)
					h3++;
				if(N2==7)
					h3++;
				if(N3==7)
					h3++;
				if(N4==7)
					h3++;
				if(h3==0||h3>1)
					System.out.println("NO");
				else{
					if(N1==4)
						h4++;
					if(N2==4)
						h4++;
					if(N3==4)
						h4++;
					if(N4==4)
						h4++;
					if(h4==0||h4>1)
						System.out.println("NO");
					else{
						System.out.println("YES");
					}
				}
			}
		}
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
int n,p[100005];
typedef pair<int,int> pii;
map<pii,bool> ex;
set<int> s[100005];
queue<pii> q;
inline int fnd(int x){
	if(p[x]==x)return x;
	return p[x]=fnd(p[x]);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n*2-2;i++){
		int u,v;
		cin>>u>>v;
		if(s[u].count(v))q.push(pii(u,v));
		else{
			s[u].insert(v);
			s[v].insert(u);
		}
	}
	for(int i=1;i<=n;i++)p[i]=i;
	while(!q.empty()){
		int u=fnd(q.front().X),v=fnd(q.front().Y);
		q.pop();
		if(u==v)continue;
		if(s[u].size()<s[v].size())swap(u,v);
		s[u].erase(v);
		s[v].erase(u);
		for(auto i:s[v]){
			s[i].erase(v);
			if(s[i].count(u))q.push(pii(u,i));
			else{
				s[u].insert(i);
				s[i].insert(u);
			}
		}
		p[v]=u;
		s[v].clear();
	}
	for(int i=2;i<=n;i++){
		if(fnd(i)!=fnd(1)){
			cout<<"NO\n";
			return 0;
		}
	}
	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 24192
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,s1,s2;
  cin >> s;
  int a=s.length();
  if(s[a-1]=='s'){
    s1=s+"e"+"s";
    cout<<s1<<endl;
  }
  else{
    s2=s+"s";
     cout <<s2<<endl; 
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int x;
	cin >> x;
	int i = 1;
	for(;i<x;i++)
	{
		if(x<=(i)*(i+1)/2)break;
	}
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in int read()
	{
		int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
int n,k,s;
int main()
{
	n=read(),k=read(),s=read();
	for(int i=1;i<=k;i++) write(s," \n"[i==n]);
	if(k<n)
	{
		if(s==1000000000) for(int i=k+1;i<=n;i++) write(1," \n"[i==n]);
		else for(int i=k+1;i<=n;i++) write(s+1," \n"[i==n]);
	}
	return ot(),0;
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

vector<PLL> G[112345][3];

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int64 N, M;
  cin >> N >> M;
  REP(i, M) {
    int64 u, v;
    cin >> u >> v; u--; v--;
    REP(j, 3)
      G[u][j].emplace_back(v, (j+1)%3);
  }
  int64 S, T;
  cin >> S >> T; S--; T--;

  vector<int64> d[3];
  REP(i, 3) d[i] = vector<int64>(N+1, INF_LL);
  d[0][S] = 0;
  using Tup = tuple<int64, int64, int64>;
  priority_queue<Tup, vector<Tup>, greater<Tup>> pq;
  pq.emplace(0, 0, S);
  while (pq.size()) {
    int64 vv, tt, dd;
    tie(dd, tt, vv) = pq.top(); pq.pop();
    if (d[tt][vv] < dd) continue;
    REP(i, G[vv][tt].size()) {
      int64 nt, uu;
      tie(uu, nt) = G[vv][tt][i];
      if (d[nt][uu] > dd + 1) {
        // cout << "(" << dd << " " << tt << " " << vv << ") (" << d[tt][vv] + 1 << " " << nt << " " << uu << ") " << endl;
        d[nt][uu] = d[tt][vv] + 1;
        pq.emplace(d[nt][uu], nt, uu);
      }
    }
  }
  if (d[0][T] != INF_LL) cout << d[0][T]/3 << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 19840
#include <cstdio>
#include <vector>

const int MN = 100005;

int N, M;
std::vector<int> G[MN];
int vis[MN], dep[MN], col[MN];

void DFS(int u, int f) {
	vis[u] = 1, dep[u] = dep[f] + 1;
	for (auto v : G[u]) {
		if (v == f) continue;
		if (vis[v]) {
			if (dep[v] < dep[u])
				col[u] ^= 1,
				printf("%d %d\n", u, v);
		}
		else DFS(v, u);
	}
	if (col[u]) printf("%d %d\n", u, f);
	else if (f) col[f] ^= 1, printf("%d %d\n", f, u);
}

int main() {
	int x, y;
	scanf("%d%d", &N, &M);
	if (M & 1) return puts("-1"), 0;
	for (int i = 1; i <= M; ++i)
		scanf("%d%d", &x, &y),
		G[x].push_back(y),
		G[y].push_back(x);
	DFS(1, 0);
	return 0;
}

Measured memory_bytes: 14336
#include<stdio.h>

int n, i;
int b[2], s;
int main(void){
	scanf("%d", &n);
	scanf("%d", b);
	s=b[0];
	for(i=1; i<n-1; i++){
		scanf("%d", b+(i&1));
		if(b[0]>b[1]){s+=b[1];}else{s+=b[0];}
	}
	s+=b[n&1];
	printf("%d\n", s);
}


Measured memory_bytes: 256