akhauriyash/Code-Regression huggingface dataset:
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

from itertools import permutations

t = [i for i in range(1, N+1)]
r = list(permutations(t))

# print(P)
# print(Q)

i1 = r.index(P)
i2 = r.index(Q)
print(abs(i1-i2))

Measured memory_bytes: 8052
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>

using namespace std;

#define rep(a) _rep(0,int(a))
#define repj(a) for(int j=0;j<int(a);j++)
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
const double pai = 3.1415926535897;
#define _cos(n) cos(n*pai/180)

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}

int k;
signed main() {
	cin >> k;
	int a = k / 2,b=k-a;
	cout << a * b << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)
i = 0
while i < N:
    if i + 5 <= N:
        if S[i:i+5] == "dream":
            if i + 7 <= N:
                if S[i:i+7] == "dreamer":
                    if S[i+5:i+10] == "erase":
                        i = i + 5
                    else:
                        i = i + 7
                else:
                    i = i + 5
            else:
                i = i + 5
        elif S[i:i+5] == "erase":
            if i + 6 <= N:
                if S[i:i+6] == "eraser":
                    i = i + 6
                else:
                    i = i + 5
            else:
                i = i + 5
        else:
            print("NO")
            exit()
    else:
        print("NO")
        exit()
print("YES")


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

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

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

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

Measured memory_bytes: 256
h, w = map(int, input().split())
table = [[False for _ in range(w + 2)]]
for i in range(h):
    row = [False]
    for c in input():
        row.append(c == '#')
    row.append(False)
    table.append(row)
table.append([False for _ in range(w + 2)])

ok = True
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if table[i][j]:
            ok = ok and (table[i][j - 1] or table[i][j + 1] or table[i - 1][j]
                         or table[i + 1][j])
        if not ok:
            break
    if not ok:
        break
if ok:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        k: usize,
        c: [proconio::marker::Bytes;h],
    }
    let mut r=0;
    for a in 0..1<<h { for b in 0..1<<w {
        let mut v=0;
        for i in 0..h { if a>>i&1==0 {
            for j in 0..w { if b>>j&1==0 {
                if c[i][j]==b'#' {
                    v+=1;
                }
            }}
        }}
        if v==k {
            r+=1;
        }
    }}
    println!("{}",r);
}

Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long
int calcNumOfCombination(int n, int r)
{
    int num = 1;
    for(int i = 1; i <= r; i++)
    {
        num = num * (n - i + 1) / i;
    }
    return num;
}

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

	int a = calcNumOfCombination(n, 2);
	int b = calcNumOfCombination(m, 2);

	cout << a + b << endl;
    return 0;
}

Measured memory_bytes: 3652
while True:
    inputCount = int(input())

    if inputCount == 0:
        break

    table = []

    for lp in range(inputCount):
        content = [int(item) for item in input().split(" ")]
        content.append(sum(content))
        table.append(content)

    table.append([])

    for col in range(inputCount + 1):
        total = 0
        for row in range(inputCount):
            total += table[row][col]

        table[inputCount].append(total)

    for array in table:
        print("".join("{:>5}".format(item) for item in array))



Measured memory_bytes: 5620
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>

typedef long long int64;

int main(void) {
  int k, n;
  std::cin >> k >> n;
  std::vector<int> ais;
  for (int i = 0; i < n; i++) {
    int ai;
    std::cin >> ai;
    ais.push_back(ai);
  }
  int max = 0;
  for (int i = 0; i < n - 1; i++) {
    int d = ais.at(i + 1) - ais.at(i);
    max = std::max(max, d);
  }
  int ds = (k - ais.at(n - 1)) + ais.at(0);
  max = std::max(max, ds);
  std::cout << k - max << std::endl;
  return 0;
}


Measured memory_bytes: 1400
def get_runrun(runruns):
    newrunrun = []
    for runrun in runruns:
        last = runrun % 10
        if last != 0:
            newrunrun .append(runrun*10+last-1)
        if last != 9:
            newrunrun .append(runrun*10+last+1)
        newrunrun .append(runrun*10+last)
    return newrunrun




def resolve():
    K= int(input())
    runruns = list(range(1,10))

    if K < 10:
        print(K)
        return
    
    while True:
        if len(runruns) >= K:
            break
        K -= len(runruns)
        runruns= get_runrun(runruns)
        runruns.sort()

    runruns.sort()
    print(runruns[K-1])



if __name__ == "__main__":

    resolve()

Measured memory_bytes: 50288
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str1 = sc.next();
    String str2 = sc.next();
    boolean flag1 = (str1.equals("H"));
    boolean flag2 = (str2.equals("H"));
    flag2 = (flag1 ? flag2 : !flag2);
    System.out.println(flag2 ? "H" : "D");
  }
}

