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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto && (i) : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

struct UnionFind {
  vector<int> par;  // par[i]:iの親の番号
  vector<int> siz;  //葉の値を持つ

  UnionFind(int n)
      : par(n),
        siz(n, 1)  //初期化
  {
    for (int i = 0; i < n; i++) par[i] = i;
  }

  int root(int x)  //データxが属する木の根を再帰で得る
  {
    if (par[x] == x)
      return x;
    else
      return par[x] = root(par[x]);
  }

  int size(int x) { return siz[root(x)]; }

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

  bool unite(int x, int y)  // xとyの木を併合
  {
    if ((x = root(x)) == (y = root(y)))  // xとyの根が同じ時はそのまま
      return false;
    if (siz[y] > siz[x]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;  // yの根にxをつける
    return true;
  }
};

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

  int n, q;
  cin >> n >> q;
  UnionFind uf(n + 1);
  rep(i, 0, q) {
    int t, v, w;
    cin >> t >> v >> w;
    if (t == 0)
      uf.unite(v, w);
    else
      cout << (!uf.same(v, w) ? 0 : 1) << '\n';
  }
  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  // 余りが 0 になる
  int lim = a * b;

  bool can = false;
  for (int i = 1; i <= lim; i++) {
    int d = a * i;
    if (d % b == c) {
      can = true;
      break;
    }
  }

