akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

class Solver {
public:
	static void solve() {
		int h, w;
		cin >> h >> w;
		vector<string> grid;
		for (int i = 0; i < h; i++) {
			string s;
			cin >> s;
			grid.emplace_back(s);
		}

		vector<bool> removableV(w, false);
		for (int i = 0; i < w; i++) {
			int cnt = 0;
			for (int j = 0; j < h; j++) {
				if (grid[j][i] == '.')cnt++;
			}
			if (cnt == h)removableV[i] = true;
		}
		vector<bool> removableH(h, false);
		for (int i = 0; i < h; i++) {
			int cnt = 0;
			for (int j = 0; j < w; j++) {
				if (grid[i][j] == '.')cnt++;
			}
			if (cnt == w)removableH[i] = true;
		}

		for (int i = 0; i < h; i++) {
			if (removableH[i])continue;
			for (int j = 0; j < w; j++) {
				if (removableV[j])continue;
				cout << grid[i][j];
			}
			cout << endl;
		}
	}
};

int main() {
	Solver::solve();
}

Measured memory_bytes: 256
from heapq import heappush, heappop
import sys
readline = sys.stdin.readline
write = sys.stdout.write

dd = ((-1, 0), (0, -1), (1, 0), (0, 1))

def solve():
    H, W, N = map(int, readline().split())
    if H == 0:
        return False
    S = readline().strip()
    C = [[0]*W for i in range(H)]
    sx = sy = gx = gy = 0
    for i in range(H):
        s = readline().strip()
        for j, c in enumerate(s):
            if c in '#.':
                C[i][j] = (c == '#')
            elif c == 'S':
                sx = j; sy = i
            else:
                gx = j; gy = i
    S0 = [1]*(N+1)
    cur = 1
    for i in range(N):
        if S[i] == 'L':
            cur = (cur - 1) % 4
        else:
            cur = (cur + 1) % 4
        S0[i+1] = cur
    d = [N+1]*4
    D = [None]*(N+1)
    for i in range(N, -1, -1):
        d[S0[i]] = i
        D[i] = d[:]

    T = [[N+1]*W for i in range(H)]
    T[sy][sx] = 0
    que = [(0, sx, sy)]
    while que:
        cost, x, y = heappop(que)
        if T[y][x] < cost:
            continue
        d = D[cost]
        for k in range(4):
            dx, dy = dd[k]; n_cost = d[k]
            nx = x + dx; ny = y + dy
            if not 0 <= nx < W or not 0 <= ny < H or C[ny][nx]:
                continue
            if n_cost < T[ny][nx]:
                T[ny][nx] = n_cost
                heappush(que, (n_cost, nx, ny))
    print("Yes" if T[gy][gx] < N+1 else "No")
    return True
while solve():
    ...


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

typedef long long int ll;
typedef pair<ll, ll> pii;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define sz(a) ll(a.size())
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front 
#define MAXN 100010
#define N 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define debug(x) cout << '>' << #x << ':' << x << " ";
#define nl '\n'
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define int long long int

vector<int> sieve(10*MAXN+1,0);
void solve(){
    fo(i,1,10*MAXN){
        sieve[i] = i;
    }
    for(int i = 2;i <= 10*MAXN; i++){
        if (sieve[i]!=i)
        {
            continue;
        }
        for(ll j = i*i;j<=10*MAXN;j+=i){
            sieve[j] = i;
        }
    }
}

main()
{
    IO;
    solve();
	int T = 1;
    // cin >> T;
    fo(c, 1, T){
        // cout<<"Case #"<<c<<": ";
        int n;
        cin >> n;
        vector<int> arr(n);
        int gcd = 0;
        for(int i = 0; i< n; i++){
            cin >> arr[i];
            gcd = __gcd(gcd, arr[i]);
        }
        if(gcd == 1){
            map<int, int> freq;
            bool ans = false;
            for(int i = 0; i < n; i++){
                map<int, int> temp;
                int x = arr[i];
                while(sieve[x] != x){
                    temp[sieve[x]]++;
                    if(freq[sieve[x]] >= 1){
                        // deb(0)
                        ans = true;
                    }
                    x /= sieve[x];
                }
                if(x > 1){
                    temp[x]++;
                    if(freq[x] >= 1){
                        // deb(1)
                        // deb(x)
                        ans = true;
                    }
                }

                x = arr[i];
                while(sieve[x] != x){
                    freq[sieve[x]]++;
                    x /= sieve[x];
                }
                if(x > 1){
                    freq[x]++;
                }
            }
            if(ans){
                cout << "setwise coprime" << nl;
            }
            else  {
                cout << "pairwise coprime" << nl;
            }
        }
        else {
            cout << "not coprime" << nl;
        }
    }
    return 0;
}

