akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll,ll> P;

template <typename T> std::string tostr(const T& t)
{
    std::ostringstream os; os<<t; return os.str();
}

int main(){
    int n,m;
    cin>>n>>m;
    int ans=1;
    for(int i=1;i*i<=m;i++){
        if(m%i!=0) continue;
        int j=m/i;
        if((long)i*n<=m) ans=max(ans,i);
        if((long)j*n<=m) ans=max(ans,j);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n; cin >> n;
  int ans = 1e9;
  for(int use6 = 0; use6 <= n; ++use6) {
    int tmp = use6;
    int cnt = 0;
    while(true) {
      if(tmp == 0) break;
      cnt += tmp%6;
      tmp /= 6;
    }
    tmp = n-use6;
    while(true) {
      if(tmp == 0) break;
      cnt += tmp%9;
      tmp /= 9;
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int a, b; cin >> a >> b;

    if (a <= 5) {
        cout << 0 << endl;
    } else if (6 <= a && a <= 12) {
        cout << b / 2 << endl;
    } else {
        cout << b << endl;
    }
}

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

using namespace std;

int main () {
    string str;
    cin >> str;
    int n = str.size();
    for(int i=1; i<=n; i+=2){
        if(str[i-1]=='R' or str[i-1]=='U' or str[i-1]=='D'){
            //ok;
        }else
            {
                cout << "No" << endl;
                return 0;
            }
    }
    for(int i=2; i<=n; i+=2){
        if(str[i-1]=='L' or str[i-1]=='U' or str[i-1] == 'D'){
            //ok;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	
	public static int[] readInts(String cad) {
		String read[] = cad.split(" ");
		int res[] = new int[read.length];
		for (int i = 0; i < read.length; i++) {
			res[i] = Integer.parseInt(read[i]);
		}
		return res;
	}
	
	static void printMatrixInt(int[][] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[0].length; j++) {
				if (j > 0)
					System.out.print(" ");
				System.out.print(array[i][j]);
			}
			System.out.println();
		}

	}
	
	public static void main(String[] args) throws IOException {
		StringBuilder out = new StringBuilder();
		BufferedReader in;
		
			in = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(in.readLine());
		
		int v[][] = new int[n][3];
		
		for( int i = 0; i< n; i++)
			v[i] = readInts(in.readLine());
		
		int dp[][] = new int[n][3];
		dp[0][0] = v[0][0];
		dp[0][1] = v[0][1];
		dp[0][2] = v[0][2];
		
		for( int i =1; i < n; i++ ) {
			dp[i][0] = v[i][0] + Math.max(dp[i-1][1], dp[i-1][2]);
			dp[i][1] = v[i][1] + Math.max(dp[i-1][0], dp[i-1][2]);
			dp[i][2] = v[i][2] + Math.max(dp[i-1][0], dp[i-1][1]);
		}
		
		
		System.out.print(Math.max(Math.max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]));

	}
	
}


Measured memory_bytes: 52308
n = int(input())
x,y = [],[]
for i in range(n):
    a,b = map(int,input().split())
    x.append([a,i])
    y.append([b,i])
x.sort()
y.sort()
g = [[] for _ in range(n)]
for i in range(n-1):
    g[x[i][1]].append([abs(x[i+1][0]-x[i][0]),x[i+1][1]])
    g[x[i+1][1]].append([abs(x[i+1][0]-x[i][0]),x[i][1]])
    g[y[i][1]].append([abs(y[i+1][0]-y[i][0]),y[i+1][1]])
    g[y[i+1][1]].append([abs(y[i+1][0]-y[i][0]),y[i][1]])
import heapq
hq = []
for d,e in g[0]:
    heapq.heappush(hq,[d,e])
cnt = 1
visit = [False]*n
visit[0] = True
ans = 0
while cnt <n:
    cost, end = heapq.heappop(hq)
    if visit[end]: continue
    ans += cost
    visit[end] = True
    cnt += 1
    for d,e in g[end]:
        if not visit[e]:
            heapq.heappush(hq,[d,e])
print(ans)
        


Measured memory_bytes: 162524
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 

const ll INF = 10010001010;
const int inf = 2000000000;


typedef tuple<string, int, int> TUP;

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N;i++)
    {
        if(i+1 == A[A[i]-1]){
            ans++;
        }
    }
    if(ans == 0){
        cout << ans << endl;
    }
    else{
        cout << ans/2 << endl;
    }
}


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

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];

    int res = b[a[0]-1];
    rep1(i, n){
        res += b[a[i]-1];

        if(a[i-1]+1 == a[i]) res += c[a[i-1]-1];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include <iostream>
#include<string>
#include <complex>
#include <algorithm>
#include<string>
#include <map>
#include <utility>

using namespace std;


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

    pair<pair<string, int>, int > p[n];

    string g;
    int h;

    for(int i = 0 ; i< n; i++){
        cin >> g;
        cin >> h;
        p[i] = make_pair(make_pair(g, 100 - h),i);
    }

    sort(p, p+n);

    for(int i = 0; i < n; i++){
        int d = p[i].second;
        cout << d+1 << endl;
    }



    
}

