akhauriyash/Code-Regression huggingface dataset:
N = int(input())
d = {}
max = 0
ans = []

for _ in range(N):
    key = input()
    if not(key in d):
        d[key] = 1
        if max<d[key]:
            max = d[key]
    else:
        d[key] += 1
        if max<d[key]:
            max = d[key]

for key in d:
    if d[key]==max:
        ans.append(key)

ans.sort()

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 32096
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

ll A[1<<20];int N;ll dp[1<<20];

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
cin>>N;
rep(i,N) {
  cin>>A[i];
  if(i == 0) dp[i] = A[i];
  else dp[i] = (dp[i-1] + A[i])%mod;
}
ll ans=0;
for(int i = 1;i < N;i++) {
  ans += A[i]*dp[i-1];
  ans %= mod;
}
cout<<ans;

 return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll N, K, R, S, P; cin >> N >> K >> R >> S >> P;
  string T; cin >> T;
  ll point[N] = {};
  rep(i,N) {
    if (T[i]=='r') point[i] = P;
    else if (T[i]=='s') point[i] = R;
    else if (T[i]=='p') point[i] = S;
    if (i>=K&&T[i]==T[i-K]&&point[i-K]) point[i] = 0;
  }
  ll result = 0; rep(i,N) result += point[i];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1280
import sys,itertools
ans = ['xxx      ','   xxx   ','      xxx','x  x  x  ',' x  x  x ','  x  x  x','x   x   x','  x x x  ']
for s in sys.stdin:
	s = s.strip()
	o = [True if c == 'o' else False for c in s]
	x = [True if c == 'x' else False for c in s]
	o = list(itertools.repeat(0,len(ans)))
	x = list(itertools.repeat(0,len(ans)))
	out = 'd'
	for i,j in itertools.product(xrange(len(ans)),xrange(len(ans[0]))):
		if ans[i][j] == 'x':
			if s[j] == 'o':
				o[i] = o[i] + 1
			if s[j] == 'x':
				x[i] = x[i] + 1
	if 3 in o:
		print 'o'
	elif 3 in x:
		print 'x'
	else:
		print 'd'

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

