akhauriyash/Code-Regression huggingface dataset:
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> 
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MaX 300005
using namespace std;

 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     new_data_set; 
bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

/************************************************/

const int N=105;
int x[N],y[N];
void solve()
{
    int n,i;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
    }
    int cnt=0;
    for(i=0;i<n;i++)
    {
        if(x[i]!=y[i])
            cnt=0;
        else
            cnt++;
        if(cnt==3)
        {
            cout<<"Yes";
            exit(0);
        }
    }
    cout<<"No";
}

int main()
{
    fast();
    int t;
    t=1;
    while(t--)
        solve();
   // time();
}

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

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int N, M;
    cin >> N >> M;
    int K[10], P[10];
    vector<int> S[10];
    for(int i=0; i<M; i++){
        cin >> K[i];
        for(int j=0; j<K[i]; j++){
            int s;
            cin >> s;
            S[i].push_back(s-1);
        }
    }
    for(int i=0; i<M; i++) cin >> P[i];

    int ans = 0;
    for(int i=0; i<(1<<N); i++){
        bool ok = true;
        for(int j=0; j<M; j++){
            int s = 0;
            for(int k : S[j]) s += nth_bit(i, k);
            if(s%2 != P[j]){
                ok = false;
                break;
            }
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

int main()
{
	int N, P, ch = 0;
	ll ans = 1;
	scanf("%d%d", &N, &P);
	for(int i = 1; i <= N; i++){
		int a;
		scanf("%d", &a);
		if( a%2 == 1 ) ch = 1;
		ans *= 2;
	}
	if( ch ) printf("%lld\n", ans/2);
	else if( P == 1 ) printf("0\n");
	else printf("%lld\n", ans);
}


Measured memory_bytes: 128
from scipy.sparse.csgraph import floyd_warshall
h,w = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(10)]
a = [list(map(int,input().split())) for _ in range(h)]
n = 10
c = floyd_warshall(c)
ans = 0
for i in a:
    for j in i:
        if j!=-1: ans += c[j][1]
print(int(ans))

Measured memory_bytes: 17264
# D - Integer Cards

from operator import itemgetter

N, M = map(int, input().split())
A = sorted([int(a) for a in input().split()])

BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append([b, c])

BC = sorted(BC, key=itemgetter(1), reverse=True)

ans = 0
for i in range(N):
    if len(BC) != 0 and A[i] <= BC[0][1]:
        ans += BC[0][1]
        BC[0][0] -= 1
        if BC[0][0] == 0:
            BC.pop(0)
    else:
        ans += A[i]

print(ans)


Measured memory_bytes: 26312
#include<iostream>
using namespace std;
int main()
{
  string s="IMPOSSIBLE";
  int i, N, M, a, b, array;
  cin >> N >> M;
  int arr1[N], arr2[N];
  for(i=0; i<N; i++){
    arr1[i]=0;
    arr2[i]=0;
  }
  while(cin >> a >> b){
    if(a==1){
      if(arr2[b]==1){
        s = "POSSIBLE";
        break;
      }else{
        arr1[b]=1;
      }
    }else if(b==N){
      if(arr1[a]==1){
        s = "POSSIBLE";
        break;
      }else{
        arr2[a]=1;
      }
    }
  }
  cout << s;
  return 0;
}

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


int main(){
	char l;
	cin >> l;
	if(l >= 'A' && l<='Z')
		cout << 'A';
	else if(l>='a' && l<='z')
		cout << 'a';

	return 0;
}

Measured memory_bytes: 3616
import numpy as np
S=input()
count=0
for i in range(len(S)):
    if i%2==0:
        if S[i]=='L':
            count+=1
            break
    else:
        if S[i]=='R':
            count+=1
            break
if count==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 21348
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n;
	cin>>n;
	vector<int> v;
	LL t=1,d=0;
	FOR(i,0,60){
		t*=2;
		if(t-1<=n)v.PB(i+1);
		else{
			d=i;
			t=n-(t/2-1);
			break;
		}
	}
	//cerr<<d<<" "<<t<<endl;
	int nx=d+1;
	map<int,int> ins;
	queue<int> ans;
	FORD(i,d+2,0){
		if(t>=(1LL<<i)){
			ins[i]=nx;
			t-=(1LL<<i);
			nx++;
		}
	}
	if(ins[0]!=0)ans.push(ins[0]);
	FORQ(i,1,d){
		ans.push(i);
		if(ins[i]!=0)ans.push(ins[i]);
	}
	FOR(i,1,nx)ans.push(i);

	cout<<ans.size()<<endl;
	while(ans.size()>1){
		cout<<ans.front()<<" ";
		ans.pop();
	}
	cout<<ans.front()<<endl;


    return 0;
}


Measured memory_bytes: 256
meta = [int(s) for s in input().split(' ')]

now = meta[0]
times = meta[1]
distance = meta[2]

time = times
i = 0
while i < times:
    # 何回移動するか決める
    if time > 0:
        # 残り距離を移動距離で割った数と移動可能回数の少ない方を回数にする
        time = min([int(abs(now) / distance), times])
        # 移動回数分カウンタ回す
        i += time
    # 残り距離 < 移動距離になる時
    else:
        # 残り移動可能回数が偶数の時はその位置で終わり
        if (times - i) % 2 == 0:
            print(abs(now))
            exit()
        # 奇数の時はあと1回だけ
        else:
            time = 1
            i = times

    # 現在位置の正負に合わせて移動実行
    if now > 0:
        now -= distance * time
    else:
        now += distance * time