Measured memory_bytes: 3620
n,k = map(int,input().split())
mod = 10**9+7
a = [0]*(k+1)
l = [0]*(k+1)
for i in range(k,0,-1):
  a[i] = pow(k//i,n,mod)
  for j in range(2,10**6):
    if i*j > k:
      break
    a[i] = (a[i] - a[i*j])%mod
ans = 0
for i in range(1,k+1):
  ans = (ans + i*a[i])%mod 
print(ans)

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

#define int ll
#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define pb push_back
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

struct node {
  ll v, d;
  node(ll _a, ll _b):v(_a),d(_b){}
  bool operator<(const node &n) const { return d > n.d; }
};
struct edge {
  ll to, d;
  edge(ll _to, ll _d):to(_to),d(_d){}
};
class dijkstra{
public:
  ll ans;

  dijkstra(ll s,ll t,vector<vector<edge>> &g,vector<vector<edge>> &f){ // sからtへの最短経路
    vector<vector<vector<edge>>> G(2);
    G[0] = move(g);
    G[1] = move(f);
    vvi dist(2,vi(G[0].size(),1ll << 59));
    vector<vector<bool>> visit(2,vector<bool>(G[0].size(),false));
  
    vector<priority_queue<node>> que(2);
    que[0].push(node(s,0));
    que[1].push(node(t,0));
    dist[0][s] = 0;
    dist[1][t] = 0;

    while(!que[0].empty() and !que[1].empty()){
      rep(k,2){
     	ll v = que[k].top().v, d = que[k].top().d;
	que[k].pop();

	if(visit[k^1][v]) goto L;
	visit[k][v] = true;

	rep(i, G[k][v].size()){
	  ll tmp = d + G[k][v][i].d;
	  if(dist[k][G[k][v][i].to] > tmp){
	    dist[k][G[k][v][i].to] = tmp;
	    que[k].push(node(G[k][v][i].to, tmp));
	  }
	}
      }
    }
  L:
    g = move(G[0]);
    f = move(G[1]);

    ans = 1ll<<61;
    rep(i,g.size()) ans = min(ans, dist[0][i]+dist[1][i]);
  }
};

main(){
  int k; cin >> k;
  vector<vector<edge>> g(k),f(k);
  rep(i,k){
    g[i].pb(edge((i+1)%k,1));
    g[i].pb(edge((i*10)%k,0));
    
    f[(i+1)%k].pb(edge(i,1));
    f[(i*10)%k].pb(edge(i,0));
  }
  dijkstra d(1,0,g,f);
  cout << d.ans+1 << endl;
}

Measured memory_bytes: 18544
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

string s;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> s;
    solve();
}

// 1 <= |s| <= 2 × 10^5
// s は英小文字のみからなる。

// string s
// 条件が成り立つように s を分割するとき、N の最小値を求めよ。
void solve(){
    ll bit=0;
    ll n=s.size();
    
    map<ll,ll> mp;
    mp[0]=0;
    rep(i,n){
        bit^=1<<(s[i]-'a');
        if(!mp.count(bit))mp[bit]=INF;
        rep(j,26){
            ll tmp=bit^(1<<j);
            if(mp.count(tmp))chmin(mp[bit],mp[tmp]+1);
        }
    }

    cout<<max(1LL,mp[bit])<<endl;
}


