akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
 
using namespace std;
int a, b, c, z;
 
int main()
{
    cin >> a >> b >> c;
 
    if ( a > b ){
     
        z = a;
        a = b;
        b = z;
    }
 
    if ( b > c ){
 
        z = b;
        b = c;
        c = z;
    }
 
    if ( a > b ){
 
        z = a;
        a = b;
        b = z;
    }
     
    cout <<a<<" "<<b<<" "<<c<<endl;
 
    return 0;
}

Measured memory_bytes: 1168
import itertools
import math

N = int(input())
xy  = [[int(i) for i in input().split()] for j in range(N)]
distance = [[0 for j in range(N)] for i in range(N)]
for i in range(N):
    for j in range(N):
        xi = xy[i][0]
        yi = xy[i][1]
        xj = xy[j][0]
        yj = xy[j][1]
        d = math.sqrt((xi-xj)**2+(yi-yj)**2)
        distance[i][j] = d
        distance[j][i] = d

anslist=[]
for route in itertools.permutations(range(N),N):
    total=0
    for i in range(N-1):
        start = route[i]
        goal = route[j]
        total += distance[start][goal]
    anslist.append(total)

print(sum(anslist)/len(anslist))

Measured memory_bytes: 4400
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Data{
public:
	int P,Y,I;
};

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	//cout<<fixed<<setprecision(10);
	
	int N=in(),M=in();
	vector<vector<Data>> D(N);
	vector<string> S(M);
	
	REP(i,M){
		int P=in(),Y=in();
		Data T;
		T.I = i;
		T.P = P;
		T.Y = Y;
		D[P-1].push_back(T);
	}

	for(auto& x:D){
		sort(ALL(x),[](Data& l,Data& r){return l.Y<r.Y;});
		for(int i=0,ei=x.size();i<ei;i++){
			char str[128];
			sprintf(str,"%06d%06d",x[i].P,i+1);
			S[x[i].I] = str;
		}
	}

	for(auto& x:S) out(x);
	return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define all(vv) (vv).begin(), (vv).end()
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0

int n, m;
pii ab[100100];
priority_queue <int, vector <int>, greater <int>> pq;

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for(int i = 0; i < n; ++i) {
		cin >> ab[i].first >> ab[i].second;
	}
	sort(ab, ab + n, greater<pii>());
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		int r = ab[i].second;
		if (pq.size() + ab[i].first <= m) {// fits the max days 
			ans += r;
			pq.push(r);
		} 
		else if (pq.size() && pq.top() < r) {// can fit cuz less days (due to sort)
			ans -= pq.top();                 // check the one with most output
			ans += r;
			pq.pop();
			pq.push(r);
		}
	}
	cout << ans;
	time;
}

Measured memory_bytes: 5792
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
	int N, X;
	cin >> N >> X;
	vector<int> list;
	int count = 0;
	for (size_t i = 0; i < N; i++)
	{
		int m;
		cin >> m;
		count++;
		X -= m;
		list.push_back(m);
	}
	sort(list.begin(), list.end());

	

	cout << (count + (X / list[0]));
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int p[4][4][2];
int s[102];
 
int main()
{
    int n, k, a, b;
    int i, j, m, i1, i2, j1, j2, k1, k2, ans;
 
    scanf("%d%d", &n, &k);
    while (k--) scanf("%d%d", &a, &b), s[a] = b;
    if (s[1] > 0) i1 = i2 = s[1]; else i1 = 1, i2 = 3;
    if (s[2] > 0) j1 = j2 = s[2]; else j1 = 1, j2 = 3;
    for (i = i1; i <= i2; i++) for (j = j1; j <= j2; j++) p[i][j][0] = 1;
 
    for (k1 = 0, k2 = 1, k = 3; k <= n; k++, k1 = k2, k2 = !k2) {
        for (i = 1; i <= 3; i++) for (j = 1; j <= 3; j++) p[i][j][k2] = 0;
        for (i = 1; i <= 3; i++) for (j = 1; j <= 3; j++) for (m = 1; m <= 3; m++) {
            if (i == j) { if (m != j) p[j][m][k2] += p[i][j][k1]; }
            else                      p[j][m][k2] += p[i][j][k1];
        }
        if (s[k] > 0) {
            for (i = 1; i <= 3; i++) for (j = 1; j <= 3; j++) if (j != s[k]) p[i][j][k2] = 0;
        }
        for (i = 1; i <= 3; i++) for (j = 1; j <= 3; j++) p[i][j][k2] %= 10000;
    }
    for (ans = 0, i = 1; i <= 3; i++) for (j = 1; j <= 3; j++) ans += p[i][j][k1];
    printf("%d\n", ans % 10000);
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K; cin >> K;
    queue<ll> que;
    rep(i, 9) que.push(i+1);
    for(int i = 1; i <= K; i++){
        ll op = que.front();
        que.pop();
        if(i == K){
            cout << op << endl;
        }
        else{
            ll op10 = op*10;
            if(op % 10 == 0){
                que.push(op10);
                que.push(op10+1);
            }
            else if(op % 10 == 9){
                que.push(op10+8);
                que.push(op10+9);
            }
            else{
                int dig = op % 10;
                que.push(op10+dig-1);
                que.push(op10+dig);
                que.push(op10+dig+1);
            }
        }
    }
    return 0;
}

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