print(abs(now))


Measured memory_bytes: 9192
line=list(input())
like=753
difference=0
ans=like

for i in range(len(line)-2):
   
    this=100*int(line[i])+10*int(line[i+1])+int(line[i+2])
    if this>=like:
        difference=this-like
    else:
        difference=like-this
    
    if difference<ans:
        ans=difference

print(ans)

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

using namespace std;

typedef long long ll;
const int maxn=103;
const int maxt=10000007;

int n,a[maxn],pr[maxt],sz,N,o[maxn],e[maxn],szo,sze,match[maxn];
bool np[maxt],vis[maxn];

int dfs(int x){
	for(int i=1;i<=sze;++i){
		if(!vis[i]&&!np[abs(e[i]-o[x])]){
			vis[i]=true;
			if(!match[i]||dfs(match[i])){
				match[i]=x;
				return 1;
			}
		}
	}
	return 0;
}
vector<int> v;
bool flag[maxt];
int main(){
	scanf("%d",&n);
	a[0]=-1;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		flag[a[i]]=true;
	}
	for(int i=1;i<maxt;++i){
		if((flag[i]^flag[i-1])==1)
			v.push_back(i);
	}
	np[1]=1;
	for(int i=2;i<maxt;++i){
		if(!np[i])
			pr[sz++]=i;
		for(int j=0;j<sz&&1ll*pr[j]*i<maxt;++j){
			np[pr[j]*i]=1;
			if(i%pr[j]==0)
				break;
		}
	}
	--sz;N=v.size();
//	for(int i=0;i<N;++i)
//		printf("%d ",v[i]);
//	puts("");
	for(int i=0;i<N;++i){
		if(v[i]%2==0) o[++szo]=v[i];
		else e[++sze]=v[i];
	}
	int  k=0;
	for(int i=1;i<=szo;++i){
		memset(vis,0,sizeof(vis));
		if(dfs(i)) ++k;
	}
	sze-=k;szo-=k;
//	printf("%d %d %d *\n",k,sze,szo);
	int res=k+((sze/2)+(szo/2))*2+(sze%2)*3;
	printf("%d\n",res);
	return 0;
}



Measured memory_bytes: 20864
//  Copyright © 2019 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 300005
using namespace std;
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
typedef long long i64;

int N, ans;
int v[MAX];
int c[MAX];

int main()
{
    optimiza_io 
    cin >> N;
    
    for( int i = 1; i <= N; i ++ )
        cin >> v[i];
        
    for( int i = 1; i <= N; i ++ )
        cin >> c[i];
    
    for( int i = 1; i <= N; i ++ )
        ans += max( 0 , v[i] - c[i] );
    
    cout << ans;
    return 0;
}

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

vector<ll> calc_primes(ll n) {
  vector<ll> primes;
  vector<bool> filtered(n + 1);

  for (ll i = 2; i <= n; i++) {
    filtered[i] = false;
  }

  for (ll i = 2; i <= n; i++) {
    if (!filtered[i]) {
      primes.push_back(i);
      for (ll j = i; j <= n; j += i) {
        filtered[j] = true;
      }
    }
  }
  return primes;
}

ll pow_mod(ll n, ll m, ll mod) {
  if (m == 0) return 1;
  if (m % 2 == 0) {
    ll tmp = pow_mod(n, m / 2, mod);
    return (tmp * tmp) % mod;
  } else {
    return (n * pow_mod(n, m - 1, mod)) % mod;
  }
}

ll pow_mod_loop(ll n, ll m, ll mod) {
  ll ans = 1;
  while (m) {
    if (m % 2) {
      ans *= n;
      ans %= mod;
    }
    n *= n;
    n %= mod;
    m /= 2;
  }
  return ans;
}

unordered_map<ll, ll> prime_factors(ll n, vector<ll> &primes) {
  unordered_map<ll, ll> ans;
  for (ll p : primes) {
    while (n % p == 0) {
      if (ans.count(p) == 0) {
        ans[p] = 0;
      }
      ans[p]++;
      n /= p;
    }
  }
  if (n > 1) {
    if (ans.count(n) == 0) {
      ans[n] = 0;
    }
    ans[n]++;
  }
  return ans;
}