Measured memory_bytes: 23780
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#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) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }



const int MAX = 72;

int dx[2] = {1, 0};
int dy[2] = {0, 1};


int W, H;
char field[MAX][MAX];
string dp[MAX][MAX];
bool seen[MAX][MAX];


bool leftbig(string s, string t) {
    if (s.size() > t.size()) return true;
    else if (s.size() < t.size()) return false;
    else return (s > t);
}

string rec(int x, int y) {
    if (seen[x][y]) return dp[x][y];
    
    string pref; pref += field[x][y];
    
    string Max = pref;
    for (int i = 0; i < 2; ++i) {
        int nx = x + dx[i], ny = y + dy[i];
        if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
        if (field[nx][ny] >= 'A' && field[nx][ny] <= 'Z') continue;
        
        string temp = pref + rec(nx, ny);
        if (leftbig(temp, Max)) Max = temp;
    }
        
    //cout << x << ", " << y << " : " << Max << endl;
    
    seen[x][y] = true;
    return dp[x][y] = Max;
}

int main() {
    while (cin >> W >> H) {
        if (W == 0) break;
        
        memset(seen, 0, sizeof(seen));
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                cin >> field[i][j];
            }
        }
        
        string Max = "";
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (field[i][j] >= 'A' && field[i][j] <= 'Z') continue;
            
                string temp = rec(i, j);
                while (temp[0] == '0' && temp != "0") temp.erase(temp.begin());
                if (leftbig(temp, Max)) Max = temp;
            }
        }
        
        cout << Max << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
ll INF = 1e12;

int main() {
  int N;
  ll K;
  cin >> N >> K;
  VI A(N);
  VI F(N);
  rep(i, N) { cin >> A.at(i); }
  rep(i, N) { cin >> F.at(i); }
  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), greater<ll>());
  ll low = -1;
  ll high = INF;
  ll mid = (low + high) / 2;
  bool pos;
  while (low + 1 < high) {
    ll usek = 0;
    pos = true;
    rep(i, N) {
      if (mid > (ll)A.at(i) * F.at(i)) {
        continue;
      }
      usek += A.at(i) - mid / F.at(i);
      if (usek > K) {
        pos = false;
        break;
      }
    }
    if (pos) {
      high = mid;
    } else {
      low = mid;
    }
    mid = (low + high) / 2;
  }
  cout << high << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int a, b, c, d, X, Y;
  int D, G;
  //char s[101][101]={};
  char sv[101]={};
  char ss[101]={};
//  char s_temp[101]={};
  char t[101]={};
//  char s[10000000000000000001]={};
  char s[2][100001]={};
  int len=0;
  int N, M;
//  int A[1000000001]={};
  int A[100001]={};
//  long int A[1001]={};
  int B[20000]={};
  int C[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=0;
  int cnt=0;
  int ans=0;
  int max_o=0;
  int max2_o=0;
  int max_o_num=0;
  int max_e=0;
  int max2_e=0;
  int max_e_num=0;
//  int ans=0;
  int str_len=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  int ans_o[100001]={};
  int ans_e[100001]={};

  scanf("%d", &a);
  if(a==1){
   printf("Hello World\n");
 } else {
     scanf("%d %d", &a, &b);
   printf("%d\n", a+b);   
 }
  

   
//   printf("%d\n",a-b+1);
  
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const ll INF = (ll)5e15;

int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll n = s.length();
  if(s[0] == '1') {
    ll cnt = 0;
    ll i = 0;
    while(s[i] == '1' && i < n) {
      cnt++;
      i++;
    }
    if (cnt < k) cout << s[i] << endl;
    else cout << s[i-1] << endl;
  } else cout << s[0] << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  cout << ((g * 10 + b) % 4 == 0 ? "YES" : "NO") << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    
    std::string s[n];
    std::map<int,int> v;
    for(int i=0; i<n; i++){
        std::string tmp;
        cin >> tmp;
        int a = 0;
        if(tmp=="AC") a = 1;
        if(tmp=="WA") a = 2;
        if(tmp=="TLE") a = 3;
        if(tmp=="RE") a = 4;
        v[a]++;
    }
    
    cout << "AC x " << v[1] << endl;
    cout << "WA x " << v[2] << endl;
    cout << "TLE x " << v[3] << endl;
    cout << "RE x " << v[4] << endl;

    return 0;
}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf n,ans=1;
    cin >>n;
    while(1){
        if(n<ans*2){
            cout << ans <<endl;
            return 0;
        }
        ans *=2;
    }
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N;
    cin >> N;
    unordered_map<string, ll> M;
    rep(i, N){
        string S;
        cin >> S;
        sort(all(S));
        M[S]++;
    }

    ll sum = 0;
    for(auto i : M){
        sum += i.second * (i.second - 1) / 2;
    }

    cout << sum << endl;
}

