akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = input()
T = input()

i = 0

if S[0] != T[0]:
    ans = 6
    i += 2
    flag = 1
else:
    ans = 3
    i += 1
    flag = 0

while i <= N-1:
    if S[i] != T[i] and flag == 1:
        ans *= 3
        i += 2
        flag = 1
    elif S[i] != T[i] and flag == 0:
        ans *= 2
        i += 2
        flag = 1
    elif S[i] == T[i] and flag == 1:
        ans *= 1
        i += 1
        flag = 0
    elif S[i] == T[i] and flag == 0:
        ans *= 2
        i += 1
        flag = 0


print(ans % (7 + 10 ** 9))

Measured memory_bytes: 3064
//Utkarsh.25dec
#include <bits/stdc++.h>
#define ll long long int 
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    ll dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans="";
    ll first=n,second=m;
    while(true)
    {
        if(dp[first][second]==0)
            break;
        if(dp[first][second]==max(dp[first-1][second],dp[first][second-1]))
        {
            if(dp[first-1][second]>dp[first][second-1])
                first--;
            else
                second--;
        }
        else
        {
            ans.pb(s[first-1]);
            first--;
            second--;
        }
    }
    reverse(all(ans));
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
}

Measured memory_bytes: 82432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1, class T2>ostream& operator<<(ostream& os, const pair<T1, T2>&a)
{
   return os << "(" << a.first << "," << a.second << ")";
}
template<class T>void pv(T a, T b)
{
   for(T i = a; i != b; ++i)
      cout << (*i) << " ";
   cout << endl;
}
template<class T>void chmin(T&a, const T&b)
{
   if(a > b)
      a = b;
}
template<class T>void chmax(T&a, const T&b)
{
   if(a < b)
      a = b;
}

int nextInt()
{
   int x;
   scanf("%d", &x);
   return x;
}



int main()
{
   string s;
   while(cin >> s) {
      set<char> st;

      for(char c = 'a'; c <= 'z'; c++)
         st.insert(c);
      for(auto c : s)
            st.erase(c);
      if(st.size()) {

         vector<char> v(st.begin(), st.end());
         sort(ALL(v));
         s += v[0];
         cout << s << endl;
      } else {
         if(s == string("zyxwvutsrqponmlkjihgfedcba"))
            cout << "-1" << endl;
         else {
            int ind;
            for(int i = s.size() - 1; i > 0; i--) {
               if(s[i] > s[i - 1]) {
                  ind = i - 1;
                  break;
               }
            }
            char maxc = 'z';
            for(int j = ind; j < s.size(); j++) {
               if(s[j] > s[ind] && s[j] < maxc)
                  maxc = s[j];
            }
            for(int i = 0; i < ind; i++) {
               cout << s[i];

            }
            cout << maxc << endl;
         }


      }


   }


   return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int a,b,c,reccount=0,lozcount=0;

	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){

		if(a!=b){
			if(a*a+b*b==c*c) reccount++;
		}
		else{
			if(a*a*+b*b!=c*c) lozcount++;
			if(a==1 && b==1 && c==1) lozcount++;

		}

		

	}
	printf("%d\n%d\n",reccount,lozcount);




	return 0;

}

Measured memory_bytes: 596
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N;

	cin >> N;

	long long ans = 0;
	int mx = 0;

	for(int i = 0; i < N; i++){
		int x;
		cin >> x;
		ans += x;
		mx = max(mx, x);
	}

	ans -= mx/2;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#![allow(unused_macros, unused_imports, dead_code)]
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty), +) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}

fn main() {
    loop {
        from_line!(a: i32, op: String, b: i32);
        if op == "?" {
            break;
        }
        let ret = match &*op {
            "+" => a + b,
            "-" => a - b,
            "*" => a * b,
            "/" => a / b,
            _ => 0,
        };
        println!("{}", ret);
    }
}



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

ll f[262144],g[262144],pre[622144],suf[262144],num[262144];
int n;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void print(ll x)
{
	static char s[233];
	if (!x) { putchar('0');putchar('\n');return; }
	int tot=0;
	for (;x;x/=10) s[++tot]=x%10+'0';
	for (;tot;tot--) putchar(s[tot]);
	putchar('\n');
}

inline ll pls(const ll &x,const ll &y) { return (x+y<mod)?x+y:x+y-mod; }
inline ll mns(const ll &x,const ll &y) { return (x-y<0)?x-y+mod:x-y; }
inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

inline void fwt(ll *a,int n)
{
	for (int w=2;w<=n;w<<=1) for (int k=0;k<n;k+=w) for (int j=k;j<k+(w>>1);j++)
	{
		ll u=a[j],t=a[j+(w>>1)];
		a[j]=pls(u,t);a[j+(w>>1)]=mns(u,t);
	}
}