Measured memory_bytes: 21588
import re
n=int(input())
s=input()
for i in range(4):
  u=format(i,'02b')
  a=('S' if u[0]=='0' else 'W')
  b=('S' if u[1]=='0' else 'W')
  t=['?']*n
  t[0]=a
  t[1]=b
  for j in range(1,n+2):
    if s[j%n]=='o' and t[j%n]=='S' or s[j%n]=='x' and t[j%n]=='W':
      t[(j+1)%n]=t[(j-1)%n]
    else:
      t[(j+1)%n]=('S' if t[(j-1)%n]=='W' else 'W')
  if t[0]==a and t[1]==b:
    print(re.sub("[^SW]","",str(t)))
    exit()
print(-1)

Measured memory_bytes: 93948
import collections


num_proc, quantum = tuple(map(int, input().split(' ')))
proc_list = collections.deque()

for i in range(0, num_proc):
    proc_elem = input().split(' ')
    proc_elem[1] = int(proc_elem[1])
    proc_list.append(proc_elem)

timer = 0
while bool(proc_list):
    if proc_list[0][1] <= quantum:
        timer += proc_list[0][1]
        print(f'{proc_list.popleft()[0]} {timer}')
    else:
        timer += quantum
        proc_list[0][1] -= quantum
        proc_list.append(proc_list.popleft())


Measured memory_bytes: 17304
#include<bits/stdc++.h>
using namespace std;
int n,i,j,s1,s2,a[1100];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	i=n;j=n-1;
	while(1)
	{
		if(i<=0&&j<=0) break;
		s1+=a[i];
		s2+=a[j];
		i-=2;j-=2;
	}
	cout<<s1-s2;
	exit(0);
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define pf push_front
# define pb push_back
# define mp make_pair
# define pr printf
# define se second
# define si size()
# define sc scanf
# define fi first
# define er erase
# define be begin
# define ss size
# define Int __int64
# define INF 100000000000000008
# define MOD 1000000007
# define MN 500500
# define eps 0.0000000000000000018
# define mem(a) memset(a,0,sizeof(a))
# define cpy(b,a) memcpy(b,a,sizeof(a))
#define fast ios_base::sync_with_stdio(false)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;

int main() {
	int n,i,sum(0),ans;
	cin>>n;
	bool f=false;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	if(sum%10){
		cout<<sum;
		return 0;
	}
	ans=0;
	for(i=0;i<n;i++){
		if((sum-a[i])%10){
			f=true;
			ans=max(sum-a[i],ans);
		}
	}
	if(!f)cout<<0;
	else{
		cout<<ans;
	}
	return 0;
}
/* and its only us now */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
const int mod=1000000007,MAX=200005,INF=1<<30;

int main() {
	int n,t;
  	cin>>n>>t;
  
  	int c[1010];
  	int p[1010];
  	
  	rep(i,n){
    	cin>>c[i]>>p[i];
    }
  	int ans=989999;
  
  for(int i=0;i<n;i++){
  	if(p[i]>t){
    	continue;
    }
    
    else{
    	if(c[i]<ans){
        	ans=c[i];
        }
    }
  }
  
  if(ans==989999){
  	cout<<"TLE"<<endl;
  }
  
  else{
  	cout<<ans<<endl;
  }

}

Measured memory_bytes: 3484
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