Measured memory_bytes: 10660
#include "bits/stdc++.h"
using namespace std;

struct chara {
	string name;
	int vote;
};
int N, M, K, L;
bool check(const vector<chara>&mcs, const vector<chara>&ocs,int need) {
	if (need == K - ocs.size())return true;
	else {
		chara target = ocs[ocs.size()-1 - (K - need)];
		long long int use = 0;
		for (int i = mcs.size() - 1; i >= int(mcs.size()) - need; --i) {
			chara mc(mcs[i]);
			if (mc.name < target.name) {
				use += max(0, target.vote - mc.vote);
			}
			else {
				use += max(0, target.vote - mc.vote + 1);
			}
		}
		return use <= L;
	}
}

int main() {
	while (1) {
		cin >> N >> M >> K >> L;
		if (!N)break;
		vector<chara>mycharas;
		vector<chara>opcharas;
		{
			map<string, chara>mp;
			for (int i = 0; i < N; ++i) {
				string name; int vote; cin >> name >> vote;
				mp[name] = chara{ name,vote };
			}
			set<string>mynames;
			for (int i = 0; i < M; ++i) {
				string name; cin >> name;
				mynames.emplace(name);

			}
			for (auto m : mp) {
				if (mynames.find(m.first) == mynames.end()) {
					opcharas.push_back(m.second);
				}
				else {
					mycharas.push_back(m.second);
				}
			}
			sort(opcharas.begin(), opcharas.end(), [](const chara&l, const chara&r) {
				return l.vote == r.vote ? l.name > r.name : l.vote < r.vote;
			});
			sort(mycharas.begin(), mycharas.end(), [](const chara&l, const chara&r) {
				return l.vote == r.vote ? l.name > r.name : l.vote < r.vote;
			});
		}
		int amin = max(0,int(K-opcharas.size())), amax = min(int(mycharas.size()),K) + 1;
		while (amin + 1 != amax) {
			int amid = (amin + amax) / 2;
			if (check(mycharas, opcharas, amid)) {
				amin = amid;
			}
			else {
				amax = amid;
			}
		}
		cout << amin << endl;
		
	}
	return 0;
}

Measured memory_bytes: 25768
#include <iostream>
#include <vector>
#include <string>
#include <functional>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

int main(){
  long long W, H;
  long long x, y;
  cin >> W >> H >> x >> y;
  cout << setprecision(15) << W * (double)(H) / 2 << " ";
  if(x*2==W && y*2==H) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
	int n,x,max,contador;
	int popa=0, papu=0;
	multiset <int> cartas;
	cin>>n;
	for (int i=0;i<n;i++){
		cin >>x;
		cartas.insert(x);
		
	}
	for (int j=0; j<n; j++){
		max = -1;
		for (auto &it:cartas){
			if (it>max){
				max = it;
			}
		}
		if (j % 2==0){
			popa+=max;
		}
		else{
			papu+=max;
		}
		
		contador = cartas.count(max);
		if (contador > 1){
			cartas.erase(max);
			for (int i=0;i<contador-1;i++){
				cartas.insert(max);
			}
		}
		else{
			cartas.erase(max);
		}
		
	}
	
	cout << fabs(papu-popa);
		
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int x,y,x1,y1,sum;
	scanf("%d%d",&x,&y);
	if(x==y) {printf("0\n");return 0;}
	if(x!=0&&y!=0)
	{
		x1=abs(x);y1=abs(y);
		sum=abs(y1-x1);
		if((x<0&&y>0)||(x>0&&y<0)) sum++;
		if(x<0&&y<0&&x>y) sum+=2;
		if(x>0&&y>0&&x>y) sum+=2;
	}
	if(x==0)
	{
		if(y<0) sum=x-y+1;
		if(y>0) sum=y-x;
	}
	if(y==0)
	{
		if(x>0) sum=x-y+1;
		if(x<0) sum=y-x;
	}
	printf("%d\n",sum);
	return 0;
}

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

