akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#ifdef _LOCAL_
	#define cout cerr
#endif
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define FORalld(it, a) for (__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}

const int maxn = 100000 + 5;
int n;
vi adj[maxn];

int dfs(int u, int p = -1) {
	int res = 0;
	int cnt[30] = {}, mx = 0;
	FOR(i, 0, sz(adj[u])) {
		int v = adj[u][i];
		if (v != p) {
			int r = dfs(v, u);
			res |= r;
			FOR(j, 0, 30) {
				if (bit(r, j)) {
					cnt[j]++;
				}
				if (cnt[j] > 1) chkmax(mx, j + 1);
			}
		}
	}
	FOR(i, mx, 30) if (!bit(res, i)) {
		FOR(j, 0, i) res |= 1 << j, res ^= 1 << j;
		res |= 1 << i;
		break;
	}
	return res;
}

void solve() {
	cin >> n;
	FOR(i, 0, n - 1) {
		int u, v; cin >> u >> v; u--, v--;
		adj[u].pb(v), adj[v].pb(u);
	}
	cout << __lg(dfs(0)) << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 20608
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
#define d_arr(arr, h, w) rep(i,(h) ){ cout << "["; rep(j,(w) ) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x);

typedef pair<int ,int> P;

class car
{
    int id;
    int num;
    public:
        car(int x, int y){ id=x; num=y; }
};


int main()
{
    int N,M;
    set<string> u;
    vector<string> t;
    //しまってる　0 　空いている 1
    int state = 0;
    //vector<int> state;
    cin >> N;
    string tmp;
    rep(i,N)
    {
        cin >> tmp;
        u.insert(tmp);
    }
    cin >> M;
    rep(i,M)
    {
        cin >> tmp;
        t.push_back(tmp);
    }
    rep(i,M)
    {
        if ( u.find( t[i] ) == u.end() ) { cout << "Unknown " << t[i] << endl; }
        else if(state == 0) {cout << "Opened by " << t[i] << endl; state = 1; }
        else if(state == 1) {cout << "Closed by " << t[i] << endl; state = 0; }
    }
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  int max = vec[N-1];
  int min = vec[0];
  cout << max - min;
}

Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))
d1={}
d2={}
l1=[]
l2=[]
for i in range(n):
    num=v[i]
    if i%2==0:
        try:
            d1[num]+=1
        except:
            d1[num]=1
    else:
        try:
            d2[num]+=1
        except:
            d2[num]=1
for i in d1:
    l1.append([d1[i],i])
for i in d2:
    l2.append([d2[i],i])
l1.sort(reverse=True)
l2.sort(reverse=True)
ans=n
if l1[0][1]!=l2[0][1]:
    ans-=(l1[0][0]+l2[0][0])
elif len(l1)==1 and len(l2)==1:
    ans//=2
elif len(l1)==1:
    ans-=l2[1][0]
elif len(l2)==1:
    ans-=l1[1][0]
else:
    a=ans-l1[0][0]-l2[1][0]
    b=ans-l1[1][0]-l2[0][0]
    ans=min(a,b)
print(ans)