  cout << (can ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include<string>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llint long long
using namespace std;
llint n;
string s;
llint sum[3][4005];
int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//n是长度
	cin >> n;
	cin >> s;
	s = "#" + s; 
	llint ans = 0;
	//把R,G,B转化成0，1，2就能存数组里了
	for(int i = 1; i <= n; i++)
	{
		if(s[i] == 'R') s[i] = '0';
		if(s[i] == 'G') s[i] = '1';
		if(s[i] == 'B') s[i] = '2';
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j < 3; j++) 
			sum[j][i] = sum[j][i-1];
		sum[s[i]-'0'][i]++;
	}
	for(int i = 1; i <= n; i++)
	{
		//c就是辨认R,G,B的一个工具变量
		llint c = s[i]-'0';
		//ans是答案
		//初步计算
		ans += sum[(c+1)%3][i-1] * (sum[(c+2)%3][n] - sum[(c+2)%3][i]);
		ans += sum[(c+2)%3][i-1] * (sum[(c+1)%3][n] - sum[(c+1)%3][i]);
		//判断符不符合条件
		for(int j = 1; j <= n; j++)
		{
			if(i-j <= 0 || i+j > n) 
				break;
			if(s[i-j] != s[i] && s[i] != s[i+j] && s[i+j] != s[i-j]) 
				ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main (void){
    long long i = 1,a,ans = 1;


    scanf("%lld",&a);

    
   while(i*i <= a){
       if(i*i > ans){
           ans = i*i;
       }
       i++;
   }
   printf("%lld\n",ans);
   
    return 0;
}

Measured memory_bytes: 128
// B - Collecting Balls (Easy Version)
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K; cin>>N>>K;
	int ans = 0;
	while(N--){
		int x; cin>>x;
		ans += min(x, K-x);
	}
	cout<< ans*2 <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+11;
int n,ans,a[N],b[N];
int ida[N],idb[N],vis[N],id[N];
inline bool cmpa(int x,int y){return a[x]<a[y];}
inline bool cmpb(int x,int y){return b[x]<b[y];}
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
signed main(){
    n=read();
    for(int i=1;i<=n;i++) a[i]=read(),ida[i]=i;
    for(int i=1;i<=n;i++) b[i]=read(),idb[i]=i;
    sort(ida+1,ida+n+1,cmpa);
    sort(idb+1,idb+n+1,cmpb);
    for(int i=1;i<=n;i++)
        if(a[ida[i]]>b[idb[i]]) return puts("No"),0;
    for(int i=1;i<n;i++)
        if(a[ida[i+1]]<=b[idb[i]]) return puts("Yes"),0;
    for(int i=1;i<=n;i++) id[ida[i]]=i;
    for(int i=1;!vis[ida[i]];i=id[idb[i]]) vis[ida[i]]=1;
    for(int i=1;i<=n;i++) if(!vis[i]) return puts("Yes"),0;
    puts("No");
    return 0;
}


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

#define MAX 100

int main() {
	int a, b;
	cin >> a >> b;
	bool white[MAX][MAX];
	for (int i = 0;i < MAX;i++) {
		for (int j = 0;j < MAX;j++) {
			white[i][j] = (j < MAX / 2) ? true : false;
		}
	}
	b--;
	for (int i = 0;i < MAX&&b!=0;i+=2) {
		for (int j = 0;j < MAX / 2&&b!=0;j+=2) {
			white[i][j] = false;
			b--;
		}
	}

	a--;
	for (int i = 0;i < MAX&&a != 0;i += 2) {
		for (int j = MAX/2+1;j < MAX && a != 0;j += 2) {
			white[i][j] = true;
			a--;
		}
	}

	cout << "100 100" << endl;
	for (int i = 0;i < MAX;i++) {
		for (int j = 0;j < MAX;j++) {
			cout << (white[i][j] ? "." : "#");
		}
		cout << endl;
	}
	cout << endl;

	return 0;
}

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

int main(){
  string s; cin >> s;
  int k; cin >> k;
  set<string> st;
  for(int i = 0; i < (int)s.size(); i++){
    string t = "";
    for(int j = 0; j < k; j++){
      if(i + j >= s.size()) break;
      t += s[i+j];
      st.insert(t);
    }
  }
  string ans;
  int cnt = 0;
  for(auto p: st){
    cnt++;
    ans = p;
    if(cnt == k) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4784
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int n,now,ans = 0;
vector<pair<int,int>> v;

int main(){
 cin >> n;
 rep(i,n){
   ll x,l = 0; cin >> x >> l;
   v.push_back(make_pair(x+l,x-l));
 }

//  rep(i,n){
//   int a = v[i].first;
//   int b = v[i].second;
//   cout << a << b << endl;
// }
 sort(v.begin(),v.end());
 now = -2e9;
//  now = v[0].first;
 ans = 0;

// rep(i,n){
//   int a = v[i].first;
//   int b = v[i].second;
//   cout << a << b << endl;
// }
// rep(i,n-1){
//   if(now > v[i+1].second){
//     ans -= 1;
//   }
// }

	// cout<<ans;
  	for (int i=0;i<n;i++){
		if (v[i].second<now) continue;
		now=v[i].first;
      	ans++;
	}
  cout << ans;


}

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


int main()
{
    int N;
    cin>>N;
    vector<int> line1(N);
    for (int i=0;i<N;++i){
        cin>>line1.at(i);
    }
    vector<int> line2(N);
    for (int i=0;i<N;++i){
        cin>>line2.at(i);
    }
    int sum = line1[0];
    for (int i=0;i<N;++i){
        sum += line2[i];
    }
    int maxs = sum;
    for (int i=0;i<N-1;++i){
        sum = sum + line1[i+1] - line2[i];
        maxs = max(sum,maxs);
    }
    cout<<maxs<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <list>
#include <vector>
#include <queue>
#include <bitset>
#include <cctype>
#include <algorithm>


typedef long long ll;
#define nn cout << '\n'
#define rep(n) for(int i = 0; i < n; i++)
#define repi(n) for(int i = 0; i <n; i++)

using namespace std;

int values[100001];

void testcase() {
	ll n; cin >> n;
	vector<ll> v(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		values[x]++;
		sum += x;
	}
	ll q; cin >> q;
	for (int i = 0; i < q; i++) {
		ll x, y; cin >> x >> y;
		sum -= values[x] * x;
		sum += values[x] * y;
		values[y] += values[x];
		values[x] = 0;
		cout << sum;
		nn;
	}

	


}


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

	int x = 1;
	rep(x) {
		testcase();
		nn;

	}
	return 0;
}

/*

*/

Measured memory_bytes: 4492
using System;

    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            int res = N;

            for(int i=0;i<=N;i++)
            {
                var count = 0;
                var t = i;
                while(t>0)
                {
                    count += t % 6;
                    t /= 6;
                }
                t = N - i;
                while (t > 0)
                {
                    count += t % 9;
                    t /= 9;
                }
                if (res > count) res = count;
            }
            Console.WriteLine(res);
        }
    }

Measured memory_bytes: 11092
N, K = map(int, input().split())
x = list(map(int,input().split()))

ans = 100000000000
#最初と最後だけ調べればOK
for i in range(N - K + 1):
    tmp_min = x[i]
    tmp_max = x[i + K - 1]
    tmp = 0
    if tmp_min < 0:
        #混合の場合
        if tmp_max > 0:
            #+に先に行く場合
            if abs(tmp_min) > tmp_max:
                tmp = tmp_max * 2
                tmp += abs(tmp_min)
            #-に先に行く場合
            else:
                tmp = abs(tmp_min) * 2
                tmp += tmp_max
        #すべてマイナスの場合
        else:
            tmp = abs(tmp_min)
    else:
        tmp = tmp_max
    ans = min(ans, tmp)
print(ans)





Measured memory_bytes: 14532
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int K  =scn.nextInt();
		int X = scn.nextInt();
		for(int i = X-K+1;i < X+K;i++) {
			System.out.print(i + " ");
		}
	}

}

Measured memory_bytes: 21844
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ParsaAlizadeh
 */

#include <bits/stdc++.h>
using namespace std;

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

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0;
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'
#define file_io         freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll MAXN  = 2e3 + 10;
const ll MAXA  = 1e5 + 10;
const ll INF   = 8e18;
const ll MOD   = 1e9 + 7; // 998244353;

ll n, m, a[MAXN], b[MAXN], dp[MAXN][MAXN];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n >> m;
    for (ll i = 1; i <= n; i++) {
       cin >> a[i];
    }
    for (ll i = 1; i <= m; i++) {
        cin >> b[i];
    }
    fill(dp[0], dp[0] + MAXN, 1);
    for (ll i = 1; i <= n; i++) {
        dp[i][0] = 1;
        for (ll j = 1; j <= m; j++) {
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            if (a[i] != b[j])
                dp[i][j] = (dp[i][j] - dp[i - 1][j - 1] + MOD) % MOD;
        }
    }
    cout << dp[n][m] << endl;