int gcd(int q,int w)
{
	return (q%w==0)?w:gcd(w,q%w);
} 

int n;
int a[100010];
int k;

int cmp(int q,int w)
{
	return q>w;
}

int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1,cmp);
	if (a[1]<k) return 0*puts("IMPOSSIBLE");
	
	int e=a[1];
	for (int i=2;i<=n;i++) e=gcd(e,a[i]);
	if (k%e==0) return 0*puts("POSSIBLE");
	return 0*puts("IMPOSSIBLE");
}

Measured memory_bytes: 640
// Problem : A - Don't be late
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O2")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int main()
{
	fast;
	ll t = 1;
	// cin >> t;
	while (t--)
	{
		ll d,t,s;
		cin>>d>>t>>s;
		double tt = (double)d/ s;
		if(tt <= t)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 3648
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);
$l = [$a, $b, $c];
$s = [5=>0,7=>0];
foreach ($l as $v) {
    if (in_array($v, [5, 7])) {
        $s[$v]++;
    } else {
        echo "NO";
        exit;
    }
}
if ($s[5] == 2 && $s[7] == 1) {
    echo "YES";
} else {
    echo "NO";
}


Measured memory_bytes: 4212
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main(){
  int a,b; cin>>a>>b;
  if(a<=8&&b<=8) cout<<"Yay!"<<endl;
  else cout<< " :( " <<endl;
  return 0;
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
   ll a,b,i;
   cin>>a>>b;
   if(b==1)
   {
       cout<<0;
       return 0;
   }
   for(i=1;i<=20;i++)
   {
       ll val=i*a-(i-1);
       if(val>=b)
       {
           cout<<i;
           return 0;
       }
   }
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };



int main() {
	int n;
	cin >> n;
	n++;
	llint sum = 0;
	hei(llint) a(n), b(n - 1);
	rep(i, 0, n) {
		cin >> a[i];
		sum += a[i];
	}
	rep(j, 0, n - 1)cin >> b[j];
	rep(i, 0, n-1) {
		if (a[i] >= b[i])a[i] -= b[i];
		else {
			llint s = b[i] - a[i];
			a[i] = 0;
			a[i + 1] -= s;
			if (a[i + 1] < 0)a[i + 1] = 0;
		}
	}
	llint ans = 0;
	rep(i, 0, n)ans += a[i];
	cout << sum-ans << endl;
	return 0;
}

Measured memory_bytes: 1792
cx1, cy1, r1 = map(float, input().split())
cx2, cy2, r2 = map(float, input().split())

import math
distance = math.sqrt( math.pow(cx1-cx2, 2) + math.pow(cy1-cy2, 2) )
rsum = r1 + r2
rmax = max(r1, r2)
rmin = min(r1, r2)

import sys
if distance > rsum:
  print(4)
elif abs(distance - rsum) < sys.float_info.epsilon:
  print(3)
else:
  if rmax < distance + rmin:
    print(2)
  elif abs(rmax - distance - rmin) < sys.float_info.epsilon:
    print(1)
  else:
    print(0)


Measured memory_bytes: 5648
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int arr[200005];
int cur[200005];

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n; cin>>n;
    for(int i=0; i<n; i++){
        int a; cin>>a;
        cur[i]=a;
        arr[a]++;
    }
    int ans = 0;
    For(i, 1, n+1){
        ans += (arr[i]*(arr[i]-1))/2;
    }
    For(i, 0, n){
        int v = arr[cur[i]];
        int vv = ((v*(v-1))/2)-(((v-2)*(v-1))/2);
        cout<<ans-vv<<"\n";
    }
    return 0;
}





Measured memory_bytes: 4736
import sys

line = raw_input()
word_list = line.translate(None, '.,').split()
ans = []
for word in word_list:
    if len(word) >= 3 and len(word) <= 6:
        ans.append(word)

for i, w in enumerate(ans):
    if i != 0:
        sys.stdout.write(" ")
    sys.stdout.write(w)
