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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> h(n);
  REP(i, n) cin >> h[i];
  REP(i, n-1){
    if (h[i+1] == h[i])  {continue;}
    if (h[i+1] > h[i]) {h[i+1]--;}
    if (h[i+1] < h[i]){
      cout << "No" << endl;
      return 0;
  }}
  cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 4064
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

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



// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~









int main(void){
    int n; std::string s;
    std::cin >> n >> s;
    bool f = n % 2 == 0;
    if(f){
        int k = n / 2;
        REP(i, k) if(s[i] != s[i+k]){
            f = false; break;
        }
    }
    puts(f ? "Yes" : "No");

    


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool arr[10000007];
vector<unsigned long long>vec;

void solve()
{
    unsigned long long i,j;
    for(i=4;i<=10000002;i+=2)
    {
        arr[i]=1;
    }
            //cout << i << endl;

    for(i=3;i*i<=10000002;i+=2)
    {
        if(arr[i]==0)
        for(j=i*i;j<=10000002;j+=i)
        {
            arr[j]=1;
        }


    }
    for(i=2;i<=10000002;i++)
    {
        if(!arr[i]){
                //cout << i << endl;
            vec.push_back(i);
        }
    }
   // cout << vec.size() << endl;







}



int main(){
   unsigned long long a,i,j,m=0,sum,k;

 solve();
 cin >> a;
 unsigned long long sum2=1;
for(i=2;i<=a;i++)
{
    j=i;
    m=0;
    sum=1;
    for(k=0;k<vec.size() && vec[k]<j;k++)
    {
        if(j%vec[k]==0)
        {
            m=0;
            while(j%vec[k]==0)
            {
                j/=vec[k];
                m++;
            }
            sum*=(m+1);
        }
        if(arr[j]==0)
        {
            break;
        }




    }
    if(j>1)
    {
        sum*=2;
    }
    sum2+=sum*i;
    //cout << sum2 << endl;
    //cout << "i  " <<i << "   " << sum << endl;




}
cout << sum2 << endl;

}


Measured memory_bytes: 21216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int minX = 0;
		int maxX = sc.nextInt();
		int minY = 0;
		int maxY = sc.nextInt();

		int n = sc.nextInt();

		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int a = sc.nextInt();

			switch (a) {
			case 1:
				minX = Math.max(minX, x);
				break;
			case 2:
				maxX = Math.min(maxX,  x);
				break;
			case 3:
				minY = Math.max(minY, y);
				break;
			case 4:
				maxY = Math.min(maxY, y);
				break;
			}
		}
		int area = maxX > minX && maxY > minY ? (maxX - minX) * (maxY - minY) : 0;

		System.out.println(area);
	}
}



Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