    return 0;
}



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int F(int x) {
  if (x == 0) return 0;
  int p = __builtin_popcount(x);
  int r = x % p;
  if (r == 0) return 1;
  return 1 + F(r);
}

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  int bit_count = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      bit_count++;
    }
  }

  int m1 = bit_count - 1;
  int m2 = bit_count + 1;
  int r1 = 0;
  int r2 = 0;
  vector<int> x1s(n);
  vector<int> x2s(n);
  if (m1 >= 2) {
    x1s[n - 1] = 1;
    for (int i = n - 2; i >= 0; i--) {
      x1s[i] = x1s[i + 1] * 2;
      x1s[i] %= m1;
    }
  }
  if (m2 >= 2) {
    x2s[n - 1] = 1;
    for (int i = n - 2; i >= 0; i--) {
      x2s[i] = x2s[i + 1] * 2;
      x2s[i] %= m2;
    }
  }

  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      if (m1 >= 2) {
        r1 += x1s[i];
        r1 %= m1;
      }
      if (m2 >= 2) {
        r2 += x2s[i];
        r2 %= m2;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      // Use m2.
      // m2 >= 1
      int r = r2 + x2s[i];
      r %= m2;
      cout << 1 + F(r) << endl;
    } else {
      // Use m1
      if (m1 == 0) {
        cout << 0 << endl;
      } else {
        int r = r1 + m1 - x1s[i];
        r %= m1;
        cout << 1 + F(r) << endl;
      }
    }
  }
}

Measured memory_bytes: 5192
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)

x4 = x3 - (x2 - x1)
y4 = y3 - (y2 - y1)

print(x3, y3, x4, y4)

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;