sys.stdout.write("\n")

Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
template<typename ...Args> void read(Args&... args) { (cin >> ... >> args); }
template <typename...Args> void writeln(const Args &... args) { ((cout << args << " "), ...), cout << "\n"; }
template <typename...Args> void write(const Args &... args) { ((cout << args), ...), cout << "\n"; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> typename enable_if<is_same<decltype(declval<T>().size()), size_t>::value, int>::type operator~(const T& ct) { return (int)ct.size(); }
template <typename T, typename... Args> bool ckmax(T &a, const Args&... b) { return (a < max({b...})) ? (a = max({b...}), true) : false; }
template <typename T, typename... Args> bool ckmin(T &a, const Args&... b) { return (a > min({b...})) ? (a = min({b...}), true) : false; }
template <typename T> struct range {
    T u, v; bool inclusive;
    range(const T& _u, const T& _v, const bool& _inclusive = false) : u(_u), v(_v), inclusive(_inclusive) {}
    bool has(const T& w) { return (u <= w) and (inclusive ? (w <= v) : (w < v)); }
};
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vpii = vector<pii>;
using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
template<typename T> using vv = vector<vector<T>>;
const int N = 200'010;
auto soln() {
    long long n, a, b, c, d; read(n, a, b, c, d);;
    map<ll, ll> dp;
    vpll ks = {{2ll, a}, {3ll, b}, {5ll, c}};
    const ll inf = 1e18;
    function<ll(ll i)> comp = [&](ll i)->ll {
        if(!(i)) return 0;
        if (i == 1)
            return d;
        else if (dp.find(i) != dp.end())
            return dp[i];
        else {
            dp[i] = (i < inf / d) ? i * d : inf;
            for (auto [k, v] : ks) {
                ll lo = (i / k), hi = (i / k) + !!(i % k);
                ll clo = d * (i - k * lo) + v, chi = d * (k * hi - i) + v;
                ckmin(dp[i], clo + comp(lo), chi + comp(hi));
            }
            return dp[i];
        }
    };
    cout << comp(n) << "\n";
}
signed main() {
    int t = 1;
    { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); }
    cin >> t;
    while (t--)
        soln();
    return 0;
}


Measured memory_bytes: 4476
n, max_w = map(int, input().split())

w = []
v = []
for i in range(n):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)

dp = [[0 for _ in range(max_w+1)] for _ in range(n+2)]

for i in range(1, n+1):
    for j in range(max_w+1):
        dp[i][j] = max(dp[i][j], dp[i-1][j])
        if j >= w[i-1]:
            dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]]+v[i-1])

print(max(dp[n]))

Measured memory_bytes: 171832
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll k,a,b;
  cin >> k >> a >> b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout <<"OK\n";
      return 0;
    }
  }
  cout <<"NG\n";
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
constexpr long long int MOD = 1000000007LL;

long long int power(long long int base, int exp) {
	switch (exp) {
	case 0: return 1LL;
	case 1: return base % MOD;
	default: return power(base * base % MOD, exp / 2) * power(base, exp % 2) % MOD;
	}
}
int main() {
	int n; std::cin >> n;
	std::vector<int> numbers(n); for (auto& a : numbers) std::cin >> a;
	std::vector<long long int> factorial(n + 1, 1LL), inverse(n + 1, 1LL);
	for (auto i = 2; i <= n; ++i) {
		factorial[i] = i * factorial[i - 1] % MOD;
		inverse[i] = (MOD - MOD / i) * inverse[MOD % i] % MOD;
	}
	std::vector<long long int> sum = inverse;
	for (auto i = 2; i < sum.size(); ++i) sum[i] = (sum[i] + sum[i - 1]) % MOD;
	long long int result = 0;
	for (auto i = 0; i < n; ++i) {
		result += (numbers[i] * (sum[i + 1] + sum[n - i] - 1)) % MOD;
		result %= MOD;
	}
	result *= factorial[n];
	std::cout << result % MOD << '\n';
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>8||b>8)
	{
		printf(":("); 
	}
	else
	{
		printf("Yay!");
	}
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    N = int(input())
    A = [int(input()) for _ in range(N)]

    sorted_A = sorted(A)

    max_A = sorted_A[-1::][0]
    next_max_A = sorted_A[-2:-1:][0]

    for i in range(N):
        if A[i] == max_A:
            print(next_max_A)
        else:
            print(max_A)

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans=0;
    for(int i = 0;i < s.size();i ++){
        if(s[i]=='2') ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
n,m,c = map(int, input().split())

B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(n)]

