akhauriyash/Code-Regression huggingface dataset:
// Author : Mohamed Sameh
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
typedef long long ll ;
using namespace std ;
string s,t ;
int n,m; 
const int M = 3000;
int dp[M][M]; 
void PrintAnswer(int i = n-1 , int j = m-1)
{
    if (i < 0 || j < 0 )return ; 
    if (i == j && i == 0 )
    {
        if (s[0] == t[0])
        cout << s[0]; 
        return ; 
    }
    if (i-1 >= 0 && dp[i][j] == dp[i-1][j])
    {
        PrintAnswer(i-1,j); 
    }else if (j-1 >=0  && dp[i][j] == dp[i][j-1])
    {
        PrintAnswer(i,j-1); 
    }else 
    {
        PrintAnswer(i-1,j-1); 
        cout << s[i]; 
    }
}
int main ()
{   
    cin >> s >> t ;
    n = SZ(s);
    m = SZ(t);
    for (int i =0 ; i < n ;i++)
    {
        for (int j =0 ; j < m ;j++)
        {
            if (s[i] == t[j])
            {
                if (i-1 >= 0 && j-1 >= 0)
                dp[i][j] = dp[i-1][j-1] + 1 ; 
                else 
                dp[i][j] = 1;   
            }else 
            {
                if (i - 1 >= 0 )dp[i][j] = max (dp[i][j] , dp[i-1][j]); 
                if (j - 1 >= 0 )dp[i][j] = max (dp[i][j] , dp[i][j-1]); 
            }
        }
    }
    PrintAnswer(); 

}

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

int s[100005];