int main() {
    int n, m; std::cin >> n >> m;
    std::vector<int> a(n);
    int v = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        v += a[i];
    }

    int cnt = 0;
    for (const auto vv: a) {
        if (4 * vv * m >= v) {
            cnt++;
        }
    }
    std::cout << ((cnt>=m)?"Yes":"No") << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

   int a, b, c, k;

   cin >> a >> b >> c;
   cin >> k;

   while(k){

      if(a >= b){
         b *= 2;
      }
      else if(b >= c){
         c *= 2;
      }

      k--;
   }

   if(a < b && b < c){
      cout << "Yes" << endl;
   }
   else{
      cout << "No" << endl;
   }

   return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}*/
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 
 






int main()
{
   int n;
   cin>>n;
   vector<string> str(n);
   for(int i=0;i<n;i++){
        cin>>str[i];
   }
   vector<int> res(n,0);
   int c1=0,c2=0,c3=0;
   for(int i=0;i<n;i++)
   {
        string t=str[i];
        for(int j=0;j<t.length();j++)
        {
             if(j+1<n&&t[j]=='A'&&t[j+1]=='B'){res[i]++;j++;}
        }
        if(t[0]=='B'&&t.back()=='A')c1++;
        else if(t[0]=='B')c2++;
        else if(t.back()=='A')c3++;
   }
   ll ans=0;
   for(int i=0;i<n;i++)ans+=res[i];
   if(c1==0)ans+=min(c2,c3);
   else if(c2+c3==0)ans+=c1-1;
   else ans+=c1+min(c2,c3);
   cout<<ans;
  

}







 
 

















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

  int main()
  {
    int num[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int a;
    cin >> a;
	cout << num[a - 1] << endl;    
    return 0;
  }




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

int main()
{
    int k;
    string s;
    cin >> k;
    cin >> s;
    if (s.size() <= k)
    {
        cout << s << endl;
    }
    else
    {
        for (int i = 0; i < k; i++)
            cout << s[i];
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,K,X,Y,s1,s2=0;
    cin>>N>>K>>X>>Y;
    if(N<K)
    {
        K=N;
        s1=K*X;
    }
    else
     s1=K*X;

    s2=(N-K)*Y;
   cout<<s1+s2<<endl;


    return 0;
}


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

#define TCLOOP() int tc; cin>>tc; while(tc--)

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) int(s.length())
#define sz(v) int(v.size())
#define MOD 1000000007

// Code Here

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

ll lcm(ll a, ll b) { if (a == 0 || b == 0) return 0; return ((a / gcd(a,b)) * b); }

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b; cin>>a>>b;
    cout<<lcm(a,b);
    return 0;
}

Measured memory_bytes: 256
n = int(input())

MOD = 10**9 + 7
dp = [1] * 2200
dp[0] = 0
dp[1] = 0
dp[2] = 0
for i in range(2001):
    cnt = dp[i]
    for j in range(3,i+1):
        ind = max(0,i-j)
        cnt += dp[ind]
        cnt %= MOD
    dp[i] = cnt % MOD
print(dp[n])



Measured memory_bytes: 66108
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(8);
  int x,y,ans=0;
  cin >> x >> y;
  if(x==0 && y==0) cout<<0<<endl;
  else if(x==0 && y>0) cout << y << endl;
  else if(x==0 && y<0) cout << 1-y << endl;
  else if(x<0 && y==0) cout << -x << endl;
  else if(x>0 && y==0) cout << x+1 << endl;
  else if(x<0 && y>0) cout << abs(abs(x)-abs(y))+1 << endl;
  else if(x>0 && y<0) cout << abs(abs(x)-abs(y))+1 << endl;
  else if(x<y) cout << y-x << endl;
  else cout << x-y+2 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>

using namespace std;
const int INF = 1001001001;
#define rep(i,n) for(int i=0;i<n;i++)
int N,K;
int cost[10][2002]; 
int c[10];
int map[12][2002];




int main(){
	scanf("%d %d",&N,&K);
	fill(c,&c[10],0);
	rep(i,N){
		int a,b;
		scanf("%d %d",&a,&b);
		cost[b-1][c[b-1]]=a;
		c[b-1]++;
	}
	rep(i,10){
		sort(&cost[i][0],&cost[i][c[i]],greater<int>());
		rep(j,c[i])if(j!=0)cost[i][j]+=cost[i][j-1]+j*2;
	}
	rep(i,10){
		rep(j,K){
			if(i==0){map[i][j]=cost[i][j];continue;}
			map[i][j]=max(map[i-1][j],cost[i][j]);
			if(j==0){continue;}
			rep(k,j){
				
				map[i][j]=max(map[i][j],map[i-1][k]+cost[i][j-k-1]);
			}
		}
	}
	printf("%d\n",map[9][K-1]);
}