Measured memory_bytes: 27272
#include<bits/stdc++.h>
using namespace std;
int main() {
	int H, W; cin >> H >> W;
	int dist[10][10];
	for (int i = 0; i <10; i++) {
		for (int j = 0; j <10; j++) {
			cin >> dist[i][j];
		}
	}
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
			}
		}
	}
	long long ans = 0;
	int A[H][W];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (A[i][j] == -1) continue;
			else ans += dist[A[i][j]][1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

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


Measured memory_bytes: 2668
#include<iostream>
#include<string>

int main(){
  std::string a, b, c;
  std::cin >> a >> b >> c;
  int m = a.size(), n = b.size();
  if(a[m - 1] == b[0] && b[n - 1] == c[0])
    std::cout << "YES";
  else
    std::cout << "NO" ;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

int main() {
  int a, b;
  scanf("%d %d", &a, &b);

  int r = 0;
  if (a >= b) {
    r += a;
    a--;
  } else {
    r += b;
    b--;
  }
  if (a >= b) {
    r += a;
    a--;
  } else {
    r += b;
    b--;
  }

  cout << r << endl;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    double a, b, x;
    cin >> a >> b >> x;

    double ans;
    if (a * a * b > 2 * x) {
        ans = atan(a * b * b / (2 * x)) * 180 / M_PI;
    } else {
        ans = atan(2 * (b - x / (a * a)) / a) * 180 / M_PI;
    }

    printf("%.10f\n", ans);
    return 0;
}

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

int n, m, q;
int a[51], b[51], c[51], d[51];
int A[11];
ll ans = 0;

void dfs(int k) {
    if (k == n) {
        ll sum = 0;
        for(int i = 1; i <= q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                sum += d[i];
            }
        }
        ans = max(ans, sum);
    } else {
        for (int i = A[k]; i <= m; i++) {
            A[k+1] = i;
            dfs(k+1);
        }
    }
}

int main() {
    cin >> n >> m >> q;
    for (int i = 1; i <= q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    A[0] = 1;
    dfs(0);
    cout << ans << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, w);
    vi dp(w+1, 0);

    rep(i, n) {
        int2(yui, kyoko);
        for (int j = w - yui; j > 0; j--) {
            if (dp[j]) 
                dp[j + yui] = max(dp[j + yui], dp[j] + kyoko);
        }
        dp[yui] = max(dp[yui], kyoko);
    }

    int ret = dp[0];
    rep(i, dp.size()) ret = max(ret, dp[i]);
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  int B= A / 1000;
  int C= A / 100 % 10;
  int D= A / 10 % 10;
  int E= A % 10;
 
  if (B==C && C==D) {
    cout << "Yes" << endl;
  }else if (C==D && D==E) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int i,j=0,k;
char a[9999],b[3]="CF";
int main()
{
	gets(a);
    k=strlen(a);
    for(i=0;i<=k;i++)
    {
		if(a[i]==b[j])  {j++;}
        if(j==2)
        {
			break;
        }
    }
    if(j>=2)   {printf("Yes\n");}
    else       {printf("No\n");}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<ll, ll>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define int ll

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int find(int x) {
        if (d[x]<0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x==y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return -d[find(x)];
    }
};
const int MX = 100005;
ll numedge[2*MX];


signed main(){
    int n;
    cin >> n;
    vector<P> v(n);
    rep(i, n) cin >> v[i].first >> v[i].second;
    UnionFind u(2*MX);
    rep(i, n) {
        int r1 = u.find(v[i].first);
        int r2 = u.find(v[i].second+MX);
        u.unite(v[i].first, v[i].second+MX);
        int r3 = u.find(v[i].first);
        if (r1!=r2) {
            numedge[r3] = numedge[r1] + numedge[r2] + 1;
        }
        else {
            numedge[r3]++;
        }
    }
    vector<P> num(2*MX);
    
    rep(i, 2*MX) {
        int r = u.find(i);
        if (i/MX==0) {
            num[r].first++;
        }
        else {
            num[r].second++;
        }
    }

    ll ans = 0;

    rep(i, 2*MX) {
        //if (num[i].first>0) debug(num[i].first);
        //if (num[i].second>0) debug(num[i].second);
        //if (numedge[i]>0) debug(numedge[i]);
        if (num[i].first>1 && num[i].second>1) {
            ans += (ll)(num[i].first*num[i].second) - numedge[i];
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7296
var
  s:string;
  a,b,i:longint;
begin
  readln(a,b);
  readln(s);
  if s[a+1]<>'-' then 
  begin
    writeln('No');
    exit;
  end;
  for i:=1 to a+b-1 do
  if i<>a+1 then
    if (s[i]<'0') or (s[i]>'9') then 
    begin
      writeln('No');
      exit;
    end;
  writeln('Yes');
end.

Measured memory_bytes: 128
def main():
    n = int(input())
    s = str(input())
    k = int(input())
    

    mozi = s[k-1]
    # print(n, s , k, mozi)
    result = ''
    for c in list(s):
        if c == mozi:
            result += mozi
        else:
            result += '*'
    print(result)
    


main()

Measured memory_bytes: 2940
N,M,C = map(int,input().split())
Bn = list(map(int,input().split()))
ans=0
nums = []
for n in range(N):
    As = list(map(int,input().split()))
    if sum([x*y for (x,y) in zip(As,Bn)])+C>0:
        ans+=1
print(ans)


Measured memory_bytes: 3060
import java.util.*;
class Main{
    private static int gcd(int a,int b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        return gcd(b,a%b);
    }
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int N = sc.nextInt();
        int ans=0;
        for(int a=1;a<=N;a++){
            for(int b=1;b<=N;b++){
                for(int c=1;c<=N;c++){
                    ans=ans+gcd(a,gcd(b,c));
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35804
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;

int main(){
	int N;
	long long A[200000];
	scanf("%d",&N);

	for(int i=0;i<N;i++){
		scanf("%lld",&A[i]);
	}

	for(int i=0;i<N;i++){
		A[i]-=i+1;
	}

	sort(A,A+N);

	int k;
	if(N%2==1) k = (N-1)/2;
	else k = N/2;
	
	long long ans = 0;
	for(int i=0;i<N;i++){
		ans += abs(A[i]-A[k]);
	}
	
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int64, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
	}
	for i := 0; i < n; i++ {
		if aa[i] == 0 {
			fmt.Fprintln(writer, 0)
			return
		}
	}
	var ans int64 = 1
	for i := 0; i < n; i++ {
		if int64(1e18)/aa[i] < ans {
			fmt.Fprintln(writer, -1)
			return
		}
		ans *= aa[i]
	}
	fmt.Fprintln(writer, ans)
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int maxn = 5e5 + 10, INF = 1000000009 , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}

vector<pair<int,int> > E[maxn];
ll d[maxn];
int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    init();
	int n,m;cin>>n>>m;
	for(int i = 0;i < m;i++) {
        int l,r,d;cin>>l>>r>>d;
        E[r].push_back(make_pair(l,-d));
        E[l].push_back(make_pair(r,d));
	}
	for(int i = 0;i < maxn;i++) d[i] = INF;
	for(int i = 1;i <= n;i++) {

        if(d[i] == INF) {
            queue<int> q;
            q.push(i);
            d[i] = 0;
            while (!q.empty()) {
                int u = q.front();
                q.pop();
                for(int j = 0;j < E[u].size();j++) {
                  //  cout<<j<<endl;
                    int v = E[u][j].first;
                    int val = E[u][j].second;
                    if(d[v] == INF) {
                        d[v] = d[u] + (ll)val;
                        q.push(v);
                    } else if(d[v] - d[u] != val) {
                        cout<<"No"<<endl;
                        return 0;
                    }
                }
            }

        }
	}
	cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 22272
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N; cin >> N;
	vector<int>V(N);
	vector<int>C(N);
	REP(i, N)cin >> V[i];
	REP(i, N)cin >> C[i];
	int out = 0;
	REP(i, N) {
		if (V[i] > C[i]) {
			out += V[i] - C[i];
		}
	}
	print(out);



	return 0;
}


Measured memory_bytes: 256
// Problem : D - Alter Altar
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
void solve()
{
	int n,i;
	cin>>n;
	string s;
	cin>>s;
	int ans=1e9;
	int cnt=0;
	int m=0;
	int cntr=0,cntw=0;
	for(i=0;i<n;i++)
	{
		if(s[i]=='W')
			cntw++;
		else
			cntr++;
	}
	int ind=cntr;
	for(i=0;i<ind;i++)
		if(s[i]=='R')
			cntr--;
	ans=min(ans,cntr);
	ind=cntw;
	for(i=n-ind;i<n;i++)
		if(s[i]=='W')
			cntw--;
	ans=min(ans,cntw);
	cout<<cntw<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}
vector<vll> G;
vll dp;

ll dfs(ll source) {
    ll res = 0;
    if(dp[source] != -1) {
        return dp[source];
    }
    for(ll ne : G[source]) {
        res = max(res, dfs(ne) + 1);
    }
    dp[source] = res;
    return res;
}

void solve()
{
    ll n,m;
    cin >> n >> m;
    G.resize(n+1);
    dp.assign(n+1, -1);
    for(ll i=0;i<m;i++) {
        ll x,y;
        cin >> x >> y;
        G[x].pb(y);
    }
    ll ans = 0;
    for(ll i=1;i<=n;i++) {
        ans = max(ans, dfs(i));
    }
    cout << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE 
      // OC;
    #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

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

int main() {
	string S;
	cin >> S;
	int ans = 0, tmp=0;

	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			tmp++;
		}
		else {
			ans = max(ans, tmp);
			tmp = 0;
		}
		if (i == S.length() - 1) {
			ans = max(ans, tmp);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
const int MAX=100001;
const double EPS=1e-10;
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,a,b;
ll v[55];
double ave=0;
int flag=1;
ll c[55][55];
void cmb(){
	REP(i,55)
		REP(j,55)c[i][j]=1;
	for(ll i=2;i<55;i++)
		c[i][1]=i;
	for(ll i=2;i<55;i++){
		for(ll j=i+1;j<55;j++){
			c[j][i]=c[j-1][i]*j/(j-i);
		}
	}
}
int main(){
	cmb();
	cin>>n>>a>>b;
	REP(i,n)cin>>v[i];
	sort(v,v+n,greater<ll>());
	for(int i=0;i<a;i++)ave+=v[i];
	printf("%f\n",ave/a);
	for(int i=0;i<a-1;i++){
		if(v[i]!=v[i+1])flag=0;
	}
	if(!flag){
		ll t1=0;
		ll t2=0;
		ll t3=v[a-1];
		for(int i=0;i<a;i++){
			if(v[i]==t3)t1++;
		}
		for(int i=0;i<n;i++){
			if(v[i]==t3)t2++;
		}
		cout<<c[t2][t1]<<endl;
		return 0;
		
	}else{
		ll t1=0;
		for(int i=0;i<n;i++){
			if(v[i]==v[0])t1++;
		}
		ll ans=0;
		for(ll i=a;i<=min(b,t1);i++){
			ans+=c[t1][i];
			//cout<<c[t1][i]<<endl;
		}
		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)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.ne(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll a[200005];
ll s[200005];
void solve() {
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) {
        s[i + 1] += a[i];
        s[i + 1] += s[i];
    }

    ll ans = inf;
    loop(i, 2, n - 1) {
        auto l = distance(s, upper_bound(s + 1, s + i - 1, s[i] / 2));
        auto r = distance(s, upper_bound(s + i, s + n, (s[i] + s[n]) / 2));
        if (s[i] / 2 - s[l - 1] < s[l] - s[i] / 2) --l;
        if ((s[i] + s[n]) / 2 - s[r - 1] < s[r] - (s[i] + s[n]) / 2) --r;
        auto x = max({ s[l],s[i] - s[l],s[r] - s[i],s[n] - s[r] });
        auto y = min({ s[l],s[i] - s[l],s[r] - s[i],s[n] - s[r] });
        mins(ans, x - y);
    }

    cout << ans << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(){
    int len = 2*pow(10,5)+1;
    char s[len], t[len];
    scanf("%s", s);
    scanf("%s", t);

int n=0;
for(int i=0; strlen(s)>i ; i++){
    if(s[i] != t[i])  n++;
}

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

Measured memory_bytes: 2084
fun main(args: Array<String>) {
    val s = readLine()!!
    print(if (req1(s)&&req2(s)&&req3(s)) ("AC") else ("WA"))
}

fun req1(s: String): Boolean {
    return s[0] == 'A'
}

fun req2(s: String): Boolean {
    val len = s.substring(2 until s.length-1).filter{it == 'C'}.length
    return len == 1
}

fun req3(s: String): Boolean {
    return s.filter{(it != 'A' && it != 'C')}.all{it.isLowerCase()}
}


Measured memory_bytes: 33752
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define mkp make_pair
#define pii pair<int,int>
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=2e5+200;
int k;
int a[maxn];
ll ans=-1;
void dfs(int step,int len){
	if(ans!=-1)return ;
	if(step==len){
		if(k>0)k--;
		if(k==0){
			ans=0;
			for(int i=0;i<len;i++)ans=ans*10+a[i];
		}
		return ;
	}
	if(a[step-1]>=1){
		a[step]=a[step-1]-1;
		dfs(step+1,len);
	}
	a[step]=a[step-1];
	dfs(step+1,len);
	if(a[step-1]<=8){
		a[step]=a[step]+1;
		dfs(step+1,len);
	}
}
int main(){
	cin>>k;
	for(int i=1;i<=1000;i++){
		for(int j=1;j<=9;j++){
			a[0]=j;
			dfs(1,i);
			if(ans!=-1)break;
		}
		if(ans!=-1)break;
	}
	cout<<ans<<endl;
	
}

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

#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

vector<ll> cycle;
vector<bool> used;

void dfs(ll v, ll m) {
    cycle.PB(v);
    if (used[v]) {
        return;
    }
    used[v] = 1;
    ll to = (v * v) % m;
    dfs(to, m);
}

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    ll n, x, m;
    cin >> n >> x >> m;
    used.assign(m, 0);
    dfs(x, m);
    ll pos = 0;
    for (; cycle[pos] != cycle.back() && pos < int(cycle.size()); pos++);
    pos ++;
    ll len = cycle.size() - pos;
    ll rem = (n - pos) % len;
    
    ll sum = 0;
    for (int i = pos; i < cycle.size(); i++) {
        sum += cycle[i];
    }

    ll ans = ((n - pos) / len) * sum;
    
    for (int i = 0; i < pos; i++) {
        ans += cycle[i];
    }

    for (int i = pos; i < pos + rem; i++) {
        ans += cycle[i];
    }
    
    cout << ans;
    return 0;
} 


Measured memory_bytes: 5244
let () =
  let n = read_int () in 
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x)) in 
  let () = Array.fast_sort compare a in 
  let rec f i sum =
    if i = n then sum else f (i + 1) (sum + a.(i) - a.(i - 1))
  in f 1 0
     |> Printf.printf "%d\n"

Measured memory_bytes: 384
import numpy as np
i8 = np.int64
i4 = np.int32



def main():
    stdin = open('/dev/stdin', 'rb')
    pin = np.fromstring(stdin.read(), i8, sep=' ')
    A = pin[1:]
    ans = np.argsort(A) + 1
    print(*ans.tolist())


if __name__ == '__main__':
    main()

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

struct UnionFind{
    vector<int>p,r;
    UnionFind(int n){
        p.resize(n,-1);
        r.resize(n,1);
    }
    int find(int x){
        if(p[x]==-1)return x;
        else return p[x]=find(p[x]);
    }
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y)return;
        if(r[x]>r[y])swap(x,y);
        if(r[x]==r[y])r[y]++;
        p[x]=y;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n+m);
    rep(i,n){
        int k; cin>>k;
        rep(j,k){
            int l; cin>>l; l--;
            uf.unite(i,l+n);
        }
    }
    bool ok=true;
    rep(i,n-1){
        if(!uf.same(i,i+1))ok=false;
    }
    printf(ok?"YES\n":"NO\n");
}

Measured memory_bytes: 4732
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define N 262144
lint dat[2][N*2+10];
lint inf=1145141919810364364LL;
//[a,b)の最小値
//外からは(a,b,0,0,n)として呼ぶ
lint query(int a,int b,int id,int k=0,int l=0,int r=N){
	if(r<=a || b<=l) return inf;
	if(a<=l && r<=b) return dat[id][k];
	lint vl=query(a,b,id,k*2+1,l,(l+r)/2);
	lint vr=query(a,b,id,k*2+2,(l+r)/2,r);
	return min(vl,vr);
}
void update(int id,int k,lint a){
	k+=N-1;
	dat[id][k]=a;
	while(k>0){
		k=(k-1)/2;
		dat[id][k]=min(dat[id][k*2+1],dat[id][k*2+2]);
	}
	return;
}
int x[252521];
int main()
{
	lint sum=0,out=inf,out2=inf;int n,q,a,b;
	cin>>n>>q>>a>>b;x[0]=a;
	rep(i,2) rep(j,N*2+5) dat[i][j]=inf;
	update(0,b,n-b);update(1,b,b);
	rep(i,q) cin>>x[i+1];
	rep(i,q){
		//rep(j,n+1) cout<<dat[0][j+N-1]-(n-j)<<',';cout<<endl;
		lint dif=abs(x[i]-x[i+1]);
		sum+=dif;
		lint ne=min(query(0,x[i+1]+1,0)-(n-x[i+1]),query(x[i+1],n+1,1)-x[i+1]);
		//cout<<ne<<endl;
		update(0,x[i],ne-dif+n-x[i]);update(1,x[i],ne-dif+x[i]);
	}
	rep(i,n+1) out=min(out,dat[0][i+N-1]-(n-i));
	rep(i,n+1) out2=min(out2,dat[1][i+N-1]-i);
	assert(out==out2);
	cout<<out+sum<<endl;
}


Measured memory_bytes: 9216
function riffle(arr){
   var len=arr.length/2;
   var after=[];
   for(var i=0;i<len;i++)after.push(arr[i],arr[i+len]);
   return after;
}
 
function cut(arr,x){
   var a=arr.slice(0,x);
   var b=arr.slice(x,arr.length+1);
   return b.concat(a);
}
 
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
var a=2*Arr[0];
var card=[];
for(var i=0;i<a;i++)card[i]=i+1;
Arr.shift();
var AL=Arr.shift();
 
for(i=0;i<AL;i++){
   if(Arr[i]==0)card=riffle(card);
   if(Arr[i]>0)card=cut(card,Arr[i]);
}
 
card.forEach(function(v){console.log(v);});

Measured memory_bytes: 10524
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
	while(1){
		int n,m,l,k,a,h;
		cin >>n>>m>>l>>k>>a>>h;
		if(n==0) break;
		
		vector<int> freeze(l+2);
		for(int i=0; i<l; i++){
			cin >> freeze[i];
		}
		freeze[l]=a; freeze[l+1]=h;
		vector<vector<int> > dp(n, vector<int>(n,inf));
		for(int i=0; i<k; i++){
			int x,y,t;
			cin >> x >> y >> t;
			dp[x][y] = dp[y][x] = t;
		}
		
		for(int k=0; k<n; k++){
			for(int i=0; i<n; i++){
				for(int j=0;j<n; j++){
					if(dp[i][k]+dp[k][j] < dp[i][j]){
						dp[i][j] = dp[i][k]+dp[k][j];
					}
				}
			}
		}
		
		for(int i=0; i<l+2; i++){
			for(int j=0; j<l+2; j++){
				if(dp[freeze[i]][freeze[j]] > m){
					dp[freeze[i]][freeze[j]] = inf;
				}
			}
		}
		for(int k=0; k<l+2; k++){
			for(int i=0; i<l+2; i++){
				for(int j=0;j<l+2; j++){
					int x=freeze[i];
					int y=freeze[j];
					int z=freeze[k];
					if(dp[x][z]+dp[z][y] < dp[x][y]){
						dp[x][y] = dp[x][z]+dp[z][y];
					}
				}
			}
		}
		
		if(dp[a][h]==inf){
			cout << "Help!" << endl;
		}else{
			cout << dp[a][h] +max(0, dp[a][h]-m) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3108
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct point
{
	long long name; long long dist;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};

ll const MAX = 100005;
ll a[MAX] = {};

int main() {
	ll n, m;
	cin >> n >> m;
	REP(i, 1, m) {
		ll u,v;
		cin >> u >> v;
		a[u]++;
		a[v]++;
	}
	REP(i, 1, n) {
		if (a[i] % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

struct point{
	int x, y;
	bool operator < (const point & a){
		if(x == a.x){
			return y < a.y;
		}
		return x < a.x;
	}
} v[100];

point nexttotop(stack<point>& st){
	point t = st.top();
	st.pop();
	point r = st.top();
	st.push(t);
	return r;
}

int compare(point  a, point  b, point  c){
	point u, v;
	u.x = a.x-b.x;
	u.y = a.y-b.y;
	v.x = c.x-b.x;
	v.y = c.y-b.y;
	int val = v.x*u.y - v.y*u.x;
	if( val == 0) return 0;
	else if(val > 1) return 1;
	else return -1;
}

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


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{ 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		String S = I.next();
		boolean good=false;
		if (S.charAt(0)==S.charAt(1)&&S.charAt(1)==S.charAt(2)) good=true;
		else if (S.charAt(1)==S.charAt(2)&&S.charAt(2)==S.charAt(3)) good=true;
		O.pln(good?"Yes":"No");
	}
	public static ArrayList<String> perms(int N,int limit){
		if (N==1) {
			ArrayList<String> ret = new ArrayList<String>();
			for (int i = 0; i < limit; i++) {
				 ret.add(Integer.toString(i));
			}
			return ret;
		}
		ArrayList<String> prev = perms(N-1,limit);
		ArrayList<String> ret = new ArrayList<String>();
		for (int i = 0; i < prev.size(); i++) {
			String cur = prev.get(i);
			boolean[] vis = new boolean[10];
			for (int j = 0; j < cur.length(); j++) {
				int dig = Integer.parseInt(cur.substring(j,j+1));
				vis[dig]=true;
			}
			if (!vis[1]) {
				for (int next = 0; next < limit; next++) {
					if (!vis[next]) {
						String add = cur;
						add+=Integer.toString(next);
						ret.add(add);
					}
				}
			}else ret.add(cur); //Just use previous end on 1 sequence	
		}
		return ret;
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define mod 1000000007
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define MAX 100001

inline int add(int a, int b) {a += b; if (a < 0) a += mod; return a;}
inline int sub(int a, int b) {a -= b; if (a < 0) a += mod; return a;}
inline int mul(int a, int b) {return (a * 1ll * b) % mod;}
inline int pwr(int x, ll y) {
    int ans = 1 % mod;
    while (y) {
        if (y & 1) ans = mul(ans, x);
        x = mul(x, x);
        y >>= 1;
    }
    return ans;
}
inline int inv(int a) {return pwr(a, mod - 2);}

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

    int n;
    cin >> n;
    string str[3];
    for (int i = 0; i < 3; i++) {
        cin >> str[i];
        //cout << str[i] << endl;
    }
    int col[n];
    for (int i = 0; i < n; i++) {
        map <char, int> mp;
        for (int j = 0; j < 3; j++) {
            mp[str[j][i]]++;
        }
        col[i] = -1;
        for (auto it : mp) {
            col[i] = max(col[i], it.second);
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans += (3 - col[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define double long double
#define PT(x) cout << (#x) << " is " << (x) << endl;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int M = 1000000007;
void PV(vi v){ for(int i=0 ; i<v.size() ; i++) cout<< v[i] << " "; cout<< endl;}
void PA(int v[],int n){ for(int i=0 ; i<n ; i++)cout<< v[i] << " " ; cout<< endl;}

signed  main(){
    SPD_emergency
  // int t; cin>>t; while(t--)
    {
     string s;
     cin>>s;
     if(s[2]==s[3]&& s[4]==s[5])
       cout<<"Yes"<<endl;
     else
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import Counter


def main():
    N = int(input())
    points = []
    for _ in range(N):
        x, y = [int(i) for i in input().split()]
        points.append([x, y])

    diffs = []
    if N == 1:
        print(1)
        return

    for i in range(N):
        for j in range(N):
            if i == j:
                pass
            else:
                x = points[i][0] - points[j][0]
                y = points[i][1] - points[j][1]
                diffs.append("{}_{}".format(x, y))

    c = Counter(diffs).most_common(1)[0][1]
    print(N-c)


main()


Measured memory_bytes: 40560
N, K = map(int, input().split())
A = list(map(int, input().split()))

mini = min(A)
idx = N + 1
mid = N / 2

for i, a in enumerate(A):
  if a == mini and abs(idx - mid) > abs(i - mid):
    idx = i

ans = i // (K - 1)
rem = i % (K - 1)
if rem:
  ans += 1
  if (N - i - 1 - (K - rem)) // (K - 1) > 0:
    ans += (N - i - 1 - (K - rem)) // (K - 1)
    if (N - i - 1 - (K - rem)) % (K - 1) != 0:
      ans += 1
else:
  if (N - i - 1) // (K - 1) > 0:
    ans += (N - i - 1) // (K - 1)
    if (N - i - 1) % (K - 1) != 0:
        ans += 1
print(ans)

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

map <string, ll> mp ;

int main()
{
    ll n, m, ans = 0 ;
    string s ;
    cin >> n ;
    for (int i = 0; i < n; i++) {
        cin >> s ;
        mp[s]++ ;
    }
    cin >> m ;
    for (int i = 0; i < m; i++) {
        cin >> s ;
        mp[s]-- ;
    }
    for (auto it = mp.begin(); it != mp.end(); it++) {
        ans = max(ans, it->second) ;
    }
    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cs[200010];
vector<int> A;
int N;
long long M;
 
template <typename T>
T binSearch(T first, T last, bool func(T)) {
    T len = last-first;
    while (len != 0) {
        T half = len / 2;
        T mid = first+half;
        if (func(mid)) {
            len -= half + 1;
            first = ++mid;
        } else {
            len = half;
        }
    }
    return first;
}
 
inline bool check(const int n) {
    long long tmp = 0;
    for (const int a : A) {
        tmp += cs[max(n-a, 0)];
    }
    return tmp > M;
}
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    A.resize(N);
    for (auto &a : A) {
        cin >> a;
        ++cs[a];
    }
    sort(A.rbegin(), A.rend());
    for (int i = 100000; i > 0; --i) {
        cs[i-1] += cs[i];
    }
    vector<long long> cs2(N+1);
    cs2[0] = 0;
    for (int i = 0; i < (int)A.size(); ++i) {
        cs2[i+1] = cs2[i] + A[i];
    }
    int bs = binSearch<int>(1, 200001, check);
    --bs;
    long long tmp = 0, ans = 0;
    for (const int a : A) {
        const int cnt = cs[max(bs-a, 0)];
        tmp += cnt;
        ans += cs2[cnt];
        ans += (long long)a*cnt;
    }
#ifdef DEBUG
    printf("bs: %d, tmp: %lld, ans: %lld\n", bs, tmp, ans);
#endif
    ans -= (tmp-M)*bs;
    printf("%lld\n", ans);
    return 0;
}

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

li = [input() for _ in range(n)]

s = list(set(li))

if n != len(s):
    print("No")
    exit()
    
for i in range(n):
    t = li[i][-1]
    try:
        u = li[i+1][0]
        if t != u:
            print("No")
            break
    except:
        pass
else:
    print("Yes")

Measured memory_bytes: 3064
N, K = map(int, input().split())
H = tuple(map(int, input().split()))

if K >= N:
    print(abs(H[0] - H[N-1]))
else:
    dp = [abs(H[0] - H[i]) for i in range(K)] + [10**9] * (N - K)

    for i in range(K, N):
        for j in range(1, K+1):
            dp[i]= min(dp[i], dp[i-j] + abs(H[i] - H[i-j]))

    print(dp[-1])

Measured memory_bytes: 55264
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    gx, gy = map(int, input().split())

    spl = list(map(len, s.split("T")))
    init_x = spl[0]
    is_x = 0
    to_x, to_y = [], []
    for i in range(1, len(spl)):
        to_x.append(spl[i]) if is_x else to_y.append(spl[i])
        is_x ^= 1

    now_x = [init_x]
    for move in to_x:
        nx = set()
        for x in now_x:
            nx.add(x + move)
            nx.add(x - move)
        now_x = nx

    now_y = [0]
    for move in to_y:
        ny = set()
        for y in now_y:
            ny.add(y + move)
            ny.add(y - move)
        now_y = ny

    print("Yes" if gx in now_x and gy in now_y else "No")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3816
#include <stdio.h>
 
int main(void)
{
    char s[1201];
    int i;
    fgets(s,sizeof(s),stdin);
    for(i=0;s[i]!='\0';i++){
        if('a'<=s[i]&&s[i]<='z')s[i]-='a'-'A';
        else if('A'<=s[i]&&s[i]<='Z')s[i]+='a'-'A';
    }
    printf("%s",s);
    return 0;
}


Measured memory_bytes: 2108