Measured memory_bytes: 12948
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        for (int i = 0; i <= n / 4; i++)
        {
            for (int j = 0; j <= n / 7; j++)
            {
                if (i * 4 + j * 7 == n)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }
        Console.WriteLine("No");
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

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

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n >> m;
    int k = 1 << m;
    cout << k * (1900 * m  + 100 * (n - m)) << endl;
    return 0;
}


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

typedef long long int ll;

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

int main()
{
	ll k,ans=0,count1=0,count2=0;
	scanf("%lld",&k);
	for(ll i=1;i<=k;i++)
	{
		for(ll j=1;j<=k;j++)
		{
			count1=gcd(i,j);
			for(ll p=1;p<=k;p++)
			{
//				count=gcd(i,j);
				count2=gcd(count1,p);
				ans+=count2;
			}
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 3816
#include <stdio.h>

void selectionSort(int num[],int n){
    int i,minj,j,tmp,count=0;
    for(i=0;i<n;i++){
        minj=i;
        for(j=i;j<n;j++){
            if(num[j]<num[minj]){
                minj=j;
            }
        }
        if(minj!=i){
            count++;
        }
        tmp=num[i];
        num[i]=num[minj];
        num[minj]=tmp;
    }
    for(j=0;j<n;j++){
        printf("%d%s",num[j],(j==n-1?"\n":" "));
    }
    printf("%d\n",count);
}

int main(void){
    int num[101];
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&num[i]);
    }
    selectionSort(num,n);
    return 0;
}



Measured memory_bytes: 1996
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int D,G;
int p[15],c[15];

signed main(){
  cin>>D>>G;
  for(int i=0;i<D;i++)cin>>p[i]>>c[i];

  int ans=INF;
  for(int bit=0;bit<(1<<D);bit++){
    int temp=G;
    int max=0,che;
    int cont=0;
    for(int i=0;i<D;i++){
      if(1&(bit>>i)){
        temp-=c[i]+p[i]*100LL*(i+1LL);
        cont+=p[i];
      }else{
        max=100*(i+1);
        che=i;
      }
    }

    if(temp>0){
      for(int j=0;j<p[che];j++){
        temp-=max;
        cont++;
        if(temp<=0)break;
      }
      if(temp>0)cont=INF;
    }

    ans=min(ans,cont);
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<29;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char c; cin >> c;
    string v = "aiueo";
    rep(i,5){
        if(v[i]==c) {
            cout << "vowel" << endl;
            return 0;
        }
    }
    
    cout << "consonant" << endl;
    return 0;
}



Measured memory_bytes: 256
N, A, B = map(int, input().split())
ans = 0

def count(n):
	sum = 0
	while n > 0:
		sum += n % 10
		n = n // 10
	return sum

for i in range(1, N + 1):
	if A <= count(i) and count(i) <= B:
		ans += i

print(str(ans))

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

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

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d) {
            ++cnt;
        }
    }

    cout << cnt;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  string ans = "No";
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if(n == i*j) ans = "Yes";
    }
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 100005;
const int mod = 1e9 + 7;
struct node {
    int x,i;
    bool operator <(const node &rhs)const {
        return x < rhs.x;
    }
}a[maxn];
int main() {
    int n,ans=0;
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>a[i].x;a[i].i = i;
    }
    sort(a, a+n);
    for (int i=0; i<n; i++) {
        if (!(i&1) && a[i].i&1) {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'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'};

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


int main(){
    int n; cin >> n; 
    string s; cin >> s;
    string t = s;
    s.erase(s.size()/2);
    if(t == s + s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

int main()
{
  INT(H);
  INT(W);
  INT(N);
  INT(y);
  INT(x);
  string S,T;
  cin >> S >> T;
  map<char,int> mp;
  map<char,int> mp2;
  int flag = 0;
  REP(i,N){
    mp[S[i]]++;
  }
  
  if(x+mp['R']>W){
    int nowx=x;
    REP(i,N){
      if(S[i]=='R'){
        nowx++;
      }
      if(nowx>W){
        flag=1;
      }
      if(T[i]=='L'&&nowx!=1){
        nowx--;
      }

    } 
  }
  if(x-mp['L']<1){
    int nowx=x;
    REP(i,N){
      if(S[i]=='L'){
        nowx--;
      }
      if(nowx<1){
        flag=1;
      }
      if(T[i]=='R'&&nowx!=W){
        nowx++;
      }

    } 
  }
  if(y-mp['U']<1){
    int nowy=y;
    REP(i,N){
      if(S[i]=='U'){
        nowy--;
      }
      if(nowy<1){
        flag=1;
      }
      if(T[i]=='D'&&nowy!=H){
        nowy++;
      }

    } 
  }
  if(y+mp['D']>H){
    int nowy=y;
    REP(i,N){
      if(S[i]=='D'){
        nowy++;
      }
      if(nowy>H){
        flag=1;
      }
      if(T[i]=='U'&&nowy!=1){
        nowy--;
      }

    } 
  }


  if(flag==1){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 3928
#include <iostream>

using namespace std;

int main() {

    uint64_t x;
    cin >> x;
    uint64_t s = 101;
    uint64_t cnt = 1;
    while(s < x) {
        s += s / 100;
        ++cnt;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out));

        int N = scanner.nextInt();
        int K = scanner.nextInt();

        int res;
        if (N % K == 0) res = 0;
        else res = 1;

        bufferedWriter.write(Integer.toString(res));

        bufferedWriter.close();
        scanner.close();
    }
}


Measured memory_bytes: 21716
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,W,i,j;cin>>n>>W;
	vector<int>dp(n*1000+1,mod);
	dp[0]=0;
	for(i=1;i<=n;i++){
		int w,v;cin>>w>>v;
		for(j=n*1000+1;j>=v;j--){mineq(dp[j],dp[j-v]+w);}
	}
	for(j=n*1000;;j--){
		if(dp[j]<=W){cout<<j<<endl;return 0;}
	}
	
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int INF = 1 << 20;
int N, M;
int a[1010], b[1010], c[1010];
int dis[110][110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  fill_n((int*)dis, 110 * 110, INF);
  for (int i = 0; i < N; i++) {
    dis[i][i] = 0;
  }
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    dis[a[i]][b[i]] = dis[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int flag = 1;
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (dis[j][k] == dis[j][a[i]] + dis[b[i]][k] + c[i]) {
          flag = 0;
        }
      }
    }
    ans += flag;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

int main(){
    int X;
    cin>>X;
    int dis = 1999-X;
    cout<<dis/200+1<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#define N 100
#define INFTY (1<<21)
#define LEN 1000


int Q[LEN];
int head, tail;
int n, G[N][N], d[N];

void enqueue(int x){
  Q[tail] = x;
  tail = ( tail + 1 ) % LEN;
}

void dequeue(){
  int x = Q[head];
  head = ( head + 1 ) % LEN;
}

void bfs(int s){
  int i, u, v;

  enqueue(s);

  for( i = 0 ; i < n ; i++ ) d[i] = INFTY;
  d[s] = 0;

  while( head != tail ){
    u = Q[head];
    dequeue();
    for( v = 0 ; v < n ; v++ ){
      if( G[u][v] == 0 ) continue;
      if( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }

  for( i = 0 ; i < n ; i++ ){
    printf("%d %d\n",i+1,((d[i]==INFTY) ? (-1) : d[i]));
  }
}

int main(){
  int i, j, u, k ,v;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      G[i][j] = 0;
    }
  }

  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d",&u,&k);
    u--;
    for( j = 0 ; j < k ; j++ ){
      scanf("%d",&v);
      v--;
      G[u][v] = 1;
    }
  }
  
  bfs(0);
  return 0;

}



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

int main(){
  int W,H,N;  cin >> W >> H >> N;
  int x,y,a;

  int right = W;
  int left = 0;
  int upper = H;
  int lower = 0;

  for(int i = 0;i < N;i++){
    cin >> x >> y >> a;
    if(a == 1 and x > left)left = x;
    if(a == 2 and x < right)right = x;
    if(a == 3 and y > lower)lower = y;
    if(a == 4 and y < upper)upper = y;
  }

  int ans = (right - left) * (upper - lower);

  if((right - left) < 0 or (upper - lower) < 0)cout << 0 << endl;
  else cout << ans << endl;
}


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

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

s_dict = dict()
for _s in s:
    s_dict[_s] = 0

for _s in s:
    s_dict[_s] += 1

max_frequency = max(s_dict.values())

s_ans_list = [_s for _s, i in zip(s_dict.keys(), s_dict.values()) if i >= max_frequency]
s_ans_list = sorted(s_ans_list)

for _s in s_ans_list:
    print(_s)

Measured memory_bytes: 35216
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a % b == 0){
    cout << a / b << "\n";
  }
  else{
    cout << a / b + 1 << "\n";
  }
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    int N, M;
    cin >> N >> M;
    int cnt = 1;
    for (int i = 1; i <= (N + 1) / 4&&cnt<=M; i++) {
        cout << i << " " << (N + 1) / 2 - i+1 << endl;
        cnt++;
    }
    for (int i = (N + 1) / 2 + 1; i <= N && cnt <= M; i++) {
        int mx = (N % 2 == 0 ? N - 1 : N);
        cout << i << " " << mx - i + (N + 1) / 2 + 1 << endl;
        cnt++;
    }

}


Measured memory_bytes: 3608
#!/usr/bin/env python3

from copy import deepcopy

def dfs(x, adj, visited):
    for y, flag in enumerate(adj[x]):
        if flag and not visited[y]:
            visited[y] = True
            dfs(y, adj, visited)

def is_simply_connected(adj):
    n = len(adj)
    visited = [(i == 0) for i in range(n)]
    dfs(0, adj, visited)
    return False not in visited

def main():
    n, m = map(int, input().split())
    adj = [[(i == j) for i in range(n)] for j in range(n)]
    edges = set()
    for i in range(m):
        a1, b1 = map(int, input().split())
        a = a1 - 1
        b = b1 - 1
        edges.add((a, b))
        adj[a][b] = True
        adj[b][a] = True

    res = 0
    for a, b in edges:
        adj[a][b] = adj[b][a] = False
        if not is_simply_connected(adj):
            res += 1
        adj[a][b] = adj[b][a] = True
    print(res)

main()


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(ll, a, b);
  set<ll> s;
  s.insert(1);
  ll p = 2;
  while (p * p <= a) {
    if (a % p == 0) {
      a /= p;
      s.insert(p);
    } else {
      ++p;
    }
  }
  s.insert(a);
  int ans = 0;
  for (ll p : s) {
    if (b % p == 0) {
      ++ans;
    }
  }
  out(ans);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);

            Dictionary<int, Result> answers = new Dictionary<int, Result>();

            for(int i = 0; i < M; i++){
                string[] ans = Console.ReadLine().Split(' ');
                int ansNO = int.Parse(ans[0]);

                if(answers.ContainsKey(ansNO)){
                    Result result = answers[ansNO];
                    result.add_resoult(ans[1]);

                }else{
                    answers.Add(ansNO,new Result(ans[1]));
                }
                
            }

            int total_AC = 0;
            int total_WA = 0;

            foreach(var qa in answers){
                if(qa.Value.result_AC){
                    total_AC++;
                    total_WA += qa.Value.result_WA;
                } 
            }

            Console.WriteLine(total_AC + " " + total_WA);

        }
    }
    class Result{
        public bool result_AC{get; private set;}
        public int result_WA{get; private set;}

        public Result(string result){
            result_AC = false;
            add_resoult(result);
            }
        public void add_resoult(string result){
            if(result == "AC") result_AC = true;
            if(result == "WA" && !result_AC) result_WA++;
        }
    }
}


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