struct mint {
    ll x;  // typedef long long ll;
    mint(ll 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(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    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; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;

        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }

    mint p(int n, int k) { return fact[n] * ifact[n - k]; }
};

int main() {
    INIT;
    ll n, k;
    cin >> n >> k;

    combination comb(200005);
    mint ans = 0;

    if (n <= k) {
        rep(i, n) { ans += comb(n, i) * comb(n - 1, n - i - 1); }

    } else {
        rep(i, k + 1) { ans += comb(n, i) * comb(n - 1, n - i - 1); }
    }
    cout << ans << endl;

    return 0;
}

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

#define ll long long int

int main()
{
    /*ll n,fl=0,a,b,c;
    cin>>n;
    a=(n%10);
    n=n/10;
    b=n%10;
    n=n/10;
    c=n;
    if(a==7 || b==7 || c==7)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;*/

    ll n,sum=0;
    cin>>n;

    for(ll i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
        {

        }
        else
            sum=sum+i;
    }
    cout<<sum<<endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = 0;
  rep(i, n) {
    if (i % 2 != 0) continue;
    if (a[i] % 2 != 0) ans++;
  }

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

Measured memory_bytes: 3624
b=False
while True:
    n = int(input())
    if n==0:break
    d=dict()
    if b:print()
    b=True
    for _ in range(n):
        line = input().split()
        tmp = int(line[1])*3+int(line[3]*1)
        if tmp in d:
            d[tmp].append(line[0])
        else:
            d[tmp] = []
            d[tmp].append(line[0])
    for k, vs in sorted(d.items(), key=lambda x: x[0])[::-1]:
        for v in vs:
            print('{0},{1}'.format(v, k))

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

using namespace std;

#define ll long long int
#define MOD 1000000007
#define mt make_tuple
#define eb emplace_back
#define error(args...){string _s = #args; replace(_s.begin(),_s.end(),',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args){cerr<<*it<<" = "<<a<<endl; err(++it,args...);}



int main()
{
    ll t,i,j,k,l,n,m;
    vector<ll> V;
    cin>>k>>l>>j;
    V.push_back(j);
    V.push_back(k);
    V.push_back(l);
    sort(V.begin(),V.end());
    cout<<V[2]-V[0];
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=100000000000000005;
const int maxn=1e6+5;
const int mod=433494437;
ll n,m,p;
string s,t;
int main()
{
    cin>>s>>t;
    cout<<t<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(ll i=(n);i<(ll) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;

string s,t;
int main(){
	cin>>s;
	t="";
	REP(i,0,s.size()){
		if(s[i]!='x'){
			t+=s[i];
		}
	}
	int ans=0;
	string tmp=t;
	reverse(tmp.begin(),tmp.end());
	if(t!=tmp) ans=-1;
	if(ans>-1){
		int bk=s.size()-1;
		for(int i=0;i<bk;i++){
			if(s[i]!=s[bk]){
				if(s[i]=='x'){
					ans++;
					bk++;
				}else if(s[bk]=='x'){
					ans++;
					i--;
				}else{
					ans=-1;
					break;
				}
			}
			bk--;

		}
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 640
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
const int INF = 1000000000;
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){
    string s;
    cin>>s;
    int n = s.length();
    int count =0;
    for(int i=0;i<n;i++){
        int p = s[i]-'0';
        count = count + p;
    }
    if(count%9)cout<<"No";
    else cout<<"Yes";
    return 0;
}




Measured memory_bytes: 3732
import sys
input = sys.stdin.readline

N, S = int(input()), input()

b, w = 0, S.count('.')

ans = b + w
for si in S:
    if si == "#":
        b += 1
    if si == ".":
        w -= 1
    ans = min(ans, b + w)
    
print(ans)


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,k;
  cin >> n >> k;
  if(k>(n-1)*(n-2)/2){
    cout << -1 << endl;
    return 0;
  }
  ll m = n*(n-1)/2-k;
  cout << m << endl;
  ll count = 0;
  REP(i,n){
    FOR(j,i+1,n){
      cout << i+1 << " " << j+1 << endl;
      if(++count==m){
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define N 200005 
bool cmp(ll A,ll B){return A>B;}
ll k,n,a[N],b[N];
bool chk(ll x){
	ll re=k;
	for(int i=1;i<=n;++i){
		ll p=x/b[i];
		if(p<a[i]) re-=a[i]-p;
	}
	return re>=0;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int i=1;i<=n;++i) cin>>b[i];
	sort(a+1,a+n+1);
	sort(b+1,b+n+1,cmp);
	ll l=0,r=0,mm=0;
	for(int i=1;i<=n;++i) r=max(r,a[i]*b[i]);
	while(l<=r){
		ll mid=(l+r)/2;
		if(chk(mid)) r=mid-1,mm=mid;
		else l=mid+1;
	}cout<<mm;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	map<string, int>hash;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		hash[s] += 1;
	}
	cout<<"AC"<<" x "<<hash["AC"]<<"\n";
	cout<<"WA"<<" x "<<hash["WA"]<<"\n";
	cout<<"TLE"<<" x "<<hash["TLE"]<<"\n";
	cout<<"RE"<<" x "<<hash["RE"]<<"\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())
 
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
 
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
 
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
 
constexpr ll INF = TEN(18);
 
int main() {
    int N, K;
    cin >> N >> K;
    V<int> P(N), C(N);
    rep(i, N) cin >> P[i], --P[i];
    rep(i, N) cin >> C[i];
 
    ll ans = -INF;
 
    rep(i, N) {
        int v = i;
        ll cycle_sum = 0;
        int cycle_cnt = 0;
 
        while (true) {
            cycle_cnt++;
            cycle_sum += C[v];
            v = P[v];
            if (v == i) break;
        }
 
        ll path = 0;
        int cnt = 0;
 
        while (true) {
            cnt++;
            path += C[v];
 
            if (cnt > K) break;
 
            int num = (K - cnt) / cycle_cnt;
            ll score = path + max(0ll, cycle_sum) * num;
            chmax(ans, score);
 
            v = P[v];
            if (v == i) break;
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3680
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()

	for i := 1; i < 4; i++ {
		if s[i-1] == s[i] {
			fmt.Println("Bad")
			return
		}
	}

	fmt.Println("Good")

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
int arr[100005];
int sum[100005];
int main()
{
	int num;
	int count=0;
	int n,i,j,l;
	scanf("%d",&n);
	int m=sqrt(n);
	memset(arr,0,sizeof(arr));
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=m;j++)
		{
			for(l=1;l<=m;l++)
			{
				num=i*i+j*j+l*l+i*j+i*l+j*l;
				arr[num]++;
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		printf("%d\n",arr[i]);
	}
}


Measured memory_bytes: 4100
n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]
if len(set([(x+y)%2 for x,y in xy]))>1:
  print(-1)
  exit()
m=0
d=[]
if sum(xy[0])%2==0:
  m+=1
  d.append(1)
for i in range(39):
  m+=1
  d.append(2**i)
print(m)
print(' '.join(list(map(str,d))))
for x,y in xy:
  ans=''
  for dd in d[::-1]:
    if y>=abs(x):
      ans='U'+ans
      y-=dd
    elif y>x and y<-x:
      ans='L'+ans
      x+=dd
    elif y<=-abs(x):
      ans='D'+ans
      y+=dd
    else:
      ans='R'+ans
      x-=dd
  print(ans)

Measured memory_bytes: 3316
import sys
import random
import time
my_input = sys.stdin.readline

start = time.time()
D = int(input())
C = list(map(int, my_input().split()))
S = [list(map(int, my_input().split())) for _ in range(D)]


def main():
    cnt = 0
    best_ans, best_score = generate_first_ans()
    while time.time() - start < 1.8:
        cnt += 1
        ans = best_ans[:]
        si = random.randint(0, 364)
        sj = random.randint(max(0, si - 125), min(364, si + 125))
        if si == sj:
            continue
        #si, sj = random.randint(0, 364), random.randint(0, 364)
        ans[si], ans[sj] = ans[sj], ans[si]
        score = calc_score(ans)
        if score > best_score:
            best_score = score
            best_ans = ans

    #print(best_score, cnt)
    for a in best_ans:
        print(a + 1)


def generate_first_ans():
    best_ans = []
    best_score = 0
    last_day = [-1] * 26
    for d in range(365):
        d_ans = -1
        d_score = -float('inf')
        d_last_day = [-1] * 26
        for t in range(26):
            d_tmp_score = 0
            d_tmp_score += S[d][t]
            d_tmp_last_day = last_day[:]
            d_tmp_last_day[t] = d
            for c, ld in zip(C, d_tmp_last_day):
                d_tmp_score -= c * (d - ld)

            if d_tmp_score > d_score:
                d_ans = t
                d_score = d_tmp_score
                d_last_day = d_tmp_last_day[:]

        best_ans.append(d_ans)
        best_score += d_score
        last_day = d_last_day[:]

    return best_ans, best_score


def calc_score(T):
    score = 0
    last_day = [-1] * 26
    for d, t in enumerate(T):
        score += S[d][t]
        last_day[t] = d
        for c, ld in zip(C, last_day):
            score -= c * (d - ld)
    return score


if __name__ == "__main__":
    main()


Measured memory_bytes: 84552
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



using P = pair<long long, long long>;

struct edge{
    long long to, cost;
};

class dijkstra
{
private:
    long long vertex;   // 頂点数
    vector<vector<edge>> list;  //隣接リスト
    vector<long long> distance;    // 距離
public:
    void init(long long n);  // nは頂点の数
    void add_edge(long long v1, long long v2, long long cost);    // 頂点v1から頂点v2に辺を張る
    void run(long long s);        // sは開始地点。
    long long get_distance(long long v);    // 頂点vへの距離を返す
};

void dijkstra::init(long long n){
    vertex = n;
    list.resize(n);
}

void dijkstra::add_edge(long long v1, long long v2, long long cost){
    list[v1].push_back({ v2, cost });
}

void dijkstra::run(long long s){
    priority_queue<P, vector<P>, greater<P>> que;
    distance = vector<long long>(vertex, INF);
    distance[s] = 0;    // 開始点の距離は0
    que.push(P(0, s));
    
    while(!que.empty()){
        P p = que.top(); que.pop();
        long long v = p.second;
        if(distance[v] < p.first) continue;
        for(auto e : list[v]){
            if(distance[e.to] > distance[v] + e.cost){
                distance[e.to] = distance[v] + e.cost;
                que.push(P(distance[e.to], e.to));
            }
        }
    }
}

long long dijkstra::get_distance(long long v){
    return distance[v];
}

int main() {
    ll n, m, s, t;
    dijkstra dik;
    
    cin >> n >> m >> s >> t;
    s--;t--;
    dik.init(n);
    REP(i, m){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;b--;c--;
        dik.add_edge(a, b, d);
        dik.add_edge(b, c, d);
        dik.add_edge(a, c, d);
        dik.add_edge(b, a, d);
        dik.add_edge(c, a, d);
        dik.add_edge(c, b, d);
    }
    
    dik.run(s);
    
    cout << dik.get_distance(t) << endl;
}


Measured memory_bytes: 23660
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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 N, K;
  cin >> N >> K;

  typedef pair<ll, int> P;
  vector<P> dt(N);
  rep(i, N) {
    cin >> dt[i].se >> dt[i].fi;
    (dt[i].se)--;
  }

  sort(all(dt), greater<P>());

  priority_queue<P, vector<P>, greater<P>> dupli;
  vector<int> cnt(N);

  ll del = 0;
  ll kind = 0;
  rep(i, K) {
    int t = dt[i].se;
    ll d = dt[i].fi;

    del += d;

    if (cnt[t] == 0)
      kind++;
    else
      dupli.push(dt[i]);
    cnt[t]++;
  }

  ll ans = del + kind * kind;
  repp(i, K, N - 1) {
    if (dupli.empty())
      break;
    int t = dt[i].se;
    ll d = dt[i].fi;

    if (cnt[t] > 0)
      continue;
    kind++;

    int ch_t = dupli.top().se;
    ll ch_d = dupli.top().fi;
    dupli.pop();

    cnt[t]++;
    del += d;

    cnt[ch_t]--;
    del -= ch_d;

    chmax(ans, del + kind * kind);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3320
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(void){
	int N;
	std::vector<int> weights;
	std::cin>>N;

	for(int i=0;i<N;i++){
		int w;
		std::cin>>w;	
		weights.push_back(w);
	}

	int min = 1000000;
	for(auto wptr = weights.begin();wptr != weights.end();wptr++){
		int s1 = std::accumulate(weights.begin(),wptr,0l);	
		int s2 = std::accumulate(wptr,weights.end(),0l);
		int sub = std::abs(s1 - s2);
		if(min > sub){
			min = sub;
		}
	}

	std::cout<<min<<std::endl;
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <functional>
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define alles(obj) obj.begin(), obj.end()
#define elif else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo std::cout <<
#define read std::cin >>
#define endl std::endl
#define fin << '\n'
#define bash push_back
#define makePair std::make_pair
#define _ << ' ' <<
// type-define
#define Stack std::stack
#define Queue std::queue
#define Set std::set
#define PQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
#define Greater std::greater
using String = std::string;
using llong = long long;
using boolean = bool;
using Pii = Pair<int, int>;
using Vi = Vector<int>;
using Vii = Vector<Pii>;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs ( llong n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }

    boolean isMovable ( int x, int y, int w, int h ) { 
        return ( x >= 0 && y >= 0 && x < w && y < h ); }
}

namespace Rlyeh {

    int problem_count[16];
    int complete_bonus[16];
    int dp[16][100100];
    int d, g;

    int dfs ( int pos, int sco ) {
        if ( g <= sco ) return 0;
        if ( pos == d+1 ) return INF;
        if ( ~dp[pos][sco] ) return dp[pos][sco];
        int min = INF;
        for ( int i = 0; i < problem_count[pos]; i++ ) {
            chmin ( min, dfs(pos+1, sco + pos*i) + i );
        }
        chmin ( min, dfs(pos+1, sco+pos*problem_count[pos]+complete_bonus[pos]) + problem_count[pos] );
        return dp[pos][sco] = min;
    }

    signed call_of_Cthulhu( signed datum ) {

        read d >> g;
        g/= 100;
        for ( int i = 1; i <= d; i++ ) {
            read problem_count[i] >> complete_bonus[i];
            complete_bonus[i] /= 100;
        }

        memset ( dp, -1, sizeof(dp) );

        echo dfs ( 1, 0 ) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 6528
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end

# exit if $0 != __FILE__

r = 0.0
n,k = cin
fn = n.to_f
fk = k.to_f

[*(1..n)].each do |x|
  if x >= k
    r += 1.0 / fn
    next
  end

  kai = Math.log2(fk / x.to_f).ceil
  r += (0.5**kai) / fn
end

puts r


Measured memory_bytes: 3452
//Counting Sort
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(void){
    unsigned short *A,*B;
    
    int C[VMAX+1];  //カウンタ配列
    int n,i,j;
    scanf("%d",&n);
    
    A = malloc(sizeof(short)*n+1);
    B = malloc(sizeof(short)*n+1);
    
    for(i=0;i<=VMAX;i++) C[i] = 0;
    
    for(i=0;i<n;i++){
        scanf("%hu",&A[i+1]);
        C[A[i+1]]++;
    }
    
    for(i=1;i<=VMAX;i++) C[i] += C[i-1];
    
    for(j=1;j<=n;j++){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    for(i=1;i<=n;i++){
        if(i>1) printf(" ");
        printf("%d",B[i]);
    }
    printf("\n");
    return 0;
}



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

int main(){
  vector<int> a(9);
  vector<int> b(9);
  rep(i,9) cin >> a[i];
  int n;
  cin >> n;
  rep(i,n){
    int tmp;
    cin >> tmp;
    rep(j,9){
      if (a[j]==tmp) b[j]=1;
    }
  }
  int ans = 0;
  rep(i,3){
    if (b[0+i]+b[3+i]+b[6+i]==3) ans = 1;
    if (b[i*3+0]+b[i*3+1]+b[i*3+2] == 3) ans = 1;
  }
  if (b[0]+b[4]+b[8]==3) ans = 1;
  if (b[2]+b[4]+b[6]==3) ans = 1;
  
  if (ans==0) cout << "No";
  else cout << "Yes";
}


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

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

using namespace std;

const int IINF = INT_MAX;
int H,W,mincost;
int P[10][10],bin[10],bc[(1<<10)];
int put[10][10],counter[10][10];

bool can_put(int len,int x,int y){
  REP(i,y,y+len)REP(j,x,x+len) if( !P[i][j] ) return false;
  return true;
}

void dfs(int cur,int cost,int remain){

  if( cost >= mincost ) return;
  if( cost + ((remain>0)?1:0) >= mincost ) return;

  if( cur >= H*W ) {
    mincost = min(mincost,cost);
    return;
  }

  int x = cur % W, y = cur / W;

  if( !P[y][x] || counter[y][x] == 1 ) {
    dfs(cur+1,cost,remain);
    return;
  }

  if( (bin[y]>>x) & 1 ) dfs(cur+1,cost,remain);

  int len = put[y][x];
  int bitmask = ((1<<len)-1)<<x;
  int buf[len];
  int add = 0, nremain = remain;
  rep(j,len) {
    buf[j] = bin[y+j];
    add += len - bc[((1<<len)-1)&(bin[y+j]>>x)];
    bin[y+j] |= bitmask;
  }
  nremain -= add;
  if( add ) dfs(cur+1,cost+1,nremain);
  rep(j,len) bin[y+j] = buf[j];

}

bool isValid(int x,int y){ return 0 <= x && x < W && 0 <= y && y < H; }

int main(){

  rep(i,(1<<10)) bc[i] = __builtin_popcount(i);

  while( scanf("%d%d",&W,&H), W | H ){

    rep(i,H){
      bin[i] = 0;
      rep(j,W){
        cin >> P[i][j];
        put[i][j] = 0;
      }
    }
    rep(y,H) rep(x,W) if( P[y][x] ) {
      for(int len=min(H,W);len>=1;len--){
        if( x + len - 1 < W && y + len - 1 < H ) {
          if( can_put(len,x,y) ){
            put[y][x] = len;
            break;
          }
        }
      }
    }

    rep(i,H)rep(j,W) counter[i][j] = 0;
    rep(i,H)rep(j,W)if(P[i][j]){
      REP(y,i,i+put[i][j])REP(x,j,j+put[i][j]){
        counter[y][x]++;
      }
    }

    rep(i,H){
      rep(j,W){
        if( counter[i][j] == 1 ){
          REP(y,i,i+put[i][j])REP(x,j,j+put[i][j]){
            bin[y] |= (1<<x);
          }
        }
      }
    }

    int add = 0;
    int remain = 0;
    mincost = 0;
    rep(i,H)rep(j,W)remain += ((bin[i]>>j)&1),mincost += P[i][j];
    remain = mincost - remain;
    dfs(0,0,remain);

    rep(i,H)rep(j,W)if(counter[i][j]==1)add++;
    cout << mincost+add << endl;

  }
  return 0;
}

Measured memory_bytes: 1260
#include<iostream>
using namespace std;
 
int main(){
  int a,b,c,count=3;
  cin>>a>>b>>c;
  if(a==b){
    count--;
  }
  if(a==c){
    count--;
  }
  if(b==c){
	count--;
  }
  if(count==0){
    cout<<"1";
  }
  else{
   cout<<count;
  }
  return 0;
}

Measured memory_bytes: 256
// ツ閉敖優ツ静ヲツ探ツ催オ
#include<iostream>
#include<queue>
using namespace std;
#define rep(i,n) for (int i=0; i<n; i++)
#define MAX 100

class State{
	public:
	int p,b,cost;
	State(int p=0, int b=0, int cost=0): p(p), b(b), cost(cost){}
};

int n,B[MAX][2];

int bfs(){
	bool V[MAX][2];
	queue<State> Q;
	rep(i,n) rep(j,2) V[i][j] = false;
	int s0=0,s1=0;
	if(B[s0][0] == 1) while(s0+1 < n && B[s0+1][0] == 1) s0++;
	if(B[s1][1] == 1) while(s1+1 < n && B[s1+1][1] == 1) s1++;
	V[s0][0] = V[s1][1] = true;
	Q.push(State(s0,0,0));
	Q.push(State(s1,1,0));
	
	State u,v;
	while(!Q.empty()){
		u = Q.front(); Q.pop();
		if(u.p == n-1) return u.cost;
		for(int r=0; r<3; r++){
			int np = u.p+r;
			int nb = (u.b+1)%2;
			if(np>=n) continue;
			if(B[np][nb] == 2) while(B[np][nb] == 2)np--;
			if(B[np][nb] == 1) while(np+1 < n && B[np+1][nb] == 1) np++;
			if(V[np][nb]) continue;
			V[np][nb] = true;
			Q.push(State(np,nb,u.cost+1));
		}
	}
	return -1;
}

int main(){
	while(cin >> n){
		if(n==0) break;
		rep(i,n) cin >> B[i][0];
		rep(i,n) cin >> B[i][1];
		int cost = bfs();
		if(cost<0) cout<<"NA"<<endl;
		else cout << cost << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define P pair
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define endl '\n'

using namespace std;

typedef long long ll;
typedef P<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int a[100005];

int32_t main()
{
	IO_OP;
	
	int n, k, q;
	cin >> n >> k >> q;
	for(int i=0;i<q;i++) {
		int t;
		cin >> t;
		a[t]++;
	}
	for(int i=1;i<=n;i++) {
		if(q-a[i] < k) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
}





Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int n,a,b,c,d;
            String s;
            n = sc.nextInt();
            a = sc.nextInt() - 1;
            b = sc.nextInt() - 1;
            c = sc.nextInt() - 1;
            d = sc.nextInt() - 1;
            s = sc.next();

            boolean aflag = true;
            for (int i = a + 1; i < c; i++) {
                if (s.charAt(i-1) == '#' && s.charAt(i) == '#') {
                    aflag = false;
                }
            }
            boolean bflag = true;
            for (int i = b + 1; i < d; i++) {
                if (s.charAt(i-1) == '#' && s.charAt(i) == '#') {
                    bflag = false;
                }
            }
            if (!aflag || !bflag) {
                System.out.println("No");
            } else {
                if (c < d) {
                    System.out.println("Yes");
                } else {
                    boolean switchflag = false;
                    for (int i = b; i <= d; i++) {
                        if (s.charAt(i-1) == '.' &&
                                s.charAt(i) == '.' &&
                                s.charAt(i+1) == '.') {
                            switchflag = true;
                        }
                    }
                    if (switchflag) {
                        System.out.println("Yes");
                    } else {
                        System.out.println("No");
                    }
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){

    int n;
    cin >> n;
    int a[110];
    rep(i,n){
        cin >> a[i];
    }
    string ans = "APPROVED";
    rep(i,n){
        if(a[i]%2==0 && a[i]%3!=0 && a[i]%5 !=0){
            ans = "DENIED";
        }
    }

    cout << ans << endl;

}

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


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

int main(){
  string SA, SB, SC;
  cin >> SA >> SB >> SC;
  int a=0, b=0, c=0;
  char turn='a';
  while(a<=SA.size() && b<=SB.size() && c<=SC.size()){
    if(turn=='a'){
      turn = SA[a];
      a++;
    }else if(turn=='b'){
      turn = SB[b];
      b++;
    }else if(turn=='c'){
      turn = SC[c];
      c++;
    }
  }
  if(a>SA.size()){
    cout << "A" << endl;
    return 0;
  }
  if(b>SB.size()){
    cout << "B" << endl;
    return 0;
  }
  cout << "C" << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let a_b = lines.next().unwrap().unwrap();
    let mut a_b = a_b.split_whitespace();
    let a = a_b.next().unwrap().parse::<i32>().unwrap();
    let b = a_b.next().unwrap().parse::<i32>().unwrap();

    let ans = if 1 <= a && a <= 9 && 1 <= b && b <= 9 {
        a * b
    } else {
        -1
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
 
char s[18][18];
string buf;
int main(){
    do{
        memset(s,0,sizeof(s));
        for(int i=1;i<=8;i++)scanf("%s",s[i]+1);
        for(int i=1;i<=8;i++){
            for(int j=1;j<=8;j++){
                if(s[i][j]!='1')continue;
                if(s[i][j+1]=='1'&&s[i+1][j+1]=='1'&&s[i+1][j]=='1'){puts("A");goto p;}
                if(s[i+1][j]=='1'&&s[i+2][j]=='1'&&s[i+3][j]=='1'){puts("B");goto p;}
                if(s[i][j+1]=='1'&&s[i][j+2]=='1'&&s[i][j+3]=='1'){puts("C");goto p;}
                if(s[i+1][j-1]=='1'&&s[i+1][j]=='1'&&s[i+2][j-1]=='1'){puts("D");goto p;}
                if(s[i][j+1]=='1'&&s[i+1][j+1]=='1'&&s[i+1][j+2]=='1'){puts("E");goto p;}
                if(s[i+1][j]=='1'&&s[i+1][j+1]=='1'&&s[i+2][j+1]=='1'){puts("F");goto p;}
                if(s[i][j+1]=='1'&&s[i+1][j-1]=='1'&&s[i+1][j]=='1'){puts("G");goto p;}
            }
        }
        p:;
    }while(getline(cin,buf));
    return 0;
}


Measured memory_bytes: 3144
<?php

	$n = trim(fgets(STDIN));
	$i = 0;
	$c = 0;
	if($n == 3) echo "2 5 63";
	else{
    	while($c + 8 <= $n - ($n % 8)){
    	    for($j=0; $j<12; $j++){
    	       $i++;
        	    if($i%2==0 || $i%3==0){
        	        echo $i." ";
        	    } 
    	    }
    	    $c += 8;
    	}
    	if($c < $n){
    	    $r = $n - $c;
    	    if($r%2 == 1) echo ($i+6)." ";
    	    if($r > 1) echo ($i+2)." ".($i+4)." ";
    	    if($r > 3) echo ($i+3)." ".($i+9)." ";
    	    if($r > 5) echo ($i+8)." ".($i+10)." ";
    	}
	}
	
?>

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
	int n;
	cin>>n;
	int a[1000001]={0};
	int ar[n];
	set<int>s;
	for(int i=0;i<n;i++){
		cin>>ar[i];
		if(s.count(ar[i]))
			a[ar[i]]=1;
		s.insert(ar[i]);
	}
	int count=0;
	for(auto i:s){
		for(int j=2*(i);j<1000001;j+=(i)){
			a[j]=1;
		}
	}
	for(int i=0;i<n;i++)
		if(!a[ar[i]])
			count++;
	cout<<count<<endl;
}



Measured memory_bytes: 17616
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b,k=map(int,input().split())
tmp=k; k=max(0,k-a)
a=max(0,a-tmp)

b=max(0,b-k)
print(a,b)

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

typedef long long ll;

const int MOD = 1e9 + 7;

ll fast_pow(ll a, ll b, ll p){
    ll ans = 1;
    ll base = a % p;
    b = b % (p - 1);
    
    while(b){
        if (b & 1)
            ans = (ans * base) % p;
        
        base = (base * base) % p;
        b >>= 1;
    }

    return ans;
}

ll inv(ll a, ll p){
    return fast_pow(a, p - 2, p);
}

ll C(ll n, ll m, ll p){
    if (n < m)
        return 0;

    m = min(m, n - m);
    
    ll nom = 1, den = 1;
    for (ll i = 1; i <= m; i++){
        nom = (nom * (n - i + 1)) % p;
        den = (den * i) % p;
    }

    return (nom * inv(den, p)) % p;
}

ll lucas(ll n, ll m, ll p){
    if (m == 0)
        return 1;
    return C(n % p, m % p, p) * lucas(n / p, m / p, p) % p;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, m, k;
    cin >> n >> m >> k;

    ll ans = 0;
    for (ll i = 1; i < n; i++){
        ans += ((((((n - i) * i) % MOD) * m) % MOD) * m) % MOD;
        ans %= MOD;
    }

    for (ll i = 1; i < m; i++){
        ans += ((((((m - i) * i) % MOD) * n) % MOD) * n) % MOD;
        ans %= MOD;
    }
    
    cout << (ans * lucas(n * m - 2, k - 2, MOD)) % MOD;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S = list(map(str,input()))

N = len(S)-1
A = [0]*N
right = 0
left = 0
for i in range(N):
    if S[i] == 'R':
        right += 1
        if left != 0:
            A[i-left] += left//2 + left%2
            A[i-left-1] += left//2
            left = 0
    else:
        left += 1
        if right != 0:
            A[i-1] += right//2 + right%2
            A[i] += right//2
            right = 0

        if i == N-1:
            A[i-left+1] += left//2 + left%2
            A[i-left] += left//2

A_str=[str(a) for a in A]
ans=" ".join(A_str)

print(ans)

Measured memory_bytes: 11580
from collections import defaultdict
n=int(input())
m=[[(0,0) for j in range(n)] for i in range(n)]
b=[]
if n==1:
    ans=1
else:
    for i in range(n):
        x,y=map(int,input().split())
        b.append((x,y))
    C=defaultdict(int)
    for i in range(n):
        for j in range(i+1,n):
            p,q=b[i][0]-b[j][0],b[i][1]-b[j][1]
            C[(p,q)]+=1
            C[(-p,-q)]+=1
                
    l=[]
    for i in C.items():
        l.append(i)
    l.sort(key=lambda x:x[1],reverse=True)

    ans=n-l[0][1]
print(ans)



Measured memory_bytes: 40176
import sys
inp = lambda: sys.stdin.readline()
mi = lambda: map(int, inp().split())
li = lambda: list(map(int, inp().split()))
mf = lambda: map(float,inp().split())
lf = lambda: list(map(float,inp().split()))

A = int(inp())
B = int(inp())
C = int(inp())
D = int(inp())
E = int(inp())
K = int(inp())
print("Yay!" if E - A <= K else ":(")

Measured memory_bytes: 9088