int main()
{
	n=rd();
	for (int i=0;i<(1<<n);i++) num[i]=rd();
	ll sum=0;
	for (int i=0;i<(1<<n);i++) sum+=num[i];
	ll Inv=ksm(sum,mod-2);
	for (int i=0;i<(1<<n);i++) f[i]=num[i]*Inv%mod;
	fwt(f,1<<n);
	pre[0]=1;
	for (int i=1;i<(1<<n);i++) pre[i]=pre[i-1]*mns(1,f[i])%mod;
	suf[1<<n]=1;
	for (int i=(1<<n)-1;i;i--) suf[i]=suf[i+1]*mns(1,f[i])%mod;
	for (int i=1;i<(1<<n);i++) g[i]=mns(0,pre[i-1]*suf[i+1]%mod);
	for (int i=1;i<(1<<n);i++) g[0]=mns(g[0],pre[i-1]*suf[i+1]%mod*f[i]%mod);
	ll now=1;
	for (int i=1;i<(1<<n);i++) now=now*mns(1,f[i])%mod;
	fwt(g,1<<n);
	ll now1=ksm(now,mod-2);
	for (int i=0;i<(1<<n);i++) print(mns(g[i],g[0])*now1%mod);
	return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int ConvStrToInt(std::string checkStr)
{
	return atoi(checkStr.c_str());
}

int ConvStrToInt(char c)
{
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}

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

	std::vector<float> value(N);
	std::vector<string> tani(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> value[i] >> tani[i];
	}

	float resultValue = 0;
	for (int i = 0; i < N; i++)
	{
		if (tani[i] == "BTC")
		{
			value[i] *= 380000.0f;
		}
		resultValue += value[i];
	}

	cout << resultValue << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    double r;

    cin >> r;

    printf("%.6f\n", r * 2 * M_PI);
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define ll  long long

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, "\e[31;1m"); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\e[0m")
#else
    #define eprintf(...) 42
#endif

ll solve(const int T, const std::vector<int>& A)
{
    std::vector<int> a;
    int b = A[0];
    for (auto itr = A.begin() + 1; itr != A.end(); ++itr)
    {
        a.push_back(*itr - b);
        b = std::min(b, *itr);
    }
#if false
    for (auto itr = a.begin(); itr != a.end(); ++itr)
    {
        std::cout << "DEBUG1: " << *itr << std::endl;
    }
#endif

    int c = *std::max_element(a.begin(), a.end());
    if (-1 == c)
    {
        return 0;
    }
    return std::accumulate(a.begin(), a.end(), 0, [c](const int a, const int v){
        if (c == v)
        {
            return a + 1;
        }
        return a;
    });
}

int main(void)
{
    int N, T;
    std::cin >> N >> T;

    std::vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> A[i];
    }
    std::cout << solve(T, A) << std::endl;

    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <string>
#include <cctype>

using namespace std;

int main()
{
	string s;
	vector<int> count('z' - 'a' + 1, 0);

	while (getline(cin, s))
	{
		for (int i = 0; i < s.size(); ++i)
		{
			if (isupper(s[i]) || islower(s[i]))
				s[i] = tolower(s[i]);
			else
				continue;

			count[s[i] - 'a']++;
		}
	}

	for (char c = 'a'; c <= 'z'; ++c)
		cout << c << " : " << count[c - 'a'] << endl;

	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
int n;
void dfs(string s,char x)
{
	if(s.size()==n)
	{
		cout<<s<<endl;
		return;
	}
	for(char i='a';i<x;i++)
		dfs(s+i,x);
	dfs(s+x,x+1);
}
int main()
{
	cin>>n;
	dfs("",'a');

	return 0;
}

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

using pos = struct{int x; int y;};

int main() {
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  vector<int> la(n);
  for (int i = 0; i < n; ++i) {
    cin >> la[i];
  }
  int grid[h][w];
  vector<pos> order;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (i % 2) {
        order.push_back({w-j-1, i});
      }
      else {
        order.push_back({j, i});
      }
    }
  }
  int id = 0;
  for (int c = 0; c < n; ++c) {
    int a = la[c];
    for (int i = 0; i < a; ++i) {
      pos p = order[id++];
      grid[p.y][p.x] = c+1;
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cout << grid[i][j] << " ";
    }
    cout << endl;
  }
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  int N;
  int A[100000];
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  int S=0;
  S+=abs(A[0])+abs(A[N-1]);
  FOR(i,0,N-1){
    S+=abs(A[i+1]-A[i]);
  }
  FOR(i,0,N){
    int ans=S;
    if(i==0){
      ans-=abs(A[0]);
      ans-=abs(A[1]-A[0]);
      ans+=abs(A[1]);
    }else if(i==N-1){
      ans-=abs(A[N-1]);
      ans-=abs(A[N-1]-A[N-2]);
      ans+=abs(A[N-2]);
    }else{
      ans-=abs(A[i]-A[i-1])+abs(A[i+1]-A[i]);
      ans+=abs(A[i+1]-A[i-1]);
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000


int main(){
	int N;
	cin>>N;
	vector<int> A(N);
	
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	vector<int> b(N,-1);
	
	for(int i=N;i>=1;i--){
		long long ok = 0;
		long long ng = N+1;
		while(ng-ok>1){
			long long mid = (ok+ng)/2;
			if((long long)mid*i>N){
				ng=mid;
			}
			else{
				ok=mid;
			}
		}

		int now = 0;
		for(int j=ok*i;j>=1;j-=i){
			if(b[j-1]!=-1){
				now+=b[j-1];
			}
			else{
				if(now%2==A[j-1]){
					b[j-1]=0;
				}
				else{
					b[j-1]=1;
					now++;
				}
			}
		}	
	}
	vector<int> ans(0);
	for(int i=0;i<b.size();i++){
		if(b[i]==1)ans.push_back(i+1);
	}
	
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++){
		if(i!=0)cout<<' ';
		cout<<ans[i];
	}
	if(ans.size()!=0)cout<<endl;
	
	
		
	
	return 0;
}



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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  
  int A,B,C;cin>>A>>B>>C;
  int cnt=0;
  bool ok=false;
  rep(i,100){
    cnt +=A;
    if(cnt%B==C){
      ok=true;
      cout<<"YES"<<endl;
      break;
    }
  }
  if(!ok){
   cout<<"NO"<<endl;
  }
 
}





Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

char a[201000];
int n, p, nx[201000][30], poz[201000], v, sz, smin;
char r[200010];

bool ver() {
    int l = smin, i, pc = 0;

    for(i = 0; r[i] != 0; ++i) {
        l--;
        pc = nx[pc + 1][r[i] - 'a'];
    }

    if(pc > n)
        return 1;

    while(l) {
        --l;
        pc = poz[pc];
        if(pc > n)
            return 1;
    }

    return 0;
}

int main() {
    //freopen("ttt", "r", stdin);

    cin >> (a + 1);
    n = strlen(a + 1);

    int i, j;

    for(j = 0; j <= 26; ++j)
        nx[n + 1][j] = n + 1;

    for(i = n; i >= 0; --i) {
        int smax = 0;
        for(j = 0; j < 26; ++j) {
            nx[i][j] = nx[i + 1][j];
            smax = max(smax, nx[i][j]);
        }

        poz[i] = smax;

        if(i)
            nx[i][a[i] - 'a'] = i;
    }

    int pc = 0;
    while(pc <= n) {
        ++smin;
        pc = poz[pc];
    }

    for(i = 0; i < smin; ++i) {

        for(j = 'a'; j <= 'z'; ++j) {
            r[i] = j;
            if(ver())
                break;
        }
    }

    cout << r;


    return 0;
}


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

int main()
{
    int n,sum=0,count=0;
    cin>>n;
    int arr[n];

    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
            {
                if(i!=j)
                   {
                       sum+=arr[i]*arr[j];
                       //cout<<arr[i]<<"*"<<arr[j]<<" ";
                   }

                //count++;
            }
    }
    cout<<sum<<endl;
   // cout<<count;

   return 0;


}