int main() {
  vector<ll> primes = calc_primes(1000000);

  ll n;
  cin >> n;

  auto f = prime_factors(n, primes);
  
  ll ans = 0;
  for (auto p : f) {
    ll cnt = 1;
    while (p.second >= cnt) {
      p.second -= cnt;
      ans++;
      cnt++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4252
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)  //  rep
#define repr(i,a,n) for(int i=a;i>n;i--)  //  repリバース
#define leng(n) (int)(log10(n)+1)  //  桁数leng
#define INF 9000000000000000000 //  巨大数INF
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string s;
  cin >> s;
  int n=0;
  rep(i, 0, 4){
    if(s[i]=='+') n++;
    else n--;
  }
  cout << n << endl;
}


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

using namespace std;

int main(){
	string s;
	cin >> s;
	int status = 0;
	for(int unsigned i=0;i<s.size();i++){
		if(s[i] == 'C' && status == 0) status = 1;
		if(s[i] == 'F' && status == 1) status = 2;
	}
	if(status == 2){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	string S; cin >> S;
	ll K; cin >> K;
	int N = S.size();
    
	vector<ll> A;
	int count = 1;
	rep(i,N) {
		if (i == 0) continue;
		if (S[i] != S[i-1]) {
			A.emplace_back(count);
			count = 1;
		} else count++;
	}
	A.emplace_back(count);
	ll ans = 0;
	if (S[0] != S[N-1]) {
		rep(i,A.size()) {
			ans += A[i] / 2LL;
		}
        ans *= K;
	} else {
		if (A.size() == 1) {
			ans += A[0]*K / 2;
		} else {
			for (int i = 1; i < A.size() - 1; i++) {
				ans += A[i] / 2LL;
			}
			ans *= K;
			ans += A[0] / 2LL + A[A.size()-1]/2LL + (A[0]+A[A.size()-1]) / 2LL *(K-1);
		}

	}
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int i,a[100009],d[100008],n;
int dp(int i){
    if(i>=n-1) return (i!=n-1)*1e6;
    if(d[i]!=-1) return d[i];
    return d[i]=min(abs(a[i+1]-a[i])+dp(i+1),abs(a[i+2]-a[i])+dp(i+2));
}
int main()
{
    cin>>n;
    for(i=0;i<n;i++) {cin>>a[i]; d[i]=-1;}
    cout<<dp(0);
    return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

pair<int, int> solve(int h, int w) {
    pair<int, int> ans = make_pair(INT_MAX, INT_MAX);
    int rute           = INT_MAX;
    long product       = w * w + h * h;
    for (int i = 1; i <= 150; i++) {
        for (int j = 1; j <= 150; j++) {
            if (product < i * i + j * j && i < j) {
                if (rute > i * i + j * j) {
                    rute = i * i + j * j;
                    ans  = make_pair(i, j);
                } else if (rute == i * i + j * j) {
                    if (ans.first > i && i < j) {
                        ans = make_pair(i, j);
                    }
                }
            } else if (product == i * i + j * j && i < j) {
                if (h < i) {
                    ans  = make_pair(i, j);
                    rute = i * i + j * j;
                    return ans;
                }
            }
        }
    }
    // pair<int, int> a = make_pair(-1, -1);
    return ans;
}

int main() {
    int w, h;
    vector<pair<int, int>> ans;
    while (1) {
        cin >> h >> w;
        if (!w && !h) break;
        ans.push_back(solve(h, w));
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}

/*
    for ( ; product < 150 * 150; product++) {
        for (int higth = 1; higth < product; higth++) {
                int val  = product - (higth * higth);
                int rute = sqrt(val);
                if (rute != 0) {
                    // cout << 1 << endl;
                    if (val / rute == rute && val % rute == 0) {
                        if (rute > higth) {
                            ans = make_pair(higth, rute);
                            return ans;
                        }
                    }
                }
        }
    }
*/


Measured memory_bytes: 3076
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,a[50000],ans;
    scanf("%d",&n);
    while(n){
        ans=1000000000;
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        sort(a,a+n);
        for(int i=1;i<n;i++){
            ans=min(ans,a[i]-a[i-1]);
        }
        printf("%d\n",ans);
        scanf("%d",&n);
    }
}


Measured memory_bytes: 2572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  string S;
  cin >> S;
  string A(S.size(),'x');
  cout << A << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>

int main(void){
  int n,i,ans=0;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    ans += a[i]-1;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<string>W(N);
  for(int i=0;i<N;i++)
    cin>>W.at(i);
  set<string>S;
  S.insert(W.at(0));
  bool ans=true;
  for(int i=1;i<N;i++){
  if(S.count(W.at(i))){
  ans=false; break;
  }else{
  if(W.at(i).at(0)!=W.at(i-1).at(W.at(i-1).size()-1)){
  ans=false; break;
  }else S.insert(W.at(i));
  }
    } if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n, m;cin >> n >> m;
	vector<ll> v(n);REP(i, n)cin >> v[i];
	vector<ll> type(n, -1);
	vector<vector<ll> > g(n);
	vector<vector<ll> > rev(n);
	vector<ll> in(n);
	REP(i, m){
		ll a, b;cin >> a >> b;
		a--;b--;
		g[a].EB(b);
		rev[b].EB(a);
	}

	queue<ll> q;
	REP(i, n)if(g[i].size() == 0)q.push(i);

	while(!q.empty()){
		ll node = q.front();q.pop();
		vector<ll> tmp(n);
		REP(i, g[node].size()){
			tmp[type[g[node][i]]]++;
		}
		REP(i, n){
			if(tmp[i] == 0){
				type[node] = i;
				break;
			}
		}

		REP(i, rev[node].size()){
			in[rev[node][i]]++;
			if(in[rev[node][i]] == g[rev[node][i]].size()){
				q.push(rev[node][i]);
			}
		}
	}

	vector<ll> ans(n);
	REP(i, n)ans[type[i]] ^= v[i];
	REP(i, n)if(ans[i] != 0){
		cout << 1 << endl;
		return 0;
	}

	cout << 2 << endl;

	return 0;
}



Measured memory_bytes: 3360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		final long FIVE_QUADRILION = 5000000000000000L;

		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		long K = Long.parseLong(sc.nextLine());

		for(int i=0;i<S.length();i++) {
			int x = Integer.parseInt(S.substring(i, i+1));

			double t = Math.pow(x, FIVE_QUADRILION);

			if( t >= K) {
				System.out.println(x);
				return;
			}else {
				K -= t;
			}
		}
	}
}


Measured memory_bytes: 21844
s = gets.chomp.split("")
t = gets.chomp.split("")
n = s.size
s_hash = {}
t_hash = {}
ans = true

n.times do |i|
    if s_hash.has_key?(s[i]) then
        if s_hash[s[i]] != t[i] then
            ans = false
            break
        end
    end
    if t_hash.has_key?(t[i]) then
        if t_hash[t[i]] != s[i] then
            ans = false
            break
        end
    end
    s_hash[s[i]] = t[i]
    t_hash[t[i]] = s[i]
end

puts ans ? "Yes" : "No"

Measured memory_bytes: 22780
#include <stdio.h>
int main () {

  int i,j,n,v,a[1000];

  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%d",&a[i]);
  }
  for(i=0 ; i<n ; i++){
    v=a[i];
    j=i-1;
    while(j >=0 && a[j]>v ){
      a[j+1] = a[j];
      j--;
      a[j+1]=v;
    }

    //output
    for(j=0 ; j<n ; j++){
      printf("%d",a[j]);

      if(j<n-1)
	printf(" ");
      
    }
    printf("\n");
    
  }
  
  return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] V = new int[N];
		int[] C = new int[N];
		for(int i = 0; i < N; i++) {
			V[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
		}
		sc.close();
		int x = 0, y = 0;
		for(int i = 0; i < N; i++) {
			if(V[i] > C[i]) {
				x += V[i];
				y += C[i];
			}
		}
		System.out.println(x - y);
	}
}