Measured memory_bytes: 1160
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <queue>
#include <iterator>
#include <map>
#include <unordered_map>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define vi vector<long long int>
#define vvi vector<vi >
#define vpi vector<pair<ll,ll> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll i,j,n;
	cin>>n;
	long double s=0;
	vector<long double>v(n);
	for(i=0;i<n;i++) cin>>v[i];
	vector<vector<long double> >d(n+1);
	for(i=0;i<=n;i++) d[i]=vector<long double>(n+1,0);
	d[0][0]=1;
	for(i=1;i<=n;i++){
		d[i][0]=d[i-1][0]*(1-v[i-1]);
		for(j=1;j<=i;j++) d[i][j]=d[i-1][j-1]*v[i-1]+d[i-1][j]*(1-v[i-1]);
	}
//	for(i=1;i<=n;i++){
//		print(d[i]);
//	}
	for(i=n/2+1;i<=n;i++) s+=d[n][i];
	printf("%.10Lf\n",s);

}


Measured memory_bytes: 141056
#include <iostream>

#include <string.h>

using namespace std;

string str_sort_asc(string str){

  for(int i = 1; i < str.size(); i++){
	for(int j = i; j > 0; j--){
	  if(str[j-1] > str[j]){
		char tmp = str[j-1];
		str[j-1] = str[j];
		str[j] = tmp;
	  }
	}
  }
  
  return str;
  
}

string str_sort_des(string str){

  for(int i = 1; i < str.size(); i++){
	for(int j = i; j > 0; j--){
	  if(str[j-1] < str[j]){
		char tmp = str[j-1];
		str[j-1] = str[j];
		str[j] = tmp;
	  }
	}
  }
  
  return str;
  
}