Measured memory_bytes: 256
def main() -> None:
    N, M, X, Y = map(int, input().split())
    lx = list(map(int, input().split()))
    ly = list(map(int, input().split()))

    for Z in range(X+1, Y):
        if max(lx) < Z <= min(ly):
            print("No War")
            exit()
        else:
            continue

    print("War")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int n,m,k,v,i,count=0;
    cin>>n>>m;
    int dp[m],t=n;
    memset(dp,0,sizeof(dp));
    while(n--){
        cin>>k;
        while(k--){
            cin>>v;
            dp[v-1]++;
        }
    }
    for(i=0;i<m;i++){
        if(dp[i]==t)
        count++;
    }
    cout<<count<<endl;
}


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

int main(){
	
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if( s == u){
		a--;
	}else {
		b--;
	}
	cout<<a<<" "<<b;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort()
cnt=0
j=0
while cnt<k:
    cnt+=a[j][1]
    if cnt>=k:
        break
    else:
        j+=1
print(a[j][0])

Measured memory_bytes: 27872
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)

int main(){
    string s;
    cin >> s;
    cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;
}





Measured memory_bytes: 256
#include <stdio.h>

int main (){

    int a,b,c,i;

    int count=0;

    scanf("%d %d %d",&a,&b,&c);

    for(i=a;i<=b;i++){

    if(c%i==0) count++;

    }

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

    return 0;

 }  

 

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