int main()
{
   	int n;
   	cin >>n;
   	int ant = 0;
	for(int i = 1; i <= n; i++){
		cin >> s[i];
		if(s[i]!=i){
			ant++;
		}
	}
 	if(ant==2 || ant==0){
 		printf("YES");
	 }
   	else{
   		printf("NO");
	   }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	string S;
	cin >> S;
	if (S[0] != 'A') {
		cout << "WA\n";
		return 0;
	}
	int N = S.size();
	int cn = 0;
	int j = 0;
	for (int i = 2;i < N - 1;i++) {
		if (S[i] == 'C') {
			cn++;
			j = i;
		}
	}
	if (cn != 1) {
		cout << "WA\n";
		return 0;
	}
	
	for (int i = 1;i < N;i++) {
		if (i != j) {
			if ('A' <= S[i] && S[i] <= 'Z') {
				cout << "WA\n";
				return 0;
			}
		}
	}
	cout << "AC\n";

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
m = []
for i in range(M):
    a, b = map(int, input().split())
    m.append((a,b-1))
ans = 0
t = None
for l,r in sorted(m, key=lambda x:x[1]):
    if t is None or l > t:
        t = r
        ans += 1
print(ans)    


Measured memory_bytes: 18972
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

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

	ll val=0;
	for(int i=0;i<n;i++){
		val += (a[i] - 1);
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
       ios::sync_with_stdio(false);
       int a, b;
       cin >> a>>b;
       if (b%2==1)cout << "No" << endl;
       else
       {
             if (b>=2*a&&b<=4*a)
                  cout << "Yes" << endl;
             else cout <<  "No" << endl;
       }
	return 0;
}


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

int main(){
  string a; cin >> a;
  int b=a.length();
  bool n=false,e=false,w=false,s=false;
  for(int i=0;i<b;i++){
    if(a[i]=='N') n=true;
    if(a[i]=='E') e=true;
    if(a[i]=='W') w=true;
    if(a[i]=='S') s=true;
  }
  string ans="No";
  if(n==s and w==e) ans="Yes";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
ans = 0
f,s = [],[]
count = 0
for i in map(int,input().split()):
    if count%2 == 0:
        f.append(i)
    else:
        s.append(i)
    count += 1
c1,c2 = Counter(f),Counter(s)
a,b = [],[]
for i in c1.keys():
    a.append([i,c1[i]])
for j in c2.keys():
    b.append([j,c2[j]])
a = sorted(a,key=lambda x: x[1],reverse = True)
b = sorted(b,key=lambda x: x[1],reverse = True)
if a[0][0] == b[0][0]:
    if a[0][1] == b[0][1]:
        if len(a) == 1 and len(b) == 1:
            print(n-a[0][1])
        elif len(a) == 1 or len(b) == 1:
            if len(a) != 1:
                print(n-a[1][1]-b[0][1])
            else:
                print(n-a[0][1]-b[1][1])
        else:
            print(n-a[0][1]-max(a[1][1],b[1][1]))
    elif a[0][1] > b[0][1]:
        if len(b) == 1:
            print(n-a[0][1])
        else:
            print(n-a[0][1]-b[1][1])
    else:
        if len(a) == 1:
            print(n-b[0][1])
        else:
            print(n-a[1][1]-b[0][1])
else:
    print(n-a[0][1]-b[0][1])

Measured memory_bytes: 24492
import copy

def partition(p, r):
    i = p
    for j in range(p, r):
        if A[r][1] >= A[j][1]:
            A[i], A[j] = A[j], A[i]
            i += 1
    A[r], A[i] = A[i], A[r]
    return i

def quick_sort(p, r):
    if p < r:
        q = partition(p, r)
        quick_sort(p, q-1)
        quick_sort(q+1, r)

def is_stable():
    for i in range(N-1):
        if A[i][1] == A[i+1][1]:
            small_idx, large_idx = 0, 0
            cnt = 0
            for j in range(N):
                if A[i] == orig_list[j]:
                    small_idx = j
                    cnt += 1
                elif A[i+1] == orig_list[j]:
                    large_idx = j
                    cnt += 1
                if cnt == 2:
                    break
            if small_idx > large_idx:
                return False
    return True


N = int(input())
A = []
for _ in range(N):
    suit, num = input().split()
    num = int(num)
    A.append([suit, num])
orig_list = copy.deepcopy(A)

quick_sort(0, N-1)

is_stable = is_stable()
if is_stable:
    print("Stable")
else:
    print("Not stable")

for card in A:
    print("%s %d" % (card[0], card[1]))


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

int main() {
  int D,G;
  cin>>D>>G;
  vector<int> p(D);
  vector<int> c(D);
  for(int i=0;i<D;i++){
    cin>>p[i]>>c[i];
  }
  int ans=1234567890;
  for(int bit=0;bit<(1<<D);bit++){
    int sum=0;
    int num=0;
    // 全完する難易度を決める
    for(int i=0;i<D;i++){
      // ex.i=5=101であれば2問目のみfalseになる
      if(bit&(1<<i)) sum+= c[i]+p[i]*100*(i+1),num+=p[i];
    }
    if(sum>=G) ans = min(ans,num);
    else{
      for(int i=D-1;i>=0;i--){
        // すでに説いた問題は除外
        if(bit&(1<<i)) continue;
        for(int j=0;j<p[i];j++){
          if(sum>=G) break;
          sum +=100*(i+1);
          num++;
        }
      }
    ans = min(ans,num);
  }
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
#define MP make_pair

#define N 212345
#define S 2
#define T 1
#define Q 3
vector<pair<int, pii>> v;
set<int> s;

int main(){
	int n, q; scanf("%d%d", &n, &q);
	REP(i, n){
		int s, t, x; scanf("%d%d%d", &s, &t, &x);
		v.EB(s-x, MP(S, x));
		v.EB(t-x, MP(T, x));
	}
	REP(i, q){
		int d; scanf("%d", &d);
		v.EB(d, MP(Q, 0));
	}
	sort(v.begin(), v.end());
	for(auto &p : v){
		int x = p.first, t=p.second.first, y = p.second.second;
		// DEBUG("x=%d, t=%d, y=%d\n", x, t, y);
		if(t==S){
			// DEBUG("insert\n");
			s.insert(y);
		}else if(t==T){
			// DEBUG("erase\n");
			s.erase(s.find(y));
		}else{
			if(s.size()) printf("%d\n", *s.begin());
			else printf("-1\n");
		}
	}
}


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

using namespace std;


typedef long long ll ;
const ll mk = 100055;
const ll logn  = 29;
const ll mod = 1e9 + 7; 
#define endl "\n"
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define pii pair<ll,ll>
#define pq priority_queue
#define UwU              uwu
#define UwU              Mikuwu
#define Miku             best_waifu
#define Miku_dancing     god_waving
#define a_Miku           cho_doi_bot_ngu

ll Sum, ans = 0  ; 

ll log10(ll x) {
	if(x == 0) return 0;
	return log10(x / 10) + 1;
}

ll query(ll x, ll y)
{
    if (!y) return 1;
    ll l = query(x, y / 2);
    if (y % 2) return l * l % mod * x % mod;
    return l * l % mod;
}

signed main()
{
    
    cin >> Sum;
    ll r = 1, sub_sum = 0 ; 
    for (ll l = 1; l < 1e7; l++)
    {
        while (sub_sum + log10(r) <= Sum) sub_sum += log10(r), r++;
        if (sub_sum == Sum) ans++;
        sub_sum -= log10(l);
    }   // brute_forces for Miku to dance uwu
    for (ll dig = 8; dig <= Sum; dig++)
    {
        if (Sum % dig == 0)
        {
            ans = (ans  + query(10, dig) - query(10, dig - 1) - Sum / dig + 1 + mod) % mod;   // number of start a sequence
        }
        ll r = Sum % dig;
        if (r == 0) r += dig;
        ll val = r * (dig + 1);
        ll c = 1ll * dig * (dig + 1);
        if (val < Sum) ans = (ans + (Sum - val) / c + ((Sum - val) % c > 0)) % mod;   // still can take those numbers as a sequence
    }
    cout << ans % mod;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int n;
  while(cin >> n && n) {
    int sum=0;
    for(int i=0; i<n/4; i++) {
      int x;
      cin >> x;
      sum+=x;
    }
    pr(sum);
  }
  return 0;
}


Measured memory_bytes: 1160
// A - Palindromic Number

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	string rN = N;
	reverse(rN.begin(), rN.end());

	string ans;
	if (N == rN) ans = "Yes";
	else ans = "No";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, L, Q, W, H, T, X, Y, S;

int main()
{
    cin >> N;
    set<ll> s;
    for (int i = 0; i < N; ++i) {
        ll o; cin >> o;
        if (s.count(o))
            s.erase(o);
        else
            s.insert(o);
    }
    cout << s.size() << endl;

    return 0;
}

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

int main() {
	long long a, b, k; cin >> a >> b >> k;
	if (k <= a) a -= k;
	else if (k <= a + b) {b -= k - a; a = 0;}
	else {a = 0; b = 0;}
	cout << a << " " << b << endl;
}

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

int main(){
  int a,b,c,Answer = 0,checks[100];
  for (int j = 0 ; j < 100 ; j++){
    checks[j - 1] = 0;
  }
  cin >> a >> b >> c;
  checks[a - 1] = 1 ; checks[b - 1] = 1 ; checks[c - 1] = 1;
  for (int j = 0 ; j < 100 ; j++){
    if (checks[j] != 0){
      Answer ++;
    }
  }
  cout << Answer <<endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int vis[n+10],arr[n+10];
    memset(vis,0,sizeof vis);
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    int pos=1,cnt=0;
    while(!vis[pos]){
        if(pos==2){
            cout<<cnt<<endl;
            return 0;
        }
        vis[pos]=1;
        cnt++;
        pos=arr[pos];
    }
    cout<<"-1\n";
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
#define END "\n"
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<ii> vii;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
 
bool pal(string s)
{
  int n = s.size();
  if (n == 1) return 1;
  for (int i = 0; i <= n / 2; i++)
  {
    if (s[i] != s[n - i - 1])
      return false;
  }
  return true;
}
 
int main()
{
    fast
    #ifdef ANUBHAB
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    string s;
    int n;
    cin >> s;
    n = s.size();
    string s1, s2;
    s1 = s.substr(0, n / 2);
    //cout << s1 << " ";
    s2 = s.substr((n + 1)/ 2, n / 2);
    //cout << s2;
    if (pal(s1) && pal(s2) && pal(s))
      cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    String ans = "NO";
    for (int i = 1; i <= B; i++) {
      if ((A * i + C) % B == 0) {
        ans = "YES";
        break;
      }
    }

    System.out.println(ans);

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 22484
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[i] + l[j] > l[k] and l[i] != l[j] != l[k]:
                ans += 1

print(ans)


Measured memory_bytes: 9172
#include <iostream>
#include <vector>

using namespace std;
#define ll long long

ll pos(ll a){
  if(a<0){
    return -a;
  }
  return a;
}

int main(void){
  ll a,b;
  cin >> a >> b;
  if(a>0){
    cout << "Positive" << endl;
  }else if(b >= 0){
    cout << "Zero" << endl;
  }else{
    if(pos(b - a) % 2 == 1){
      cout << "Positive" << endl;
    }else{
      cout << "Negative" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3596
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


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


def main():
    N, M, Q = map(int, input().split())
    A = []
    B = []
    C = []
    D = []
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        a -= 1
        b -= 1
        A.append(a)
        B.append(b)
        C.append(c)
        D.append(d)

    ans = 0
    for a0 in range(1, M + 1):
        for a1 in range(a0, M + 1):
            for a2 in range(a1, M + 1):
                for a3 in range(a2, M + 1):
                    for a4 in range(a3, M + 1):
                        for a5 in range(a4, M + 1):
                            for a6 in range(a5, M + 1):
                                for a7 in range(a6, M + 1):
                                    for a8 in range(a7, M + 1):
                                        for a9 in range(a8, M + 1):
                                            array = [a0, a1, a2, a3,
                                                     a4, a5, a6, a7, a8, a9]
                                            res = 0
                                            for i in range(Q):
                                                if array[B[i]] - array[A[i]] == C[i]:
                                                    res += D[i]
                                            ans = max(ans, res)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71480
while True:
    n = int(raw_input())
    cnt = 0
    _sum = 1
    if n == 0:
        break
    for i in range(1, n+1):
        _sum*=i
    while _sum  >= 10:
        if _sum % 10 != 0:
            break
        else:
            _sum /= 10
            cnt+=1
    print cnt


Measured memory_bytes: 5184
#include<stdio.h>

int isPrimeNum( int num)
{
	int i;
	
	if( 2 == num ) {
		return 1;
	}
	if( 0==num%2 ) {
		return 0;
	}
	for( i=3; i<=num/i; i+=2 ) {
		if( 0==num%i ) {
			return 0;
		}
	}

	return 1;
}

int main( void ) 
{

	int n;
	int num;
	int cnt;
	int i;

	scanf( "%d", &n );
	
	cnt=0;
	for( i=0; i<n; i++ ) {
  		scanf( "%d", &num );
   		cnt+=isPrimeNum( num );
  	}
 	
	printf( "%d\n", cnt );


	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		long next = 2;
		for (int i = 0; i < x; i++) {
			next = (next + 1) * 2;
		}
		System.out.println(next);
	}
}


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

const int MOD = 1000000007;
struct mint
{
    int64_t x;
    mint(int64_t x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(int64_t n) const
    {
        if (n == 0)
            return 1;
        mint t = pow(n >> 1);
        t *= t;
        if (n & 1)
            t *= *this;
        return t;
    }
    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

vector<mint> fac;
vector<mint> fac_inv;
vector<mint> inv;
void init_comb(int mx)
{
    fac = vector<mint>(mx + 1), fac_inv = vector<mint>(mx + 1), inv = vector<mint>(mx + 1);
    fac.at(0) = fac.at(1) = 1;
    fac_inv.at(0) = fac_inv.at(1) = 1;
    inv.at(1) = 1;
    for (int i = 2; i <= mx; i++)
    {
        fac.at(i) = fac.at(i - 1) * i;
        inv.at(i) = -inv.at(MOD % i) * (MOD / i);
        fac_inv.at(i) = fac_inv.at(i - 1) * inv.at(i);
    }
}
mint comb(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac.at(n) * fac_inv.at(k) * fac_inv.at(n - k);
}

mint perm(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac.at(n) * fac_inv.at(n - k);
}

void solve(int N, int M)
{
    init_comb(5e5);
    mint res;
    for (int s = 0; s <= N; s++)
    {
        mint x = comb(N, s) * perm(M, s) * perm(M - s, N - s) * perm(M - s, N - s);
        if (s % 2 == 0)
            res += x;
        else
            res -= x;
    }
    cout << res << endl;
}

int main()
{
    int N;
    cin >> N;
    int M;
    cin >> M;
    solve(N, M);
    return 0;
}


Measured memory_bytes: 14848
#include<stdio.h>
#define BLACK 1
#define WHITE 0
#define INF 100000
#define NUM 100

int main(){
  int n,i,j,a[NUM][NUM],d[NUM],pi[NUM],color[NUM],minv,u,sum,v,a1;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a1);
      if(a1!=-1){
	a[i][j]=a1;
      }else{
	a[i][j]=INF;
      }
    }
  }  
  for(i=0;i<n;i++){
    d[i]=INF;
    pi[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;
  
  while(1){
    minv=INF;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
	minv=d[i];
	u=i;
      }
    }

    if(u==-1){
      break;
    }

    color[u]=BLACK;
    
    for(v=0;v<n;v++){
      if(color[v] != BLACK && a[u][v] != INF){
	if(a[u][v] < d[v]){
	  pi[v]=u;
	  d[v]=a[u][v];
	}
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(pi[i]!=-1){
      sum+=a[i][pi[i]];
    }
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2112
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		Map <Long,Long> map = new HashMap<>();
		
		for(int i = 0; i < n; i++) {
			long a = stdIn.nextLong();
			
			if(map.containsKey(a)) {
				map.put(a,map.get(a)+1);
			}else {
				map.put(a,(long)1);
			}
			
		}
		
		long cnt = 0;
		
		for(long a: map.keySet()) {
			if(a < map.get(a)) { //2 4 のように多すぎた場合
				cnt += map.get(a) - a;
			}else if(a > map.get(a)) { //4 2 にように少ない場合
				cnt += map.get(a);
			}
			
		}
		System.out.println(cnt);
		
	}

}


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

int main(){
    int N;
    long long int sum =0;
    cin >> N;
    for(int i = 1; i <= N; i++){
        if(i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;

class Program {

    const int MAX = 100001;
    const int wht = 0;
    const int gry = 1;
    const int blk = 2;
    static int[] stt = new int[MAX];
    static int[] grp = new int[MAX];

    static List<List<int>> g = new List<List<int>>();

    static void Main(string[] args) {

        grp = Enumerable.Repeat(-1, MAX).ToArray();
        var inp = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();

        for (int i = 0; i < inp[0] + 1; i++) {
            g.Add(new List<int>());
        }

        for (int i = 0; i < inp[1]; i++) {
            var a = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            g[a[0]].Add(a[1]);
            g[a[1]].Add(a[0]);
        }

        for (int i = 0; i < inp[0]; i++) {
            bfs(i);
        }

        var q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++) {
            var a = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            string s = grp[a[0]] == grp[a[1]] ? "yes" : "no";
            Console.WriteLine(s);
        }

    }


    static void bfs(int v) {

        var q = new Queue<int>();
        q.Enqueue(v);
        grp[v] = grp[v] == -1 ? v : grp[v];

        while (q.Count > 0) {

            var u = q.Dequeue();
            for (int i = 0; i < g[u].Count; i++) {
                int c = g[u][i];
                if (stt[c] != blk) {
                    q.Enqueue(c);
                    stt[c] = gry;
                    grp[c] = grp[c] == -1 ? v : grp[c];
                }
            }

            stt[u] = blk;
        }
    }
}



Measured memory_bytes: 36064
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  lint a, b; cin >> a >> b;
  V<lint> s(n); for (int i = 0; i < n; i++) cin >> s[i];
  V<> ca(n), cb(n);
  for (int i = 0; i < n - 1; i++) {
    ca[i + 1] = ca[i] + (s[i + 1] - s[i] >= a);
    cb[i + 1] = cb[i] + (s[i + 1] - s[i] >= b);
  }
  V<lint> dpx(n + 1), dpy(n + 1);
  dpx[0] = dpy[0] = dpx[1] = dpy[1] = 1;
  for (int i = 1; i < n; i++) {
    int j = upper_bound(s.begin(), s.end(), s[i] - a) - s.begin();
    if (j == i) dpx[i + 1] = (dpx[i] + dpy[i]) % mod;
    else if (i - j < 2 or cb[i - 1] - cb[j] == i - 1 - j) dpx[i + 1] = dpy[j + 1] % mod;
    j = upper_bound(s.begin(), s.end(), s[i] - b) - s.begin();
    if (j == i) dpy[i + 1] = (dpx[i] + dpy[i]) % mod;
    else if (i - j < 2 or ca[i - 1] - ca[j] == i - 1 - j) dpy[i + 1] = dpx[j + 1] % mod;
  }
  cout << emod(dpx[n] + dpy[n]) << '\n';
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    string S;
    cin >> S;

    if (S == "ABC") {
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
namespace I_am_the_brown_coder{
    class Inonoa{
        static void Main(){
            string[] nx = Console.ReadLine().Split();
            int n = int.Parse(nx[0]);
            int x = int.Parse(nx[1]);
            string[] ls = Console.ReadLine().Split();
            int[] l = new int[n];
            for(int i=0;i<n;i++){
                l[i] = int.Parse(ls[i]);
            }
            int ans = 1;
            int ima = 0;
            for(int i=0;i<n;i++){
                ima += l[i];
                if(ima>x){
                    Console.WriteLine(ans);
                    return;
                }
                ans ++;
            }
            Console.WriteLine(ans);
        }
    }
}

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

int main()
{
  int N, result=0;
  cin >> N;

  for(int c=1;c<N;c++){
    int tmp = N-c;
    int index = sqrt(tmp);
    for(int a=1;a<=index;a++){
      if(tmp%a==0){
        result += 2;
      }
    }
    if(index * index == tmp){
      result -= 1;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 3672
s=input()

if 12<int(s[:2]) or 0==int(s[:2]):
    if 12>=int(s[2:])>=1:
        print("YYMM")
    else:
        print("NA")
elif 1<=int(s[:2])<=12:
    if 12>=int(s[2:])>=1:
        print("AMBIGUOUS")
    else:
        print("MMYY")
    


Measured memory_bytes: 9112
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// 出力
      	double b = Math.ceil((double)a/1.08);
      	if(Math.floor(b*1.08)==(double)a){
			System.out.println((int)b);    
        }else{
			System.out.println(":(");
        }
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<functional>
using namespace std;
int main() {
	int n, i, j, k;
	int z = 0;
	while (1) {
		cin >> n;
		if (n == 0) break;
		vector < pair < int,string  > > x(n);
		for (int q = 0; q < n; q++) {
			cin >> x[q].second;
			cin >> i >> j >> k;
			x[q].first = 3 * i + k;
		}
		for (int w = 0; w < n; w++) {
			for (int q = 0; q+1 < n; q++) {
				if (x[q].first < x[q + 1].first) {
					swap(x[q], x[q + 1]);
				}
			}
		}
		for (int q = 0; q < n; q++) {
			if (q == 0) {
				if (z != 0)	cout << endl;
			}
			cout << x[q].second << ',' << x[q].first << endl;
			z = 1;
		}
	}

	return 0;
}

Measured memory_bytes: 3020
from math import gcd
from itertools import permutations

k = int(input())
ans = 0

for i in range(1, k+1):
    for j in range(i, k+1):
        for l in range(j, k+1):
            dup = len(set([i, j, l]))
            if dup == 1:
                num = 1
            elif dup == 2:
                num = len(list(permutations([i, j, l]))) / 2
            else:
                num = len(list(permutations([i, j, l])))
            ans += gcd(i, gcd(j, l)) * num

print(int(ans))


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

int v[100], w[100], W, n,ret;
int memo[101][10001];

int calc(int i, int j) {
	if (memo[i][j] != -1)return memo[i][j];
	if (i == n)ret = 0;
	else if (j < w[i])ret = calc(i + 1, j);
	else {
		ret = max(calc(i + 1, j), calc(i + 1, j - w[i]) + v[i]);
	}
	return memo[i][j]=ret;
}
int main() {
	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 10001; j++) {
			memo[i][j] = -1;
		}
	}
	
	int ans;
	cin >> n >> W;
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> w[i];
	}
	ans = calc(0, W);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6988
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
int n,a[105];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,greater<int>());
	int x = 0, y = 0;
	for(int i=1;i<=n;i++){
		if(i & 1) x += a[i];
		else y += a[i];
	}
	printf("%d\n",x - y);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 200010
int a[maxn],b[maxn]={0},c[maxn]={0},d[maxn],ans=1e9,n,i;
int min(int x,int y)
{
	return x<y ? x : y;
}
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		d[a[i]]=i;
	}
	for (i=1;i<=n;i++)
		b[a[i]]=b[a[i]-1]+1;
	for (i=n;i;i--)
		c[a[i]]=c[a[i]+1]+1;
	ans=min(n-c[1],n-b[n]);
	for (i=1;i<n;i++)
		if (d[i]<d[i+1]) ans=min(ans,n-b[i]-c[i+1]);
			else ans=min(ans,min(n-b[i],n-c[i]));
	printf("%d",ans);
	return 0;
}

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

int main(){
    int n,e=0,w=0;
    string s;
    cin>>n>>s;
    rep(i,n){
        e+=s[i]=='E';
        w+=s[i]=='W';
    }
    int ans=INT_MAX,now=e;//now=変えるべき人数
    rep(i,n){
        if(s[i]=='E'){
            ans=min(ans,now-1);
            now--;
        }
        else{
            ans=min(ans,now);
            now++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{

    ll n;
    cin>>n;
    ll x[n+1];
    for(int i =1;i<=n;i++)cin>>x[i];ll mi=LLONG_MAX;
    for(int i =1;i<=100;i++){
        ll ans = 0;
        for(int j = 1;j<=n;j++){
            ans += (x[j]-i) * (x[j]-i);
        }
        mi=min(mi,ans);
    }
    cout<<mi<<endl;
    
    return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n t ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let rec loop i mi best count =
        if i = n then count else
            if a.(i) < mi        then loop (i + 1) a.(i) best count else
            if a.(i) - mi > best then loop (i + 1) mi (a.(i) - mi) 1           else
            if a.(i) - mi = best then loop (i + 1) mi  best        (count + 1) else
                                          loop (i + 1) mi  best count
    in
    loop 1 a.(0) 0 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <algorithm>
#define BLACK 1
#define RED 2
#define ARUKERUYO 10
using namespace std;

void aaa(int *data, int n, int a, int b){

  data[n] = ARUKERUYO;

  if(data[n-a] == BLACK && n-a >= 0) aaa(data,n-a,a,b);
  if(data[n-1] == BLACK && n%a != 0) aaa(data,n-1,a,b);
  if(data[n+1] == BLACK && n%a != a-1) aaa(data,n+1,a,b);
  if(data[n+a] == BLACK && n+a <= a*b-1) aaa(data,n+a,a,b);

  return;
}

int main(){
  int a,b;

  while(cin>>a>>b){
    if(a==0&&b==0)
      break;
    char sym;
    int data[a*b];
    int stand;

    for(int i=0;i<a*b;i++){
      cin >> sym;
      if(sym=='.')
	data[i] = BLACK;
      else if(sym=='#')
	data[i] = RED;
      else
	stand = i;
    }
    aaa(data,stand,a,b);
    stand = 0;
    for(int i=0;i<a*b;i++)
      if(data[i] == ARUKERUYO)
	stand++;
    cout << stand << endl;
  }
  return 0;
}

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

using namespace std;

const long long MOD = 1000000000 + 7;
const string abc = "abacaba";

void solve() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<pair<long long, long long>> dp1(n + 1, {0,0});
    vector<long long> dp2(n + 1, 0);
    dp1[0] = make_pair(0, 1000);
    dp2[0] = 1000;
    for (int i = 1; i <= n; i++) {
        dp2[i] = max(dp2[i - 1], dp1[i - 1].second + dp1[i - 1].first * a[i - 1]);
        pair<long long, long long> q = dp1[i - 1], w = {dp2[i - 1] / a[i - 1], dp2[i - 1] % a[i - 1]},
            e = {dp1[i - 1].first + dp1[i - 1].second / a[i - 1], dp1[i - 1].second % a[i - 1]};
        dp1[i] = max(q, max(w, e));
    } 
    cout << dp2[n];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // int t;
    // cin >> t;
    // for (int tt = 0; tt < t; tt++) {
        solve();
    // }
    return 0;
}

Measured memory_bytes: 3648
/*author : Yashvardhan
Thursday, May 09, 2019
6:22 PM
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __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...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int rxor(int n){
	int mv = n%4;
	if(mv == 0) return n;
	if(mv == 1) return 1;
	if(mv == 2) return n+1;
	if(mv == 3) return 0;
	return -1;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int a,b;
	cin>>a>>b;

	if(a == 0){
		cout<<rxor(b)<<endl;
	}
	else{
		int aval = rxor(a - 1);
		if(a == 1) aval = 0;
		int bval = rxor(b);
		if (b == 0) bval = 0;
		int ans = aval ^ bval;
		cout << ans << endl;
	}
	
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



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

long long N, K;
long long A[100005];
long long B[100005];


long long cal(long long limi, long long len){
	//cout << limi << ", " << len << endl;
	long long ret = 0;
	for(long long i = 0; i < N; i++){
		bool ok = true;
		if((len > 0) && (A[i]>>(len - 1))&1){
			ok = false;
		}

		for(long long j = len; j < 32; j++){
			if((((limi >> j)&1) == 0) && (((A[i] >> j)&1) == 1)){
				ok = false;
			}
		}
		if(ok){
			//cout << "ok " << A[i] << endl;
			ret += B[i];
		}
	}
	return ret;
}



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

	for(long long i = 0; i < N; i++)
		cin >> A[i] >> B[i];

	long long maxi = 0;
	for(long long i = 0; i < 32; i++){
		if(i == 0 || (K>>(i-1))&1){
			long long tmp = cal((K>>i) << i, i);
			maxi = max(maxi, tmp);
		}
	}
	cout << maxi << endl;
}


Measured memory_bytes: 1792
# AtCoder Beginner Contest 150 : C (2020/01/10)
import itertools
N = int(input())
in_p = input().split()
in_q = input().split()
P = [0 for i in range(N)]
Q = [0 for i in range(N)]
for i in range(N):
    P[i] = int(in_p[i])
    Q[i] = int(in_q[i])
R = list(itertools.permutations(sorted(P)))
idx_P = 0
idx_Q = 0
for i in range(len(R)):
    if list(R[i]) == P:
        idx_P = i+1
    if list(R[i]) == Q:
        idx_Q = i+1
    if idx_P != 0 and idx_Q != 0:
        break
print(abs(idx_P-idx_Q))

Measured memory_bytes: 8052
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i].first >> a[i].second;// value number
	sort(a.begin(), a.end());
	ll sum = 0;
	ll value = 0;
	int i = 0;
	while (sum < m) {
		value += a[i].first;
		a[i].second--;
		if (a[i].second == 0)
			i++;
		sum++;
	}
	cout << value << endl;
	return 0;
}

Measured memory_bytes: 1024
import math

a , b = map(int , input().split())

# 8 percent of x is a
# x = a/0.08 
x=[]
for i in range(10000):
	if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
		x.append(i)

if not len(x)==0:
	print(min(x))
else: print("-1")


Measured memory_bytes: 2940
import math

n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

p1 = p2 = p3 = pinf = 0

for i in range(n):
    d = abs(x[i] - y[i])
    p1 += d
    p2 += d * d
    p3 += d * d * d
    pinf = max(pinf, d)

p2 = math.sqrt(p2)
p3 = math.pow(p3, 1/3.0)

print(p1)
print(p2)
print(p3)
print(pinf)



Measured memory_bytes: 5692
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int A = Integer.parseInt(st.nextToken());
         int B = Integer.parseInt(st.nextToken());
         int C = Integer.parseInt(st.nextToken());
         int D = Integer.parseInt(st.nextToken());
         int x = C/B;
         if(C%B > 0)
            x++;
         int y = A/D;
         if(A%D > 0)
            y++;
         if(y >= x)
            System.out.println("Yes");
         else
            System.out.println("No");
      }
   }

Measured memory_bytes: 32604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 1;
    int MOD = 1e9 + 7;
    vector<int> cnt(26);
    REP(i, N) {
        cnt[S[i] - 'a']++;
    }
    REP(i, 26) {
        ans *= cnt[i] + 1;
        ans %= MOD;
    }
    ans = ans - 1 + MOD;
    ans %= MOD;
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    sc.close();

    String result;
    if (s.matches("^(dream|dreamer|erase|eraser)*$")) {
      result = "YES";
    } else {
      result = "NO";
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 36400
a, b = map(int, input().split())
if (a / 0.08) == int(a / 0.08):
    a1 = a / 0.08
else:
    a1 = int(a / 0.08) + 1
if ((a + 1) / 0.08) == int((a + 1) / 0.08):
    a2 = ((a + 1) / 0.08) - 1
else:
    a2 = int((a + 1) / 0.08)
if (b / 0.1) == int(b / 0.1):
    b1 = b / 0.1
else:
    b1 = int(b / 0.1) + 1
if ((b + 1) / 0.1) == int((b + 1) / 0.1):
    b2 = ((b + 1) / 0.1) - 1
else:
    b2 = int((b + 1) / 0.1)
if a1 == a2:
    ans = a1
    if b1 <= ans <= b2:
        ans = a1
    else:
        ans = -1
elif a1 > b2 or b1 > a2:
    ans = -1
elif a1 >= b1:
    ans = a1
else:
    ans = b1
print(int(ans))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const string str="CODEFESTIVAL2016";
int main()
{
	string s;
	cin>>s;
	int cnt;
	for(int i=0;i<=16;i++)
		if(s[i]!=str[i])
			cnt++;
	cout<<cnt<<"\n";
	return 0;
}

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

public class Solution
{
    public static void Main()
    {
        var card = new int[3][];
        for (int i = 0; i < 3; i++)
        {
            card[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        var n = int.Parse(Console.ReadLine());
        var b = new HashSet<int>();
        for (int i = 0; i < n; i++)
        {
            b.Add(int.Parse(Console.ReadLine()));
        }
        var bingo = Enumerable.Range(0, 3).Select(_ => new bool[3]).ToArray();
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (b.Contains(card[i][j]))
                {
                    bingo[i][j] = true;
                }
            }
        }

        var ok = false;
        for (int i = 0; i < 3; i++)
        {
            if (bingo[i].All(x => x))
            {
                ok = true;
            }
            if (bingo.All(x => x[i]))
            {
                ok = true;
            }
        }
        if (bingo[0][0] && bingo[1][1] && bingo[2][2])
        {
            ok = true;
        }
        if (bingo[0][2] && bingo[1][1] && bingo[2][0])
        {
            ok = true;
        }

        Console.WriteLine(ok ? "Yes" : "No");
    }
}

Measured memory_bytes: 13664
import itertools

n = int(input())
cities = []
for i in range(n):
    x, y = map(int, input().split())
    cities.append((x, y))

# print(cities)

distances = []
for i in range(8):
    distances.append([0. for j in range(8)])

for i in range(n):
    for j in range(i + 1, n):
        x = cities[i][0] - cities[j][0]
        y = cities[i][1] - cities[j][1]
        d = (x **2 + y ** 2) ** 0.5
        distances[i][j] = d
        distances[j][i] = d
# print(distances)

order_cnt = 0
sum_distance = 0.0
for order in itertools.permutations(range(n)):
    # print(order)
    current_distance = 0
    for i in range(len(order) - 1):
        current_distance += distances[order[i]][order[i + 1]]
    # print(current_distance)
    order_cnt += 1
    sum_distance += current_distance

print(sum_distance / order_cnt)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)        (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007 
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
inline LL moduloMultiplication(LL x, LL y) { return (x%mod * 1LL * y%mod) % mod; }
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}

LL gcd(LL a, LL b)
{
	if (!a)
		return b;
	return gcd(b%a, a);
}
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
int main()
{
	int a, b;
	cin >> a >> b;
	if (a == b)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256