Measured memory_bytes: 23764
#include <cstdio>

int main()
{
    int A,B;
    scanf("%d %d", &A, &B);
    if ((A + B) % 3 == 0 or A % 3 == 0 or B % 3 == 0)
    {
        printf("Possible");
    }
    else
    {
        printf("Impossible");
    }
    
}

Measured memory_bytes: 1724
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, n) for(ll i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vector<ll> ans;
int make_divisors(ll n){
//    vector<int> ans;
    for(ll i=1; i < ll(sqrt(n))+1; ++i){
        if(n % i == 0){
            ans.push_back(i);
            if(i != n/i) ans.push_back(n/i);
        }
    }
    sort(ans.begin(), ans.end());
//    for(int i=0; i< ans.size(); ++i) cout << ans[i] << endl;
    return 0;
}

bool IsPrime(ll num){
  if (num < 2) return true;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  long double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0) return false;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll A, B;
  cin >> A >> B;
  ll x = euclidean_gcd(A,B);
  make_divisors(x);
  vector<ll> sosu;
  REP(i, ans.size()) if(IsPrime(ans[i])) sosu.push_back(ans[i]);
  OUT(sosu.size());
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef pair<int, int> P;

const int MAX_N = 100000;

int N, L;
int Is[MAX_N + 2];
int Tm[MAX_N + 2];

int main ( void )
{
	while (cin >> N >> L) {
		priority_queue<P, vector<P> > que;
		fill(Is, Is+MAX_N+2, 0);
		fill(Tm, Tm+MAX_N+2, 0);
		for (int i = 0; i < N; ++i) {
			cin >> Is[i+1];
			que.push(P(Is[i+1], i+1));
		}

		int mx = 0;

		while (!que.empty()) {
			P p = que.top(); que.pop();
			int i = p.second;
			mx = max(mx, Tm[i] = L - p.first + max(Tm[i-1], Tm[i+1]));
		}

		cout << mx << endl;
	}

	return 0;
}

Measured memory_bytes: 2832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200002;
struct node{
	int to,ne,w;
}e[N<<1];
struct kk{
	int x,y;ll w;
	bool operator<(kk a)const{return w<a.w;}
}E[N*30];
int du,a[N],sz[N],mx[N],rx,ry,fa[N],tot,h[N],S,rt,m,n,i,x,y,z;
bool vis[N];
ll dw,pre[N],ans;
void add(int x,int y,int z){e[++tot]={y,h[x],z},h[x]=tot;}
int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
void getrt(int u,int fa){
	sz[u]=1,mx[u]=0;
	for (int i=h[u],v;i;i=e[i].ne)
		if ((v=e[i].to)!=fa && !vis[v]) getrt(v,u),sz[u]+=sz[v],mx[u]=max(mx[u],sz[v]);
	mx[u]=max(mx[u],S-sz[u]);
	if (mx[u]<mx[rt]) rt=u;
}
void chk(int u,int fa){
	if (pre[u]+a[u]<dw) dw=pre[u]+a[u],du=u;
	for (int i=h[u],v;i;i=e[i].ne)
		if ((v=e[i].to)!=fa && !vis[v]) pre[v]=pre[u]+e[i].w,chk(v,u);
}
void getdis(int u,int fa){
	E[++m]={du,u,dw+a[u]+pre[u]};
	for (int i=h[u],v;i;i=e[i].ne)
		if ((v=e[i].to)!=fa && !vis[v]) getdis(v,u);
}
void dfs(int u){
	du=u,dw=a[u],vis[u]=1,pre[u]=0,chk(u,0),getdis(u,0);
	for (int i=h[u],v;i;i=e[i].ne)
		if (!vis[v=e[i].to]) S=sz[v],rt=0,getrt(v,0),dfs(rt);
}
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<n;i++) scanf("%d%d%d",&x,&y,&z),add(x,y,z),add(y,x,z);
	mx[0]=n+1,S=n,rt=0,getrt(1,0),dfs(rt);
	sort(E+1,E+m+1);
	for (i=1;i<=n;i++) fa[i]=i;
	for (i=1;i<=m;i++){
		rx=find(E[i].x),ry=find(E[i].y);
		if (rx!=ry) ans+=E[i].w,fa[rx]=ry;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 74752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N, M;
	cin >> N >> M;

	int A[101][101] = {};
	rep1(i, 100) {
		rep1(ii, 100) {
			if (i != ii) A[i][ii] = 10000000;
		}
	}

	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c;

		A[a][b] = c;
		A[b][a] = c;
	}

	int B[101][101] = {};
	rep1(k, N) {
		rep1(i, N) {
			rep1(j, N) {
				if (A[i][k] + A[k][j] < A[i][j]) {
					B[i][j] = 1;
					A[i][j] = A[i][k] + A[k][j];
				}
			}
		}
	}

	int goukei = 0;
	rep1(i, N) {
		rep1(ii, N) {
			if (B[i][ii]) goukei++;
		}
	}
	int hennmax = N * (N - 1) / 2;

	co(goukei / 2 + M - hennmax);

	Would you please return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    string N; cin >> N;
    if((N.at(0) == N.at(1) &&N.at(1) == N.at(2)) || 
   (N.at(1) == N.at(2) && N.at(2) == N.at(3)))
    cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