int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;

    double wa,wb,wab;
    wa = 30 * h + m / 2;
    wb = 6 * m;
    if(abs(wa - wb) <= 180){
        wab = abs(wa - wb);
    }else{
        wab = 360 - abs(wa - wb);
    }
    double ans = sqrt(a*a + b*b - 2 * a * b * cos(wab * M_PI / 180));
    cout << fixed << setprecision(20) << ans <<endl;
    return 0;
}

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

using namespace std;

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

int main(){
    long int n;
    cin >> n;
    long int a[n], b[n], c[n];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    long int numb[n];
    numb[n-1] = n - (upper_bound(c, c + n, b[n-1]) - c);
    for (int i = n - 2; i >= 0; i--){
        long int num = n - (upper_bound(c, c + n, b[i]) - c);
        numb[i] = numb[i+1] + num;
        // cout << num << endl;
    }
    // rep(i, n) cout << numb[i] << " ";
    // cout << endl;

    long int ans = 0;
    for (int i = 0; i < n; i++){
        long int num = upper_bound(b, b + n, a[i]) - b;
        if (num < n){
            ans += numb[num];
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3328
import sys

S=input()
T=input()
n=len(S)
D={}
C=[]
for i in range(n):
    if not S[i] in D:
        if T[i] in C:
            print("No")
            sys.exit()
        D[S[i]]=T[i]
        C.append(T[i])
    else:
        if D[S[i]]!=T[i]:
            print("No")
            sys.exit()
print("Yes")

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vvi vector<vector<int>>;
#define mi  map<int,int>
#define mii map<pii,int>
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define sz(x) (int)x.size()
#define all(v) (v).begin(), (v).end()
#define ret(x) return cout<<x,0;
#define rety return cout<<"YES",0;
#define retn return cout<<"NO",0;
#define fl fflush(stdout)   
#define hell 1000000007  
#define hell2 998244353 
#define pi 3.14159265358979323846

int solve(){
    int x,a,b;
    cin>>x>>a>>b;
    x=x-a;
    cout<<x%b;
    return 0;
}

signed main(){
    auto start = high_resolution_clock::now();
    IOS;
    int t=1;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
   // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr<<"Time taken:"<<duration.count()/1000000.0<<"seconds"<<"\n";
    return 0;
} 

Measured memory_bytes: 3808
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

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

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

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
    getline(cin,a);
    getline(cin,b);
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    sort(a.begin(),a.end());
    if(a<b)
        puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main() {
  std::string s;
  int cnt1 = 0, cnt2 = 0;
  std::cin >> s;
  for(int i = 0; i != s.size(); ++i) {
    if(i % 2 == 0) {
      (s[i]-48?++cnt1:++cnt2);
    }
    else {
      (s[i]-48?++cnt2:++cnt1);
    }
  }
  std::cout << (cnt1<cnt2?cnt1:cnt2) << "\n";
}
  

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+10;
ll n,m,k,t;
ll a[N],id[N],x[N],sta[N],vis[N],ans[N];
int main(){
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) scanf("%lld",&x[i]),id[i]=i;
	for(ll i=n;i>=1;i--) x[i]-=x[i-1];
	scanf("%lld%lld",&m,&k);
	for(ll i=1;i<=m;i++) scanf("%lld",&t),swap(id[t],id[t+1]);
	for(ll i=1;i<=n;i++){
		if(!vis[i]){
			ll cnt=0;
			for(ll j=i;!vis[j];j=id[j]) sta[++cnt]=j,vis[j]=1;
			for(ll j=1;j<=cnt;j++) ans[sta[j]]=x[sta[(j+k-1)%cnt+1]];
		}
	}
	for(ll i=1;i<=n;i++) ans[i]+=ans[i-1],printf("%lld.0\n",ans[i]);
}

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

int main(void){
    int n,x,sum=0,ans;
    cin >> n >> x;
    vector<int> m(n);
    int hoge = 10001;
    for(int i=0;i<n;i++){
        cin >> m[i];
        sum += m[i];
        if(m[i]<hoge) hoge = m[i];
    }
    ans = n + (x-sum)/hoge;
    
    cout << ans << endl;

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
    
int main(void){
    int x, n;
    cin >> x >> n;
    
    if(n == 0){
        cout << x << endl;
        return 0;
    }
    
    vector<int> p(n);
    rep(i, n){
        cin >> p.at(i);
    }
    
    sort(p.begin(), p.end());

    
    int offset = 0;
    bool find_x = false;
    rep(i, n){
        if(p.at(i) == x){
            offset = i;
            find_x = true;
        }
    }
        
    if(find_x == false){
        cout << x << endl;
        return 0;
    }
    
    int i = 0;
    while(true){
        if(offset - i < 0){
            cout << (x - i) << endl;
            break;
        }
            
        if(p.at(offset - i) != (x - i)){
            cout << (x - i) << endl;
            break;
            
        }
        if(offset + i >= n){
            cout << (x + i) << endl;
            break;
        }
        if(p.at(offset + i) != (x + i)){
            cout << (x + i) << endl;
            break;
        }
        i = i + 1;
    }
                
    
}


Measured memory_bytes: 3628
//UG-02-51-19-002

#include <stdio.h>
int main()
{
int A_1,A_2,A_3;

 scanf("%d",&A_1);

 scanf("%d",&A_2);

 scanf("%d",&A_3);

{
if(A_1+A_2+A_3 >=22)
    printf(" bust\n");

else

    printf("win\n");
}
return 0;

}



Measured memory_bytes: 128
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    S = list(input())
    ans = 0

    for p in range(1000):
        p = str(p).zfill(3)
        i = 0
        for j in range(N):
            if p[i] == S[j]:
                i += 1
            if i == 3:
                ans += 1
                break

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 41584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    ll x;
    cin >> x;
    ll count = 0;
    ll money = 100;
    while (money < x){
        money = (ll)(money*1.01);
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(){
  int a,b,c,temp;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    temp=a;
    a=b;
    b=temp;
  }
  if(a>c){
    temp=a;
    a=c;
    c=temp;
  }
  if(b>c){
    temp=b;
    b=c;
    c=temp;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 596
def gcd(a,b):
##
#  if b == 0 :
#    return a
#  else:
#    return gcd(b,a % b)
##
  while b:
    a,b = b,a % b
  return a
###########################
N = int(input())
tmp = list()
s = 0

for i in range(1,N + 1):
  for j in range(1,N + 1):
      a = gcd(i,j)
      tmp.append(a)

for aTmp in tmp:
  for j in range(1,N + 1):
      a = gcd(aTmp,j)
      s += a

print(s)


Measured memory_bytes: 9328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
const ll MOD = (ll) 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);

	ll n; cin >> n;

	vector<vb> ppl(n,vb(n,false));
	FOR(i,0,n) {
		FOR(j,0,n) {
			int x; cin >> x;
			if (x == 1) {
				ppl[i][j] = true;
			}
		}
	}

	vvl dp(n+1,
			vl ((1LL<<n),0));

	dp[0][0] = 1;

	// maenner
	FOR(i,0,n) {
		// frauen
		FOR(j,0,n) {
			if (!ppl[i][j]) {
				continue;
			}

			FOR(k,0, 1LL<<n) {
				if (dp[i][k] == 0) {
					continue;
				}
				if (__builtin_popcount(k) != i) {
					continue;
				}
				if ( (1LL<<j) & k) {
					// bit already set
					continue;
				}
				ll nex = k | (1LL << j);
				dp[i+1] [nex] = (dp[i+1][nex] + dp[i][k]) % MOD;
			}
		}
	}

	/*
	FOR(i,0,n+1) {
		FOR(j,0, 1LL<< n) {
			cerr << dp[i][j] << " ";
		}
		cerr << endl;
	}
	cerr << endl;
	*/

	cout << dp[n][(1LL << n) - 1] << endl;

	return 0;
}


Measured memory_bytes: 377216
N = int(input())
now = list(input())
already = [now]
Flag = False
for _ in range(N - 1):
    next_word = list(input())
    if next_word in already or now[-1] != next_word[0]:
        Flag = True
    already.append(next_word)
    now = next_word

print("No" if Flag else "Yes")

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

int main(){
	// sengen
	unsigned long long n;
	// nyuryoku
	cin >> n;
	unsigned long long w = 1e9 + 7;
	unsigned long long a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	unsigned long long s[n-1];
	for(int i=n-2;i >= 0;i--){
		if(i == n-2){
			s[i] = a[n-1];
		}else{
			s[i] = (s[i+1] + a[i+1])%w;
		}
	}
	// keisan
	unsigned long long ans = 0;
	for(int i=0;i<n-1;i++){
		ans = (ans + a[i]*s[i]%w)%w;
	}
	// syutsuryoku
	cout << ans << endl;
}

Measured memory_bytes: 6748
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
	string s;
	cin>>s;
	vector<int> cnt(200);
	ll re=1;
	rep(i,s.size()){
		re+=i-cnt[s[i]];
		++cnt[s[i]];
	}
	cout<<re<<endl;
  return 0;
	
}


Measured memory_bytes: 720
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int cnt = 0;

    for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      }
    }

    System.out.println(cnt);
  }
}


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