cnt = 0

for i in range(n):
    if sum([A[i][j]*B[j] for j in range(m)]) > -c:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define maxn 100001
#define maxa 2000005
#define MOD  998244353 //1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define mem(a, b) memset(a, b, sizeof(a))
#define sort(v) sort(v.begin(), v.end())
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout << setprecision(10) << fixed;
}
ll ceil(ll a, ll b){ return (a+ b-1)/b; }
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
// power and modulo inverse
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}
// factorial
ll fact[maxa], finv[maxa];
void calf(){
    fact[0] = finv[0] = 1;
    for(ll i = 1; i < maxa; i++){fact[i] = (fact[i-1]*i) %MOD;finv[i] = (finv[i-1]*power(i))%MOD;}
}
// nCr
ll ncr(ll N, ll R){ if(R > N) return 0; return (fact[N]*((finv[R]*finv[N-R])%MOD))%MOD;}

void solve(){
    ll n;
    cin >> n;
    vector<pii> v, vec;
    rep(i, n)
    {
        ll x, y; cin >> x >> y; v.pb({x, y});
    }
    sort(v);
    ll dp[n+1];
    mem(dp, 0);
    dp[n] = 1;
    vec.pb({n, INF});
    repr(i, n)
    {
        while(!vec.empty() && vec.back().sd < v[i].ft + v[i].sd){
            vec.pop_back();
        }
        ll p = vec.back().ft;
        dp[i] = dp[p];
        vec.pb({i, v[i].ft});
        dp[i] = (dp[i] + dp[i+1])%MOD;
    }
    cout << dp[0];
}

int main()
{
    fast();
    ll t = 1;//cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 8556
#include <cstdio>
#include <algorithm>
using namespace std;

int N;
int W;
int ans;
int v[100];
int w[100];
int dp[101][10001];

int main() {
    scanf("%d%d", &N, &W);
    for (int i=0; i<N; i++) {
        scanf("%d%d", &v[i], &w[i]);
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<=W; j++) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
            
        for (int j=0; j<=W; j++) {
            if (j + w[i] <= W) {
                dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j]+v[i]);
            }
        }
    }

    for (int i=0; i<=W; i++) {
        ans = max(ans, dp[N][i]);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 4936
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = ni();

		int count = 0;

		for (int i = 1; i <= n; i++) {
			if (ketasuu(i) % 2 == 1) {
				count++;
			}
		}

		out(count);

	}

	/*
	 * 以下メソッド集
	 */

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + 2))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


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


void main_(istream &cin) {
    ll R;
    cin >> R;
    solve(R);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        System.out.println(n*a < b ? n*a : b);
    }
}