//By Ralif Rakhmatullin
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<ctime>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<valarray>
#include<iterator>
#include<list>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define S second
#define ld long double
#define F first
#define y1 LOL
#define ld long double
#define pb push_back
#define len length
#define sz size
#define beg begin
const ll INF = (ll)1e18 + 123;
const int inf=(int)2e9 + 123; 
const int mod=1e9+7;
using namespace std;
int n, w, h;
vector<pair<int, int> > v[6];
bool border(int x, int y){
	if(x == 0 || x == h || y == 0 || y == w)
		return 1;
	return 0;
}
int main(){
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  	srand(FOR);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin >> h >> w >> n;
	for(int i = 1; i <= n; i ++){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if(!border(x1, y1) || !border(x2, y2))
			continue;
		if(x1 == 0){
			v[1].pb(mp(y1, i));
		}else
		if(y1 == w){
			v[2].pb(mp(x1, i));
		}else
		if(x1 == h)
			v[3].pb(mp(y1, i));
		else
		if(y1 == 0)
			v[4].pb(mp(x1, i));
		if(x2 == 0){
			v[1].pb(mp(y2, i));
		}else
		if(y2 == w){
			v[2].pb(mp(x2, i));
		}else
		if(x2 == h)
			v[3].pb(mp(y2, i));
		else
		if(y2 == 0)
			v[4].pb(mp(x2, i));
	}	
	stack<int> s;
	sort(v[1].beg(), v[1].end());
	sort(v[2].beg(), v[2].end());    
	sort(v[3].beg(), v[3].end());    
	sort(v[4].beg(), v[4].end());
	reverse(v[3].beg(), v[3].end());
	reverse(v[4].beg(), v[4].end());
	for(int i = 0; i < v[1].sz(); i ++){
		if(s.sz() && s.top() == v[1][i].S){
			s.pop();
		}else
			s.push(v[1][i].S);
	}
	for(int i = 0; i < v[2].sz(); i ++){
		if(s.sz() && s.top() == v[2][i].S){
			s.pop();
		}else
			s.push(v[2][i].S);
	}
	for(int i = 0; i < v[3].sz(); i ++){
		if(s.sz() && s.top() == v[3][i].S){
			s.pop();
		}else
			s.push(v[3][i].S);
	}
	for(int i = 0; i < v[4].sz(); i ++){
		if(s.sz() && s.top() == v[4][i].S){
			s.pop();
		}else
			s.push(v[4][i].S);
	}
	if(s.sz() > 0)
		cout << "NO";
	else
		cout << "YES";
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

ll bin_pow(ll x, ll n, ll mod){
	ll res = 1LL;
	for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
	return res;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; string x;
	cin >>n >>x;
	int pcct=0;
	rep(i, n) pcct += x[i] =='1';
	int pctp=pcct+1, pctm=pcct-1;
	ll smp=0, smm=0;
	rep(i, n){
		if(pctm !=0) smm = (smm * 2 + (x[i]=='1')) % pctm;
		smp = (smp * 2 + (x[i]=='1')) % pctp;
	}
	//dbg("sm",smp, smm,"ct",pcct,pctp, pctm);
	auto f3=[](int s){
		int p=0;
		for(int w=s; w>0; ){
			w = w % __builtin_popcount(w); p++;
		}
		return p;
	};
	
	rep(i, n){
		ll cnd =0;
		if(x[i]=='1'){
			if(pctm==0){
				cout << 0 <<"\n";
			}
			else{
				cnd =( smm + pctm - bin_pow(2, n-1-i,pctm))%pctm;
				
				cout << f3(cnd) +1 <<"\n";
			}
		}else{
				cnd =( smp + pctp + bin_pow(2, n-1-i,pctp))%pctp;
				cout << f3(cnd) +1 <<"\n";
		}
	}
	
	return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

//  COMMAND TO USE WHEN RUNNING CODE: g++ day8.cpp -o day8 -std=c++11 -O2  | to run: ./(name of file)  //

int N, ma, mi;
stack<int> A;
int main() {
    cin >> N;
    for ( int i=0; i<N; i++ ) {
        cin >> ma;
        A.push(ma);
    }
    ma = A.top();
    mi = A.top();
    for ( int i=0; i<N;  i++ ) {
        if (A.top() > ma ) {
            ma = A.top();
        }
        if (A.top() < mi ) {
          mi = A.top();
        }
      	A.pop();
    }
  cout << ma - mi << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
int N, K, C;
string S;
int dp[2][200100];
int NG[200100];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K >> C >> S;
    for(int i = 0; i < N; i++) {
        chmax(dp[0][i+1], dp[0][i]);
        if(S[i] == 'o' and i-C >= 0) {
            chmax(dp[0][i+1], dp[0][i-C] + 1);
        }
        else if(S[i] == 'o') chmax(dp[0][i+1], 1);
        //cerr << dp[0][i+1] << " ";
    }
    //cerr << endl;
    for(int i = N - 1; i >= 0; i--) {
        dp[1][i] = dp[1][i+1];
        if(i+C+1 < N) {
            if(S[i] == 'o') chmax(dp[1][i], dp[1][i+C+1] + 1);
            else chmax(dp[1][i], dp[1][i+C+1]);
        }
        else if(S[i] == 'o') chmax(dp[1][i], 1);
    }
    for(int i = 0; i < N; i++) {
        if(S[i] == 'x') continue;
        //cerr << i << " " << dp[1][i] << endl;
    }
    /*
    int maxi = dp[0][N];
    for(int i = 0; i < N; i++) {
        if(S[i] == 'x') continue;
        int before = 0;
        int after = 0;
    }
    */
    map<int, vector<int>> mp;
    map<int, vector<int>> mp2;
    for(int i = 0; i < N; i++) {
        if(S[i] == 'x') continue;
        //cerr << i << " " << dp[0][i+1] << " " << dp[1][i] << endl;
        if(dp[1][i] > K) return 0;
        //v.push_back({dp[1][i], i+1});
        mp[dp[1][i]].push_back(i);
        mp2[dp[0][i+1]].push_back(i);
    }
    for(int i = 1; i < K; i++) {
        int r = mp[i].back();
        int l = mp2[K-i][0];
        //cerr << i << " " << l << " " << r << endl;
        if(l >= r) continue;
        NG[l+1]++;
        NG[r]--;
    }
    NG[0]++;
    int r = mp[K].back();
    NG[r]--;
    int l = mp2[K][0];
    NG[l+1]++;
    NG[N]--;
    for(int i = 1; i <= N; i++) {
        NG[i] += NG[i-1];
    }
    //for(int i = 0; i < N; i++) cout << NG[i] << " ";
    for(int i = 0; i < N; i++) {
        if(S[i] == 'o' and NG[i] == 0) {
            cout << i + 1 << endl;
        }
    }
    return 0;
    int nowday = -1e9;
    for(int d = K; d > 0; d--) {
        int idx = 0;
        while(mp[d][idx] <= nowday + C) idx++;
        //cerr << d << " " << nowday << " " << idx << endl;
        if(idx + 1 == mp[d].size()) {
            cout << mp[d].back() << endl;
        }
        nowday = mp[d][0];
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> list(1);
  cin >> list.at(0);
  int number = 1;
  int count = 1;
  while (count < N) {
    int64_t a;
    cin >> a;
    if (a != list.at(number - 1)) {
      list.push_back(a);
      number++;
    }
    count++;
  }
  
  int64_t money = 1000;
  int64_t kabu = 0;
  int x = list.size();
  
  if (x == 1) {
    cout << money << endl;
  }
  
  if (x == 2) {
    if (list.at(0) < list.at(1)) {
      kabu = money/list.at(0);
      money = money - list.at(0)*kabu + list.at(1)*kabu;
    }
    cout << money << endl;
  }
  
  if (x > 2) {
    if (list.at(0) < list.at(1)) {
        kabu = money/list.at(0);
        money -= kabu*list.at(0);
    }
    for (int j = 1; j < x - 1; j++) {
      if (list.at(j) < list.at(j + 1) && list.at(j - 1) > list.at(j)) {
        kabu = money/list.at(j);
        money -= list.at(j)*kabu;
      }
      if (list.at(j) > list.at(j + 1) && list.at(j - 1) < list.at(j)) {
        money += list.at(j)*kabu;
        kabu = 0;
      }
    }
    money += list.at(x - 1)*kabu;
    cout << money << endl;
  }
}


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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

const long long MOD = 1000000007;

using LL = long long;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVLL = vector<VLL>;
using VVVLL = vector<VVLL>;

void add(LL &a, LL b)
{
  a += b;
  if (a >= MOD)
    a -= MOD;
  if (a < 0)
    a += MOD;
}

int main()
{
  IOS;

  string K;
  cin >> K;
  int D;
  cin >> D;

  int n = K.size();
  VVVLL dp(10001, VVLL(2, VLL(100)));
  dp[0][0][0] = 1;

  forn(i, 0, n) forn(s, 0, 2) forn(d, 0, D)
  {
    for (int x = 0; x <= (s ? 9 : K[i] - '0'); x++)
      add(dp[i + 1][s || x < K[i] - '0'][(d + x) % D], dp[i][s][d]);
  }
  LL res = dp[n][0][0] + dp[n][1][0];
  add(res, -1LL);
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 20224
#include <bits/stdc++.h>
// #include <math.h>
// #include <cmath>
// #include <vector>
// #include <utility> 
// #include <unordered_map>
// #include <map>
// #include <string>

using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;

#define M_PI_H  3.14159265358979323846/2  /* pi by two*/
#define rep(i, start, end) for(int i = start; i < end; i++) 
#define repr(i, start, end) for(int i = start; i >= end; i--)   //INCLUSIVE



int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	
	int n; cin>>n;
  
  	cout<<(n>=30 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3636
import math

n,d = map(int,input().split())
x = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n):
  for j in range(i+1,n):
    sq= 0
    for k in range(d):
      sq += (x[i][k]-x[j][k])**2
    if math.sqrt(sq).is_integer():
      ans += 1
print(ans)

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

int main()
{
    
    int a,b,c,d,k;
    cin>>a>>b>>c>>d>>k;
    
    int x  =  (c-a);
    int y  =  (d-b);
    int ans  =  (x*60)+y;
    ans=ans-k;
    
    cout<<ans<<endl;
    
}

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

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

    bool one[n+1], enu[n+1];
    for(int i = 0; i < n+1; i++)    one[i] = enu[i] = false;

    int a, b;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        if(a == 1)  one[b] = true;
        if(b == n)  enu[a] = true;
    }

    bool judge = false;
    for(int i = 2; i <= n-1; i++){
        if(one[i] && enu[i])    judge = true;
    }

    if(judge)   cout << "POSSIBLE" << endl;
    else        cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 #define DIV 1000000007
 

int n;
int dangerous[100001];
long long dp[100001];
long long get(int cur){
long long result=0;
  if(dp[cur]>=0)
    return dp[cur];
if(cur==n)
    return dp[cur]=1;
  
if(dangerous[cur+1]==0)
  {
    result+=get(cur+1)%DIV;
    result=result%DIV;
  }
if(cur<n-1 && dangerous[cur+2]==0){
    result+=get(cur+2)%DIV;
    result=result%DIV;
}
return dp[cur]=result;



}
int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  memset(dp,-1,sizeof(dp));
int m;
cin >> n >> m;
for(int i=0;i<m;i++){
    int c;
    cin >> c;
    
    
    dangerous[c]=1;
}
cout << get(0);











}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    string s;
    cin>>s;
    int n;
    n = s.length();
    vi lv,rv,pv;
    int lf=0,rf=0;
    int l=0,r=0;
    int ans[n]={};
    

    rep(i,n){
        if(s[i]=='R'){
            if(lf==1)lv.push_back(l);
            lf=0;
            rf=1;
            l=0;
            r++;
        }
        else if(s[i]=='L'){
            if(rf==1){
                rv.push_back(r);
                pv.push_back(i);
            }
            lf=1;
            rf=0;
            r=0;
            l++;
        }
    }
    lv.push_back(l);

    rep(i,pv.size()){
        if(lv[i]%2==rv[i]%2){
            ans[pv[i]]=(lv[i]+rv[i])/2;
            ans[pv[i]-1]=(lv[i]+rv[i])/2;
        }
        else if(lv[i]%2==1){
            ans[pv[i]]=(lv[i]+rv[i]+1)/2;//left
            ans[pv[i]-1]=(lv[i]+rv[i]-1)/2;//r
        }
        else if(rv[i]%2==1){
            ans[pv[i]]=(lv[i]+rv[i]-1)/2;//left
            ans[pv[i]-1]=(lv[i]+rv[i]+1)/2;//r
        }
    }

    rep(i,n){
        if(i==0)cout<<ans[i];
        else cout<<" "<<ans[i];
    }

}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n;
  cin >> n;
  vl x(n);
  rep (i, n) {
    cin >> x[i];
  }
  ll m, k;
  cin >> m >> k;
  vl a(m);
  rep (i, m) {
    cin >> a[i];
    a[i]--;
  }
  vll dp(61, vl(n - 1));
  rep (i, n - 1) {
    dp[0][i] = i;
  }
  rep (i, m) {
    swap(dp[0][a[i] - 1], dp[0][a[i]]);
  }
  rep (i, 60) {
    rep (j, n - 1) {
      int now = j;
      now = dp[i][now];
      now = dp[i][now];
      dp[i + 1][j] = now;
    }
  }
  vi diff(n - 1);
  rep (i, n - 1) {
    int now = i;
    ll nokori = k;
    rrep (j, 61) {
      if (nokori >= 1LL << j) {
        nokori -= (1LL << j);
        now = dp[j][now];
      }
    }
    diff[i] = now;
  }
  vl d(n - 1);
  rep (i, n - 1) {
    d[i] = x[i + 1] - x[i];
  }
  cout << x[0] << endl;
  ll pre = x[0];
  rep (i, n - 1) {
    int idx = diff[i];
    cout << pre + d[idx] << endl;
    pre = pre + d[idx];
  }
}