int main()
{
    ll N, M, ans = 0;
    cin >> N >> M;

    priority_queue<ll, vector<ll>, greater<ll>> A;
    vector<pair<ll, ll>> CB(M);

    for (int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        A.push(a);
    }

    for (int i = 0; i < M; i++)
    {
        ll B, C;
        cin >> B >> C;

        CB[i] = make_pair(C, B);
    }

    sort(CB.begin(), CB.end(), greater<pair<ll, ll>>());

    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < CB[i].second; j++)
        {
            if (A.top() < CB[i].first)
            {
                A.pop();
                A.push(CB[i].first);
            }

            else
            {
                break;
            }
        }
    }

    while (!A.empty())
    {
        ans += A.top();
        A.pop();
    }

    cout << ans << endl;
}


Measured memory_bytes: 2936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        String s1 = s.next();
        String s2= s.next();
        int res=0;
        for(int i=0;i<s1.length();i++){
            if(s1.charAt(i)!=s2.charAt(i))
                res++;
        }
        System.out.println(res);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                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());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 30668
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int mi = N + 1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int P;
    cin >> P;
    ans += P <= mi;
    mi = min(mi, P);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void) {
    int n, x;
    scanf("%d%d", &n, &x);
    int l[n], d = 0, count = 1;
    for(int i = 0; i < n; i++) {
        scanf("%d",&l[i]);
    }
    for(int i = 0; i < n; i++) {
        if(d + l[i] <= x) {
            d += l[i];
            count++;
        } else {
            break;
        }
    }
        printf("%d\n", count);
        return 0;
}