Measured memory_bytes: 35780
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int gusu = 0, kisu = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x % 2 == 0)
      gusu++;
    else
      kisu++;
  }
  if (kisu % 2 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
def solve():
    S = input()
    N = len(S)
    Srev = []
    for i in reversed(range(N)): Srev.append(S[i])
    Srev = "".join(Srev)
    ti = 0
    while ti < N:
        if Srev[ti] == "m":
            if Srev[ti:min(N, ti + 5)] == "maerd": ti += 5
            else:
                print("NO")
                break
        elif Srev[ti] == "e":
            if Srev[ti:min(N, ti + 5)] == "esare": ti += 5
            else:
                print("NO")
                break
        elif Srev[ti] == "r":
            if Srev[ti:min(N, ti + 6)] == "resare": ti += 6
            elif Srev[ti:min(N, ti + 7)] == "remaerd": ti += 7
            else:
                print("NO")
                break
        else:
            print("NO")
            break
    else: print("YES")


    return 0

if __name__ == "__main__":
    solve()

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

int main(){
	int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int dp[n];
  dp[n-1]=0;
  dp[n-2]=abs(a[n-1]-a[n-2]);
  for(int i=n-3;i>=0;i--){
  	dp[i]=min(abs(a[i]-a[i+1])+dp[i+1],abs(a[i]-a[i+2])+dp[i+2]);
  }
  cout<<dp[0]<<endl;
  return 0;
	



}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e18
ll MOD = 1e9+7;
ll a[403];
ll n,K;
ll dp[100000000];
//dp[i] - in which rows i have done and ways to make it happen
int main(){
	cin>>n;
	memset(dp,0,sizeof dp);
	ll a[n][n];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	dp[0]=1;
	for(int i=0;i<(1<<n);i++){
		int col = __builtin_popcount(i);
		for(int j=0;j<n;j++){
			if(((1<<j)&i)==0){
				if(a[j][col]){
					dp[(i|(1<<j))]+=dp[i];
					dp[(i|(1<<j))] = dp[(i|(1<<j))]%MOD;
				}
			}
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 784844
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.math.*

fun main() {
    var fs = Atcoder.FastReader()
    var str = fs.next()
    var count = 0
    var ans = 0
    for (c in str.toCharArray()) {
        if(c == 'R') count++
        else{
            count = 0
        }
        ans = max(ans,count)
    }
    println(ans)
}

class Atcoder {
    internal class FastReader {
        private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
        private var st: StringTokenizer? = null

        operator fun next(): String {
            while (st == null || !st!!.hasMoreElements()) {
                try {
                    st = StringTokenizer(br.readLine())
                } catch (e: IOException) {
                    e.printStackTrace()
                }

            }
            return st!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        fun nextLine(): String {
            var str = ""
            try {
                str = br.readLine()
            } catch (e: IOException) {
                e.printStackTrace()
            }
            return str
        }

        fun readIntArray(n: Int): IntArray {
            val a = IntArray(n)
            for (i in 0 until n) a[i] = nextInt()
            return a
        }

        fun readLongArray(n: Int): LongArray {
            val a = LongArray(n)
            for (i in 0 until n) a[i] = nextLong()
            return a
        }

        fun readDoubleArray(n: Int): DoubleArray {
            val a = DoubleArray(n)
            for (i in 0 until n) a[i] = nextDouble()
            return a
        }
    }
}


Measured memory_bytes: 34336
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll x,n;
    cin>>x>>n;
    bool c[105];
    fill(c,false);
    ll a[n];
    for(ll i=0;i<n;i++){
      cin>>a[i]; 
      c[a[i]]=true; 
    }
    ll l=x,r=x;
    while(1){
      if(c[l]==false){
        cout<<l<<endl; 
        break; 
      }
      if(c[r]==false){
        cout<<r<<endl; 
        break; 
      }
      l--,r++;
    }
    
    //printclock;
    return 0;
}
    

Measured memory_bytes: 3628
N,X = list(map(int,input().split()))
L = list(map(int,input().split()))

D = []
D.append(0)

for i in range(1,N+1):
	tmp = D[i-1] + L[i-1]
	D.append(tmp)

n = sum(x <= X for x in D)
print(n)


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

#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
unsigned GetDigit(unsigned num){
    return log10(num)+1;
}

signed main(){
 string s;
 cin >> s;
 int c=0;
 REP(i,s.size()/2){
 if(s[i]!=s[s.size()-i-1]){
            c++;
 }
             }
             cout <<c;
             }


Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
        // Your code here!
        string[] s = System.Console.ReadLine().Split(' ');
        int[] n = new int[3];
        int cnt = 0;
        foreach(string str in s){
            n[cnt++] = int.Parse(str);
        }
        System.Console.WriteLine(((n[2]-(n[0]-n[1])>=0)? n[2]-(n[0]-n[1]):0));
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;
typedef long long ll;
ll n, p, a[N], dp[2][N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld",&n ,&p);
	for(ll i = 1; i <= n; i++)
		scanf("%lld",a + i);
	dp[0][0] = 1;
	for(ll i = 1; i <= n; i++){
		if(a[i] % 2){
			dp[1][i] = dp[0][i - 1] + dp[1][i - 1];
			dp[0][i] = dp[1][i - 1] + dp[0][i - 1];
		} else{
			dp[1][i] = dp[1][i - 1]*2;
			dp[0][i] = dp[0][i - 1]*2;
		}
	}
	printf("%lld\n", dp[p][n]);
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
int segTree[600100];


int query(int s, int e, int index, int qs, int qe){
    if(qe < s || qs > e) return 0;
    if(s== e){
        return segTree[index];
    }
    if(qs <= s && e <= qe){
        return segTree[index];
    }
    int mid = (s+e)/2;
    return query(s, mid, index*2, qs, qe) + 
        query(mid+1,e, index*2+1, qs, qe);
}

void update(int s, int e, int index, int loc, int val){
    if(s == e && s == loc){
        segTree[index]++;
        return;
    }
    if(loc <s || loc > e) return;
    int mid = (s+e)/2;
    update(s, mid, index*2, loc, val);
    update(mid+1, e, index*2+1, loc, val);
    segTree[index] = segTree[index*2]+ segTree[index*2+1];
}


const int mx = (int)1e5 + 10;
vi in;
int n;

int pairs;
bool check(int mid){
    vi temp(n);
    int pre = 0;
    int mn = 0;
    FOR(i, n){
        if(in[i] <= mid)temp[i] = -1;
        else temp[i] = 1;
        pre += temp[i];
        temp[i] = pre;
        mn = min(temp[i], mn);
    }
    FOR(i, n)temp[i] += abs(mn);

    int ans = 0;

    update(0, mx, 1, abs(mn), 1);
    FOR(i, n){
        assert(temp[i]<= mx);
        ans += query(0, mx, 1, 0, temp[i]);
        update(0, mx, 1, temp[i], 1);
    }
    memset(segTree, 0, sizeof(segTree));

    //cout << mid << " " << ans <<endl;
    return ans < (pairs+1)/2;

}

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

   // freopen("1_05.txt", "r", stdin);
    cin >> n;
    pairs = (n*(n-1))/2 + n;
    in.resize(n);
    FOR(i,n)cin >> in[i];
    vi temp = in;
    //reverse(in.begin(), in.end());
    sort(temp.begin(), temp.end());
    //assert(temp == in);
    //check(50001);
    int s= 0, e = temp.size() -1;
    int ans = 0;
    while(s <= e){
        int mid = (s+e)/2;
        if(check(temp[mid])){
            ans = mid;
            e = mid-1;
        }else{
            s = mid+1;
        }

    }
    cout << temp[ans];
}




Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
using namespace std;
#define res register int
typedef long long ll;
typedef long double ld;
inline int read(){
	char ch=getchar();int s=0,f=1;
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=(s<<1)+(s<<3)+(ch^48);ch=getchar();}
	return s*f;
}
int n,x,y;
int ans[2010];
inline int abs(int x){
	return x<0?-x:x;
}
inline int dis(int i,int j){
	return min(j-i,abs(x-i)+abs(y-j)+1);
}
int main(){
	n=read();x=read();y=read();
	for(res i=1;i<n;++i)for(res j=i+1;j<=n;++j){
		ans[dis(i,j)]++;
	}
	for(res i=1;i<n;++i)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
S = input()

R = []
G = []
B = []

d = defaultdict(int)
for i in range(N):
    if S[i] == 'R':
        R.append(i+1)
    elif S[i] == 'G':
        G.append(i+1)
    else:
        B.append(i+1)
        d[i+1] = 1

res = 0
bl = len(B)
sb = set(B)
for r in R:
    for g in G:
        for b in [2*r-g, 2*g-r, g+(r-g)/2]:
            res -= d[b]
        res += bl


#        for k in B:
#            res += 1

print(res)

Measured memory_bytes: 10772
#include <iostream>

using namespace std;

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

  int c[3][3] = {{0}};
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j) cin >> c[i][j];

  for (int a1 = 0; a1 <= 100; a1++) {
    const int b1 = c[0][0] - a1;
    for (int a2 = 0; a2 <= 100; a2++) {
      const int b2 = c[1][1] - a2;
      for (int a3 = 0; a3 <= 100; a3++) {
        const int b3 = c[2][2] - a3;
        if (a1 + b2 == c[0][1] && a2 + b1 == c[1][0] && a1 + b3 == c[0][2] &&
            a3 + b1 == c[2][0] && a2 + b3 == c[1][2] && a3 + b2 == c[2][1]) {
          cout << "Yes\n";
          return 0;
        }
      }
    }
  }
  cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
city={1:0,2:0,3:0,4:0}
for q in range(3):
    n,k=map(int,input().split())
    city[n]+=1
    city[k]+=1


if min(city.values()) ==0 or max(city.values())==3:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3060
#include <stdio.h>

int i, m, n;
int S[100];
int res;

solve (i,m) {
	if (m == 0) {
		return 1;
	}
	if (i >= n) {
		return 0;
	}
	res = solve(i + 1, m) || solve(i + 1, m - S[i]);
	return res;
}

int main (void) {
	int q, i, x;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);

	for (i = 0; i < q; i++) {
		scanf("%d", &x);
		if ( solve(0, x)) {
			printf("yes\n");
		}
		else {
			printf("no\n");
		}

	}

	return 0;
}




Measured memory_bytes: 2136