int main(){

  string s,t;

  cin >> s >> t;

  s = str_sort_asc(s);
  t = str_sort_des(t);
  
  if(s.compare(t) < 0){
	cout << "Yes" <<"\n";
  }
  else{
	cout << "No" <<"\n";
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std;
using namespace __gnu_cxx;
#define write_to_file() freopen("output.txt" , "w" , stdout)
#define read_from_file() freopen("input.txt" , "r" , stdin)
#define GeoOutputFix(VV) cout<<fixed<<setprecision(VV)
#define MAX_V  1e9
#define MIN_V -1e9
template<class T>istream& operator>> (istream& is, complex<T>& p){T value;is >> value, p.real(value), is >> value, p.imag(value);return is;}
typedef long long lld;
typedef pair<lld, lld> dd;
typedef complex<double> point;
#define X real()
#define Y imag()
#define dist(a , b) sqrt(pow(a.X - b.X , 2) + pow(a.Y- b.Y , 2))
#define dist2(a , b) ((long double)hypot(a , b))
#define mid(a,b) (((a)+(b))/point(2,0))
#define compare(a , b) (fabs(a.X - b.X) < -1e9 && fabs(a.Y - b.Y) < -1e9)
#define all(c) c.begin() , c.end()
#define MOD (lld)(1e9+7)
#define EPS 1e-9
#define neighbours(u , e , v) for(int e = head[u] , v ; v = to[e] , ~e ; e = nxt[e])
#define watch1(x) cout<<(#x)<<" = "<<x<<"\n"
#define watch2(x , y) cout<<(#x)<<" = "<<x<<"  "<<(#y)<<" = "<<(y)<<"\n"
#define watch3(x , y , z) cout<<(#x)<<" = "<<x<<"  "<<(#y)<<" = "<<(y)<"  "<<(#z)<<" = "<<(z)<<"\n"
int dr[] = {1 , 1 , 1 , 0 , 0 , -1 , -1 , -1};
int dc[] = {-1 , 0 , 1 , -1 , 1 , -1 , 0 , 1};
int ddr[] = {1 , 0 , 0 , -1};
int ddc[] = {0 , -1 , 1 , 0};
inline int SD(){int i ;scanf("%d", &i);return i;}
inline lld SLL(){lld i;scanf("%lld", &i);return i;}
inline char SC(){char i;scanf(" %c", &i);return i;}
const int AKA = 1e6 + 6 , OO = 0x3f3f3f3f;
//----------------------------------------[TO_OO]--[To infinity and beyond]--------------------------------------------------------
int a[AKA];
int main()
{
    int n = SD();
    for(int i = 0 ; i < n ; ++i)
        a[i] = SD();
    int cnt = 0 , ans = 0;;
    for(int i = 1 ; i < n ; ++i)
        if(a[i] <= a[i - 1])
            ++cnt;
        else
            ans = max(cnt , ans) , cnt = 0;
    ans = max(cnt , ans);
    printf("%d" , ans);
}


Measured memory_bytes: 640
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int n,k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] = s[k - 1] + 'a' - 'A';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
x,n=map(int,input().split())
p=list(map(int,input().split()))
f=0
ans=[]
for i in range(60):
    if not (x+i) in p or not (x-i) in p:
        ans.append(x-i)
        ans.append(x+i)
if not ans[0] in p and not ans[1] in p:
    print(ans[0])
elif not ans[0] in p and ans[1] in p:
    print(ans[0])
elif ans[0] in p and not ans[1] in p:
    print(ans[1])

Measured memory_bytes: 9208
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <vector>
#include <string>
#include <bitset>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
 
typedef long long ll;
typedef long double ld;
 
const ll MOD = 1e9 + 7, INF = 1e18 + 1;
 
using namespace std;
ll l;
 
ll grundy (ll height)
{
	return (height & (-height));
}
 
struct Node
{
	bool leaf;
	Node* to[2];
 
	Node ()
	{
		leaf = false;
		to[0] = to[1] = NULL;
	}
};
 
Node* root;
 
int n, ptr;
ll s;
 
void add (string s)
{
	auto x = root;
	for (int i = 0; i < s.length (); i++)
	{
		if (!x -> to[s[i] - '0']) x -> to[s[i] - '0'] = new Node ();
		x = x -> to[s[i] - '0'];
	}
 
	x -> leaf = true;
}
 
void dfs (Node* x, ll h)
{
	if (!x) s ^= grundy (h);
	else
	{
		dfs (x -> to[0], h - 1);
		dfs (x -> to[1], h - 1);
	}
}
 
int main ()
{
	root = new Node ();
 
	cin >> n >> l;
 
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
 
		add (s);
	}
 
	dfs (root, l + 1);
 
	if (!s || !n) cout << "Bob";
	else cout << "Alice";
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

using ll = long long;

int main() {

    ll n, h;

    cin >> n >> h;

    vector<ll> attack(n);
    vector<ll> throwing(n);

    for(int i = 0; i < n; ++i)
        cin >> attack[i] >> throwing[i];

    ll maxAttack = 0;
    ll sumThrowing = 0;
    ll throwingCount = 0;

    for(int i = 0; i < n; ++i)
        maxAttack = max(maxAttack, attack[i]);
    
    sort(throwing.begin(), throwing.end(), greater<ll>());

    for(int i = 0; i < n; ++i) {
        if(maxAttack < throwing[i]) {
            sumThrowing += throwing[i];
            throwingCount++;
            if(sumThrowing >= h)
                break;
        }
    }

    
    h -= sumThrowing;
    if(h < 0)
        h = 0;

    ll ansCount = (h / maxAttack) + throwingCount;
    if(h % maxAttack)
        ansCount++;

    cout << ansCount << endl;

    return 0;

}

Measured memory_bytes: 4808
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll N;
  string S;
  ll c[4]={};
  cin >> N;
  rep(i,N){
    cin >> S;
    if(S=="AC") c[0]++;
    else if(S=="WA") c[1]++;
    else if(S=="TLE") c[2]++;
    else if(S=="RE") c[3]++;
  }
  
  cout << "AC x " << c[0] << endl;
  cout << "WA x " << c[1] << endl;
  cout << "TLE x " << c[2] << endl;
  cout << "RE x " << c[3] << endl;  
}

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void)
{
    long n,a[200000],i,b,sorrow;

    scanf("%ld",&n);
    for ( i = 0; i < n; i++)
    {
        scanf("%ld",a+i);
    }

    for ( i = 0; i < n; i++)
    {
        a[i]-=i+1;
    }

    qsort(a,n,sizeof(long),compare_int);

    b=a[n/2];

    sorrow=0;
    for ( i = 0; i < n; i++)
    {
        sorrow+=abs(a[i]-b);
    }

    printf("%ld",sorrow);

    return 0;
}

Measured memory_bytes: 3324
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int x, y;
    cin >> x >> y;
    if(x >= 0 ^ y > 0){
        cout << abs(x + y) + 1 << endl;
    }else if(x <= y){
        cout << abs(x - y) << endl;
    }else{
        cout << abs(x - y) + 2 << endl;
    }
}

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

int main() {
	/*
	int a;
	int b;
	scanf("%d %d",&a,&b);
	int result=0;
	result = (a*b) - (a + b - 1);
	printf("%d",result);
	*/
	int n=0;
	scanf("%d",&n);
	int total=0;
	int result = 0;
	for (int i = 1; i <= n;i++) {
		
			for (int j = 1; j <= i; j++) {
				if (i%j == 0) {
					total++;
				}
			}
		
			if (total == 8) {
				if(i%2 == 1)
				result++;
			}
		total = 0;
	}
	printf("%d",result);
	


	return 0;
}

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

