akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
int main()
{
    // long double pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692;
    double pi = acos(-1);
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double rm;
    rm = double(M * 6);
    double rh;
    rh = double(H * 60 + M) / 2;
    // cout << rh << endl;
    // cout << rm << endl;

    double angle;
    angle = abs(rm - rh);
    // cout << angle << endl;
    // cout << fixed << setprecision(20) << sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(pi * angle / 180)) << endl;
    // cout << fixed << setprecision(20) << static_cast<long double>(sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(pi * angle / 180))) << endl;
    // printf("%.10f\n", double(A));
    // printf("%.10f\n", double(A * A + B * B));
    // printf("%.10f\n", double(2 * A * B) * cos(pi * angle / 180));
    printf("%.20f\n", double(sqrt(double(A * A + B * B) - double(2 * A * B) * cos(double(pi * angle) / 180))));
    // cout << fixed << setprecision(20) << cos(pi * angle / 180) << endl;
    // cout << fixed << setprecision(20) << sqrt(A * A + B * B - 2 * A * B * cos(pi * angle / 180)) << endl;
    // long double rad = (pi * angle) / 180;
    // double c = cos(rad);
    // double x = A * A + B * B - 2 * A * B * c;
    // // cout << fixed << setprecision(20) << static_cast<long double>(rad) << endl;
    // // cout << fixed << setprecision(20) << c << endl;
    // // cout << fixed << setprecision(20) << x << endl;
    // // cout << fixed << setprecision(20) << sqrt(x) << endl;
    // cout << fixed << setprecision(20) << static_cast<double>(sqrt(x)) << endl;
    return 0;
}

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