template<int mod=1000000007>
class ModInt {
  int x;
public:
  ModInt() : x(0) {}
  ModInt(const ModInt &y): x(y.x) {}
  ModInt(int64_t y){ x = y % mod; if(x < 0) x += mod; }
  ModInt &operator += (const ModInt &p){ x += p.x; if(x >= mod) x -= mod; return *this; }
  ModInt &operator -= (const ModInt &p){ x -= p.x; if(x < 0) x += mod; return *this; }
  ModInt &operator *= (const ModInt &p){ x = (int) (1LL * x * p.x % mod); return *this; }
  ModInt &operator /= (const ModInt &p){ *this *= p.inverse(); return *this; }
  ModInt operator -() const { return ModInt(-x); }
  ModInt operator + (const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator - (const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator * (const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator / (const ModInt &p) const { return ModInt(*this) /= p; }
  ModInt operator ^ (const int64_t y) const { return pow(y); }
  bool operator == (const ModInt &p) const { return x == p.x; }
  bool operator != (const ModInt &p) const { return x != p.x; }
  ModInt operator = (const int64_t y) { return *this = ModInt(y); }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0){
      t = a/b; a -= t*b; swap(a, b);
      u -= t*v; swap(u, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t y) const {
    if(x==0) return ModInt(0);
    int64_t r = 1, t = x;
    while(y > 0){
      if(y&1) r = r*t%mod;
      t = t*t%mod; y >>= 1;
    }
    return ModInt(r);
  }
  friend ostream &operator << (ostream &os, const ModInt<mod> &p) { return os<<p.x; }
  friend istream &operator >> (istream &is, ModInt<mod> &a) { int64_t x; is>>x; a = ModInt<mod>(x); return is; }
};
using Int = ModInt<>;


int main(){
  int n;
  cin>>n;
  vector<vector<int>> m(n, vector<int>(n));
  rep(i,n) rep(j,n) cin>>m[i][j];

  vector<Int> dp(1<<n, 0);
  dp[0] = 1;
  rep(i,n){
    rep(mask,1<<n) if(__builtin_popcount(mask) == i){
      rep(j,n) if(m[i][j] && (mask>>j)%2==0){
        dp[mask + (1<<j)] += dp[mask];
      }
    }
  }

  cout << dp[(1<<n) - 1] << endl;

  return 0;
}


Measured memory_bytes: 8448
#include <stdio.h>
#define PI 3.14159265359
 
void kock(int n, double px1, double py1, double px2, double py2) {
     
    double sx,sy,tx, ty, ux, uy;
    if (n == 0) return;
     
    sx = (2*px1 + 1*px2)/3;
    sy = (2*py1 + 1*py2)/3;
    tx = (1*px1 + 2*px2)/3;
    ty = (1*py1 + 2*py2)/3;
    ux = (tx - sx) * cos(PI/3) - (ty - sy) * sin(PI/3) + sx;
    uy = (tx - sx) * sin(PI/3) + (ty - sy) * cos(PI/3) + sy;
 
     
    kock(n-1, px1, py1, sx, sy);
    printf("%f %f\n",sx, sy);
     
    kock(n-1, sx, sy, ux, uy);
    printf("%f %f\n", ux, uy);
     
    kock(n-1, ux, uy, tx, ty);
    printf("%f %f\n", tx, ty);
     
    kock(n-1, tx, ty, px2, py2);
     
}
 
int main() {
    int n;
    scanf("%d", &n);
     
    printf("0 0\n");
    kock(n, 0, 0, 100, 0);
    printf("100 0\n");
     
    return 0;
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int n; cin >> n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    sort(all(v));

    double ans = v[0];
    for(int i=1;i<n;i++){
        ans = (ans + v[i]) / 2.0;
    }
    cout << Double(ans) << endl;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<pair<pair<string, int>, int>> data(n);
    rep(i, n) {
        cin >> data[i].ffir >> data[i].fsec;
        data[i].fsec *= -1;
        data[i].sec = i+1;
    }

    sort(all(data));

    rep(i, data.size()) {
        std::cout << data[i].sec << std::endl;
    }

    return 0;
}


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

const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

void printv(vector<ll> v) {
  for (ll i : v)
    cout << i << " ";
  cout << endl;
}

bool operator<(pair<bool, ll> p1, pair<bool, ll> p2) {
  return (p1.second == p2.second ? p1.first < p2.first : p1.second < p2.second);
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    ans += i*(i+1)/2;
  }
  ll E = 0;
  for (ll i = 0; i < n-1; i++){
    ll u, v;
    cin >> u>>v;
    if (u<v){
      E += u*(n-v+1);
    }else{
      E += v*(n-u+1);
    }
  }
  cout << ans-E <<endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s,t;
  cin >> s >> t;
  
  rep(i,s.size()+1){
    char tmp = s[s.size()-1];
    s.pop_back();
    s = tmp + s;
    
    if(s==t){
      cout << "Yes";
      return 0;
    }
  }
  
  cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int c[100100];

signed main(){
    IOS;
    int n; cin >> n;
    vector<int> a(n);
    rep(i,0,n){
        cin >> a[i];
        c[a[i]]++;
    }
    int k = 0;
    rep(i,0,100100){
        if(c[i]>1) k+=c[i]-1;
    }
    if(k%2 == 1) k++;
    cout << n - k << "\n";
}

Measured memory_bytes: 1792
/*
2020-04-22
atcoder ABC
D - String Formation / 
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    //変数定義, 入力処理
    // vector<vector<int>> data(3, vector<int>(4)); //二次元配列
    string S, leftSide = "", rightSide = "";
    bool isReversed = false;
    int Q;
    cin >> S >> Q;
    //処理
    rep(i, Q) {
        int t, f;
        char c;
        cin >> t;
        // cout << "left: " << leftSide << endl;
        // cout << "right: " << rightSide << endl;
        
        if (t == 1) {
            isReversed = !isReversed;
            continue;
        } else {
            cin >> f >> c;
            if (f == 1) {
                if (!isReversed) {
                    leftSide = c + leftSide;
                } else {
                    rightSide = rightSide + c;
                }
            } else {
                if (isReversed) {
                    leftSide = c + leftSide;
                } else {
                    rightSide = rightSide + c;
                }
            }
        }
    }
    if (!isReversed) {
        cout << leftSide + S + rightSide << endl;
    } else {
        reverse(S.begin(), S.end());
        reverse(leftSide.begin(), leftSide.end());
        reverse(rightSide.begin(), rightSide.end());
        cout << rightSide + S + leftSide << endl;
    }
    return 0;
}


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

using namespace std;

int main()
{     
	int q,w[20],t[20],u=0;
	cin>>q;
	for(int r=1;r<=q;r++)  cin>>w[r];
	
	for(int r=1;r<=q;r++)  cin>>t[r];
	for(int r=1;r<=q;r++)
	if(w[r]-t[r]>0) u=w[r]-t[r]+u;
	
	cout<<u;
}

Measured memory_bytes: 256
#define f first
#define s second
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    //freopen("Inp.txt","r", stdin);
    //freopen("Out.txt","w", stdout);

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

    sort (a.begin(),a.end());
    for (int i = 0; i < n-1; i++)
    	a[i] = a[i+1]-a[i];
    a[n-1] = 0;
    sort (a.begin(),a.end()-1);
    int sum = 0;
    for(int i = 0; i < n-k; i++)
    	sum += a[i];
    cout << sum;

    return 0;
}


Measured memory_bytes: 640
program main
    implicit none
    integer h1, m1, h2, m2, k
    integer time

    read(*,*) h1, m1, h2, m2, k

    time = 0
    time = time + (60-m1)
    time = time + (h2-(h1+1))*60
    time = time + m2
    time = time - k

    write(*,*) time

end program



Measured memory_bytes: 2792
###C - Monsters Battle Royale
N = int(input())
A = list(map(int, input().split()))

while(len(set(A)) != 1):
    minA  = min(A)
    for i in range(N):
        if A[i] > minA:
            time = A[i] // minA
            if time == 1:
                A[i] =A[i] -  time * minA
            else:
                A[i] =A[i] -  (time - 1) * minA
                
print(min(A))

Measured memory_bytes: 14480
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    ll cnt=0;
    cin>>n;
    rep(i,n){
        ll a;
        cin>>a;
        while (a%2==0){
            a=a/2;
            cnt++;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

void search(vector<int>& a, ll& k, int& ans, vector<bool>& visited, vector<int>& loop, int now){
  if(k == 0){
    ans = now;
    return;
  }
  now = a[now];
  k--;
  if(visited[now]){
    if(!loop.empty() && loop[0] == now){
      return;
    }
    loop.push_back(now);
  }
  visited[now] = true;
  search(a, k, ans, visited, loop, now);
}

int main(){
  ll n, k;
  cin >> n >> k;
  vector<int> a(n, 0);
  rep(i, n){
    cin >> a[i];
    a[i]--;
  }
  vector<bool> visited(n, false);
  visited[0] = true;
  vector<int> loop;
  int ans = -1;
  search(a, k, ans, visited, loop, 0);
  // for(auto m : loop){
  //   cout << m << endl;
  // }
  if(ans == -1){
    cout << loop[k % loop.size()] + 1 << endl;
  }else{
    cout << ans + 1 << endl;
  }
  return 0;
}


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

using namespace std;

#define inf (ll)1e15
#define ll long long
#define all(x) x.begin(), x.end()
#define x first
#define y second

typedef pair<int, int> Point;

const int mod = (int) 1e9 + 7;
const int mod2 = 998244353;
const int MAX_NODES = 1000;

struct Trie{

	int sz;
	int t[MAX_NODES][26], cnt[MAX_NODES][26];

	Trie(){
		memset(t, 0xff, sizeof t);
		memset(cnt, 0, sizeof cnt);
		sz = 0;
	}

	void insert(string s){
		int node = 0;
		for(int i = 0; i < s.size(); ++i){
			if(t[node][s[i] - 'a'] == -1)
				t[node][s[i] - 'a'] = ++sz;
			++cnt[node][s[i] - 'a'];
			node = t[node][s[i] - 'a'];
		}
	}

	int find(string s){
		int node = 0;
		int res = 0;
		for(int i = 0; i < s.size(); ++i){
			res = cnt[node][s[i] - 'a'];
			node = t[node][s[i] - 'a'];
		}
		return res;	
	}

}trie;

int main(){

    cin.tie(0);
    cin.sync_with_stdio(0);

    #ifdef Cyborg101
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

 	string s;
 	cin >> s;

 	int n = s.size();

 	// auto chk = [](string x){
 			
 	// 	int sz = x.size();
 	// 	for(int i = 0; i < sz / 2; ++i){
 	// 		if(x[i] != x[sz - i - 1])
 	// 			return false;
 	// 	}
 	// 	return true;
 	// };
 	

 	// if(chk(s)){
 	// 	cout << 0 << endl;
 	// 	return 0;
 	// }

 	// string pure;

 	int res = 0;

 	int l = 0, r = n - 1;
 	bool ok = true;

 	while(l < r){

 		if(s[l] == s[r]) l++, r--;
 		else if(s[l] == 'x') l++, res++;
 		else if(s[r] == 'x') r--, res++;
 		else {
 			ok = false;
 			break;
 		}
 	}

 	if(ok){
 		cout << res << endl;
 	}
 	else{
 		cout << -1 << endl;
 	}
 	
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,a,b,c,d;
 	cin >> n>>a>>b>>c>>d;
 	string y;
 	cin >> y;
 	y='#'+y+'#';
 	bool rev=false;
 	bool ans=false;
 	bool revpos=true;
 	for (int i = a; i < c; i++){
 		if (y[i]=='#'&&y[i+1]=='#'){
 			ans=true;
 		}
 	}
 	for (int i = b; i < d; i++){
 		if (y[i]=='#'&&y[i+1]=='#'){
 			ans=true;
 		}
 	}
 	if(c>d){
 		for (int i = b; i < d+1; i++){
 			if(y[i]=='.'&&y[i+1]=='.'&&y[i-1]=='.'){
 				revpos=false;
 			}
 		}
 	}
 	if(ans){
 		cout << "No" << endl;
 	}else if(c>d&&revpos){
 		cout << "No" << endl;
 	}else{
 		cout << "Yes" << endl;
 	}
 }

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

int main(){

    size_t n, m;
    std::cin >> n >> m;

    std::vector<std::vector<size_t>> mat(n, std::vector<size_t>(m));
    std::vector<size_t> vec(m);

    for(auto&& v : mat){
        for(auto&& e : v){
            std::cin >> e;
        }
    }

    for(auto&& e : vec){
        std::cin >> e;
    }

    for(size_t i = 0; i < n; i++){
        size_t sum = 0;
        for(size_t j = 0; j < m; j++){
            sum += mat[i][j] * vec[j];
        }
        std::cout << sum << std::endl;
    }

    return 0;
}



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

drinks = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    drinks.append((a, b))

drinks.sort()

ans = 0
req = M
for a, c in drinks:
    cnt = min(c, req)
    ans += a * cnt
    req -= cnt

print(ans)


Measured memory_bytes: 16968
import math
a, b, h, m = map(int, input().split())

rad_a = 360 * h / 12 + 30 * m / 60
rad_b = 360 * m / 60 
  
if rad_a >= rad_b:
  ans = a**2 + b **2 - 2*a*b*math.cos(math.radians(rad_a - rad_b))
  print(math.sqrt(ans))
else:
  ans = a**2 + b **2 - 2*a*b*math.cos(math.radians(rad_b - rad_a))
  print(math.sqrt(ans))


Measured memory_bytes: 9508
import numpy as np

N = int(input())
A,B = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]

low = len([i for i in P if i <= A])
mid = len([i for i in P if (i > A and i <= B)])
high = len([i for i in P if i > B])

num = min(low,mid,high)

print(num)


Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls x<<1
#define rs x<<1|1
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+100;

void solve()
{
	int a,b;
	scdd(a,b);
	if(a<1||a>9||b<1||b>9){
		printf("-1\n");
		return ;
	}printf("%d\n",a*b);
}
int main(){
    //IOS;
    solve();
    return 0;
}


Measured memory_bytes: 256
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    int n,k;
    string s;
    cin >> n >> k;
    cin >> s;

    s[k-1] = tolower(s[k-1]);

    cout << s << endl;
    return 0;

}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int k[n];
  int cnt=0;
  rep(i,n)cin >> k[i];
  rep(i,n-2){
    if(max(max(k[i],k[i+2]),k[i+1])==k[i+1])continue;
    if(min(min(k[i],k[i+2]),k[i+1])==k[i+1])continue;
    cnt++;
  }
  cout << cnt << endl;
}  


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

int main(){
    char ch;
    while(1){
    scanf("%c", &ch);
    if('a' <= ch && ch <= 'z'){
        printf("%c",ch-32);
    }else if('A'<= ch && ch <='Z'){
        printf("%c",ch+32);
    }else{
        printf("%c",ch);
    }
    if ( ch == '\n' ) break;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main (){
    int A, B; cin >> A >> B;
    int h, w; cin >> h >> w;
    
    
    
    cout << (A - h)* (B - w) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    long long t, a;
    t = a = 1;
    for(int i=0; i<N; ++i){
        long long ti, ai;
        cin >> ti >> ai;
        long long d = max((ai+a-1)/ai, (t+ti-1)/ti);
        a = d * ai;
        t = d * ti;        
    }
    cout << a+t << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


suits = ["S","H","C","D"]
check = [[False]*14 for _ in range(4)]


def get_row(arg_ch):
    for i in range(len(suits)):
        if arg_ch == suits[i]:
            return i


N = int(input())

for _ in range(N):
    tmp = input().split()
    check[get_row(tmp[0])][int(tmp[1])] = True


for row in range(4):
    for col in range(1,14):
        if check[row][col] == False:
            print("%s %d"%(suits[row],col))


Measured memory_bytes: 6368
n = int(input())
s = [list(input()) for _ in range(2)]

mod = 10 ** 9 + 7
res = 1
flag = 0
skip = False
for i in range(n):
    if s[0][i] == s[1][i]:
        if flag == 0:
            res = res * 3 % mod
        elif flag == 1:
            res = res * 2 % mod
        
        flag = 1

    else:
        if skip:
            skip = False
            continue

        if flag == 0:
            res = res * 6 % mod
        elif flag == 1:
            res = res * 2 % mod
        else:
            res = res * 3 % mod
        
        flag = 2
        skip = True

print(res)

Measured memory_bytes: 61068
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


const int MOD = 1000000007;

int main() {
    long long N, K;
    cin >> N >> K;
    long long res = 0;
    for (long long k = K; k <= N+1; ++k) {
        long long first = k * (k-1) / 2;
        long long final = (N*2-k+1) * k / 2;
        long long add = final - first + 1;
        res = (res + add) % MOD;
    }
    cout << res << endl;
}





// N-k+1, N











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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

const int N = 123456;
int n, b, ans;
int p[N];
V<int> g[N];

int dfs(int v) {
    int ma = 0;
    for (int u: g[v]) {
        int d = dfs(u) + 1;
        if (d == b) {
            ans++;
        } else {
            ma = max(ma, d);
        }
    }
    return ma;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    cin >> n >> b;
    for (int i = 0; i < n; i++) {
        cin >> p[i]; p[i]--;
        if (i) g[p[i]].push_back(i);
    }
    ans += (p[0] != 0);
    for (int u: g[0]) dfs(u);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9856
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"

using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1E9+7
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const string yes = "Yes", no = "No";
// vector<bad()ool> v(1E5, false);

int main()
{
    string s;
    cin>>s;
    ll a=0,b=0;
    loop(i,0,3){
        if(s[i]=='A')
            a++;
        else
            b++;
    }

    if(a==0 || b==0){
        cout<<"No";
    }
    else
        cout<<"Yes";


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    vector<int> cnt(30,0);
    for(auto c:s){
        cnt[c-'a']++;
    }
    int sum=0;
    for(auto it:cnt){
        sum+=it*(it-1)/2;
    }
    int n=s.size();
    cout<<n*(n-1)/2+1-sum<<endl;
}

Measured memory_bytes: 720
/* Insertion Sort */

#include <stdio.h>

void print_seq(const int seq[], int num)
{
    printf("%d", seq[0]);
    
    int i;
    for (i = 1; i < num; i++)
        printf(" %d", seq[i]);

    putchar('\n');
}

int main(void)
{
    int N, i, j, key;

    scanf("%d", &N);

    int s[N];

    for (i = 0; i < N; i++)
        scanf("%d", &s[i]);

    for (i = 1; i < N; i++) {
        print_seq(s, N);

        key = s[i];
        j = i - 1;
        while (j >= 0 && s[j] > key) {
            s[j + 1] = s[j];
            j--;
        }
        s[j + 1] = key;
    }

    print_seq(s, N);

    return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S;

signed main(){
	cin>>S;
	int N=S.size();
	for(int i=N-1;0<=i;i--){
		if(S[i]=='?'){
			S[i]='D';
		}
	}
	cout<<S<<endl;
	return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e15
#define mod 1000000007
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long 
#define lb lower_bound
#define ub upper_bound
#define fr(a,b,c) for(ll a = b ; a <= c ; ++a )
#define frn(a,b,c) for(ll a = b ; a >= c ; a -- )
#define fra(a,b) for(auto a: b)
#define ms(a) memset(a,0,sizeof a);
#define alla(a) a,a+n
#define allv(a) a.begin(),a.end()
#define size(a) (ll)a.size()
#define getMat(x,n,m,val) vector<vector<ll>>x(n,vector<ll>(m,val))
const ll MAXN = 1e5+5;
#define pii 3.14159265358979323846 
ll pw(ll b, ll r, ll md){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%md;
		b = (b*b)%md;
		r>>=1;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,m;cin>>n>>m;
	ll dp[n+1];ms(dp);
	ll ans[n+1];ms(ans);
	vector<ll>adj[n+1];
	fr(i,0,m-1){
		ll a,b;cin>>a>>b;
		adj[a].pb(b);
		dp[b]++;
	}
	ll an = 0 ;
	queue<ll>q;
	fr(i,1,n)if(!dp[i])q.push(i);
	while(!q.empty()){
		ll u = q.front();
		q.pop();
		for(auto x: adj[u]){
			ans[x]=max(ans[x],ans[u]+1);
			an=max(ans[x],an);
			dp[x]--;
			if(!dp[x])q.push(x);
		}
	}
	cout<<an<<en;
	return 0 ;

}

Measured memory_bytes: 10620
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int k, n; cin >> k >> n;
    vi a(n); list(i,n) cin >> a[i];
    vi diff(n);
    list(i,n-1) diff[i] = a[i+1]-a[i];
    diff[n-1] = k-a[n-1]+a[0];
    //Find the sum
    int sum = 0;
    list(i,n) sum += diff[i];
    //Find the maximum difference
    int maxDiff = -INF;
    list(i,n) maxDiff = max(maxDiff,diff[i]);
    //print the answer
    cout << sum - maxDiff << "\n";

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[n];
  rep(i,n) R a[i];
  rep(i,n-1) {
    if(a[i]+a[i+1]>=m) {
      pr("Possible");
      rep(j,i) pr(j+1);
      for(int j=n-2; j>=i+1; j--)  pr(j+1);
      pr(i+1);
      return;
    }
  }
  pr("Impossible");
}

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


Measured memory_bytes: 1664
N,M,C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0
for _ in range(N):
  A = list(map(int, input().split()))
  sums = sum([A[i]*B[i] for i in range(M)])+C
  if sums > 0:
    cnt += 1
print(cnt)

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

using namespace std;

int main() {
    string s, ans = "";
    cin >> s;

    for (int i = 0; i < s.length(); ++i) {
        if (i % 2 == 0) {
            ans += s.at(i);
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 2e5 + 5;

int arr[maxr], co[maxr];

int32_t main()
{
	GO;
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int rem = 0;
	for (int j = 0; j < k; j++) {
		memset(co, 0, sizeof(co));
		for (int i = 0; i < n; i++) {
			int l = i + 1 - arr[i];
			int r = i + 1 + arr[i];
			l = max(l, 1ll);
			r = min(r, n);
			co[l] ++;
			co[r + 1]--;
		}
		bool found = false;
		for (int i = 2; i <= n; i++) {
			co[i] += co[i - 1];
		}
		for (int i = 1; i <= n; i++) {
			arr[i - 1] = co[i];
			if (co[i] < n) {
				found = true;
			}
		}
		if (found == false) {
			rem = k - j;
			break;
		}
	}
	for (int i = 1; i <= n; i++)
		cout << co[i]  << " ";
	cout << endl;

	return 0;
}

//!

Measured memory_bytes: 6632
N, M = map(int, input().split())
H = list(map(int, input().split()))
r = list()
for _ in range(N):
    r.append([])
for i in range(M):
    A, B = map(int, input().split())
    A-=1
    B-=1
    r[A].append(H[B])
    r[B].append(H[A])

cnt = 0
i = 0
for l in r:
    if len(l) == 0:
        cnt += 1
    elif max(l) < H[i]:
        cnt += 1
    i += 1

print(cnt)


Measured memory_bytes: 23040
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MAXN 1000
int k, n, a[MAXN][MAXN];
int main() {
	scanf("%d", &k);
	if (k == 1) {
		puts("1");
		puts("1");
		return 0;
	}
	if (k == 2) {
		puts("2");
		puts("1 1");
		puts("2 2");
		return 0;
	}
	n = ((k - 1) / 4 + 1) * 2;
	printf("%d\n", n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int x = (i & 1 ? n : 0) + (i + j) % n;
			if (x >= k) x -= n;
			printf("%d ", x + 1);
		}
        puts("");
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[100]={},ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	n+=n%2;
	sort(a,a+n);
	for(int i=0;i<n;i+=2)
		ans+=a[i+1]-a[i];
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <tuple>
#include <vector>
#include <cstdio>
#include <iostream>
#include <climits>

constexpr int MAX = 200010;

int main(void){
    int N;
    scanf("%d", &N);
    std::vector<unsigned int> A1(N), A2(N);
    for (auto itr = A1.begin(); itr != A1.end(); itr++){
        scanf("%d", itr);
    }
    for (auto itr = A2.begin(); itr != A2.end(); itr++){
        scanf("%d", itr);
    }
    
    std::vector<unsigned int> sA1(N), sA2(N);
    unsigned int sum = 0;
    for (auto itr = A1.begin(), sitr = sA1.begin(); itr != A1.end(); itr++, sitr++){
        sum += *itr; *sitr = sum;
    }
    sum = 0;
    for (auto ritr = A2.rbegin(), sritr = sA2.rbegin(); ritr != A2.rend(); ritr++, sritr++){
        sum += *ritr; *sritr = sum;
    }
    unsigned int result = 0;
    for (int i = 0; i < N; i++){
        if (result < sA1[i] + sA2[i]) result = sA1[i] + sA2[i];
    }
    printf("%u", result);
    return 0;
}


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

#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)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  bool ok = false;
  int cnt = 0;
  rep(i, n) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) {
      cnt++;
    } else {
      cnt = 0;
    }
    if (cnt >= 3) {
      ok = true;
      break;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int h, w, c[15][15], ans = 0, x;
  scanf("%d%d", &h, &w);
  for(int i = 0; i < 10; i++)
    for(int j = 0; j < 10; j++)
      scanf("%d", &c[i][j]);
  
  for(int i = 0; i < 10; i++)
    for(int j = 0; j < 10; j++)
      for(int k = 0; k < 10; k++)
        c[j][k] = min(c[j][i] + c[i][k], c[j][k]);
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      scanf("%d", &x);
      ans += (x == -1 ? 0 : c[x][1]);
    }
  }
  printf("%d\n", ans);
}


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

#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;

const ll oo=1e18;
const int MOD=1000000007;
const int INF=1000000000;
const ld EPS=0.000000001;

int dp[100005],h[100005],n,k=2;

signed main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,0x3f3f,sizeof dp);
    dp[1]=0;
    h[0]=0;
    cin>>n;
    for(int i=1;i<=n;++i) cin>>h[i];
    for(int i=2;i<=n;++i) {
        for(int j=1;j<=min(k,i);++j) {
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
using namespace std;
char in[110];
vector<int>x1[110];
vector<int>y1[110];
vector<int>x2[110];
vector<int>y2[110];
vector<string>na[110];
string name[110];
int buf[11000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		int h,w;scanf("%d%d",&h,&w);
		for(int i=0;i<110;i++){
			x1[i].clear();
			x2[i].clear();
			y1[i].clear();
			y2[i].clear();
			na[i].clear();
		}
		for(int i=0;i<a;i++){
			int c;scanf("%s%d",in,&c);
			name[i]=in;
			for(int j=0;j<c;j++){
				int p,q,r,s;
				scanf("%d%d%d%d%s",&p,&q,&r,&s,in);
				string tmp=in;
				x1[i].push_back(p);x2[i].push_back(r);
				y1[i].push_back(q);y2[i].push_back(s);
				na[i].push_back(tmp);
			}
		}
		int at=0;
		for(int i=0;i<11000;i++)buf[i]=-1;
		buf[0]=0;
		int b;scanf("%d",&b);
		while(b--){
			scanf("%s",in);
			if(in[0]=='s'){
				printf("%s\n",name[buf[at]].c_str());
			}
			if(in[0]=='b'){
				at=max(0,at-1);
			}
			if(in[0]=='f'){
				if(~buf[at+1])at++;
			}
			if(in[0]=='c'){
				int to=-1;
				int x,y;scanf("%d%d",&x,&y);
				for(int i=0;i<x1[buf[at]].size();i++){
					if(x1[buf[at]][i]<=x&&x<=x2[buf[at]][i]&&y1[buf[at]][i]<=y&&y<=y2[buf[at]][i]){
						for(int j=0;j<a;j++)if(na[buf[at]][i]==name[j])to=j;
						break;
					}
				}
				if(~to){
					buf[++at]=to;
					for(int i=at+1;i<110;i++)buf[i]=-1;
				}
			}
		}
	}
}

Measured memory_bytes: 1156
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1, l, M
#define rson rt<<1|1, M+1, r
#ifdef local
#define dbg(a) cout << #a": " << a << endl;
#else
#define dbg(a)
#endif // loacl


using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-6;
const int mod=1e9+7;
const int maxn=200+10;
const int N=1e5+10;
const int M=N*20;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll MOD)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%MOD;
        b>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}

int n,m;
char mp[2005][2005];
int f1[2005][2005],f2[2005][2005],f3[2005][2005],f4[2005][2005];
int main()
{
	scdd(n,m);
	rep1(i,n) scanf("%s",mp[i]+1);
	for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j) if(mp[i][j]=='.')
            f1[i][j]=f1[i-1][j]+1,f2[i][j]=f2[i][j-1]+1;
    for(int i=n;i>=1;--i)
        for(int j=m;j>=1;--j) if(mp[i][j]=='.')
            f3[i][j]=f3[i+1][j]+1,f4[i][j]=f4[i][j+1]+1;
    ll ans=0;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j) if(mp[i][j]=='.')
            ans=max(ans,(ll)f1[i][j]+f2[i][j]+f3[i][j]+f4[i][j]-3);
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 66944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B;
    cin >> A >> B;
    if(abs(A-B)<2) cout << "Yay!" << endl;
    else cout << ":(" << endl;



}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def find(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)
n,m=map(int,input().split())
p=[0]+list(map(int,input().split()))
uf=UnionFind(n)
for _ in range(m):
  a,b=map(int,input().split())
  uf.unite(a,b)
cnt=0
for i,j in enumerate(p):
  if uf.same(i,j):cnt+=1
print(cnt-1)

Measured memory_bytes: 86212
dishes = [int(input()) for _ in range(5)]
S = [((10 - dishes[i] % 10) % 10) * 5 + i for i in range(5)]
S.sort()
M = 0
for i in range(4):
  M += -int((-dishes[S[i]%5])//10)*10
M += dishes[S[4]%5]
print(M)

Measured memory_bytes: 3060