int main() {
  int N,L;
  cin >> N >> L ;
  vector<string> s(N);
  for(int i=0;i<N;i++){
    cin >> s.at(i);
  }
  sort(s.begin(), s.end());
  string result = "";
  for(int i=0;i<N;i++){
    result += s.at(i);
  }
  cout << result << endl;
  return 0;
}

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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

using mint = modint<(int)1e9+7>;

vector<mint> prod(const vector<mint>& A, const vector<mint>& B){
  int n = A.size();
  vector<mint> ret(n);
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      ret[(i+j)%n] += B[j]*A[i];
    }
  }
  return ret;
}

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  vector<mint> D(N);
  D[0] += 1;
  for(int i = 0; i < M; ++i){
    int p;
    cin >> p;
    // D[((-p)%N+N)%N] += 1;
    D[p%N] += 1;
  }
  vector<mint> ans(N);
  ans[0] += 1;
  // for(int i = 0; i < K; ++i){
  //   ans = prod(ans,D);
  //   for(auto e : ans){
  //     cerr << e << " ";
  //   }
  //   cerr << endl;
  // }
  while(K > 0){
    if(K&1){
      ans = prod(D,ans);
    }
    D = prod(D,D);
    K /= 2;
  }
  for(auto e : ans)
    cout << e << "\n";
}



Measured memory_bytes: 3116
N = int(input())
pn_L = [2, 3, 5] 
for i in range(7, 10000):
    for j in range(2, i):
        if i % j == 0:
            break
    else:
        pn_L.append(i)

pn = 0
for i in range(N):
    n = int(input())
    if n <= 10000:
        if n in pn_L:
            pn += 1
    else:
        sqn = round(n**0.5)
        L = [p for p in pn_L if p <= sqn]
        for j in L:
            if n % j == 0:
                break
        else:
            pn += 1
print(pn)


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

int main(){
  int N;
  cin >> N;
  
  int count=0;
  for(int i=1; i<=N; i++){
    if(i/10000 < 10 && i/10000 >0){
      count++;
      continue;
    }
    else if(i/100 <10 && i/100 >0){
      count++;
      continue;
    }
    else if(i < 10 && i > 0){
      count++;
    }      
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def primes(n):
    is_prime = [1] * (n + 1)
    is_prime[0] = 0
    is_prime[1] = 0
    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] = 0
    return {i for i in range(n + 1) if is_prime[i]}



n = 10 ** 5
prime_set = primes(n)
q = I()
C = [0] * (n + 1)
for i in range(n + 1):
    if i % 2 and i in prime_set and (i + 1) // 2 in prime_set:
        C[i] = 1


acc = list(accumulate(C))
for i in range(q):
    l, r = LI()
    print(acc[r] - acc[l - 1])

Measured memory_bytes: 53152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec(x) vector<x>
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pair<ll,ll>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define ff first
#define ss second
#define mp make_pair
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main()
{
ll n;
cin>>n;
ll a[n];
ld total=0;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    total=total+a[i];
}
ld res=floor(total/n);
ld res1=ceil(total/n);
ll ans=0,ans1=0;
for(ll i=0;i<n;i++)
{
    ans=ans+(res-a[i])*(res-a[i]);
     ans1=ans1+(res1-a[i])*(res1-a[i]);

}
cout<<min(ans,ans1)<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  vector<int> a(n);
  int sum=0;
  rep(i,n){
    cin>>a[i];
    if(i==0)
    sum+=abs(a[i]);
    else
    sum+=abs(a[i]-a[i-1]);
  }
  sum+=abs(a[n-1]);

  rep(i,n){
    int s=sum;
    if(i==0){
      s+=-(abs(a[i])+abs(a[i]-a[i+1]))+abs(a[i+1]);
    }else if(i==n-1){
      s+=-(abs(a[i])+abs(a[i]-a[i-1]))+abs(a[i-1]);
    }else{
      s+=-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1]);
    }
    cout<<s<<endl;
  }


  return 0;

}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int C;
int A[414];
int B[414];
LL dp[414][414];
LL mypow[414][414];
LL L[414][414];

LL Expr(int idx, LL c) {
  return (L[c][B[idx]] + MOD - L[c][A[idx]-1]) % MOD;
}