int main() {
  int N, Y;
  scanf("%d %d",&N,&Y);
  int x, y;
  for (int x=0; x<=N; x++) {
    for (int y=0; (x+y)<=N; y++) {
      int z=(N-x-y);
      if ((10000*x+5000*y+1000*z)==Y) {
        printf("%d %d %d\n",x,y,z);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  while(true)
  {
    int r;
    int n;
    cin >> r >> n;
    if(r + n == 0) break;
    int h[42] = {0};
    for(int i = 0;i<n;i++)
    {
      int l,r,hi;
      cin >> l >> r>> hi;
      for(int j = l+1 ; j <= r;j++)
      {
        chmax(h[j+20],hi);
      }
    }
    double t_min = 1e9;
    for(int i = 0;i<41;i++)
    {
      if(r * r - (i-20)*(i-20) <=0) continue;
      if(h[i+1] > h[i]) 
      {
        double tmp = h[i]-sqrt(r * r - (i-20)*(i-20)) +r;
        chmin<double>(t_min,tmp);
      }
      

      if(h[i+1] < h[i]) 
      {
        double tmp = h[i+1]-sqrt(r * r - (i-20)*(i-20)) +r;
        chmin<double>(t_min,tmp);
      }

    }
    chmin<double>(t_min,min(h[20],h[21]));
    cout << t_min << endl;
  }
  
  
}


Measured memory_bytes: 3244
time = 0
n, q = map(int, input().split())
qname = list(range(n))
qtime = list(range(n))
ename = []
etime = []
for i in range(n):
    inp = input().split()
    qname[i], qtime[i] = inp[0], int(inp[1])
while len(qtime) > 0:
    if qtime[0] <= q:
        time += qtime.pop(0)
        ename.append(qname.pop(0))
        etime.append(time)
    else:
        time += q
        qname.append(qname.pop(0))
        qtime.append(qtime.pop(0)-q)
for (a, b) in zip(ename, etime):
    print(a, b)

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 N, M, V, P;
  cin >> N >> M >> V >> P;
  vector<int64> A(N), sumA(N+1, 0);
  REP(i, N) cin >> A[i];
  sort(all(A));
  REP(i, N) sumA[i+1] += sumA[i] + A[i];
  int64 res = P, sum = 0;
  REP(i, N-P) {
    if (A[N-P] <= A[i]) {
      res++;
      continue;
    }
    int64 AA = A[i] + M;
    int64 X = A.end() - upper_bound(all(A), AA);
    int64 r1 = upper_bound(all(A), A[i])-A.begin(), r2 = lower_bound(all(A), AA)-A.begin();
    int64 r3 = min(r1, N-P), r4 = min(r2, N-P);
    int64 rest = r3*M + (r4-r3)*(AA) - (sumA[r4]-sumA[r3]);
    if (A[N-P] > A[i]) {
      rest -= M - max((int64)0, AA-A[N-P]);
    }
    if (X < P && (V <= P || (V-P)*M <= rest)) { //      cout << i << endl;
      res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<stdlib.h>



int main(){
  int n;
  int *A,*B;
  int C[10001]={};
  int i,j;

  scanf("%d",&n);
  A=malloc(n*sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&A[i]);//読み込み完了
  
  for(i=0;i<n;i++) C[A[i]]+=1;//C[k]はkが登場する回数を表す。
  for(i=1;i<=10000;i++) C[i]+=C[i-1];//C[k]はk以下の数字の個数を表す
  
  B=malloc((n+1)*sizeof(int));
  for(i=n-1;i>=0;i--){
    B[C[A[i]]]=A[i];
    C[A[i]]-=1;
  }
  
  printf("%d",B[1]);
  for(i=2;i<=n;i++) printf(" %d",B[i]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 17416
#include<bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ED(x) ((int)x.size()-1)
#define _for(i,a,b) for(int i=(a);i<=(b);++i)
#define _rep(i,a,b) for(int i=(a);i>=(b);--i)
#define changxv ios::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int maxn=3003;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;

int f[maxn][maxn];
int s[maxn],r[maxn];

int main(){changxv
	int n,m;cin>>n>>m;
	_for(i,1,n){
		char c;cin>>c;
		s[i]=s[i-1]+c-'0';
	}
	s[n+1]=s[n];
//	_for(i,1,n)cerr<<s[i]<<' ';
//	cerr<<'\n';
	_for(i,1,n+1)r[i]=i;
	_for(i,1,m){
		int x,y;cin>>x>>y;
		r[x]=max(r[x],y);
	}
	_for(i,1,n+1)r[i]=max(r[i],r[i-1]);
	
	f[1][s[r[1]]]=1;
	_for(i,1,n){
		_for(j,0,n)if(f[i][j]){
			int L=r[i]+1,R=r[i+1];
			if(j)(f[i+1][j-1+s[R]-s[L-1]]+=f[i][j])%=mod;
			if(r[i]-i+1-j)(f[i+1][j+s[R]-s[L-1]]+=f[i][j])%=mod;
		}
	}
	cout<<f[n+1][0]<<'\n';
return 0; }

Measured memory_bytes: 33920
#include "iostream"
#include "iomanip"
using namespace std;

int main()
{
	bool anotherWay = 0;
	double Smax;
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	double S = w * h;
	Smax = S / 2;
	cout << fixed << setprecision(9) << Smax << " ";
	if (x == w / 2 && y == h / 2)
	{
		anotherWay = 1;
	}
	cout << anotherWay << endl;
}

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


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

    ll sum=0;

    rep(i,n) {
        if ((i % 3 != 0) && (i%5 != 0)) {
            sum += i;
        }
    }

    cout << sum << endl;




    return 0;
}



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

int main(){
  int year(4);
  char a;
  int month(2);
  char b;
  int day(2);
  cin >>year >>a >>month >>b >>day;
  if(month > 4){
    cout<<"TBD"<<endl;
  }else{
    cout<<"Heisei"<<endl;
  }
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int N=105;
int a[N],ans[N],n;
int main(){
//	freopen("testdata.in","r",stdin);
	n=read();
	fp(i,1,n)a[i]=read();
	fd(i,n,1){
		bool flag=0;
		fd(j,i,1)if(a[j]==j){
			ans[i]=j,flag=1;
			fp(k,j,i-1)a[k]=a[k+1];
			break;
		}
		if(!flag)return puts("-1"),0;
//		fp(j,1,i-1)printf("%d%c",a[j]," \n"[j==i-1]);
	}
	fp(i,1,n)print(ans[i]);
	return Ot(),0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using pll = pair<LL, LL>;


int main()
{
    const char alphabet[27] = "abcdefghijklmnopqrstuvwxyz";
    
    cin.sync_with_stdio(0);

    LL N;
    cin >> N;

    string res;
    while (N)
    {
        res += alphabet[(N - 1) % 26];
        N = N / 26 - (N % 26 == 0);
    }

    reverse(begin(res), end(res));
    cout << res;
}

Measured memory_bytes: 3640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;
int main() {
	cin >> s;
	if (s.size() == 1) {
		cout << s << endl;
		return 0;
	}
	int sum = 0;
	for (int i = s.size() - 1; i > 0; i--) {
		if (s[i] != '9')break;
		sum += s[i] - '0';
		if (i == 1) {
			cout << sum+s[0]-'0' << endl;
			return 0;
		}
	}
	int ans = (s[0]-'0')-1;
	REP(i, s.size()) {
		if (i)ans += 9;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef struct{
	int	P;
	int	Y;
	int	NUM;
	int ID1;
	int ID2;
}City;

int cmp_Y( const void *p, const void *q ) {
    return ((City*)p)->Y - ((City*)q)->Y;
}
int cmp_NUM( const void *p, const void *q ) {
    return ((City*)p)->NUM - ((City*)q)->NUM;
}

int main(void){
	int N,M;
	int i,j;
	int Numberofoccurrences[100001]={};
	scanf("%d %d",&N,&M);
	City city[M];
	for(i=0;i<M;i++){
		scanf("%d %d",&city[i].P,&city[i].Y);
		city[i].NUM=i+1;
	}
	int n = sizeof city / sizeof( City );
	qsort( city, n, sizeof(City), cmp_Y );
	/*
	for(i=0;i<M;i++){
		printf("%d %d %d\n",city[i].P,city[i].Y,city[i].NUM);
	} 
	*/
	/*
	Y[i]についてソートして識別番号を作ったのちに
	NUM[i]についてソートして元の順番に戻せばOK
	*/
	for(i=0;i<M;i++){
		Numberofoccurrences[city[i].P]++;
		city[i].ID1 = city[i].P;
		city[i].ID2 = Numberofoccurrences[city[i].P];
	}
	qsort( city, n, sizeof(City), cmp_NUM );
	
	for(i=0;i<M;i++){
		printf("%06d",city[i].ID1);
		printf("%06d",city[i].ID2);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 5736
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
  long double a, b, x;
  cin >> a >> b >> x;

  long double theta;

  if(2*x/(a*b) <= a){
    theta = atan(a*b*b/(2.0*x));
  }else{
    theta = atan(2*(b-x/(a*a))/a);
  }

  cout << setprecision(10) << theta * 180.0 / M_PI << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    getline(cin,a);
    int letters[26],i,flag=0;
    for(i=0;i<26;i++)
      letters[i]=0;

    for(i=0;a[i];i++)
       letters[a[i]-'a']++;
    for(i=0;i<26;i++)
       if(letters[i]%2==1){
          flag=1;
          break;
       }
    if(flag)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

vector<vector<int>> graph(100001,vector<int>());

int main(){
  string s;cin >> s;
  string ans = "Yes";
  for(int i = 0;i<s.size();i++){
    if(i%2 == 1 && s.at(i) == 'R') ans = "No";
    else if(i%2==0 && s.at(i)=='L') ans ="No"; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
using namespace std;

#define N_MAX   (100000)

typedef long long ll;

int main()
{
    // 整数の入力
    int N;
    int result = 0;
    vector<int> A1, A2;
    cin >> N ;
    int num;
    for (int i = 0; i < N; i++) {
        cin >> num;
        A1.push_back(num);
        
    }
    for (int i = 0; i < N; i++) {
        cin >> num;
        A2.push_back(num);
    }

    for (int i = 0; i < N; i++) {
        int restmp = accumulate(&A1[0], &A1[i+1], 0) + accumulate(&A2[i], &A2[N], 0);
        if (result < restmp) {
            result = restmp;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<int> a(N), b(N);
    priority_queue<ll> sei;
    ll fu = 0;


    rep(i, 0, N) {
        cin >> a[i];
    }
    rep(i, 0, N) {
        cin >> b[i];
    }

    rep(i, 0, N) {
        if (b[i] - a[i] > 0) {
            sei.emplace(abs(b[i] - a[i]));
        } else {
            fu += 1LL * abs(b[i] - a[i]);
        }
    }
    ll gomi = 0LL;
    while (!sei.empty() && fu > 0) {
        ll tmp = sei.top();
        sei.pop();
        ll hiku = min(fu,tmp / 2);
        tmp -= hiku * 2;
        fu -= hiku;

        if(tmp <= 1) gomi++;
        else sei.push(tmp);
    }

    if(fu == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
void solve() {
	set<int> s;
	int x;
	forn(i, 3) cin >> x, s.insert(x);
	if(sz(s) == 2) cout << "Yes";
	else cout << "No";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 256
import math
x = int(input())
ans = x//11
ans2 = x%11
if x <= 6:
    print(1)
elif x<=11:
    print(2)
else:
    if x%11 == 0:
        print(ans*2)
    else:
        if ans2 > 6:
            print(ans*2+2)
        else:
            print(ans*2+1)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>
int stack[1000];
int n = 0;
int pop(){
	n --;
	return stack[n+1];
}
void push(int m){
	stack[++ n] = m;
	return ;
}
int main(void){
	char ch, input[100];
	int i = 0, len, tem1, tem2;
	while(scanf("%s", input) != EOF){
			if(input[0] == '+'){
				tem2 = pop();
				tem1 = pop();
				push(tem1 + tem2);
			}
				
			else if(input[0] == '*'){
				tem2 = pop();
				tem1 = pop();
				push(tem1 * tem2);
			}
			else if(input[0] == '-'){
				tem2 = pop();
				tem1 = pop();
				push(tem1 - tem2);
			}
			else{
				push(atoi(input));
			}	
	}
	printf("%d\n", pop());
	return 0;
}


Measured memory_bytes: 2100
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long max = (long) Math.pow(10, 18);

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            if (a[i] == 0) {
                a[0] = 0; break;
            }
        }
        long ans = a[0];

        for (int i = 1; i < n; i++) {
            if(ans==0) break;
            if (max / ans < a[i]){
                ans= -1; break;
            } 
            ans*=a[i];
        }
        System.out.println(ans);
    }
}

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

typedef long long LL;
typedef pair<LL,LL> pll;

pll add(const pll &a, const pll &b){
	return pll(a.first + b.first, a.second + b.second);
}

pll sub(const pll &a, const pll &b){
	return pll(a.first - b.first, a.second - b.second);
}

pll mul(LL t, const pll &a){
	return pll(a.first * t, a.second * t);
}

LL cross(const pll &a, const pll &b){
	return a.first * b.second - b.first * a.second;
}

LL div(const pll &a, const pll &b){
	if(b.first != 0){ return a.first / b.first; }
	return a.second / b.second;
}

vector<pll> input(int n){
	vector<pll> pts(n);
	for(int i = 0; i < n; ++i){
		cin >> pts[i].first >> pts[i].second;
	}
	rotate(pts.begin(), min_element(pts.begin(), pts.end()), pts.end());

	vector<pll> vec(n);
	for(int i = 0; i < n; ++i){
		vec[i] = sub(pts[i + 1], pts[i]);
	}
	vec[n - 1] = sub(pts[0], pts[n - 1]);
	return vec;
}

LL area(const vector<pll> &v){
	int n = v.size();
	pll p;
	LL s = 0;
	for(int i = 0; i < n; ++i){
		pll q = add(p, v[i]);
		s += cross(p, q);
		p = q;
	}
	return s;
}

int main(){
	int n, m;
	while(cin >> n >> m && n){
		vector<pll> v1 = input(n);
		vector<pll> v2 = input(m);
		if(area(v1) > area(v2)){ v1.swap(v2); }
		vector<int> idxs;
		while(true){
			int s1 = v1.size(), s2 = v2.size();
			idxs.assign(s1, -1);
			int j = 0;
			LL u = 1LL << 50;
			for(int i = 0; i < s1; ++i){
				for(; j < s2; ++j){
					if(cross(v1[i], v2[j]) == 0){ break; }
				}
				if(j >= s2){
					u = 0;
					break;
				}
				idxs[i] = j;
				LL t = div(v2[j], v1[i]);
				u = min(t, u);
				++j;
			}
			if(u <= 0){ break; }
			for(int i = 0; i < s1; ++i){
				int k = idxs[i];
				v2[k] = sub(v2[k], mul(u, v1[i]));
			}
			v2.erase(remove(v2.begin(), v2.end(), pll()), v2.end());
			v1.swap(v2);
		}
		LL a1 = area(v1);
		LL a2 = area(v2);
		cout << (a1 + a2) << endl;
	}
}



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

int main(){
  int n;
  char c;
  string text;
  cin>>n;
  getline(cin,text,'\n');
  for(;n>0;n--){
    getline(cin,text,'\n');
    while(text.find("Hoshino")!=-1){
      int f = text.find("Hoshino");
      text = text.substr(0,f)+"Hoshina"+text.substr(f+7);
    }
    cout<<text<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var param = ReadLine().Split(' ').Select(int.Parse).ToArray();
    var n = param[0];
    var a = param[1];
    var b = param[2];
    var c = param[3];
    var d = param[4];
    var s = ReadLine();

    var isPossible = false;
    if(b < c && c < d)
    {
      if(!s.Substring(a - 1, d - a + 1).Contains("##"))
      {
        isPossible = true;
      }
    }
    else if(c < b)
    {
      if(!s.Substring(a-1, c - a + 1).Contains("##")
        && !s.Substring(b-1, d - b + 1).Contains("##"))
      {
        isPossible = true;
      }
    }
    else
    {
      if(s.Substring(b-2, d - b + 3).Contains("...")
        && !s.Substring(a-1, c - a + 1).Contains("##"))
      {
        isPossible = true;
      }
    }

    var ans = isPossible ? "Yes" : "No";
    WriteLine(ans);
  }
}

Measured memory_bytes: 13920
A = int(input())
B = int(input())
C = int(input())
X = int(input())

a = X // 500
count = 0
i = 0
while (i <= a and i <= A):
  b = ( X-500*i ) // 100
  j = 0
  while (j <= b and j <= B):
    c = ( X-500*i-100*j ) // 50
    if ((X-500*i-100*j-50*c)==0 and c <= C):
      count += 1
    j += 1
  i += 1
print(count)

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

int N,A[100010];
int sum[110] = {0};

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%d",A + i),sum[A[i]]++;
    sort(A,A + N);

    int MAX = A[N - 1];
    for(int i = MAX; i > MAX / 2; i--)
    {
        if(sum[i] < 2)
        {
            printf("Impossible\n");
            return 0;
        }
        sum[i] -= 2;
    }
    if(MAX % 2 == 0)
    {
        if(sum[MAX / 2] == 0)
        {
            printf("Impossible");
            return 0;
        }
        sum[MAX / 2] -= 1;
    }

    for(int i = 0; i < N; i++)
    {
        if(A[i] <= (MAX + 1) / 2 && sum[A[i]] != 0)
        {
            printf("Impossible\n");
            return 0;
        }
    }
    printf("Possible\n");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int num,i,j,a[100],count=0,min,n,x=0;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<num;i++){
    min=a[i];
    for(j=num-1;j>i-1;j--){
      if(min>=a[j]){
	min=a[j];
	x=j;
      }
    }
    if(a[i]>a[x]){
      n=a[i];
      a[i]=a[x];
      a[x]=n;
      count+=1;
    }
    
  }
  for ( i=0; i<num; i++){
    if(i!=num-1) printf("%d ",a[i]);
    else printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}

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

ll gcd(ll m, ll n) {
  if(m < n) swap(m, n);
  if(n == 0) return abs(m);
  else return gcd(n, m % n);
}

int main() {
  ll A, B; cin >> A >> B;
  ll x = gcd(A, B);
  ll ans = 0;
  for(int i = 2; i <= sqrt(x); i++) {
    if(x % i == 0) {
      while(x % i == 0) {
        x /= i;
      }
      ans++;
    }
  }
  if(x != 1) ans++;
  cout << ans + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#define INF 1<<28
using namespace std;

int p[1111111];
int memo[1111111];
int memo2[1111111];

int solve(int n){
  
  if(!n) return 0;
  if(~memo[n]) return memo[n];

  int ans = INF;
  for(int i=199;i>0;i--) if(n >= p[i]) ans = min(ans, solve(n-p[i])+1);
  
  return memo[n] = ans;
}

int solve2(int n){
  
  if(!n) return 0;
  if(~memo2[n]) return memo2[n];

  int ans = INF;
  for(int i=199;i>0;i--) if(p[i]&1 && n >= p[i]) ans = min(ans, solve2(n-p[i])+1);

  return memo2[n] = ans;
}

int main(){
  
  int n;
  
  memset(memo, -1, sizeof(memo));
  memset(memo2, -1, sizeof(memo2));

  for(int i=0;i<200;i++) p[i] = i*(i+1)*(i+2)/6;
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;

}

Measured memory_bytes: 11400
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	
	int x[10],y[10] ;
	for(int i=0;i<n;i++) {
		cin >> x[i] >> y[i] ;
	}
	double f[10][10] ;
	double s=0 ;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++)
			f[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
	}
	for(int i=0;i<n-1;i++) {
		for(int j=i+1;j<n;j++) 
			s+=f[i][j] ;
	}
	printf("%.6f",s*2/n) ;
	return 0;
} 

Measured memory_bytes: 256
using System;
//using System.Linq;

class Program
{
    static void Main()
    {
        string[] s_data = Console.ReadLine().Split(' ');
        if ((int.Parse(s_data[0]) * int.Parse(s_data[1])) % 2 == 0) Console.WriteLine("Even");
        else Console.WriteLine("Odd");
    }
}

Measured memory_bytes: 11092
import sys
h,w=map(int,input().split())
ss=[list(input()) for i in range(h)]
num=0
for i in range(h):
    num+=ss[i].count('.')

visited=[[0 for i in range(w)] for j in range(h)]
queue=[]
queue.append([0,0])
ss[0][0]='fin'
dy=[1,0,-1,0]
dx=[0,1,0,-1]


while len(queue)>0:
    now=queue.pop(0)
    for i in range(4):
        x= now[1]+dx[i]
        y= now[0]+dy[i]
        if 0<=x<w and 0<=y<h :
            if ss[y][x]=='.' and visited[y][x]==0:
                visited[y][x]=visited[now[0]][now[1]]+1
                queue.append([y,x])
            if x==w-1 and y==h-1:
                print(num-visited[y][x]-1)
                sys.exit()
print(-1)


Measured memory_bytes: 9288
from collections import deque
N = int(input())
A = [list(map(int, input().split())) for _ in range(N-1)]

T = [[] for _ in range(N)]
for i in range(N-1):
    u, v = A[i][0] - 1, A[i][1] - 1
    d = A[i][2] % 2 
    T[u].append([v, d])
    T[v].append([u, d])

visited = [True] + [False] * (N-1)
ans = [0] * N
que = deque([0]) 
while len(que) > 0:
    q = que.popleft()
    for v, d in T[q]:
        if visited[v]:
            pass
        else:
            que.append(v)
            visited[v] = True
            ans[v] = (ans[q] + d) % 2
            
for a in ans:
    print(a)

Measured memory_bytes: 66780
#include <stdio.h>
#include <math.h>

int main(int argc,char* argv[]){
  
  for(;;){
    int n,i;
    double rad,x,y;
    scanf("%d",&n);
    if(n == -1){break;}
    

    x = y = 1.0;
    rad = M_PI/4;
    for(i = 0; i < (n-2); i++){
      x += cos(rad + M_PI/2);
      y += sin(rad + M_PI/2);
      rad = atan2(y,x);
    }

    printf("%.2lf\n%.2lf\n",x,y);
  }
  
  return 0;
  
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n,K,mod,f[310][310][310];
//f[i][j][k] means we're inserting i,at time j,the len before inserting is k
//we may assume that when we insert a smaller number,it can only be inserted before a strictly bigger number
//for example:the current sequence is
//2
//2 3
//then when we insert first 1,it could be like this:
//2
//2 1
//2 1 3
//when we insert the second one into the third sequence,it can only be inserted before 3 and 2,but not 1 
//2
//2 1 3
//2 1 1(new) 3
inline int add(int a,int b)
{
	if((a+=b)>=mod)a-=mod;
	return a;
}
inline int mult(int a,int b)
{
	long long t=1ll*a*b;
	if(t>=mod)t%=mod;
	return t;
}
int main()
{
	scanf("%d%d%d",&n,&K,&mod);
	f[K+1][0][0]=1;
	for(int i=K;i>=1;i--)//inserting numbers from the bigger ones to smaller ones
	{
		for(int k=0;k<=n;k++)f[i][k][k]=f[i+1][0][k];
		for(int j=n;j>=0;j--)//insert line number
		//caculating reversely can avoid the line number changes before the insertion,and we don't need to care what we insert before it
		{
			for(int k=j;k<=n;k++)
			{
				if(j)f[i][j-1][k]=add(f[i][j-1][k],f[i][j][k]);//do not insert anymore
				f[i][j][k+1]=add(f[i][j][k+1],mult(f[i][j][k],j+1));//insert a new number and the line id would not change
			}
		}
	}
	printf("%d\n",f[1][0][n]);
	return 0;
}

Measured memory_bytes: 114560
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=51;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
ll int power(ll int a,int b)
{
    ll int ans=1,f=a;
    while(b)
    {
        if(b&1) ans=(ans*f);
        f=(f*f);
        b=b>>1;
    }
    return ans;
}
vector<pair<int,int> > v[mex];
int tr[51];
int pth[21][51];
map<pair<int,int>,int> mp;
void dfs(int n,int p,int vi,int j)
{
    //cout<<n<<endl;
    if(p!=0)
    {
      //  cout<<v[p][n].se<<endl;
        tr[mp[{p,n}]]=1;
    }
    if(n==vi)
    {
        fo(i,0,50)
        pth[j][i]=tr[i];
    }
   
    fo(i,0,sz(v[n]))
    if(v[n][i].fi!=p)
    dfs(v[n][i].fi,n,vi,j);
    
    if(p!=0)
    tr[mp[{p,n}]]=0;
}
int main()
{
   int n;
   cin>>n;
   fo(i,0,n-1)
   {
       int l,r;
       cin>>l>>r;
       //cout<<i<<endl;
       v[l].pb({r,i});
       v[r].pb({l,i});
       mp[{l,r}]=i;
       mp[{r,l}]=i;
   }
  //cout<<v[3][2].se<<endl;
   int m;
   cin>>m;
   fo(i,0,m)
   {
       int u,vi;
       cin>>u>>vi;
       dfs(u,0,vi,i);
   }
   ll int pth2[m];
   fo(i,0,m)
   {
       ll int ans=0;
       fo(j,0,n-1)
       if(pth[i][j]==1) ans+=(1ll<<j); 
       pth2[i]=ans;
   }
   
   ll int ans2=0;
   for(int i=1;i<(1<<m);i++)
   {
       ll int ans=0,cnt=0,cnt2=0;
       fo(j,0,m)
       {
           if((i>>j)&1)
           {
               cnt++;
               ans=ans|pth2[j];
           }
       }
      // cout<<ans<<" ";
       while(ans)
       {
           if(ans&1) cnt2++;
           ans=ans>>1;
       }
       cnt2=n-1-cnt2;
      // cout<<i<<" "<<cnt2<<endl;
       if(cnt%2==0)
       ans2=(ans2-power(2,cnt2));
       else ans2=(ans2+power(2,cnt2));
   }
   //cout<<ans2<<endl;
   ans2=(power(2,n-1)-ans2);
   cout<<ans2;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    string S,T;
    cin >> S >> T;
    int Slen,Tlen;
    Slen = S.length();
    Tlen = T.length();
    if(Tlen-Slen == 1){
        for(int i=0;i<Slen;i++){
            if(S[i] != T[i]){
                goto error;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
error:
    cout << "No" << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; } 
 
// Debug //
 
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
// Constants //
 
 
/*** Template Ends ***/
ll n,k;
std::vector<ll> h(100005),cache(100005,-1);
ll cost(ll n)
{
  if(n==1)
    return 0;
  // if(n==2)
  //   return abs(h[2]-h[1]);
  if(cache[n]!=-1)
    return cache[n];
  ll i;
  cache[n]=INT_MAX;
  for(i=n-1;i>=max(n-k,1LL);i--)
    cache[n] = min(abs(h[n]-h[i])+cost(i),cache[n]);
  return cache[n];
}
void solve()
{
  cin>>n>>k;
  ll i=0;

  for(i=1;i<=n;i++)
    cin>>h[i];
  if(n==1)
    cout<<0;
  else
    cout<<cost(n);
}
 
int main(){ 
  ios;
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
 
  return 0;
}

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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
//#define int long long
#define INF 1e18
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, pair<T1, T2> P)
{
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream &operator<<(ostream &s, vector<T> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        if (i > 0)
        {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream &operator<<(ostream &s, vector<vector<T>> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        s << endl
          << P[i];
    }
    return s << endl;
}
template <class T>
ostream &operator<<(ostream &s, set<T> P)
{
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, map<T1, T2> P)
{
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
template <class T>
void show(vector<T> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}
typedef long long ll;
int p[10], q[10];
int main()
{
    int n;
    cin>>n;
    REP(i, n)
        cin >> p[i];
    REP(i, n)
        cin >> q[i];

    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        a[i] = i+1;
    }
    int x, y;
    int cnt = 0;
    do
    {
        cnt++;
        bool ok1 = true;
        bool ok2 = true;
      //  show(a);
        for (int i = 0; i < n; i++)
        {
            if(p[i]!=a[i]){
                ok1 = false;
            }
            if(q[i]!=a[i]){
                ok2 = false;
            }
        }
        if(ok1)
            x = cnt;
        if(ok2)
            y = cnt;

    } while (next_permutation(ALL(a)));
    cout << abs(x - y) << endl;
   // cerr << x << y << endl;
    //cerr << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

bool E[200010];
int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> V;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (a > b) swap(a, b);
		if (a == 0) V.push_back(b);
		if (b == N - 1) E[a] = true;
	}
	for (int A : V) {
		if (E[A]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 4028
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int n = input[0];
        int d = input[1];
        int[,] x = new int[n, d];
        int[] tmp;
        for (int i = 0; i < n; i++)
        {
            tmp = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            for (int j = 0; j < d; j++)
            {
                x[i, j] = tmp[j];
            }
        }
        int ans = 0;
        double sum;
        for (int i = 0; i < n - 1; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                sum = 0.0;
                for (int k = 0; k < d; k++)
                {
                    sum += Math.Pow(Math.Abs(x[i, k] - x[j, k]), 2);
                }
                if (Math.Sqrt(sum) % 1 == 0)
                    ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
		using namespace std;
		#define int long long int
		#define loop(i,a,b) for(int i=a;i<b;i++)
		#define scan(arr,n) for (int i = 0; i < n; ++i) cin >> arr[i]
		#define vi vector<int>
		#define si set<int>
		#define pii pair <int, int>
		#define sii set<pii>
		#define vii vector<pii>
		#define mii map <int, int>
		#define pb push_back
		#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
		//Constants
		const int MOD = 1000000007; /* 1e9 + 7*/
		const int MAXN = 1000005; /*1e6 +5 */
		 
		int spf[1000009]; // stores the smallest prime factor of a number
		 
		void sieve()
		{
		spf[1] = 1;
			for (int i=2; i<MAXN; i++)
				spf[i] = i;
			for (int i=4; i<MAXN; i+=2)
				spf[i] = 2;
		 
			for (int i=3; i*i<MAXN; i++)
				if (spf[i] == i)
				{
					for (int j=i*i; j<MAXN; j+=i)
						if (spf[j]==j)
							spf[j] = i;
				}
			}
		
		 
		/* Iterative Function to calculate (x^y)%p in O(log y) */
		int power(int x,  int y, int p)
		{
			int res = 1;     // Initialize result
			x = x % p; // Update x if it is more than or
						// equal to p 
			if (x == 0) return 0; // In case x is divisible by p;     
			while (y > 0)
			{
				// If y is odd, multiply x with result
				if (y & 1)
					res = (res*x) % p;     
				// y must be even now
				y = y>>1; // y = y/2
				x = (x*x) % p;
			}
			return res;
		}
		
		 
		void solve()
		{
			int n;cin>>n;
			int arr[n];
			scan(arr,n);
			int maxm=arr[0],s=0;
			loop(i,1,n)
			{
				if(arr[i]<maxm)
				{
					s=s+abs(maxm-arr[i]);
				}
				else
				maxm=arr[i];
			}
			cout<<s<<endl;
		}

		 
		int32_t main()
		{
			faster;
			/*sieve();*/
		   // compute();
		  // int t;cin>>t;
		 int t=1;
			while(t--)
			solve();
		 
		 
			return 0;
		}


Measured memory_bytes: 5208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<numeric>
using namespace std;

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

int main()
{
    int K;
    long long a=0,b=0;
    cin>>K;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            a=gcd(i,j);
            for(int k=1;k<=K;k++){
                b+=gcd(a,k);
            }
        }
    }
    cout<<b<<endl;
}

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

using namespace std;
int v[200004];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        int x;
        cin>>x;
        v[x]++;
    }
    for(int i=1;i<=n;i++){
        cout<<v[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 4320
#include<bits/stdc++.h>
using namespace std;
#define pb push_back 
#define in long long
#define inf INT_MAX

int main()
{
   
in n; cin>>n; in a[n];
for(in i=0;i<n;i++) {cin>>a[i];}
in dp[n][n];

for(in i=n-1;i>=0;i--)
{
    for(in j=i;j<n;j++)
    {
        if(i==j) dp[i][j]=a[i];
        else
        {
            dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
        }
    }
}
in x=dp[0][n-1];
cout<<x;
return 0;
}


Measured memory_bytes: 46464
import java.util.Scanner;
public class Main {
	private Scanner sc;
	private void run () {
		
		sc = new Scanner( System.in );
		while( true ) {
			int n = sc.nextInt();
			if( n == 0 ) { return; }
			int m = sc.nextInt();
			String s = sc.next();
			char[] cs = s.toCharArray();
			int[] ioib = new int[ m ];
			for( int i = 0; i < m; i++ ) {
				ioib[ i ] = -1;
			}
			int ioin = 0;
			for( int i = m - 1; i >= 0; i-- ) {
				if( cs[ i ] == 'I' ) {
					if( i != m - 1 && cs[ i + 1 ] == 'O') {
						ioib[ i ] = ioin;
					} else {
						ioib[ i ] = 0;
						ioin = 0;
					}
				} else { // 'O'
					if( i != m - 1 && cs[ i + 1 ] == 'I') {
						ioin++;
					} else {
						ioin = 0;
					}
				}
			}
			int counter = 0;
			
			for( int i = 0; i < m; i++ ) {
				if( ioib[ i ] >= n ) {
					counter++;
				}
			}
			System.out.println( counter );
			
		}
		
	}
	
	public static void main( String[] args ) {
		new Main().run();
	}
}

Measured memory_bytes: 36948
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE BangPatterns #-}
module Main where
import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import qualified Data.Vector.Generic           as VG
import qualified Data.Vector.Generic.Mutable   as VGM
import           Data.Ratio
import           Data.Int
import           Data.Map.Strict            ( Map )
import qualified Data.Map.Strict           as Map
import           Data.Maybe
import           Data.Tuple
import Prelude hiding ((^))

main :: IO ()
main = do
  n <- readLn @ Int
  abs <- V.replicateM n $ (\[x, y] -> (x, y)) . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let abs' = V.map f abs
  let zeros = V.length $ V.filter isNothing abs'
  let h = Map.fromListWith (+) [ (x, toM 1) | Just x <- V.toList abs']
  print $ unM $ go h 1 - 1 + fromIntegral zeros
 where
  go h ans
    | Map.null h = ans
    | otherwise =
      let
        ((r, c), h') = Map.deleteFindMin h
        r' = (\(x, y) -> (y, -x)) r
      in case h' Map.!? r' of
        Nothing -> go h' (2^c * ans)
        Just c' -> go (Map.delete r' h') ((2^c-1 + 2^c'-1 + 1) * ans)

f :: (Int, Int) -> Maybe (Int, Int)
f (0, 0) = Nothing
f (x, y) = if y < 0 || (y == 0 && x < 0)
  then Just (-x', -y') 
  else Just (x', y')
  where
    g = gcd x y
    x' = x `div` g
    y' = y `div` g

-- DO NOT use constructor directry, instead: toM 
newtype MInt = M { unM :: Int64 } deriving (Show, Eq, Ord)

modNum :: Int64
modNum = 1000000007

toM :: Int64 -> MInt
toM a = M (a `mod` modNum)

instance Enum MInt where
  toEnum a = M (toEnum a)
  fromEnum a = fromEnum (unM a)

instance Num MInt where
  a + b = toM (unM a + unM b)
  a - b = toM (unM a - unM b + modNum)
  a * b = toM (unM a * unM b)
  abs a = toM (abs (unM a))
  signum a = toM (signum (unM a))
  fromInteger a = toM (fromIntegral a)

-- Safe only if modNum is prime
instance Fractional MInt where
  fromRational a = fromInteger (numerator a) / fromInteger (denominator a)
  a / b = a * powerMod b (modNum-2) modNum where
    -- SICP Power iteration
    power :: Integral a => (t -> t -> t) -> t -> a -> t -> t
    power _ _ 0 e = e
    power f x n e = power f (f x x) (div n 2) (if odd n then f x e else e)
    powerMod x n _ = power (*) x n 1

-- import Prelude hiding ((^))
(^) :: MInt -> MInt -> MInt
(^) b' e' = M $ fastpow (unM b') (unM e') modNum where
  -- https://www.reddit.com/r/haskell/comments/mqtk6/fast_power_function/
  fastpow :: Int64 -> Int64 -> Int64 -> Int64
  fastpow base exponents modulo = fastpow' (base `mod` modulo) exponents modulo 1
    where fastpow' _ 0 _ !r = r
          fastpow' b e m r = fastpow' (b * b `mod` m) (e `div` 2) m (if even e then r else r * b `mod` m)
infixr 8 ^


Measured memory_bytes: 102284