Measured memory_bytes: 128
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    count = 0
    p_list = [int(i) for i in input().split()]
    for i in range(1, n - 1):
        hoge = p_list[i - 1 : i + 2]
        if min(hoge) == p_list[i]:
            continue
        if len(set(hoge)) == 3 and max(hoge) == p_list[i]:
            continue
        count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int a, b, n;
    cin >> a >> b >> n;
    int ans = 0;
    if (n < b)
    {
        //ans = floor(a * n / b);
        ans = a * n / b;
        ans -= a * (n / b);
    }
    else
    {
        n = b - 1;
        //ans = floor(a * (n / b));
        ans = a * n / b;
        ans -= a * (n / b);
    }
    cout << ans;
}

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

using namespace std;
const long long INF = 1LL <<60;
const long long Mo=1000000007;
         

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

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void){
  long long tmp,tmp1,tmp2;
  long long x,y,xx,yy;
  long long i,j;
  long long res=0;

  cin>>x>>y;
  tmp=x+y;
  if(tmp%3!=0 || max(x,y)>2*min(x,y)){
    cout<<res<<endl;
    return 0;
  }
  
  tmp=tmp/3;
  x=x-tmp;
  y=y-tmp;
  
  xx=min(x,y);
  yy=max(x,y);
  
  //cout<<xx<<" "<<yy<<endl;
  tmp=1;
  res=1;
  for(i=yy+1;i<=x+y;i++){
    res=res*i%Mo;
  }
  for(i=1;i<=xx;i++){
    tmp=tmp*i%Mo;
  }

  //cout<<res<<" "<<tmp<<" "<<modinv(tmp,Mo)<<endl;
  res=res*modinv(tmp,Mo)%Mo;
  
  //cout<<setprecision(15)<<res<<endl;
  cout<<res<<endl;

  
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;

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

i64 X; cin>> X;

if (X == 2) {
    cout << "2\n";
    return 0;
}
if (X%2 == 0) ++X;

while(1){
    // 素数判定
    bool f = true;
    for (i64 i = 3; i * i < X; i += 2){
        if (X % i == 0) f = false;
    }
    if (f) {
        cout << X << endl;
        return 0;
    }
    X += 2;
}


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#define int long long
using namespace std;

signed main() {
	double N,T,A;
	cin >> N >> T >> A;
	vector<double> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	for(int i = 0;i < N;i++) {
		vec.at(i) = T - vec.at(i) * 0.006;
	}
	double answer1 = 1e9;
	int answer2;
	for(int i = 0;i < N;i++) {
		if(answer1 > abs(A - vec.at(i))) {
			answer1 = abs(A - vec.at(i));
			answer2 = i + 1;
		}
	}
	cout << answer2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXH=1005;
const int MAXW=1005;
const int MAXN=205;
const int MAXP=105;
typedef unsigned long long ull;
const ull ba1=9973;
const ull ba2=100000007;
char code[MAXN];
bool mag[MAXH][MAXW],pat[MAXH][MAXW], tmpb[MAXH][MAXW];
ull tmp[MAXH][MAXW], hap[MAXH][MAXW], ham[MAXH][MAXW];
ull base1[MAXW],base2[MAXH];
void init(){
    base1[0]=1;
    base2[0]=1;
    for(int i=1;i<MAXH;i++){
        base1[i]=base1[i-1]*ba1;
        base2[i]=base2[i-1]*ba2;
    }
}
int decrypt(char c){
    if(c>='A'&&c<='Z') return c-'A';
    if(c>='a'&&c<='z') return c-'a'+26;
    if(c>='0'&&c<='9') return c-'0'+52;
    if(c=='+') return 62;
    return 63;
}
void input(bool in[MAXH][MAXW], int n, int m){
    for(int i=0; i<n; i++){
        scanf("%s",code);
        for(int j=0, x=0; j<(m+5)/6; j++){
            int tmp=decrypt(code[j]);
            for(int k=5; k>=0; k--){
                if(x==m) break;
                in[i][x++]=tmp>>k&1;
            }
        }
    }
}
void hash_matrix(bool mat[MAXH][MAXW],int n, int m, int P, int Q, ull ha[MAXH][MAXW]){
    for(int i=0;i<n;i++){
        for(int j=0;j<Q;j++)
            tmp[i][j]=(j==0)?mat[i][j]:(tmp[i][j-1]*ba1+mat[i][j]);
        for(int j=Q;j<m;j++)
            tmp[i][j]=tmp[i][j-1]*ba1+mat[i][j]-mat[i][j-Q]*base1[Q];
    }
    for(int j=Q-1;j<m;j++){
        for(int i=0;i<P;i++)
            ha[i][j]=(i==0)?tmp[i][j]:(ha[i-1][j]*ba2+tmp[i][j]);
        for(int i=P;i<n;i++)
            ha[i][j]=ha[i-1][j]*ba2+tmp[i][j]-tmp[i-P][j]*base2[P];
    }
}
void rotate(bool mat[MAXH][MAXW], int n, int m){
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            tmpb[i][j]=mat[j][n-1-i];
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            mat[i][j]=tmpb[i][j];
        }
    }
}
void mirror(bool mat[MAXH][MAXW], int n, int m){
    for(int i=0; i<n; i++){
        reverse(mat[i],mat[i]+m);
    }
}
int main(){
    int w, h, p;
    init();
    while(cin>>w>>h>>p&&w+h+p){
        input(mag,h,w);
        input(pat,p,p);
        set<ull> st;
        int ans=0;
        hash_matrix(mag,h,w,p,p,ham);
        for(int i=0; i<8; i++){
            hash_matrix(pat,p,p,p,p,hap);
            ull hash_val=hap[p-1][p-1];
            if(st.find(hash_val)==st.end()){
                st.insert(hash_val);
            }
            else{
                goto next;
            }
            for(int j=p-1; j<h; j++){
                for(int k=p-1; k<w; k++){
                    if(ham[j][k]==hash_val){
                        ans++;
                    }
                }
            }
            next:;
            rotate(pat,p,p);
            if(i==3) mirror(pat,p,p);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 23780
#include<bits/stdc++.h>
using namespace std;
 
int main(){
int N,sum=0,ave,ans=0;
int a[100];
 
cin>>N;

for(int i=0;i<N;i++){
cin>>a[i];
sum+=a[i];
}
if(sum>=0){
ave=(double)sum/N+0.5;
}else{
ave=(double)sum/N-0.5;
}
for(int i=0;i<N;i++){
ans+=pow(a[i]-ave,2);
}
 
cout<<ans<<endl;
 
return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

c1 = Counter(D)
c2 = Counter(T)

ans = 'YES'
for k, v in c2.items():
    if not k in c1.keys():
        ans = 'NO'
        break
    if c1[k] < v:
        ans = 'NO'
        break

print(ans)

Measured memory_bytes: 57048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;
const int mod1=998244353;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<vector<int>> s(m,vector<int>());
	rep(i,m){
		int k;cin >> k;
		s.at(i).resize(k);
		rep(j,k) cin >> s.at(i).at(j);
	}
	vector<int> p(m);
	rep(i,m) cin >> p.at(i);
	int ans=0;
	for(int mask=0;mask<(1<<n);++mask){
		int cnt=0;
		rep(i,m){
			int sum=0;
			rep(j,s.at(i).size()){
				if((mask&(1<<s[i][j]-1))) sum++;
			}
			if(sum%2==p.at(i)) cnt++;
		}
		if(cnt==m) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

//-----------------------------------------------

//------------------------------------------------
int main(){
  string s;
  int a,b,c;
  cin>>s;
  a=s.size();
  b=1;
  rep(i,0,a) {
    if(i%2==0 && s.at(i)=='L') b=0;
    if(i%2==1 && s.at(i)=='R') b=0;
  }
if(b) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 256
def solve():
    a, b, k = map(int, input().split())
    ds = []
    for i in range(1, min(a, b) + 1)[::-1]:
        if a % i == 0 and b % i == 0:
            ds.append(i)
    return ds[k - 1]


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, k, mx, a[N], b[N];

ll f(ll p) {
	ll i, j, re = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j <= 30; j++) if (!(p & (1 << j)) && (a[i] & (1 << j))) break;
		if (j > 30) re += b[i];
	}
	return re;
}

int main()
{
	ll i, j, t;
	cin >> n >> k;
	for (i = 0; i < n; i++) scanf("%lld %lld", &a[i], &b[i]);
	mx = f(k);
	for (i = 0; i <= 30; i++) {
		if (!(k & (1 << i))) continue;
		for (j = t = 0; j < 30 - i - 1; j++) t = t * 2 + 1;
		for (j = 0; j <= i; j++) t *= 2;
		mx = max(mx, f(k & t | ((1 << i) - 1)));
	}
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 1792
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long Long;

const int N = 1e5;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int tc, ca = 0;
  Long n, m, el;
  cin >> n >> m;
  Long sum = 0;
  for (int i = 0;i < m;i++){
    cin >> el;
    sum += el;
  }
  Long ans = n-sum;
  if (ans < 0)ans = -1;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; i++)
        cin >> arr[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(arr[1] - arr[0]);
    for(int i=2; i<n; i++)
    {
        dp[i] = min(abs(arr[i]-arr[i-2]) + dp[i-2], abs(arr[i]-arr[i-1]) + dp[i-1] );
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{
	double n;
	scanf("%lf",&n);
	printf("%.10lf",2.0*3.1415926*n); 
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int h,n;cin>>h>>n;
  while(n--){
    int a;cin>>a;h-=a;
  }
  if(h<=0)puts("Yes");
  else puts("No");
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
#include<iomanip>
#include<tuple>
#include<stack>

#define _USE_MATH_DEFINES
#include<math.h>


using namespace std;
typedef long long ll;

typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef tuple<int, int, int> ti3;

const ll MOD_CONST = 1000000007;
//const ll MOD_CONST = 998244353;


const int BIG_NUM = 1000000005;
const ll INF = 1000000000000000000;

//const vector<vector<int>> DIR{ {1,0},{0,1},{-1,0},{0,-1} };

//const double EPS = 1e-10;


int main() {
	int n;
	cin >> n;
	vector<pii> p(n);
	for (int i = 0; i < n; i++) {
		int pi;
		cin >> pi;
		pi--;
		p[i] = make_pair(pi, i);
	}
	p.emplace_back(make_pair(n, -1));

	sort(p.begin(), p.end());
	int ma = 1;
	int cnt = 1;
	for (int i = 0; i < n; i++) {
		if (p[i].second < p[i + 1].second) {
			cnt++;
		}
		else {
			ma = max(ma, cnt);
			cnt = 1;
		}
	}

	cout << n - ma << endl;

}



Measured memory_bytes: 4864