int main() {
  scanf("%d%d", &N, &C);

  reps(i, 1, N+1) {
    scanf("%d", &A[i]);
  }

  reps(i, 1, N+1) {
    scanf("%d", &B[i]);
  }

  rep(i, 414) {
    mypow[i][0] = 1;
    reps(j, 1, 414) {
      mypow[i][j] = mypow[i][j-1] * i % MOD;
    }
  }

  rep(i, 414) {
    reps(j, 1, 414) {
      L[i][j] = (L[i][j-1] + mypow[j][i]) % MOD;
    }
  }
  
  dp[0][0] = 1;
  reps(i, 1, N+1) {
    rep(c, C+1) {
      rep(k, C+1) {
        if (c+k > C) break;
        dp[i][c+k] += dp[i-1][c] * Expr(i, k) % MOD;
        dp[i][c+k] %= MOD;
      }
    }
  }

  /*reps(i, 1, N+1) {
    rep(c, C+1) {
      printf("%lld ", dp[i][c]);
    }
    puts("");
  }*/

  printf("%lld\n", dp[N][C]);
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
//#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
 
int main(){
   
  int64_t n,ans=0;
  cin>>n;
 
  vector<int> A(n);

  vector<vector<int>> x(n,vector<int>(n));
  vector<vector<int>> y(n,vector<int>(n));
  
  rep(i,n){
      cin>>A.at(i);
      rep(j,A.at(i)){
          cin>>x.at(i).at(j)>>y.at(i).at(j);
      }
  }


 
  for (int tmp = 0; tmp < (1 << (n)); tmp++) {
      bool error = true;

    bitset<16> honest(tmp); 
   // cout<<"honest"<<honest<<endl;
    
 
    // ビット列の1のビットに対応する所だけx、yの条件
   for (int i = 0; i < n; i++) {
      if (honest.test(i)) {
          rep(j,A.at(i)){
              if(!(((honest.test(x.at(i).at(j)-1))&&(y.at(i).at(j)==1))||(!(honest.test(x.at(i).at(j)-1))&&(y.at(i).at(j)==0))))
                  error=false;
          }
      }
      //cout<<error<<endl;
     

   }
    if(error){
          if(ans<=honest.count()) ans=honest.count();
         // cout<<honest.count()<<endl;
      }
   
  }
    cout<<ans<<endl;
}

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


void solve(long long A, long long B){
    if(A > B)swap(A, B);
    if(A == 1 && B == 2){
        cout<<3<<endl;
    }
    if(A == 2 && B == 3){
        cout<<1<<endl;
    }
    if(A == 1 && B == 3){
        cout<<2<<endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		
		for (;;) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0) break;
			System.out.println(a < b ? (a + " " + b) : (b + " " + a));
		}
		
		sc.close();
	}

}

Measured memory_bytes: 36756
X = int(input())
A = -1000
B = -1000
ok = False


for i in range(200):
    for j in range(200):
        if i**5 - j**5 == X:
            A = i
            B = j
            ok = True
        elif i**5 + j**5 == X:
            A = i
            B = -j
            ok = True
        if ok:
            break
    if ok:
        break