int main()
{
    int n,f,b;
    scanf("%d",&n);
    f=n/100;
    b=n%100;
    if(0<f && f<13){
        if(0<b && b<13)
            printf("AMBIGUOUS");
        else
            printf("MMYY");
    }
    else{
        if(0<b && b<13)
            printf("YYMM");
        else
            printf("NA");
    }
}

Measured memory_bytes: 128
//
//  main.cpp
//  Test
//
//  Created by Nag on 2017/08/18.
//  Copyright ?? 2017??´ Nag. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>

using namespace std;

int main(void) {
    string str;
    int numOfCmd;
    string cmd;
    int from, to;
    string rep;
    
    cin >> str >> numOfCmd;
    
    for(int i=0; i<numOfCmd; i++) {
        cin >> cmd;
        
        if( cmd == "print" ) {
            cin >> from >> to;
            cout << str.substr(from, to-from+1) << endl;
        }
        
        else if( cmd == "reverse") {
            cin >> from >> to;
            reverse(str.begin()+from, str.begin()+to+1);
//            cout << str << endl;
        }
        
        else if( cmd == "replace") {
            cin >> from >> to >> rep;
            int j = 0;
            for(int i=from; i<=to; i++) {
                str[i] = rep[j++];
            }
//            cout << str << endl;
        }
        
    }
    
    return 0;
    
}