Measured memory_bytes: 51824
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb       push_back
#define all(x)   begin(x), end(x)
#define sz(x)    (int)(x).size()
#define ff       first
#define ss       second
#define mp       make_pair
#define lb       lower_bound
#define ub       upper_bound
#define tcase()  int t; cin >> t; while(t--)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

void primeFactors(ll n)
{
    if(n == 1){
        cout << 0;
        return;
    }

    ll cnta = 0, cntb = 0, Ans = 0;

    while (n % 2 == 0)
    {
        n = n / 2LL;
        cnta++;
    }
    if(cnta == 1) Ans++;
    else if(cnta) Ans += (-1LL + sqrt(1LL + 8LL * cnta)) / 2LL;

    for (ll i = 3; i * i <= n; i = i + 2)
    {
        cntb = 0;
        while (n % i == 0)
        {
            n = n / i;
            cntb++;
        }

        if(cntb == 1) Ans++;
        else if(cntb) Ans += (-1LL + sqrt(1LL + 8LL * cntb)) / 2LL;
    }

    if(n > 2) Ans++;

    cout << Ans;
}

int main(){

    setIO();

    ll n;
    cin >> n;

    primeFactors(n);
}


Measured memory_bytes: 3672
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e9+7;

struct Sieve{
    ll n;
    vector<ll> f, primes;
    //コンストラクタを定義
    Sieve(ll n=1):n(n), f(n+1){//メンバ変数の初期化
        f[0]=f[1]=-1;
        for(ll i=2;i<=n;i++){
            if(f[i]) continue;
            primes.push_back(i);
            f[i]=i;
            for(ll j=i*i;j<=n;j+=i){
                if(!f[j]) f[j]=i;
            }
        }
    }
    bool isPrime(ll x) { return f[x]==x;} //xが素数かどうかを判定
    vector<ll> factorList(ll x){//xの素因数を重複ありで小さい順に列挙
        vector<ll> res;
        while(x!=1){
            res.push_back(f[x]);
            x/=f[x];
        }
        return res;
    }
    vector<pll> factor(ll x){//xの素因数と、その出現回数
        vector<ll> fl=factorList(x);
        if(fl.size()==0) return {};
        vector<pll> res(1,make_pair(fl[0],0));
        for(auto p : fl){
            if(res.back().first==p){
                res.back().second++;
            }else{
                res.emplace_back(p,1);
            }
        }
        return res;
    }
};
map<ll,ll> m;
Sieve sieve=Sieve(1000001);