int main(){
int n,w;
cin >> n >> w;

string s[n];
int i,j;
for(i=0;i<n;i++) cin >> s[i];
const int dx[8] ={1,0,-1,0,1,-1,-1,1};
const int dy[8] ={0,1,0,-1,1,1,-1,-1};
for(i=0;i<n;i++){
  for(j=0;j<w;j++){
    if(s[i][j] == '#') continue;
    int count=0;
    for(int d=0; d<8;d++){
      const int ni = i + dy[d];
      const int nj = j + dx[d];

      if(ni<0 or n<=ni) continue;
      if(nj<0 or w<=nj) continue;
      if(s[ni][nj] == '#') count++;
      }
      s[i][j]=char(count+'0');
    }
  }
  for(i=0;i<n;i++) cout << s[i] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

void f(int n, char *s, int *i, int *t){
  if(n == 0){
    t[*i] = atoi(s);
    (*i) += 1;
    return;
  }
  else{
    s[n - 1] = '3';
    f(n - 1, s, i, t);
    s[n - 1] = '5';
    f(n - 1, s, i, t);
    s[n - 1] = '7';
    f(n - 1, s, i, t);
  }
}

int
main(int argc, char *argv[])
{
  int x;
  scanf("%d", &x);

  int keta = 0, temp = x;
  while(temp > 0){
    temp /= 10;
    keta++;
  }


  int ans = 0;

  if(keta <= 2) ans = 0;

  else{
    int i; char s[20] = {}; int t[1000000]; int c3, c5, c7, c;
    for(int j = 3; j <= keta; j++){
      i = 0;
      f(j, s, &i, t);
      for(int k = 0; k < i; k++){
	c3 = 0; c5 = 0; c7 = 0; c = 0;
	if(t[k] <= x){
	  while(t[k] > 0){
	    if(t[k] % 10 == 3) c3++;
	    else if(t[k] % 10 == 5) c5++;
	    else if(t[k] % 10 == 7) c7++;
	    else{c = 1; break;}
	    t[k] /= 10;
	  }
	  if(c == 0 && (c3 > 0 && c5 > 0 && c7 > 0)) ans++;
	}
      }
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c;
	cin>>a>>b>>c;
	puta(max(0,c-(a-b)));
	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 1000000007
int main() {
	int n = ri();
	bool a[n][n];
	for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) a[i][j] = ri();
	int dp[1 << n];
	memset(dp, 0, sizeof(dp));
	dp[0] = 1;
	for (int i = 0; i < 1 << n; i++) {
		for (int j = 0; j < n; j++) {
			if (!(i >> j & 1) && a[j][__builtin_popcount(i)]) {
				dp[i | 1 << j] += dp[i];
				if (dp[i | 1 << j] >= MOD) dp[i | 1 << j] -= MOD;
			}
		}
	}
	std::cout << dp[(1 << n) - 1] << std::endl;
	return 0;
}


Measured memory_bytes: 8448
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    ll a,b,k;
    cin>>k>>a>>b;
    for (int i=a;i<=b;i++)
    {
        if (i%k==0)
        {
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";




}


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

int main() {
    int a,b,c,x; cin >> a >> b >> c >> x;
    int ans = 0;
    for (int i = 0; i <= min(x/500, a); i++)
    {
        for (int j = 0; j <= min(x/100, b); j++)
        {
            for (int k = 0; k <= min(x/50, c); k++)
            {
                int money = 500*i + 100*j + 50*k;
                if (money == x)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math

cityNum = int(input())
city = [[0] * 2 for i in range(cityNum)]
for i in range(cityNum):
  city[i][0], city[i][1] = map(int, input().split())
if cityNum == 2:
  mulTimes = 2
  divNum = 2
else:   
  mulTimes = math.factorial(cityNum - 1) * 2
  divNum = math.factorial(cityNum)
total = 0.0
for i in range(cityNum-1):
  j = i + 1
  while j < cityNum:
    length = math.sqrt((city[i][0] - city[j][0]) ** 2 + (city[i][1] - city[j][1]) ** 2)
    total = total + length * mulTimes
    j = j + 1
ans = total / divNum
print(ans)

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

#include <iostream>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> pn(n);
  for (auto& pi : pn) {
    cin >> pi;
  }
  sort(pn.begin(), pn.end());
  int total = 0;
  for (int i = 0; i < k; ++i) {
    total += pn[i];
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#define llinf 4154118101919364364
//Heap and Priority_queue

typedef struct{
long long node;
long long cost;
}data;

data heap[524288];
long long hsize=0;

void resheap(){
    hsize=0;
    long long i;
    heap[0].node=-1;
    heap[0].cost=llinf;
    for(i=1;i<524288;i++){
        heap[i].node=-1;
        heap[i].cost=-llinf;
    }
}

int swjud(data high,data low){
    if(high.cost < low.cost){return 1;}
    return -1;
}

void pqpush(data x){
    long long a,b;
    data m;
    hsize++;
    heap[hsize]=x;
    a=hsize;
    while(1){
        b=a/2;
        if(swjud(heap[b],heap[a]) == 1){
            m=heap[a];heap[a]=heap[b];heap[b]=m;
        }
        else{break;}
        a=b;
    }
}

data pqpop(){
    long long a,b,c;
    data m,sw;
    m=heap[1];
    heap[1]=heap[hsize];
    heap[hsize].node=-1;
    heap[hsize].cost=-llinf;
    hsize--;
    a=1;
    while(1){
        b=a*2;c=a*2+1;
        if(swjud(heap[a],heap[b])==-1 && swjud(heap[a],heap[c])==-1){break;}
        if(swjud(heap[b],heap[c])==-1){
            sw=heap[a];heap[a]=heap[b];heap[b]=sw;
            a=b;
        }
        else{
            sw=heap[a];heap[a]=heap[c];heap[c]=sw;
            a=c;
        }
    }
    return m;
}

typedef struct{
long long val;
long long node;
}sd;

int sdsortfncsj(const void *a,const void *b){
if(((sd*)a)->val < ((sd*)b)->val){return -1;}
if(((sd*)a)->val > ((sd*)b)->val){return 1;}
return 0;
}

int sdsortfnckj(const void *a,const void *b){
if(((sd*)a)->val > ((sd*)b)->val){return -1;}
if(((sd*)a)->val < ((sd*)b)->val){return 1;}
return 0;
}

int main(){
  resheap();
  data pd,od;
  long long t,res,i,n;
  long long k,l,r;
  sd fd[524288],ld[524288];
  long long fdc=0,ldc=0;
  scanf("%lld",&t);
  while(t>0){
    t--;
    res=0;
    scanf("%lld",&n);
    fdc=0;ldc=0;
    for(i=0;i<n;i++){
      scanf("%lld%lld%lld",&k,&l,&r);
      if(l==r){res+=l;continue;}
      if(l>r){
        res+=r;
        fd[fdc].val=k;
        fd[fdc].node=l-r;
        fdc++;
      }
      if(l<r){
        res+=l;
        ld[ldc].val=k;
        ld[ldc].node=r-l;
        ldc++;
      }
    }
    qsort(fd,fdc,sizeof(fd[0]),sdsortfncsj);
    qsort(ld,ldc,sizeof(ld[0]),sdsortfnckj);
    fdc--;ldc--;
    while(hsize>0){pqpop();}
    for(i=n;i>=1;i--){
      while(fdc>=0){
        if(fd[fdc].val<i){break;}
        pd.cost=fd[fdc].node;
        pqpush(pd);
        fdc--;
      }
      if(hsize>0){
        od=pqpop();
        res+=od.cost;
      }
    }
    while(hsize>0){pqpop();}
    for(i=1;i<=n;i++){
      while(ldc>=0){
        if(ld[ldc].val>=i){break;}
        pd.cost=ld[ldc].node;
        pqpush(pd);
        ldc--;
      }
      if(hsize>0){
        od=pqpop();
        res+=od.cost;
      }
    }
    printf("%lld\n",res);
  }
}

Measured memory_bytes: 14552
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(void) {
  int N, T, A;
  vector<int> H;
  cin >> N >> T >> A;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    H.push_back(tmp);
  }

  int ans = 0;
  double minimum = abs(0.006 * H[0] + A - T);

  for (int i = 1; i < N; i++) {
    double tmp = abs(0.006 * H[i] + A - T);
    if (tmp < minimum) {
      ans = i;
      minimum = tmp;
    }
  }

  cout << (ans + 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
vector<pll> G[100010];
bool exi[100010];
int st,go;
bool dfs1(int s,int p){
	bool f = false;
	if(s==go) f = true;
	for(auto v:G[s]){
		if(v.first==p) continue;
		f |= dfs1(v.first,s);
	}
	return exi[s] = f;
}

ll t,wei[100010];
void ord(int s, int p){
	vector<pair<pll,ll>> pri;
	for(auto v:G[s]){
		int ver = v.first,i = v.second;
		if(!exi[ver]) pri.push_back({{wei[i] - t*(G[ver].size()),ver},i});
		else pri.push_back({{100000000000000,ver},i});
	}
	sort(pri.begin(),pri.end());
	G[s].clear();
	for(auto v:pri){
		int ver = v.first.second,i = v.second;
		G[s].push_back({ver,wei[i]});
	}
	pri.clear();
	for(auto v:G[s]){
		if(v.first==p) continue;
		ord(v.first,s);
	}
}

bool flag = false;
ll cnt[100010] = {};
int n;
void dfs2(int s,int p){
	cnt[s]++;
	for(auto v:G[s]){
		int ver = v.first,hp = v.second;
		if(ver==p) continue;
		if(hp<=t*(cnt[s] + cnt[ver])) return;
		dfs2(ver,s);
		if(hp<=t*(cnt[s] + cnt[ver])) return;
		cnt[s]++;
	}
	if(s==go){
		for(int i=0;i<n;i++){
			if(i!=st && cnt[i]==0) break;
			if(i==n - 1) flag = true;
		}
	}
}

int main(){
	int i;
	cin >> n >> t >> st >> go;
	st--; go--;
	for(i=0;i<n - 1;i++){
		long long a,b,c;
		cin >> a >> b >> c; a--; b--;
		wei[i] = c;
		G[a].push_back({b,i});
		G[b].push_back({a,i});
	}
	dfs1(st,-1); ord(st,-1);
	cnt[st]--; dfs2(st,-1);
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	for(i=0;i<n;i++){
		if((i!=st) && flag && cnt[i]==0){
			assert(false);
		}
	}
}


Measured memory_bytes: 22944
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    ssort(a);
    rep(i,n) cin >> a[i];
    int ans = gcd(a[0], a[1]);
    repSE(i,2,n) {
        ans = gcd(ans, a[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 4999999999999999999
#define ALL(n) n.begin(),n.end()


ll N, K,a = 0,b = 0;
int main(){
	cin >> N >> K;
	a = N / K;
	if(K % 2 == 0)b = (N + K / 2)/ K;
	cout << a * a * a + b * b * b << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[6][6];
int rec[6][6][6][6];
int n;
int solve(int p,int q,int t,int c){
	if(t==0){
		if(c)return 0;
		return 1;
	}
	if(p==n)return 0;
	if(q==n)return solve(p+1,0,t,c);
	if(!(c&(1<<(p*n+q))))return solve(p,q+1,t,c);
	for(int h=q;h<n;h++){
		for(int i=p;i<n;i++){
			if(solve(p,q+1,t-1,c^rec[p][q][i][h]))return 1;
		}
	}
	return 0;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		n=a;
		for(int i=0;i<6;i++)for(int j=0;j<6;j++)for(int k=0;k<6;k++)for(int l=0;l<6;l++)
			rec[i][j][k][l]=0;
		for(int i=0;i<a;i++)for(int j=0;j<a;j++){
			for(int k=i;k<a;k++)for(int l=j;l<a;l++){
				for(int x=i;x<=k;x++)for(int y=j;y<=l;y++)
					rec[i][j][k][l]+=(1<<(x*a+y));
			}
		}
		for(int i=0;i<a;i++)for(int j=0;j<a;j++)scanf("%d",&b[i][j]);
		int st=0;
		for(int i=0;i<a;i++)for(int j=0;j<a;j++)if(b[i][j])st+=(1<<(i*a+j));
		for(int i=1;;i++){
			if(solve(0,0,i,st)){
				for(int j=0;j<i;j++)printf("myon");
				printf("\n");
				break;
			}
		}
	}
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main() {
   ll n;cin >>n;
   vector<ll>ans(100000,0);
    for (int x = 1; x <=100; ++x) {
        for (int y = 1; y <=100; ++y) {
            for (int z = 1; z <=100; ++z) {
                ll k=x*x+y*y+z*z+x*y+y*z+z*x;
                if(k<0||k>11000)continue;
                ans[k]++;
            }
        }
    }
    for (int i = 1; i <=n; ++i) {
        cout <<ans[i]<<endl;
    }
}


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



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

    string S;
    cin >> S;
    int ans=0;
    string T=S;
    reverse(T.begin(),T.end());
    rep(i,S.size()){
        if(S[i]!=T[i]) ans++;
    }
    cout << (ans+1)/2 << endl;



}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {
    static int n;
    static int W;
    static long[][] dp;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        W = sc.nextInt();
        dp = new long[n+1][W+1];
        for (int i = 0; i < n; i++) {
            int w = sc.nextInt();
            int v = sc.nextInt();
            for (int j = 0; j < w; j++) {
                dp[i+1][j] = dp[i][j];
            }
            for (int j = w; j <= W; j++) {
                dp[i+1][j] = Math.max(dp[i][j], dp[i][j-w] + v);
            }
        }
        System.out.println(LongStream.of(dp[n]).max().getAsLong());
     }

}


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

int main(){
	int a, b, k;
	cin >> a >> b >> k;
	int i=a, count=0;
	
	do{
//		i--;
		if(a%i==0 && b%i==0)	count++;
//		cout << i << "\t" << count << endl;}
		i--;
	}while(count!=k);
	
	cout << i+1 << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))

flag = True
cnt = 0
while(flag):
	for a in (A):
		if a % 2 == 1:
			flag = False
			break

	if flag:
		for i in range(N):
			A[i] = A[i] / 2
		cnt += 1
	    
print(cnt)

Measured memory_bytes: 3188
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int n;
  ull k;
  cin >> n >> k;

  vector<pair<int, int>> pairs(n);
  REP(i, n) {
    int a,b;
    cin >> a >> b;
    pairs[i] = make_pair(a, b);
  }

  SORT(pairs);

  ull currentTotal = 0;
  REP(i, n) {
    // cout << pairs[i].first << " " << pairs[i].second << endl;
    // continue;
    currentTotal += pairs[i].second;
    if(currentTotal >= k) {
      // if(n-1 != i && currentTotal + pairs[i+1].second)
      cout << pairs[i].first << endl;
      return 0;
    }
  }

  return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == N) {
                cout << "Yes" << endl;
              	return 0;
            }
        }
    }
    
    cout << "No" << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(int i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define f(n)                for (ll i=0;i<n;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define N                   100005
ll MOD=pow(10,9)+7;
ll INF=1ll<<60;

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int h[n+1];
    h[0]=-1;
    rep(i,1,n+1)
    {
        scanf("%d",&h[i]);
    }
    ll dp[n+1];
    rep(i,0,n+1)
    dp[i]=INF;
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    rep(i,3,n+1)
    {
        for(ll j=max(1,i-k);j<i;j++)
        {
            dp[i]=min(dp[i],abs(h[j]-h[i])+dp[j]);
        }
    }
    printf("%lld",dp[n]);
}


Measured memory_bytes: 1408
#include <iostream>

int main() {
  int n;
  std::cin >> n;

  int min, max;
  min = 1000000000;
  max = 0;

  for (auto i = 0; i < n; i++) {
    int t;
    std::cin >> t;
    if (t < min) {
      min = t;
    }
    if (t > max) {
      max = t;
    }
  }

  std::cout << max - min << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

X = iin()

ans = X//500 * 1000
ans += X%500//5 * 5
print(ans)

Measured memory_bytes: 5428
#include <iostream>
#include<math.h>
using namespace std;
#define int long long

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

	int N;
	cin >> N;
	if (N % 2) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 0;
	int i = 10;
	while (i<=N) {
		ans += N / i;
		i *= 5;
	}
	cout << ans << endl;
	return 0;
}



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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    cout << ((n-h)+1) * ((n-w)+1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	char a[100010];
	f(i, 100010)a[i] = 0;
	int k, s;
	int n, m;
	int x, y, z;
	int ans = 10000000;

	scanf("%s", a);
	n = strlen(a);
	ans = n;

	f(i, n-1){
		if (a[i] != a[i + 1]){
			ans = min(ans, max(i + 1, n - i - 1));
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 384
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "aising2020_b.cpp"

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

  int n;
  cin >> n;
  vi a(n);

  cin >> a;
  int ans = 0;
  REP(i, n) {
    if (a[i] % 2 == 1 && i % 2 == 0)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3656
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		WriteLine(N % 2 == 0 ? N : 2 * N);
	}
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}


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

  ll x;
  cin >> x;
  ll dec = x - (x/500)*500;
  cout << (x/500)*1000 + (dec/5) * 5 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,t,cnt=0;
    scanf("%d%d",&n,&m);
    int a[m+10],i,j,k;
    for(i=1;i<=m;i++)
    {
        a[i]=0;
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&k);
        for(j=1;j<=k;j++)
        {
            scanf("%d",&t);
            a[t]++;

        }
    }
    for(i=1;i<=m;i++)
    {
       if(a[i]==n)
       {
            cnt++;
       }
    }
          printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  ll h, n;
  cin >> h >> n;
  ll a[10010], b[10010];
  rep(i, n) cin >> a[i] >> b[i];
  ll dp[10010];
  fill(dp, dp + 10010, LINF);
  dp[0] = 0;
  REP(i, 1, h + 1)
  {
    rep(j, n)
    {
      dp[i] = min(dp[i], dp[max(i - a[j], 0LL)] + b[j]);
    }
  }
  cout << dp[h] << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
char s[200000];
int keep[200000];
int main(){

    scanf("%s",s);
    int l,r,p,cntr=0,cntl,n=strlen(s);
    for(int i=0;i<n;i++) keep[i]=1;
    for(int i=0;i<n;i++){
        if(s[i]=='R'&&s[i+1]=='L'){
            keep[i+1]+=(cntr+1)/2;
            keep[i]+=(cntr-(cntr+1)/2);
            cntr=0;
        }else if(s[i]=='R'&&s[i+1]=='R'){
            keep[i]=0;
            cntr++;
        }else if(s[i-1]=='R'&&s[i]=='L'){
            cntl=0;
            p=i;
        }else if(s[i-1]=='L'&&s[i]=='L'){
            cntl++;
            keep[i]=0;
            if(!(cntl%2))
                keep[p]++;
            else
                keep[p-1]++;
        }
    }
    for(int i=0;i<n-1;i++)
        printf("%d ",keep[i]);
    printf("%d",keep[n-1]);
}

Measured memory_bytes: 4304
#include<iostream>
using namespace std;
int main(){
    int dice[6];
    int q;
    for(int i=0; i<6; i++)  cin>>dice[i];
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        if((a==dice[3] && b==dice[1]) || (a==dice[1] && b==dice[2]) || (a==dice[2] && b==dice[4]) || (a==dice[4] && b==dice[3]))    cout<<dice[0]<<endl;
        else if((a==dice[3] && b==dice[5]) || (a==dice[5] && b==dice[2]) || (a==dice[2] && b==dice[0]) || (a==dice[0] && b==dice[3]))    cout<<dice[1]<<endl;
        else if((a==dice[0] && b==dice[1]) || (a==dice[1] && b==dice[5]) || (a==dice[5] && b==dice[4]) || (a==dice[4] && b==dice[0]))    cout<<dice[2]<<endl;
        else if((a==dice[0] && b==dice[4]) || (a==dice[4] && b==dice[5]) || (a==dice[5] && b==dice[1]) || (a==dice[1] && b==dice[0]))    cout<<dice[3]<<endl;
        else if((a==dice[0] && b==dice[2]) || (a==dice[2] && b==dice[5]) || (a==dice[5] && b==dice[3]) || (a==dice[3] && b==dice[0]))    cout<<dice[4]<<endl;
        else if((a==dice[1] && b==dice[3]) || (a==dice[3] && b==dice[4]) || (a==dice[4] && b==dice[2]) || (a==dice[2] && b==dice[1]))    cout<<dice[5]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
#include 	<ctype.h>
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define		in(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopchar() for(char c='a';c<='z';c++)
#define 	printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define		printv(v) for (int i: v) cout << i << " "; cout << endl;
#define 	loopitr(vec) for(auto itr=vec.begin();itr!=vec.end();itr++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	time cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	endl '\n'
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(15)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	intsize(num) trunc(log10(num)) + 1
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())
using 		namespace __gnu_pbds; 
using 		namespace std;

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

//code start from here 

vector<ll>adj[200100];
bool visited[200100];

int main() {
	fast;
	time;
  	memset(visited,false,sizeof(visited));
	read(n)
	read(k)
	bool dp[k+5];
	memset(dp,false,sizeof(dp));
	readarr(arr,n);
	loop(j,0,k+1){
		for(ll x:arr){
			if(j-x>=0 && !dp[j-x])
				dp[j]=true;
		}
	}
	string s="";
	s= dp[k] ? "First" : "Second";
	cout<<s<<endl;
	return 0;
}

//ends here 

Measured memory_bytes: 5248
#include<stdio.h>
int s[5];
int main ()
{
    int p,q,r;
    scanf("%d%d%d",&p,&q,&r);
    s[1]=p+q;
    s[2]=p+r;
    s[3]=q+r;
    int minn=500;
    for (int i=1;i<=3;i++)
    {
        if (s[i]<minn)
            minn=s[i];
    }
    printf("%d\n",minn);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <deque>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <string>

using namespace std;

int main(){
    int H,W;
    int diver[26];
    int diverp[26];
    int pnum[4];
    char buf;
    bool flag;

    for(int i=0;i<26;i++){
        diver[i] = 0;
    }

    scanf("%d %d",&H,&W);

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> buf;
            diver[buf-'a']++;
        }
    }

    for(int i=0;i<4;i++){
        pnum[i]=0;
    }

    for(int i=0;i<26;i++){
        if(diver[i]!=0)
            pnum[diver[i]%4]++;
    }

    


    if(H%2!=0 && W%2!=0){
        if(pnum[1]>=2){
            printf("No\n");
            return 0;
        }
        if(pnum[2]>H/2+W/2){
            printf("No\n");
            return 0;
        }
        if(pnum[3]>=2){
            printf("No\n");
            return 0;
        }
    }else if(H%2==0 && W%2!=0){
        if(pnum[1]>0){
            printf("No\n");
            return 0;
        }
        if(pnum[2]>H/2){
            printf("No\n");
            return 0;
        }
    }else if(H%2!=0 && W%2==0){
        if(pnum[1]>0){
            printf("No\n");
            return 0;
        }
        if(pnum[2]>W/2){
            printf("No\n");
            return 0;
        }
    }else{
        if(pnum[1]>0 || pnum[2]>0){
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");

    return 0;
}

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

// https://ei1333.github.io/library/library/structure/union-find/union-find.cpp.html
struct UnionFind {
    vector<int> data;

    UnionFind() = default;

    explicit UnionFind(size_t sz) : data(sz, -1) {}

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int find(int k) {
        if (data[k] < 0) return (k);
        return data[k] = find(data[k]);
    }

    int size(int k) { return -data[find(k)]; }

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

int main() {
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0)
            uf.unite(u, v);
        else
            cout << int(uf.same(u, v)) << '\n';
    }
}

Measured memory_bytes: 3976
import math
n = int(input())
lst = list()
num = 0
flag = 1
for i in range(n):

    s = input()
    s = list(s)
    s.sort()
    lst.append(s)

lst.sort()

for i in range(n-1):
    if (lst[i] == lst[i+1]):
        flag = flag + 1
    else:
        if (flag > 1):
            num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
        flag = 1
if (flag > 1):
    num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
print(num)


Measured memory_bytes: 25516
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
  ll N,M;
  cin >> N >> M;

  if(N>=M+2||M>=N+2){
    cout << 0 << endl;
  }else if(N==M){
    mint ans = 1;
    REP(i,N){
      ans*=i+1;
    }

    cout << ans*ans*2 << endl;
  }else{
    mint x = 1;
    REP(i,N){
      x*=i+1;
    }
    mint y = 1;
    REP(i,M){
      y*=i+1;
    }

    cout << x*y << endl;
  }
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main():
    N = int(input())

    while True:
        if is_prime(N):
            print(N)
            return
        N += 1



if __name__ == '__main__':
    main()



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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    int32 sum = 0;
    int32 mn = INF;
    REP(i,n){
        int32 s;
        cin >> s;
        sum += s;
        if(s % 10 != 0){
            mn = min(mn, s);
        }
    }
    if(sum % 10 == 0)sum -= mn;
    ANS(max<int32>(0,sum));
    return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
shops = sorted([list(map(int,input().split())) for _ in range(n)])
rest = m
ans = 0
while rest > 0:
    shop = shops.pop(0)
    buy = min(rest, shop[1])
    ans += buy*shop[0]
    rest -= buy
print(ans)

Measured memory_bytes: 28648
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

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

int main() {
  ll n;
  cin >> n;
  
  int count = 0;
  
  while (n--) {
    ll k;
    cin >> k;
    
    while (!(k & 1)) {
      k >>= 1;
      count++;
    }
  }
  
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,m,j,a[1000]={0},t,s;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&t);
		for(j=1;j<=t;j++)
		{
			scanf("%d",&s);
			a[s]++;
		}
	}
	s=0;
	for(i=1;i<=m;i++)
	{
		if(a[i]==n)
		{
			s++;
		}
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
while(1){
    int a,b,i=0,j=0;
    cin>>a;
if(a==0)return 0;
    char str[a+1][2]={0};
    for (i=0;i<a;i++) cin>>str[i][0]>>str[i][1];
    cin>>b;
    char c;
    for (i=0;i<b;i++){
        cin>>c;
        for (j=0;j<a;j++){
            if (c==str[j][0]){
                c=str[j][1];
                break;
            }
	}
        cout<<c;
    }
    cout<<endl;
}//tuketasi
    return 0;
}



Measured memory_bytes: 3024
use proconio::{input, fastout};
use proconio::marker::{Chars};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
    }

    let mut t: Vec<usize> = vec![0;1];
    let mut ords: Vec<(usize,usize)> = vec![(0,0);1];
    for i in 0..n {
        input!{
            t_tmp: usize,
            x: usize,
            y: usize,
        }
        t.push(t_tmp);
        ords.push((x,y));
    }
    debug!(ords);
    debug!(t);
    for i in 0..n {
        let dis = (ords[i+1].0 as i64 - ords[i].0 as i64).abs()
                 +(ords[i+1].1 as i64 - ords[i].1 as i64).abs();
        let time = t[i+1]-t[i];
        debug!(dis);
        debug!(time);
        if time as i64 >=dis && (time as i64 - dis)%2==0{
            continue;
        } else {
            println!("No");
            return;
        }
    }

    println!("Yes");

}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, a[maxn], cnt[maxn];

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

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		cnt[a[i]]++;
	}
	int MAX = *max_element(a, a + n);
	bool ans = true;
	for (int i = MAX; i >= (MAX + 1) / 2; i--)
	{
		if (i == (MAX + 1) / 2)
		{
			if (MAX & 1)
			{
				if (cnt[i] != 2)
				{
					ans = false;
				}
			}
			else
			{
				if (cnt[i] != 1)
				{
					ans = false;
				}
			}
		}
		else
		{
			if (cnt[i] < 2)
			{
				ans = false;
			}
		}
	}
	for (int i = 0; i < (MAX + 1) / 2; i++)
		if (cnt[i])
			ans = false;

	cout << (ans ? "Possible" : "Impossible") << endl;
}



Measured memory_bytes: 384
#include <iostream>

typedef long long ll;

int main(){
   int N;
   std::cin >> N;
   ll A[N+1], B[N];
   for(int i=0; i<N+1; ++i)
      std::cin >> A[i];
   for(int i=0; i<N; ++i)
      std::cin >> B[i];

   ll ans = 0;
   for(int i=0; i<N; ++i){
      ll tmp = std::min(A[i], B[i]);
      ans += tmp;
      A[i] -= tmp;
      B[i] -= tmp;
      tmp = std::min(A[i+1], B[i]);
      ans += tmp;
      A[i+1] -= tmp;
      B[i] -= tmp;
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

ll a, b, c;

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

  int sum = 0;
  while(1){
    if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1)  break;
    if(a == b && b == c) {
      sum = -1;
      break;
    }
    ll ta = b/2 + c/2;
    ll tb = a/2 + c/2;
    ll tc = b/2 + a/2;
    a = ta; b = tb; c = tc;
    sum++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256