//abcde
//3
//replace 1 3 xyz
//reverse 0 2
//print 1 4

Measured memory_bytes: 3216
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//大きい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return bNum - aNum;}

int main(void){
    long long H;
    int cnt=0;
    long long shun;
    scanf("%lld",&H);
    if(H==1){
        printf("1");
        return 0;
    }
    shun=H;
    while(shun>1){
        shun/=2;
        cnt++;
    }
    long long ans=0;
    for(int i=0;i<=cnt;i++){
        ans+=pow(2,i);
    }
    printf("%lld",ans);
    return 0;
}


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

using namespace std;

int main(){
    int N,D,com=0,ans=0;
    cin >> N >> D;
    int X[N][D];
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin >> X[i][j];
        }
    }

    for(int i=0;i<(N-1);i++){
        for(int j=i+1;j<N;j++){
            for(int n=0;n<D;n++){
                com += (X[i][n]-X[j][n])*(X[i][n]-X[j][n]);
            }
            int a = (int)sqrt((double)com);
            if (a*a == com){
                ans++;
            }
            com = 0; 
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
struct Edge {
  int from, to, cost, rev;
  Edge(int from, int to, int cost, int rev)
      : from(from), to(to), cost(cost), rev(rev) {}
};
struct Graph {
  int V;
  vector<vector<Edge>> G;
  vector<int> used;
  Graph(int V) : V(V) {
    used = vector<int>(V, 0);
    G = vector<vector<Edge>>(V);
  }
  void add_edge(int from, int to, int cost = 1) {
    G[from].push_back(Edge(from, to, cost, G[to].size()));
    G[to].push_back(Edge(to, from, 0, G[from].size() - 1));
  }
  int augment_path(int s, int t, int f) {
    if (s == t)
      return f;
    used[s] = true;
    rep(i, 0, G[s].size()) {
      Edge &e = G[s][i];
      if (!used[e.to] && e.cost > 0) {
        int d = augment_path(e.to, t, min(f, e.cost));
        if (d > 0) {
          e.cost -= d;
          G[e.to][e.rev].cost += d;
          return d;
        }
      }
    }
    return 0;
  }
  int max_flow(int s, int t) {
    int flow = 0;
    while (1) {
      used = vector<int>(V, 0);
      int f = augment_path(s, t, INF);
      if (f == 0)
        break;
      flow += f;
    }
    return flow;
  }
};

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

  int X, Y, E;
  cin >> X >> Y >> E;
  Graph g(X + Y + 2);
  int s = X + Y, t = s + 1;
  rep(i, 0, E) {
    int x, y;
    cin >> x >> y;
    g.add_edge(x, X + y);
  }
  // take care of the direction of edges
  rep(i, 0, X) g.add_edge(s, i);
  rep(i, 0, Y) g.add_edge(i + X,t);

  cout << g.max_flow(s, t) << endl;

  return 0;
}



Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std ;
	#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define lli long long int
	#define ulli unsigned long long int
	#define ff first
	#define ss second
	#define mp make_pair
	#define pb push_back
	#define pf pop_front()
	#define lb lower_bound
	#define ub upper_bound
	#define bs binary_search
	#define loop(i,a,b) for(lli i=a;i<b;i++)
	#define loopi(i,a,b) for(int i=a;i<b;i++)
	#define all(v) v.begin(), v.end()
	#define mod 1000000007
	#define inf 100000000000000000
	#define lld long double
	#define pll pair<long long int,long long int>
	#define pii pair<int,int>
	#define vll vector<lli>
	#define vii vector<int>
	#define endl '\n'
	#define setp(k, x) fixed << setprecision(k) << (x)
	#define deb(x) cerr << #x << ": " << x << " " << endl;
	#define debug(x) cout << "m here-" <<#x<<" ..."<<"\n";
	#define printa(a,n) for(lli i=0;i<n;i++) cout<<a[i]<<" "; cout<<"\n";
  #define printv(a) for(lli i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<"\n";
	bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) //sort on basis of column //use- sort(vect.begin(), vect.end(),sortcol);
      { return v1[1] < v2[1]; }//[] o based indexing in column
	bool sortpair(const pair<char, lli> &a, const pair<char, lli> &b)
				{return a.second < b.second;}