int main() {
    int n;
    cin >> n;
    if (n < 1200) {
        cout << "ABC" << endl;
    } else if (n < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N, K;
string S;

signed main()
{
  cin >> N >> K;
  cin >> S;

  S[K-1] = S[K-1] - 'A' + 'a';

  cout << S << endl;

  return 0;
}

Measured memory_bytes: 256
#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  out << "{" << p.first << "," << p.second << "}";
  return out;
}
void solve() {

}

static const int NMAX = 100000;
int A[NMAX], n;

int partition(int a[], int p, int r) {
  int x = a[r];
  //[p, i] <= x
  //[i+1, j] > x
  int i = p - 1;
  for (int j = p; j < r; ++j) {
    if (a[j] <= x) {
      i++;
      swap(a[i], a[j]);
    }
  }
  //a[i] <= a[r] < a[i+1]
  //a[i]はx=a[r]以下のグループの末尾
  //a[i+1]はx=a[r]より大きいグループの先頭
  swap(a[i + 1], a[r]);
  return i + 1;
}

int main() {
  scanf("%d", &n);
  rep(i,0,n)
  {
    scanf("%d", &A[i]);
  }
  int pivot = partition(A, 0, n - 1);
  rep(i,0,n)
  {
    if (i > 0) {
      printf(" ");
    }
    if (i == pivot) {
      printf("[%d]", A[i]);
    } else {
      printf("%d", A[i]);
    }
  }
  printf("\n");
  return 0;
}



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

using namespace std;

char str[200001];
bool check(int x, int y) {
	for (int i = x; i <= y; i ++)
		if (str[i] != str[y - i + x]) return false;
	return true;
}
int main( ) {
	scanf("%s", str + 1);
	int n = (int )strlen(str + 1);
	int tmp = (check(1, n) & check(1, (n - 1) / 2) & check((n + 3) / 2, n));
	printf(tmp ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

int main()
{
    int n, q;
    string s, s_r;

    cin >> n >> q;
    cin >> s;
    s_r = s;
    reverse(s_r.begin(), s_r.end());
    vector<int> l(q), r(q);

    rep(i,q) {
        cin >> l[i] >> r[i];
        l[i]--; r[i]--;
    }
    vector<int> dp_sl(n+2,0);
    vector<int> dp_sr(n+2,0);
    
    for(int i = 1; i < n; i++) {
        if(s.substr(i-1,2) == "AC")   { dp_sl[i] = dp_sl[i-1]+1; }
        else                          { dp_sl[i] = dp_sl[i-1];   }
        if(s_r.substr(i-1,2) == "CA") { dp_sr[i] = dp_sr[i-1]+1; }
        else                          { dp_sr[i] = dp_sr[i-1];   }
    }
    rep(i,q) { 
        int a = max(dp_sl[l[i]], dp_sl[l[i]-1]); 
        int b = max(dp_sr[n-r[i]-1], dp_sr[n-r[i]-2]); 
        cout << dp_sl[n-1] - (a+b) << endl; 
    }

    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        int a[3] = {p[i-1], p[i], p[i + 1]};
        sort(a, a + 3);
        ans += (a[1] == p[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N;
		String S;
		N = stdIn.nextInt();
		S = stdIn.next();
		if(N == 1 || N % 2 == 1) {
			System.out.println("No");
			return;	
		}
		for(int i = 0; i < N / 2; i++) {
			if(S.charAt(i) != S.charAt(i + (N / 2))) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 23124
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
int n;
int mx,sum;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	int x;
	for(int i=0;i<n;i++){
		cin>>x;
		mx=max(mx,x);
		sum+=x;
	}
	cout<<sum-mx/2;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
a = int(input())
s = list(map(int, input().split(" ")))
t = sorted(s)
ans = 'NO'
all = 0
c = 0

sn = 0
sv = 0
snn = 0

for i in range(a):
    if i == 0:
        continue
    elif s[i] < s[i-1] and c == 0:
        sn = i-1
        sv = s[i-1]
        c = 1
    elif s[i] < s[i-1] and c == 1:
        snn = s[i]
        s[i] = sv
        s[sn] = snn 
        break

for i in range(a):
    if s[i] == t[i]:
        continue
    else:
        all = 1
        break

if all == 0 :
    ans = 'YES'

print(ans)

Measured memory_bytes: 38860
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import string
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())

a = math.factorial(N) % (10 ** 9 + 7)
print(a)
# print(pow(2, N , 10 ** 9 + 7))


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

void solve() {
    string X, Y;
    cin >> X >> Y;
    vector<vector<int>> dp(X.size() + 1, vector<int>(Y.size() + 1));
    for (int i = 0; i < X.size(); ++i) {
        for(int j = 0; j < Y.size(); ++j) {
            if (X[i] == Y[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }
    cout << dp[X.size()][Y.size()] << endl;
}

int main() {
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        solve();
    }
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
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(void) {
    llint n;
    cin >> n;

    string s;
    char c;
    while(n) {
        n--;
        c = static_cast<int>(n%26LL) + 'a';
        s.push_back(c);
        n /= 26LL;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3624
X, N = map(int, input().split())
p = list(map(int, input().split()))
if X not in p:
    print(X)
    exit()
judge = [False] * 102
for pi in p:
    judge[pi] = True
now = 1
Flag = False
while not Flag:
    if not judge[X - now]:
        print(X - now)
        Flag = True
    elif not judge[X + now]:
        print(X + now)
        Flag = True
    else:
        now += 1


Measured memory_bytes: 61740
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
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; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll N, M; cin>>N>>M;
    vector<P> A(N);
    REP(i, N) {
        ll a, b; cin >> a>> b;
        A[i] = P(b, a);
    }
    sort(ALL(A), [&](P x, P y){return x.second<y.second;});

    int idx = 0;
    ll res = 0;
    priority_queue<P> pq;
    for(int i=M-1; i>=0; i--){
        while(idx<N and i+A[idx].second<=M){
            pq.push(A[idx]);
            idx++;
        }
        if(pq.empty()) continue;
        P p = pq.top(); pq.pop();
        while(!pq.empty() and i+p.second>M){
            p = pq.top();
            pq.pop();
        }
        if(i+p.second<=M){
            res += p.first;
        }        
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3956
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var q = int.Parse(line[1]);
            if (n == 0 && q == 0) break;
            var a = new int[101];
            var max = 0; var maxi = 0;
            for (int i = 0; i < n; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                var m = int.Parse(line[0]);
                for (int j = 0; j < m; j++)
                {
                    var w = int.Parse(line[j + 1]);
                    a[w]++;
                    if (a[w] == max && w < maxi) maxi = w;
                    else if (a[w] > max) { max = a[w]; maxi = w; }
                }
            }
            Console.WriteLine(max >= q ? maxi : 0);
        }
    }
}




Measured memory_bytes: 17988
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include<bits/stdc++.h>
#define 	ll		    long long
#define 	rep(i,a,n)  for(int i=a;i<n;i++)
#define 	MOD 		1000000007
#define 	vp 			vector<pair<int,int> >
#define 	ff 			first
#define 	ss 			second
#define 	pb 			push_back
#define 	all(x) 		(x).begin(),(x).end()
#define 	dg(x)		cerr<<"--- x = "<<x<<"\n"
#define 	endl		"\n"


using namespace std;
const int N = 2e5  + 5;
ll ar[N];
ll cfreq[N];

ll mod_expo(ll a, ll b){
	
	ll ans = 1;
	while(b){
		if(b & 1)
			ans = ans * a % MOD;
		b = b >> 1;
		a = a * a % MOD;
	}
	return ans ;
}

void solve(){
	int n; cin >> n;
	
	int ans = 0;
	cfreq[n + 1] = 0;
	
	rep(i ,1 ,n + 1)
		cin >> ar[i];
	
	for(int i = n; i >= 1; i--)
		cfreq[i] = (cfreq[i + 1] + ar[i]) % MOD;
	
	rep(i, 1, n)
		ans = (ans + (cfreq[i + 1] * ar[i]) % MOD)  % MOD;	
	
	cout << ans << endl;
	
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 6720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <complex>
using namespace std;
int main() {
  long long x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  long long ll = min(k, x/d);
  k -= ll;
  x -= ll*d;
  if (k%2) {
    x = d-x;
  }
  cout << x << endl;
}

Measured memory_bytes: 3196
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		long n = sc.nextLong();
		long m = sc.nextLong();
		long ans = (1900 * m + 100 * (n - m)) * power(2, m);
		System.out.println(ans);
	}
	
	static long power(long a, long x) {
		long res = 1;
		for(; x > 0; --x) res *= a;
		return res;
	}
}

Measured memory_bytes: 22996
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;


void solve() {
	priority_queue<int> q;
	int n, m; cin >> n >> m;
	rep(i, n) {
		int a; cin >> a; q.push(a);
	}
	rep(i, m) {
		int x = q.top(); q.pop();
		q.push(x / 2);
	}
	ll sum = 0;
	while (!q.empty()) {
		sum += q.top(); q.pop();
	}
	cout << sum << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 892
#include<stdio.h>

unsigned short s_scan_sentence(unsigned char * str, unsigned short length_max);
unsigned short s_sarch_text(unsigned char * ring, unsigned short r_length, unsigned char * look, unsigned short l_length);

int main(){
	unsigned char ring_text[101];
	unsigned char look_text[101];
	unsigned short ring_length;
	unsigned short look_length;
	unsigned short frg = 0;
	unsigned short i;
	
	for(i = 0;i < 100;i++){
		ring_text[i] = 0;
		look_text[i] = 0;
	}
	
	ring_length = s_scan_sentence(ring_text, 101);
	look_length = s_scan_sentence(look_text, 101);
	
	frg = s_sarch_text(ring_text, ring_length, look_text, look_length);
	
	if(frg == 0){
		printf("No\n");
	}
	else if(frg == 1){
		printf("Yes\n");
	}
	
	return 0;
}


/* 関数名：文字列入力 */
/* 概要：文字列を入力する。その長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short s_scan_sentence(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = 0;  	/* 文字列長カウンタ */
	unsigned short usW_C_i;                         	/* ループ変数 */

	/* 文字列の入力 */
	for(usW_C_i = 0;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i);
		/* 入力終了の処理 */
		if(*(str + usW_C_i) == '\n'){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}

	/* 文字列長を返す */
	return usW_C_count_text;
}

unsigned short s_sarch_text(unsigned char * ring, unsigned short r_length, unsigned char * look, unsigned short l_length)
{
	unsigned char twi_ring[100 * 2];
	unsigned short frg = 0;
	unsigned short i, j;
	
	for(i = 0;i < 200;i++){
		twi_ring[i] = 0;
	}
	
	for(i = 0;i < r_length;i++){
		twi_ring[i] = *(ring + i);
	}
	for(i = 0;i < l_length;i++){
		twi_ring[r_length + i] = *(ring + i);
	}
	
	for(i = 0;i <= r_length;i++){
		for(j = 0;j <= l_length;j++){
			if(*(look + j) == '\n'){
				frg = 1;
			}
			if(twi_ring[i + j] != *(look + j)){
				break;
			}
		}
	}
	
	return frg;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> p(n), q(n), searchv(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  iota(ALL(searchv), 1);
  int num = 0, nump, numq;
  do {
    num++;
    if (searchv == p) nump = num;
    if (searchv == q) numq = num;
  } while (next_permutation(ALL(searchv)));
  cout << abs(nump - numq) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;



int main(void) {
  double N, M, d;
  cin >> N >> M >> d;
  double ans;
  if(d)
    ans=2*(N-d)/N/N*(M-1);
  else
    ans=1/N*(M-1);
  
  printf("%.9f\n", ans);
}





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void)
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n, m, t[110], p[110], x[110], sum = 0;
    cin >> n;
    rep(i,n){
        cin >> t[i];
        sum += t[i];
    }
    cin >> m;
    rep(i,m){
        cin >> p[i] >> x[i];
    }
    rep(i,m){
        cout << sum + x[i] - t[p[i] - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//g++でビルド

#include "bits/stdc++.h"

using namespace std;
const int inf = 1000000000;

int abs(int a){
    if(a < 0) return -a;
    return a;
}

//int max(int a, int b){
  //  if(a > b) return a;
    //else return b;
//}

int main(){
    int n ,k;
    cin >> n >> k;
    int stages[n];
    int dp[n];
    for(int i = 0; i<n; i++){
        cin >> stages[i];
        dp[i] = inf;
    }
    
    for(int i = 0; i < n; i++){
        if(i == 0){
            dp[i] = 0;
        }else{
            int tempmin = inf;
            for(int j = i-1; j >= max(i-k, 0); j--){
                int now = dp[j] + abs(stages[j] - stages[i]);
                if(now < tempmin) tempmin = now;
            }
            dp[i] = tempmin;
        }
    }

    

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
abc = list(map(int, input().split(' ')))
count = 0

while(True):
    abc = sorted(abc, reverse=True)

    if abc[0] == abc[1] == abc[2]:
        break
    elif abc[1] == abc[2]:
        abc[1] += 1
        abc[2] += 1
    else:
        abc[2] += 2
    count += 1
print(count)



Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    if(n % 2 == 1){
      System.out.println( n / 2 + 1);
    }else{
      System.out.println( n / 2);
    }
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<utility>
#include<iterator>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
#define cY cout<<"YES\n"
#define cN cout<<"NO\n"
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define sc second
#define fs first
#define c(a) cout<<a<<endl

void solve()
{
	ll x, y; cin>>x>>y;
	for(ll i=0;i<=x;i++)
	{
		if(i*2+(x-i)*4==y)
		{
			cy; return;
		} 
	} 
	cn;
}

int main()
{
	solve();
}
/*




*/


Measured memory_bytes: 3628
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n) cin >> p[i];

    int cnt = 0;
    REP(i, n-1){
        if(p[i] == i+1){
            swap(p[i], p[i+1]);
            cnt++;
        }
    }
    if(p[n-1] == n) cnt++;
    cout << cnt << endl;
}


Measured memory_bytes: 640
//created by krishna
#include <bits/stdc++.h>
using namespace std;
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull;
#define debug(x) cout<<"the value of "<<#x<<" is "<<x<<endl;
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    vector<int>arr(5);
    for(auto& i:arr)
        cin>>i;
    for(int i=0;i<5;i++)
        if(arr[i]==0){
            cout<<i+1<<endl;
            break;
        }

}

Measured memory_bytes: 3580
n = int(input())
A = [*map(int, input().split())]
q = int(input())
BC = [[*map(int, input().split())] for _ in range(q)]

# print(n,q)
# print(A)
# print(BC)
C = {}
for a in A:
    if a in C:
        C[a]+=1
    else:
        C[a]=1

s = sum(A)
# print(a)
for b,c in BC:
    # print(b,c)
    d = c-b
    if not b in C:
        C[b] = 0
    s += d*C[b]
    if not c in C:
        C[c] = 0
    C[c] += C[b]
    C[b] = 0
    print(s)


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


void solve(std::string S){
    int n=S.length();
    int ans=0;
    for(int i=0;i<n/2;i++) if(S[i]!=S[n-1-i]) ++ans;
    cout<<ans<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>


int main(){
    int n;
    std::string s;
    std::cin >> n >> s;
    if(n%2){
        std::cout << "No";
        return 0;
    }
    for (int i = 0; i < n/2; ++i) {
        if(s[i]!=s[i+n/2]){
            std::cout << "No";
            return 0;
        }
    }
    std::cout << "Yes";
}

Measured memory_bytes: 256
w, h, n = map(int, input().split(" "))
xyas = [map(int, input().split(" ")) for i in range(n)]

X = 0
X1 = w
Y = 0
Y1 = h
for x, y, a in xyas:
    if a == 1:
        X = max(X, x)
        X1 = max(X1, x)
    elif a == 2:
        X = min(X, x)
        X1 = min(X1, x)
    elif a == 3:
        Y = max(Y, y)
        Y1 = max(Y1, y)
    else:
        Y = min(Y, y)
        Y1 = min(Y1, y)

print(abs(X - X1) * abs(Y - Y1))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main (void){

    int a ,b;

    cin >> a >> b;

    if(0 <= a && a <= 5)
    cout << "0" << endl;

    else if(6 <= a && a <= 12){
    b /= 2;
    cout << b << endl;
    }

    else
    cout << b << endl;




    return 0;
}

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

typedef long long ll;

int a;
string s;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> s;
    if (a < 3200)
        cout << "red" << endl;
    else
        cout << s << endl;

    return 0;
}



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

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> d(N);
    for(int i=0; i<N; ++i){
        cin>>d[i];
    }
    sort(d.begin(), d.end());
    cout<<d[d.size()/2] - d[d.size()/2-1]<<endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int n,a,c,j;
	int b[105];
	int s[505];
	int i=0;
	while(cin>>n && n){
		n++;
		for(j=0;j<n;j++){
			cin>>b[j];
		}
		c=b[1]-b[0];
		for(j=1;j<n-1;j++){
			if(c!=b[j+1]-b[j]){
				if(j==1){
					c=b[4]-b[3];
					a=b[1]-b[0];
					if(c!=a){
						if(c==b[2]-b[0]){
							j=0;
						}else{
							j=-1;
						}
					}
				}
				if(j==2){
					if(b[2]-b[0]==b[4]-b[3]){
						j=0;
					}
				}
				j++;
				break;
			}
		}
		s[i]=b[j];
		i++;
	}
	for(j=0;j<i;j++){
		cout<<s[j]<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 1164
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;

queue<int> Q;
vector<int> v[111111];
int visit[111111], what[111111];

int main(void)
{
	int n, m, i;

	scanf("%d %d", &n, &m);
	while (m--)
	{
		int a, b;

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

		v[a].push_back(b);
		v[b].push_back(a);
	}

	Q.push(1);
	visit[1] = 1;

	while (!Q.empty())
	{
		int t = Q.front(); Q.pop();

		for (i = 0; i < v[t].size(); i++)
		{
			int next = v[t][i];

			if (!visit[next])
			{
				visit[next] = 1;
				Q.push(next);
				what[next] = t;
			}
		}
	}

	for (i = 1; i <= n; i++)
		if (!visit[i])
		{
			puts("No");
			return 0;
		}

	puts("Yes");
	for (i = 2; i <= n; i++)
		printf("%d\n", what[i]);
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> d(N);
	for(auto &i:d)cin >> i;
	sort(d.begin(),d.end());
	cout << d[N/2]-d[N/2-1] << endl;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))
ans = 0

for i in range(n - 1):
    if a_list[i + 1] - a_list[i] == 1:
        ans += c_list[a_list[i] - 1]

for i in range(n):
    ans += b_list[i]

print(ans)

Measured memory_bytes: 3064
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

int s[4];
pair<double,bool> a[4];
int n;
ll ans;

int main(){
	rep(i,4)scanf("%d",&s[i]);
	scanf("%d",&n);
	a[0].fi=(double)s[0]*(double)4;
	a[1].fi=(double)s[1]*(double)2;
	a[2].fi=(double)s[2];
	a[3].fi=(double)s[3]/(double)2;
	a[3].se=true;
	sort(a,a+4);
	if(!a[0].se)printf("%lld\n",(ll)n*(ll)a[0].fi);
	else {
		ans+=(ll)n/2ll*(ll)(a[0].fi*(double)2);
		if(n%2==1)ans+=(ll)a[1].fi;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
C = {}
for _ in range(N):
    s = "".join(sorted(list(input())))
    if s not in C:
        C[s]=0
    C[s] += 1
cnt = 0
for s in C:
    if C[s]>1:
        cnt += (C[s]*(C[s]-1))//2
print(cnt)

Measured memory_bytes: 62168
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <map>

template <typename T>
void read(T& x)
{
    x = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar());
    for (; isdigit(c); x = x * 10 + (c ^ 48), c = getchar());
}

unsigned long long get2(std::string s)
{
    while (s[0] == '0')
        s = s.substr(1, s.length() - 1);
    unsigned long long x = s[0] - '0', ans = 0;
    if (x == 0)
        return 0;
    if (s.length() >= 2)
        ans += 1ull * (x - 1ull) * (s.length() - 1ull) * 9ull;
    if (s.length() >= 3)
        ans += 1ull * (s.length() - 1ull) * (s.length() - 2ull) / 2ull * 81ull;
    if (s.length() >= 2)
    {
        for (int i = 1; i < s.length(); ++i)
        {
            if (s[i] == '0')
            {
                continue;
            }
            else
            {
                ans += s[i] - '0';
                ans += (s.length() - (i + 1ull)) * 9ull;
                break;
            }
        }
    }
    return ans;
}

std::string s;
int k;

int main()
{
    std::ios::sync_with_stdio(0);
    std::cin >> s >> k;
    if (k == 1)
    {
        int x = s[0] - '0';
        std::cout << x + (s.length() - 1) * 9 << std::endl;
    }
    else if (k == 2)
    {

        std::cout << get2(s) << std::endl;
    }
    else
    {
        unsigned long long x = s[0] - '0';
        if (s.length() <= 2)
        {
            std::cout << 0 << std::endl;
            return 0;
        }
        unsigned long long ans = 0;
        ans += 1ull * (x - 1ull) * (s.length() - 1ull) * (s.length() - 2ull) / 2ull * 81ull;
        if (s.length() >= 4)
            ans += 1ull * (s.length() - 1ull) * (s.length() - 2ull) * (s.length() - 3ull) / 2ull * 243ull;
        ans += get2(s.substr(1, s.length() - 1));
        std::cout << ans << std::endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <float.h>
#include <cfloat>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <errno.h>
#include <cerrno>
#include <assert.h>
#include <cassert> 
#include <map>
#include <memory.h>
#include <cctype>
#include <ctype.h>
#include <math.h>
#include <vector> 
#include <cstdio> 
#include <set>
#include <string.h>
#include <stdio.h>
#include <new>
#include <memory>
#include <cmath>
#include <queue>
#include <cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define mp make_pair 
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define pii pair<int,int>  
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{int a,b;
 cin>>a>>b;
 if(a!=1)
 a--;
 else
 a+=12;
 if(b!=1)
 b--;
 else
 b+=12;
 if(a>b)
 cout<<"Alice"<<endl;
 else if(a==b)
 cout<<"Draw"<<endl;
 else cout<<"Bob"<<endl; 
 system("pause");
 return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    set<int> s;
    for(int i=0; i<=101; i++)
        s.insert(i);
    int x,n; cin>>x>>n;
    for(int i=1; i<=n; i++){
        int t; cin>>t;
        s.erase(t);
    }
    auto it=s.lower_bound(x);
    if(it==s.begin()){
        cout<<abs(*it-x);
    }
    else{
        int x2=abs(*it-x);
        it--;
        int x1=abs(*it-x);
        if(x1<=x2) cout<<*it;
        else{
            it++;
            cout<<*it;
        }
    }
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

#define FOR(a, b, c) for (int a = (b), _for = (c); a < _for; ++a)
#define REP(a, n) FOR(a, 0, n)
#define x first
#define y second
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;

char c[MAX];

int main(){
	int sol=0;
	scanf ("%s",c);
	int n=strlen(c);
	REP(i,n) if (c[i]!=c[n-1-i]) sol++;
	printf ("%d\n",sol/2);
	
	return 0;
}


Measured memory_bytes: 256