bool dfs(ll v,ll mul,ll s){
    vector<pll> res=sieve.factor(v);
    if(s==res.size()){
        if(mul==v && m[mul]>=2){
            return false;
        }
        if(mul!=v && m.count(mul)){
            //cout << "ok" << endl;
            return false;
        }
        return true;
    }
    
    ll t=res[s].se;
    ll val=1;
    bool ok=true;
    for(ll i=0;i<=t;i++){
        if(!dfs(v,mul*val,s+1)){
            ok=false;
        }
        val*=res[s].fi;
    }
    if(ok){
        return true;
    }
    else{
        return false;
    }
}

int main(){
    ll n;
    cin >> n;
    
    vector<ll> q(n),r(1000001),used(1000001);
    
    rep(i,n){
        cin >> q[i];
    }
    sort(q.begin(),q.end());
    rep(i,n){
        m[q[i]]++;
    }
    ll ans=0;
    rep(i,n){
        if(used[q[i]]){
            if(r[q[i]]) ans++;
            continue;
        }
        if(dfs(q[i],1,0)){
            r[q[i]]=1;
            ans++;
        }
        used[q[i]]=1;
    }
    
    
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 41416
n = gets.to_i
a = Array.new(n){ gets.split.map &:to_i }
a.sort_by! { |a| - a[0] - a[1] }

ans = 0
n.times do |i|
  if i.even?
    ans += a[i][0]
  else
    ans -= a[i][1]
  end
end

puts ans

Measured memory_bytes: 12664
import math

n = int(input())
tmp = []
for i in range(n):
    tmp.append(list(map(int, input().split())))

total = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        x1, y1 = tmp[i]
        x2, y2 = tmp[j]
        total += math.sqrt((x1-x2)**2 + (y1-y2)**2)

print(total * (n - 1) * 2 / (n * (n - 1)))


Measured memory_bytes: 38384