int main ()
{
	// fastio
 	//lli  t;
 	//cin>>t;
 	//while(t--)
 	{
		lli n,i,d,a,b,c,j,k=0,flag=0,x,y,ans,tt=0;
    string s;
    cin>>s;//>>y;
  
    a=s.find('7');
    if(a>=0 )
      cout<<"Yes\n";
    else cout<<"No\n";

 	}
	return 0;
}


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

int main(){
  int n;
  cin >>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  int count=0;
  for(int i=0;i<n;i++){
    if(i+1 != vec.at(i)){
      count++;
    }
  }
  if(count==0||count==2){
    cout <<"YES"<<endl;
  }
  else{
    cout <<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


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 V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


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



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);

	return x * y / tmp;
}

vector<pii> v[20];

int main() {

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


	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		int c;
		cin >> c;
		for (int j = 0; j < c; j++)
		{
			int x, y;

			cin >> x >> y;
			x--;
			v[i].push_back(pii(x, y));
		}

	}

	int ans = 0;
	
	for (int i = 0; i < (1 << n); i++)
	{
		//正直者と仮定
		queue<int> que;
		int flag[20];
		for (int i = 0; i < 20; i++)
		{
			flag[i] = -1;
		}

		bool exist = true;
		
		for (int j = 0; j < n; j++)
		{
			if ((i >> j) & 1) {
				que.push(j);
				flag[j] = 1;
			}
		}

		

		while (!que.empty()) {
			//正直者しか入っていない
			int now = que.front();
			que.pop();

			for (pii t : v[now]) {

				if (t.second == 1) {
					//正直者
					if (flag[t.first] == 0) {
						exist = false;
						break;
					}
					else if (flag[t.first] == -1) {
						flag[t.first] = 1;
						que.push(t.first);
					}

				}
				else
				{
					
					if (flag[t.first] == 1) {
						exist = false;
						break;
					}
					else if (flag[t.first] == -1) {
						flag[t.first] = 0;
					}
				}

			}
			if (!exist) {
				break;
			}
		}



		if (exist) {
			int cnt = 0;
			for (int j = 0; j < n; j++)
			{
				if (flag[j] == 1) {
					cnt++;
				}
			}
			ans = max(ans, cnt);
		}
		
	}

	cout << ans << endl;





	return 0;
}



Measured memory_bytes: 256
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,a,b,c = gets.chomp.split.map(&:to_i)
l = []
n.times do
  l.push gets.chomp.to_i
end
l.sort!

ans = INF
size = l.size
indexes = (0..(n-1)).to_a
1.upto(size-2).each do |i|
  indexes.combination(i) do |atakes|

    1.upto(size-1-i).each do |j|
      (indexes-atakes).combination(j) do |btakes|
        # p [atakes,btakes]

        1.upto(size-i-j).each do |k|
          (indexes-atakes-btakes).combination(k) do |ctakes|

            cost = (i-1 + j-1 + k-1) * 10
            cost += (atakes.map{|i| l[i]}.inject(&:+) - a).abs
            cost += (btakes.map{|i| l[i]}.inject(&:+) - b).abs
            cost += (ctakes.map{|i| l[i]}.inject(&:+) - c).abs

            if ans > cost
              ans = cost
              # p [cost, atakes, btakes, ctakes]
            end
          end
        end
      end
    end

  end
end

puts ans


Measured memory_bytes: 2428
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n, i, result;
	int taro, hanako;
	char taro_str[101], hanako_str[101];
	scanf("%d", &n);
	taro = 0;
	hanako = 0;
	for (i = 0; i < n; ++i) {
		memset(taro_str, '\0', sizeof(taro_str));
		memset(hanako_str, '\0', sizeof(hanako_str));
		scanf("%s %s", taro_str, hanako_str);
		result = strcmp(taro_str, hanako_str);
		if (result > 0) {
			taro += 3;
		} else if (result < 0) {
			hanako += 3;
		} else {
			++taro;
			++hanako;
		}
	}
	printf("%d %d\n", taro, hanako);
	
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

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