print(A, B)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int n,m,arr[100005],ans;
vector<int> v[100005];
int main(){
    cin>>n>>m;
    for(int i =1;i<=n;i++){
        cin>>arr[i];
    }
    while(m--){
        int a,b;
        cin>>a>>b;
        if(v[a].empty())v[a].pb(arr[b]);
        else if(v[a][0]<arr[b]){
            v[a].pop_back();
            v[a].pb(arr[b]);
        }
        if(v[b].empty())v[b].pb(arr[a]);
        else if(v[b][0]<arr[a]){
            v[b].pop_back();
            v[b].pb(arr[a]);
        }
        
    }
    for(int i =1;i<=n;i++){
        // if(!v[i])
        if(v[i].empty())ans++;
        else if(v[i][0]<arr[i])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9064
if __name__ == "__main__":
    bits = [0] * 64

    num_mask = int(input())
    masks = [[] for _ in range(num_mask)]  # type: ignore
    for idx in range(num_mask):
        k, *v = map(lambda x: int(x), input().split())
        for value in v:
            masks[idx].append(value)

    num_query = int(input())
    for _ in range(num_query):
        op, *v = map(lambda x: int(x), input().split())
        if (0 == op):
            if (1 == bits[v[0]]):
                print(1)
            else:
                print(0)
        elif (1 == op):
            for m_idx in masks[v[0]]:
                bits[m_idx] = 1
        elif (2 == op):
            for m_idx in masks[v[0]]:
                bits[m_idx] = 0
        elif (3 == op):
            for m_idx in masks[v[0]]:
                bits[m_idx] = 1 if bits[m_idx] == 0 else 0
        elif (4 == op):
            all_flg = 1
            for m_idx in masks[v[0]]:
                all_flg *= bits[m_idx]
            if all_flg:
                print(1)
            else:
                print(0)
        elif (5 == op):
            any_flg = 0
            for m_idx in masks[v[0]]:
                any_flg += bits[m_idx]
            if any_flg:
                print(1)
            else:
                print(0)
        elif (6 == op):
            none_flg = 0
            for m_idx in masks[v[0]]:
                none_flg += bits[m_idx]
            if not none_flg:
                print(1)
            else:
                print(0)
        elif (7 == op):
            count = 0
            for m_idx in masks[v[0]]:
                count += bits[m_idx]
            print(count)
        else:
            ans = [0] * 64
            for m_idx in masks[v[0]]:
                ans[m_idx] = bits[m_idx]
            bin_str = "".join([str(elem) for elem in ans[::-1]])
            print(f"{int(bin_str, 2)}")



Measured memory_bytes: 5640
#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;

vector<ll>ok;
vector<ll>ng;
vector<P>ans;

void f(){
    if(ng.empty()){
        return;
    }
    ll copy=min(ng.size(),ok.size());
    auto addok=[&](){
        ll c=ok.back();ll d=ng.back();
        ok.pop_back();ng.pop_back();
        ans.push_back({c,d});
        ok.push_back(c-d);
    };
    auto addng=[&](){
        ll c=ok.back();ll d=ng.back();
        ok.pop_back();ng.pop_back();
        ans.push_back({d,c});
        ng.push_back(d-c);
    };
    for (ll i = 0; i < copy; ++i) {
        if(ok.size()>ng.size())addng();
        else addok();
    }
    f();
}

int main(){
    ll n;cin >>n;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    if(a[n-1]<0){
        ok.push_back(a.back());
        a.pop_back();
    }
    reverse(all(a));
    if(a[n-1]>=0){
        ng.push_back(a[n-1]);
        a.pop_back();
    }
    for (auto e:a) {
        if(e>=0)ok.push_back(e);
        if(e<0)ng.push_back(e);
    }
    f();
    cout <<ok[0]<<endl;
    for(auto p:ans){
        cout <<p.first<<" "<<p.second<<endl;
    }
    return 0;
}

Measured memory_bytes: 15912
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;

int main()
{
    int n, sum = 0, k, smin = INT_MAX;
    vector<int> s;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> k;
        s.push_back(k);
        sum += k;
        if(k % 10 != 0) smin = min(smin, k);
    }
    if(sum % 10 != 0) cout << sum << endl;
    else{
        if(smin != INT_MAX) cout << sum - smin << endl;
        else cout << 0 << endl;
    }
    return 0;
}

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

long long nc2(long long n) { return n * (n - 1) / 2; }

void solve(long long N, std::vector<long long> A) {
    vector<long long> Acount(N + 1);
    vector<long long> AComb(N + 1);
    vector<long long> AComb2(N + 1);
    for (long long i = 0; i < N; i++) {
        Acount[A[i]]++;
    }
    // calc combination
    long long sumComb = 0;
    for (long long i = 1; i <= N; i++) {
        if (Acount[i] >= 2) {
            AComb[i] = nc2(Acount[i]);
            AComb2[i] = nc2(Acount[i] - 1);
            sumComb += AComb[i];
        }
    }

    for (long long i = 0; i < N; i++) {
        cout << sumComb - AComb[A[i]] + AComb2[A[i]] << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 8832
#include <iostream>

int main() {
  int h;
  int w;

  while(std::cin >> h >> w) {
    if(h == 0 && w == 0) {
      break;
    }

    int sum;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; ++j) {
        sum = (i + j) % 2;
        if(sum == 0) {
          std::cout << "#";
        }
        else {
          std::cout << ".";
        }
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;

  }

  return 0;
}

Measured memory_bytes: 3048
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {n:String}
    let mut sum = 0;
    if n == "0" {
        println!("Yes");
    } else {
        for i in n.chars() {
            sum += i as i32 - 48;
        }
        if sum % 9 == 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 2392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1 << 30;
// const ll INF = 1LL << 62;
// --------------------------------------------------------


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

    int N; cin >> N;
    VI P(N); REP(i,N) cin >> P[i];
    VI Q(N); REP(i,N) cin >> Q[i];

    VI R(N); iota(ALL(R), 1);
    int i = 1;
    int a = 1, b = 1;
    do {
        if (equal(ALL(P), ALL(R))) a = i;
        if (equal(ALL(Q), ALL(R))) b = i;
        i++;
    } while (next_permutation(ALL(R)));

    int ans = abs(a - b);
    cout << ans << '\n';

    return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;


void solve()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1 + a2 + a3 >= 22) cout << "bust" << endl;
    else if(a1 + a2 + a3 <= 21) cout << "win" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> p(N);
  for(auto& buf : p) { std::cin >> buf; }
  
  int count = 0;
  for(int i = 1; i <= N; ++i) {
    if(i != p[i-1]) { ++count; }
  }
  if(count <= 2) { std::cout << "YES" << std::endl; }
  else { std::cout << "NO" << std::endl; }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

//グラフのテンプレート
template<typename T>
struct edge {
	int from, to;
	T cost;

    edge(int to,T cost):from(0),to(to),cost(cost){}
	edge(int from, int to, T cost) :from(from), to(to), cost(cost) {}
};

template<typename T>
T prim(vector<vector<edge<T>>> &g){//プリム法(最小全域木)
    using P=pair<T,int>;//firstがcost,secondが行き先

    T sum=0;
    vector<bool>used(g.size(),false);
    priority_queue<P,vector<P>,greater<P>>pq;
    pq.emplace(0,0);
    while(!pq.empty()){
        auto p=pq.top();
        pq.pop();
        if(used[p.second])continue;
        used[p.second]=true;
        sum+=p.first;
        for(auto &x: g[p.second]){
            pq.emplace(x.cost,x.to);
        }
    }
    return sum;
}


signed main(){
	int n;
	cin>>n;
	vector<pair<int,int>>x,y;
	vector<vector<edge<int>>>g(n);
	rep(i,n){
		int a,b;
		cin>>a>>b;
		x.eb(a,i);//firstは座標,secondはid
		y.eb(b,i);
	}
	sort(begin(x),end(x));
	sort(begin(y),end(y));
	rep(i,n-1){
		g[x[i].second].eb(x[i+1].second,x[i+1].first-x[i].first);
		g[x[i+1].second].eb(x[i].second,x[i+1].first-x[i].first);
		g[y[i].second].eb(y[i+1].second,y[i+1].first-y[i].first);
		g[y[i+1].second].eb(y[i].second,y[i+1].first-y[i].first);//両方向張る
	}
	cout<<prim(g)<<endl;
	return 0;
}

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


int main()
{
	int h, w;
	
	while (true)
	{
		cin >> h >> w;

		if (h == 0 && w == 0) {
			break;
		}

		for (int i = 0;i < h;i++) {
			for (int j = 0;j < w;j++) {
				if ((i + j) % 2 == 0) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}

			cout << "\n";
		}

		cout << "\n";
	}

    return 0;
}



Measured memory_bytes: 2980
#include<stdio.h>

int main(){
    int i,kazu,judge1,judge2,count;
    int max=0,max1=0,max2=0;
    int x[10];
    
    for(i=0;i<10;i++){
        scanf("%d",&kazu);
        x[i]=kazu;
    }
    
    do{
      count = 0;
      for(i=0; i<9; i++){
         judge1 = x[i];
         judge2 = x[i+1];
          
         if(judge1 < judge2){
            x[i] = judge2;
            x[i+1] = judge1;
            count++;
         }
       
      }
    }while(count != 0);
    
    printf("%d\n",x[0]);
    printf("%d\n",x[1]);
    printf("%d\n",x[2]);
    
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
 
int main(void)
{
  
    int n,x=0,y=0,i,a[100];
      
    scanf("%d",&n);
  
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
  
    for(i=0;i<n;i++){
        if(a[i]%2==0){
          if((a[i]%3==0)||(a[i]%5==0))  x++;
        y++;
        }
    }
  
    if(x==y)  printf("APPROVED\n");
    else      printf("DENIED\n");
  
    return 0;
}  


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


int main() {
    int n, a, b;
    string s;

    cin >> n >> a >> b >> s;

    int taken = 0, foreign = 0;
    for(const char& ch: s) {
        if(ch == 'c') {
            cout << "No\n";
        } else if(ch == 'b') {
            if(foreign < b and taken < a + b) {
                cout << "Yes\n";
                ++taken;
                ++foreign;
            } else {
                cout << "No\n";
            }
        } else {
            if(taken < a + b) {
                cout << "Yes\n";
                ++taken;
            } else {
                cout << "No\n";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int n,k;
  cin>>n>>k;
  if(n%k == 0) cout<<0<<endl;
  else cout<<1<<endl;
  return 0;
}


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

#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(c,x)       ((c).find(x) != (c).end())
#define isp(c,x)      (find(all(c),x) != (c).end())
#define pb             push_back
#define ppb            pop_back
#define sz(x)          (int)x.size()
#define fill(a,v)      memset(a, v, sizeof a)
#define fs first
#define sc second
#define ub upper_bound
#define lb lower_bound
#define en '\n'

typedef long long int lli;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair< int, int > pii;
typedef pair< lli, lli > plli;
typedef list<int> li;
typedef map<int, int> mi;
typedef map<lli, lli> mlli;
lli gcd(lli a,lli b){return (!b)?a:gcd(b,a%b);}
int t = 1; int ti;


const int N = 1e5 + 5;
li adj[N], idj[N];
vi tsrt;
int vis[N], dp[N];

void dfs(int s){
    vis[s] = 1;

    for(auto x:adj[s]){
        if(!vis[x]){
            dfs(x);
        }
    }

    tsrt.pb(s);
}


void solve(){
    int n, m; cin>>n>>m;

    fori(i, 1, m){
        int u, v; cin>>u>>v;

        adj[u].pb(v);
        idj[v].pb(u);
    }

    fori(i, 1, n){
        if(!vis[i]){
            dfs(i);
        }
    }


    reverse(all(tsrt));

    int ans = 0;

    fori(i, 0, sz(tsrt)-1){
        for(auto x:idj[tsrt[i]]){
            dp[tsrt[i]] = max(dp[tsrt[i]], dp[x]+1);
            ans = max(dp[tsrt[i]], ans);
        }

//        cout<<i<<" "<<dp[i]<<"\n";
    }    

    cout<<ans;    
}
//THINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL

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

//    cin>>t;

    for(ti= 1; ti <= t; ti++)
    solve();

//    cout<<"\nTHINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL";
}

Measured memory_bytes: 13052