const long long INF = 0x3f3f3f3f3f3f3f3f;

int n;
long long d;
long long a[200010];
int fa[200010];
vector <plii> e;

int find(int x){
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}

long long fl(int x){
	return x == -1 ? INF : a[x] - x * d;
}

long long fr(int x){
	return x == -1 ? INF : a[x] + x * d;
}

void add_edge(int l, int r){
	if (l == r) return ;
	int mid = (l + r) >> 1;
	int pos = -1;
	for (int i = l; i <= mid; i++){
		if (fl(i) < fl(pos)) pos = i;
	}
	for (int i = mid + 1; i <= r; i++){
		e.push_back(mp(a[i] + a[pos] + (i - pos) * d, mp(i, pos)));
	}
	pos = -1;
	for (int i = mid + 1; i <= r; i++){
		if (fr(i) < fr(pos)) pos = i;
	}
	for (int i = l; i <= mid; i++){
		e.push_back(mp(a[i] + a[pos] + (pos - i) * d, mp(i, pos)));
	}
	add_edge(l, mid), add_edge(mid + 1, r);
}

int main(){
	scanf("%d%lld", &n, &d);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	add_edge(0, n - 1);
	sort(e.begin(), e.end());
	for (int i = 0; i < n; i++){
		fa[i] = i;
	}
	long long ans = 0;
	int tot = n - 1;
	for (int i = 0; i < e.size(); i++){
		int u = e[i].se.fi, v = e[i].se.se;
		long long dist = e[i].fi;
		if (find(u) == find(v)) continue;
		fa[find(u)] = find(v);
		ans += dist, tot--;
		if (!tot) break;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 69472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const double INF = 1e18;
int n;
double dist[1050][1050];
double x[1050];
double y[1050];
double r[1050];
double xs,ys,xt,yt;

double d(int i, int j) {
	return sqrt(fabs(x[i]-x[j]) * fabs(x[i]-x[j]) + fabs(y[i]-y[j]) * fabs(y[i]-y[j]));
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> xs >> ys >> xt >> yt;
	cin >> n;
	rep(i,0,n) {
		cin >> x[i] >> y[i] >> r[i];
	}
	x[n] = xs; y[n] = ys; r[n] = 0;
	x[n+1] = xt; y[n+1] = yt; r[n+1] = 0;
	rep(i,0,n+2) rep(j,0,n+2) {
		dist[i][j] = max(d(i,j) - r[i] - r[j], 0.0);
	}

	vector<double> upper(n+2, INF);
	upper[n] = 0;
	priority_queue<pair<double, int> > Q;
	Q.push(mp(0, n));
	while(!Q.empty()) {
		double cost = -Q.top().F;
		int idx = Q.top().S;
		Q.pop();
		if(cost > upper[idx]) continue;
		rep(i,0,n+2) {
			double ncost = cost + dist[idx][i];
			if(ncost < upper[i]) {
				upper[i] = ncost;
				Q.push(mp(-ncost, i));
			}
		}
	}
	cout << fixed << setprecision(10) << upper[n+1] << '\n';
	return 0;
}


Measured memory_bytes: 13808
import copy

n, m = map(int, input().split())
Adj_dict_all = {} 
Input_ab_list = []

for i in range(n):
    new = {i+1: []}
    Adj_dict_all.update(new)

# Input + making Adjcency list
for _ in range(m):
    a, b = map(int, input().split())
    Adj_dict_all[a].append(b)
    Adj_dict_all[b].append(a)
    Input_ab_list.append((a,b))

# DFSで求めていく
def Connection(Adj_dict = {}, start = 1, Visited = [False]*n):

    if Visited[start-1]:
        return
    
    # 対象のnodeをVisitedに追加
    Visited[start-1] = True
    
    for node in Adj_dict[start]:
        if Visited[node-1] == False:
            Connection(Adj_dict, node, Visited)
    
    return

ans = 0

# loop for delete each bridge
for i in range(m):
    
    del_a = Input_ab_list[i][0]
    del_b = Input_ab_list[i][1]

    # delete one bridge -> Adj_dict
    Adj_dict = copy.deepcopy(Adj_dict_all)
    Adj_dict[del_a].remove(del_b)
    Adj_dict[del_b].remove(del_a)

    Visited=[False]*n
    Connection(Adj_dict, 1, Visited)

    # check connection
    if not all(Visited):
        ans += 1    

print(ans)



Measured memory_bytes: 3572