akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0043 : Puzzle **/
bool bfs(int *num)
{
	bool f=false;
	
	bool ff=true;
	for (int i=1; i<10; i++) {
		if (num[i]!=0) {
			ff=false;
		}
	}
	if (ff) return true;
	
	for (int i=1; i<10; i++) {
		if (num[i]>=3) {
			num[i]-=3;
			f |= bfs(num);
			num[i]+=3;
		}
	}
	
	for (int i=1; i<8; i++) {
		if (num[i]>0 && num[i+1]>0 && num[i+2]>0) {
			num[i]--; num[i+1]--; num[i+2]--;
			f |= bfs(num);
			num[i]++; num[i+1]++; num[i+2]++;
		}
	}
	
	return f;
}

int main()
{
	int num[10] = {0};
	vector<int> ans;
	string s;
	
	while (cin>>s) {
		ans.clear();
		rep(i, 10) num[i]=0;
		rep(i, s.length()) {
			num[s[i]-'0']++;
		}
		
		for (int k=1; k<10; k++) {
			if (num[k]==4)
				continue;
			else if (num[k]>4) {
				cout << 0 << endl;
				goto end;
			} else {
				num[k]++;
				bool f=false;
				for (int i=1; i<10; i++) {
					if (num[i] >= 2) {
						num[i]-=2;
						f |= bfs(num);
						num[i]+=2;
					}
				}
				num[k]--;
				if (f)
					ans.push_back(k);
			}
		}
		
		if (ans.size()>0) {
			rep(i, ans.size()-1)
				cout << ans[i] << " ";
			cout << ans[ans.size()-1] << endl;
		} else {
			cout << 0 << endl;
		}
		
	end:;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
long long MAX(long long a,long long b){
    return a>b?a:b;
}
long long MIN(long long a,long long b){
    return a<b?a:b;
}
int compare(const void *a,const void *b){
    return *(long long *)a>*(long long *)b?1:-1;
}
long long factrial(int w){
    long long num=1;
    for(int i=1;i<=w;i++){
        num*=i;
        num%=1000000007;
    }    
    return num;
} 
int main()
{   int a,b,n,m,k,x,y,i;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    int alp[26]={0};
    long long ans=1,sub=0;
    int letter=0;
    for(i=0;i<n;i++){
        if(alp[s[i]-'a']==0){
            letter++;
        }
        alp[s[i]-'a']++;
        
    }
    for(i=0;i<26;i++){
            ans*=(alp[i]+1);
            ans%=1000000007;
        
    }
    ans-=1;
    
    
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

def prime_factorization(n):
    '''
    Trial division.
    Input: 
        n : a positive integer
    Output:
        a dictionary of #(each prime factors) of n,
    '''
    result = defaultdict(int)
    if n < 2:
        return result
    while n % 2 == 0:
        result[2] += 1
        n //= 2
    p = 3
    while p*p <= n:
        while n % p == 0:
            n //= p
            result[p] += 1
        p += 2
    if n > 1:
        result[n] += 1
    return result

N = int(input())
MOD = 10**9 + 7
factors = defaultdict(int)
for i in range(2, N+1):
    fac = prime_factorization(i)
    for p, n in fac.items():
        factors[p] += n
ans = 1
for _, n in factors.items():
    ans = (ans * (n+1)) % MOD
print(ans)

Measured memory_bytes: 3444
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <iostream>
 

using namespace std;
int main(void)
{
    int a, p;
    scanf("%d %d", &a, &p);
    int k = a*3+p;
    printf("%d\n", k/2);
   
 
    return 0;
}
    



Measured memory_bytes: 256
S = input()
T = input()

S_count = len(S)
T_count = len(T)
record = []

try_number = S_count - T_count + 1

for i in range(try_number):
	count = 0
	search_word = S[i:i+T_count]
	for i, letter in enumerate(search_word):
		if T[i] == letter:
			count += 1
		else:
			continue
	record.append(count)
print(T_count-max(record))

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 300300;
const ll inf = 1ll<<50;
int n;
ll a[N];

ll f(ll b){
ll ret=0;
for(int i=1;i<=n;i++)
    ret += llabs(a[i]-i-b);
return ret;
}

int main(){

scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%lld",a+i);

ll low = -inf , high = inf;
while( low < high ){
    ll mid = low+high >> 1;
    if( f(mid) < f(mid+1) )high=mid;
    else low=mid+1;
}
printf("%lld\n",f(high));
return 0;
}


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

int main(){
  long n;  scanf("%ld", &n);
 
  int ans[100] = {0};
 
  do{
    if((n-1) / 26){
      ans[++ans[0]] = (n-1) % 26;
    }else{
      ans[++ans[0]] = n - 1;
    }
    n = (n-1) / 26;
  }while(n);
 
  while(ans[0])
    printf("%c", (char)(ans[ans[0]--]+(int)'a'));
 
  puts("");
 
  return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i*i <= n; i++) {
        ans = i*i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a[5];
	int i,j,buf;
	scanf("%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4]);
	for(i=1;i<5;i++)
	{
		for(j=1;j<5;j++)
		{
			if(a[j-1]<a[j])
			{
				buf=a[j-1];
				a[j-1]=a[j];
				a[j]=buf;
			}
		}	
	}
	printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
	return 0;


}

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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		double r = Double.parseDouble(br.readLine());

		double circle = r * 2 * Math.PI;
		double area = r * r * Math.PI;

		System.out.printf("%.6f",area);
		System.out.printf(" " + "%.6f",circle);
	}
}

Measured memory_bytes: 24660
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define forN(i, n) for(int i = 1; i <=n ; ++i)
#define endl "\n"
typedef long long ll;
using namespace std;
const ll INF = 1e18;

const int N = 405;
ll A[N],DP[N][N],prefix[N],n;

ll cost(int i ,int j){
    if(i-1>=0)return prefix[j]-prefix[i-1];
    return prefix[j];
}

ll calc(int L , int R){
    if (L == R)return 0;
    ll &ans  = DP[L][R];
    if(ans != -1)return ans;
    ans = INF;
    for(int k = L ; k<R+1 ; k++){
        ans = min(ans , calc(L,k) + calc(k+1,R) + cost(L,R));
    }
    return ans;
}

int main(){
    fastIO;
    cin>>n;
    for(int i = 0 ; i<n ; i++){
        cin>>A[i];
        prefix[i] = A[i];
        if(i>0)prefix[i]+=prefix[i-1];
    }
    memset(DP,-1,sizeof DP);
    cout<<calc(0,n-1);
    return 0;
}



Measured memory_bytes: 4976
#include<iostream>
using namespace std;
int main(){
   int house[5][4][11];
   int n,b,f,r,v;

   for(int i=1; i<=4; i++){
   	for(int j=1; j<=3; j++){
   		for(int k=1; k<=10; k++){
   			house[i][j][k] = 0;
   		}
   	}
   }

   cin >> n;

   for(int l=0; l<n; l++){
   	cin >> b >> f >> r >> v;
   	house[b][f][r] += v;
   }

   for(int i=1; i<=3; i++){
   	for(int j=1; j<=3; j++){
   		for(int k=1; k<=10; k++){
   			cout << " " << house[i][j][k];
   		}
   		cout << endl;
   	}
   	for(int l=0; l<20; l++){
   		cout << "#";
   	}
   	cout << endl;
   }

   	for(int j=1; j<=3; j++){
   		for(int k=1; k<=10; k++){
   			cout << " " << house[4][j][k];
   		}
   		cout << endl;
   	}

   return 0;
}
   

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

int main(void) {
    int N;
    int min = 1000000000, max = 1;
    int buf;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> buf;
        if(buf < min) min = buf;
        if(buf > max) max = buf;
    }   
    cout << max - min << endl;
    return 0;
}

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

int main() {
    int a, b, c, n = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            n++;
        }
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
typedef int  i32;
typedef long long i64,ll;
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef MODE_DEBUG
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl

#define  DUMP(x)  cerr << #x << " = " << (x) <<endl
#define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl
#define CHECK(exp,act)  if(exp!=act){DUMP(exp);DEBUG(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#else
#define DUMP(x)
#define DEBUG(x)
#define CHECK(exp,act)
#define STOP(e)
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T>>& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

int main(){
	while(true){
		int N;cin >> N;
		if(N==0)break;
		vector<int> as(N);	

		REP(i,N)cin >>as[i];

		int v;cin >> v;
		int l=0,r=N-1;

		int c=0;
		while(r>l){
			// DUMP(l);
			// DUMP(r);
			c++;
			int m=(l+r)/2;
			if(as[m]<v){
				l=m+1;
			}else if(as[m]>v){
				r=m-1;
			}else{
				break;
			}
		}
		if(l==r)c++;
		cout<<c<<endl;
	}

	return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(long long &a, long long b) { if (a > b) a = b; }

int main(){
  ll i = 0, j;
  ll n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) spa max(a + b - n, i) << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
b = []
for _ in range(n):
    atmp, btmp = map(int, input().split())
    a.append(atmp)
    b.append(btmp)
a.sort()
b.sort()
if n % 2 == 1:
    pos = n // 2
    print(b[pos] - a[pos] + 1)
else:
    pos = n // 2 - 1
    a1 = a[pos]
    a2 = a[pos + 1]
    b1 = b[pos]
    b2 = b[pos + 1]
    medmin = a1 + a2
    medmax = b1 + b2
    print(medmax - medmin + 1)


Measured memory_bytes: 25552
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, A, B, C, D;
string S;

bool check(int a, int b) {
	int cnt = 0;
	char c = 'o';
	rep(i, a, b + 1) {
		if(c != S[i]) {
			if(c == '#' && cnt >= 2) return false;
			cnt = 1;
			c = S[i];
		}
		else cnt++;
	}
	return true;
}

void solve() {
	cin >> N >> A >> B >> C >> D;
	A--; B--; C--; D--;
	cin >> S;
	bool ok = true;
	if(!check(A, C)) ok = false;
	if(!check(B, D)) ok = false;
	if(D < C) {
		bool con = false;
		rep(i, B, D + 1) {
			if(S[i] == '.' && S[i - 1] == '.' && S[i + 1] == '.') {
				con = true; break;
			}
		}
		if(!con) ok = false;
	}
	if(ok) cout << "Yes\n";
	else cout << "No\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	   string s;
	   cin >> s;
	   int count = 0;
	   if (s[0] == s[1] && s[1] == s[2] && s[1] == 'R')
	        cout << 3 << endl;
	   else if (s[0] == s[1] && s[1] == 'R' || s[1] == s[2] && s[2] == 'R')
	        cout << 2 << endl;
	   else {
	       if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')   cout << 1 << endl;
	       else cout << 0 << endl;
	   }
	
	return 0;
}


Measured memory_bytes: 3628
intToKString :: Int -> Int -> String
intToKString x n
    | n == 0 = []
    | n == 1 = replicate x '1'
    | n <= 16 = getKString x n
    | otherwise = []
    where
        getKString :: Int -> Int -> String
        getKString x n
            | x == 0 = []
            | otherwise = (getKString (x `div` n) n) ++ (numbers !! (x `mod` n))
            where numbers = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]
main = do
    [n,k]<-map read.words<$>getLine
    print$length(intToKString n k )

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, 0, n) {
        int a;
        cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for (auto x:mp) {
        if (x.second % 2 == 1) ans++;
    }

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


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long m = (C * D) / gcd(C, D);
    long long canC = B / C - (A - 1) / C;
    long long canD = B / D - (A - 1) / D;
    long long canCD = B / m - (A - 1) / m;
    cout << (B - A + 1) - canC - canD + canCD << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    int n; cin>>n;
    map<char,int> mp;
    rep(i,0,n){
        char c; cin>>c;
        mp[c]++;
    }
    if(mp.size()==3) cout<<"Three"<<endl;
    else cout<<"Four"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char ch[99],l,a,b,c;
    int i,j,h,k,n,m,x=0,y=0,z=0;
    gets(ch);
    n=strlen(ch);
    k=(n-1)/2;
    m=(n+3)/2;
    for(i=0,j=n-1;i<n/2;i++,j--)
    {
        if(ch[i]==ch[j])
            z++;
    }
      if(z==n/2)
            {
                for(i=0,j=k-1;i<k/2;i++,j--)
    {
        if(ch[i]==ch[j])
        {
            x++;
        }
    }
    for(i=k+1,j=n-1;i<(k+1+(k/2));i++,j--)
    {
        if(ch[i]==ch[j])
        y++;
    }
    if(x==(k/2) && y==(k/2))
        printf("Yes\n");
    else printf("No\n");
            }
            else printf("No\n");

    return 0;
}


Measured memory_bytes: 128
// https://atcoder.jp/contests/abc165/tasks/abc165_e

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N, M;
  cin >> N >> M;

  ll forward_ct = (M + 1) / 2;
  ll back_ct = M - forward_ct;

  ll forward_begin_i = 1;
  ll forward_end_i = forward_begin_i + (2 * forward_ct - 1);

  rep(i, forward_ct) {
    ll a = forward_begin_i + i;
    ll b = forward_end_i - i;
    cout << a << " " << b << "\n";
  }

  ll back_begin_i = forward_end_i + 1;
  ll back_end_i = back_begin_i + (2 * back_ct - 1) + 1;

  rep(i, back_ct) {
    ll a = back_begin_i + i;
    ll b = back_end_i - i;
    cout << a << " " << b << "\n";
  }
}


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

int main() {
	int n; cin >> n;
	vector<int>a(n + 2, 0);
	long long sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];		
	}
	for (int i = 0; i <= n; i++) {
		sum += abs(a[i] - a[i + 1]);
	}

	for (int i = 1; i <= n; i++) {
		cout << sum + abs(a[i - 1] - a[i + 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 250010, MOD[2] = {(int)(1e9 + 7), 998244353}, BAS = 233;
inline void Add(int& x,int y,int mod) {
  x = x + y >= mod ? x + y - mod : x + y;
}
inline void Sub(int& x,int y,int mod) {
  x = x - y < 0 ? x - y + mod : x - y;
}
int power(int a,int b,int mod) {
  int ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % mod;
    a = 1ll * a * a % mod;
    b >>= 1;
  }
  return ret;
}

char str[N];
int n, rec[2], val[2][N][2], tmp[2][N][2];
ll ans;
map<pii,int> mp;
void solve(int l,int r) {
  if (l == r) {
    if (val[1][l][0] == rec[0] && val[1][l][1] == rec[1])
      ++ ans;
    return;
  }
  int mid = (l + r) >> 1;
  mp.clear();
  rep (k, 0, 1) {
    tmp[0][mid][k] = val[0][mid][k], tmp[1][mid][k] = val[1][mid][k];
    rrp (i, mid-1, l) {
      tmp[0][i][k] = 1ll * val[0][i][k] * tmp[0][i+1][k] % MOD[k];
      tmp[1][i][k] = (1ll * val[0][i][k] * tmp[1][i+1][k] + val[1][i][k]) % MOD[k];
    }
    tmp[0][mid+1][k] = val[0][mid+1][k], tmp[1][mid+1][k] = val[1][mid+1][k];
    rep (i, mid+2, r) {
      tmp[0][i][k] = 1ll * tmp[0][i-1][k] * val[0][i][k] % MOD[k];
      tmp[1][i][k] = (1ll * tmp[0][i-1][k] * val[1][i][k] + tmp[1][i-1][k]) % MOD[k];
    }
  }
  rep (i, mid+1, r) ++ mp[pii(tmp[1][i][0], tmp[1][i][1])];
  rep (i, l, mid) {
    // tmp[0][i] * v + tmp[1][i] = rec
    int v0 = rec[0];
    Sub(v0, tmp[1][i][0], MOD[0]);
    v0 = 1ll * v0 * power(tmp[0][i][0], MOD[0] - 2, MOD[0]) % MOD[0];
    int v1 = rec[1];
    Sub(v1, tmp[1][i][1], MOD[1]);
    v1 = 1ll * v1 * power(tmp[0][i][1], MOD[1] - 2, MOD[1]) % MOD[1];
    ans += mp[pii(v0, v1)];
  }
  solve(l, mid);
  solve(mid+1, r);
}
int main() {
  read(n);
  scanf("%s", str+1);
  rep (k, 0, 1) {
    rep (i, 1, n) {
      if (str[i] == '+') val[0][i][k] = 1, val[1][i][k] = 1;
      if (str[i] == '-') val[0][i][k] = 1, val[1][i][k] = MOD[k] - 1;
      if (str[i] == '<') val[0][i][k] = BAS;
      if (str[i] == '>') val[0][i][k] = power(BAS, MOD[k] - 2, MOD[k]);
    }
    rrp (i, n, 1)
      rec[k] = (1ll * rec[k] * val[0][i][k] + val[1][i][k]) % MOD[k];
  }
  solve(1, n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23936
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
x,y = map(int,input().split())
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 2940
#include <stdio.h>

int main() {
    int n, m, a[105][105] = {0}; 
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
            a[i][m] += a[i][j];
            a[n][j] += a[i][j];
            a[n][m] += a[i][j];
        }
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            printf("%d", a[i][j]);
            if (j < m) printf(" ");
            else printf("\n");
        }
    }
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define double long double
#define M_PI 3.14159265358979323846 
const int mod = 1e9 + 7;

int32_t main()
{
    fastio;

    int a, b; cin >> a >> b;
    cout << a*b << endl;
    return 0;
}

/*

*/

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

int main(){
    string s;
    cin>>s;
    int  count=0;
    for(int i=0;i<s.size();i++){
       if(s.at(i)=='x'){
          count++;
          }
     } 
     if(count<8){
       cout<<" YES"<<endl;
       }
     else if(count>=8){
       cout<<"NO"<< endl;
       }
}
       

Measured memory_bytes: 3512
import sys

#fp = open("input.txt", "r")
fp = sys.stdin

while True:
    n = int(fp.readline()[:-1])
    if n == 0:
        break

    change = 1000 - n
    count = 0

    coin = [500, 100, 50, 10, 5, 1]

    for c in coin:
        count += change / c
        change = change - (change / c) * c

    print count

Measured memory_bytes: 4224
s = list(input())
t = list(input())
ans = "UNRESTORABLE"
if len(s) >= len(t):
    for i in range(len(s) - len(t) + 1):
        ss = s[i:i + len(t)]
        count = 0
        for j in range(len(ss)):
            if (ss[j] == "?") | (ss[j] == t[j]):
                count += 1
            else:
                break
        if count == len(ss):
            ans = "".join(s[:i] + t + s[i + len(t):])
    print(ans.replace("?", "a"))
else:
    print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int n,q,i=0,j=0,c=0;
  int s[100000],t[500];

  while(1){
    scanf("%d",&n);
    if(n<=10000){
      while(i<n){
	scanf("%d",&s[i]);
	if(0<=s[i]&&s[i]<=1000000000) i++;
      }
      break;
    }
  }

  i=0;
  while(1){
    scanf("%d",&q);
    if(q<=500){
      while(i<q){
	scanf("%d",&t[i]);
	if(0<=t[i]&&t[i]<=1000000000) i++;
      }
      break;
    }
  }

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(t[i]==s[j]){
	c++;
	break;
      }
    }
  }

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

  return 0;
}



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

bool passed[51];

static void step_edge(const int now_pos, const vector <vector <int>> &edge, const pair <int, int> &unused_edge) {
  if (passed[now_pos]) return;
  passed[now_pos] = true;

  int cannot_to = -1;
  if (unused_edge.first == now_pos) cannot_to = unused_edge.second;
  if (unused_edge.second == now_pos) cannot_to = unused_edge.first;

  for (int i = 0; i < edge[now_pos].size(); i++) {
    int next_pos = edge[now_pos][i];
    if (next_pos == cannot_to) continue;

    step_edge(next_pos, edge, unused_edge);
  }
}

int main(void) {
  int N, M;
  cin >> N >> M;
  vector <vector <int>> edge(N+1);
  vector <pair <int, int>> bridge(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
    bridge[i].first = a;
    bridge[i].second = b;
  }

  int ans = 0;
  for (int unused_m = 0; unused_m < M; unused_m++) {
    // init
    for (int i = 1; i <= N; i++) passed[i] = false;

    step_edge(1, edge, bridge[unused_m]);

    // passed check
    bool all_passed = true;
    for (int i = 1; i <= N; i++) {
      if (!passed[i]) {
        all_passed = false;
        break;
      }
    }
    if (!all_passed) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
const int INF = 1e9;
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
} 
int32_t main() 
{
	fastio();
	int n;
	cin>>n;
	int ans=0;
	f(i,1,n+1)
	{
		int tt=0,aa=i;
		while(aa>0)
		{
			tt++;
			aa=aa/10;
		}
		if(tt%2!=0)
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
odd = true
even = true
gets.chomp.chars.each_with_index do |v, i|
  break unless odd || even
  if (i + 1).odd?
    odd = false unless v =~ /(R|U|D)/
  elsif (i + 1).even?
  even = false unless v =~ /(L|U|D)/
  end
end
puts (odd && even) ? 'Yes' : 'No'

Measured memory_bytes: 1788
n = int(input())
s = input()
t = input()

lt = min(len(s), len(t))
i = -1
overlap = 0
for i in range(lt):
    if s[-(i + 1):] == t[:i + 1]:
        overlap = i + 1
        if lt >= 2 and s[-(i + 2):] != t[:i + 2]:
            break
    
ans = max(n, len(s) + len(t) - overlap)
print(ans)

Measured memory_bytes: 8988
N, M = map(int, input().split())
switches = []

for i in range(M):
    tmp = list(map(int,input().split()))
    tmp.pop(0)
    switches.append(tmp)

R = list(map(int,input().split()))

a = [list(format(i, '0%db' % N)) for i in range(2**N)]

ans = 0

for i in a:
    flag = 0
    for j in range(M):
        SUM = 0
        for k in switches[j]:
            SUM += int(i[k-1])
        if SUM%2 != R[j]:
            flag = 1
    if flag == 0:
        ans += 1

print(ans)

Measured memory_bytes: 3188
def main():
    n = int(input())
    s = input()
    x = 0
    tmp = 0
    for i in range(len(s)):
        if(s[i]=="D"):
            x-=1
        if(s[i]=="I"):
            x+=1
        tmp = max(tmp,x)
    print(tmp)
if __name__ == '__main__':
    main()


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

int main(){
  int a,s[300];
  cin>>a;
  for(int i=1;i<=a;i++){
    cin>>s[i];
  }
  for(int i=1;i<=a;i++){
    cout<<"node "<<i<<": key = "<<s[i]<<", ";
    if(i/2>=1)cout<<"parent key = "<<s[i/2]<<", ";
    if(i*2<=a)cout<<"left key = "<<s[2*i]<<", ";
    if(i*2+1<=a)cout<<"right key = "<<s[i*2+1]<<", ";
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()

const ll Mod = 1e9 + 7;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	ld a = (n+1)/2;
	
	printf("%0.10lf\n", a/n);
	return 0;
}


















Measured memory_bytes: 256
import sys
from numba import jit
N = int(input())
import math
if N == 2:
  print(1)
  sys.exit()
@jit
def nd(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1
    
    return num
cheat = [1166714,3829761,6638407,9529244,12478098,13222660,13820210]
if N < 100000:
  k = 3
  for i in range(3,N):
    k += nd(i)
  print(k)
  sys.exit()
if N < 300000:
  k = cheat[0]
  for i in range(10**5 , N):
    k += nd(i)
  print(k)
  sys.exit()
if N < 500000:
  k = cheat[1]
  for i in range(3*10**5 , N):
    k += nd(i)
  print(k)
  sys.exit() 
if N < 700000:
  k = cheat[2]
  for i in range(5*10**5 , N):
    k += nd(i)
  print(k)
  sys.exit()  
if N < 900000:
  k = cheat[3]
  for i in range(7*10**5 , N):
    k += nd(i)
  print(k)
  sys.exit()   
if N < 950000:
  k = cheat[4]
  for i in range(9*10**5 , N):
    k += nd(i)
    print(k)
    sys.exit()
if N < 990000:
  k = cheat[5]
  for i in range(99*10*4 , N):
    k += nd(i)
    print(k)
    sys.exit()    
k = cheat[6]
for i in range(99*10**4 , N):
  k += nd(i)
print(k)
sys.exit()


Measured memory_bytes: 110484
#include<cstdio>
using namespace std;
long long n,m,q,a[505],b[505],c[505],d[505],ans=0,dfn[105];
inline void dfs(long long step,long long min){
	if(step==n+1){
		long long cur=0;
		for(long long i=1;i<=q;++i)
			if(dfn[b[i]]-dfn[a[i]]==c[i])
				cur+=d[i];
		if(cur>ans)ans=cur;
		return;
	}
	for(long long i=min;i<=m;++i)
		dfn[step]=i,dfs(step+1,i);
	return;
}
int main(){
	scanf("%lld%lld%lld",&n,&m,&q);
	for(long long i=1;i<=q;++i)
		scanf("%lld%lld%lld%lld",&a[i],&b[i],&c[i],&d[i]);
	return dfs(1,1),printf("%lld",ans),0;
}

Measured memory_bytes: 1752
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int inf=1e9,mod=998244353;
int n,sl,fh,ex[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
int main()
{
	n=rd();ex[0]=1;
	for(int i=100;i<=105;++i)
		for(int j=0;j<=n-i;++j)
			ex[j+i]|=ex[j];
	printf("%d\n",ex[n]);
	return 0;
}

Measured memory_bytes: 640
#coding: utf-8

dirc = ((0, 1, 2, 3, 4, 5), (4, 0, 2, 3, 5, 1), (3, 1, 0, 5, 4, 2),
(2, 1, 5, 0, 4, 3), (1, 5, 2, 3, 0, 4), (5, 4, 2, 3, 1, 0))
sideNum = (1, 2, 4, 3)

def judge(diceRef, diceNew):
    for i in diceNew:
        if diceRef.count(i) != diceNew.count(i):
            return False
    for i in range(6):
        diceTmp = [0 for k in range(6)]
        for j in range(6):
            diceTmp[dirc[i][j]] = diceRef[j]
        if diceNew[0] == diceTmp[0] and diceNew[5] == diceTmp[5]:
            sideNew = ''
            sideTmp = ''
            for j in sideNum:
                sideNew += str(diceNew[j])
                sideTmp += str(diceTmp[j])
            sideTmp += sideTmp
            if sideNew in sideTmp:
                return True
    return False

dice = list()
n = int(input())
dice.append(list(map(int, input().split())))
for i in range(1, n):
    dice.append(list(map(int, input().split())))
    for j in range(i):
        if judge(dice[j], dice[i]):
            print('No')
            exit()    
print('Yes')


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

void main_()
{
    ll N, M;
    cin >> N >> M;

    bitset<200007> bs1;
    bitset<200007> bs2;

    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        if (a == 1) {
            bs1.set(b);
        }
        if (b == N) {
            bs2.set(a);
        }
    }

    cout << ((bs1 & bs2).any() ? "POSSIBLE\n" : "IMPOSSIBLE\n");
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n]; 
    int odd = 0,even = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] % 2 == 0) even++;
        else if (a[i] % 2 == 1) odd++;
    }
    if(odd % 2 == 0){
        cout << "YES" << endl; 
    }else{ 
        cout << "NO" << endl;
    }
 
 
    return 0;
}

Measured memory_bytes: 3876
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int x,y,h,w;
	int size;
	int fee[6]={600,800,1000,1200,1400,1600};
	int n;
	while(scanf("%d",&n)){
		if(n==0) break;
		int sum=0,fl=0;
		for(int i=0;i<n;i++){
			scanf("%d %d %d %d",&x,&y,&h,&w);
			size=x+y+h;
			if(size<=60&&w<=2) sum+=fee[0];
			else if(size<=80&&w<=5) sum+=fee[1];
			else if(size<=100&&w<=10) sum+=fee[2];
			else if(size<=120&&w<=15) sum+=fee[3];
			else if(size<=140&&w<=20) sum+=fee[4];
			else if(size<=160&&w<=25) sum+=fee[5];
		}
		printf("%d\n",sum);
	}
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

struct LCA
{
    int i,j;
    vector<vector<int>> parent;
    vector<int> dist;
    LCA(const vector<vector<ll>> &graph, int root = 0){
        init(graph, root);
    }

    void init(const vector<vector<ll>> &graph, int root = 0){
        int v = graph.size();
        int k = 1;
        while((1ll << k) < v) ++k;
        parent.assign(k, vector<int>(v, -1));
        dist.assign(v, -1);
        dfs(graph, root, -1, 0);
        for(i = 0;i < k-1;++i){
            rep(j,v){
                if(parent.at(i).at(j) < 0){
                    parent.at(i+1).at(j) = -1;
                }else{
                    parent.at(i+1).at(j) = parent.at(i).at(parent.at(i).at(j));
                }
            }
        }
    }

    void dfs(const vector<vector<ll>> &graph, int v, int p, int d){
        parent.at(0).at(v) = p; //戻る方向?
        dist.at(v) = d;
        for(auto next:graph.at(v)){
            if(next != p) dfs(graph, next, v, d+1);
        }
    }

    int query(int u, int v){
        if(dist.at(u) < dist.at(v)) swap(u, v);
        int n = parent.size();
        for(i = 0;i < n;++i){
            if((dist.at(u) - dist.at(v)) >> i & 1) u = parent.at(i).at(u);
        }

        if(u == v) return u;
        for(i = n-1;i >= 0;--i){
            if(parent.at(i).at(u) != parent.at(i).at(v)){
                u = parent.at(i).at(u);
                v = parent.at(i).at(v);
            }
        }
        return parent.at(0).at(u);
    }

    int get_dist(int u, int v){
        return dist.at(u) + dist.at(v) - 2*dist.at(query(u, v));
    }

    bool is_on_path(int u, int v, int a){
        return get_dist(u, a) + get_dist(a, v) == get_dist(u, v);
    }

};

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<vector<ll>> graph(n);
    for(i = 0;i < n;++i){
        ll k;
        cin >> k;
        rep(j,k){
            ll c;
            cin >> c;
            graph.at(i).push_back(c);
            graph.at(c).push_back(i);
        }
    }

    LCA lca(graph, 0);
    ll q;
    cin >> q;
    for(i = 0;i < q;++i){
        ll u,v;
        cin >> u >> v;
        cout << lca.query(u,v) << endl;
    }

    return 0;
}


Measured memory_bytes: 18988
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;
typedef long long ll;

int main(){
  int N, K;
  cin >> N >> K;
  if (N % K == 0 || K == 1) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    { 
        
        static void Main(string[] args)
        {
            string s = ReadLine();
            string ans = "No";
            for (int i = 0; i < s.Length-1; i++)
            {
                if (s.Substring(i,2) == "AC")
                {
                    ans = "Yes";
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n;
    cin>>n;
    vector<ll> v(n);
    ll sum=0;
    for(int i=0; i<n; i++){
        cin>>v[i];
        v[i]*=2;
        sum+=v[i];
    }
    sum/=2;
    
    for(int i=0; i<n-1; i+=2){
        sum-=v[i];
    }
    vector<ll> answer(n);
    answer[n-1]=sum;
    for(int i=n-2; i>=0; i--){
        answer[i]=v[i]-answer[i+1];
    }
    for(ll ans : answer) cout<<ans<<" ";

    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define REP(i,c) for(int i=0;i<(int)c;i++)
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> ac(N,0);
  vector<int> wa(N,0);
  for(int i=0;i<M;i++){
    int x;
    string s;
    cin>>x>>s;
    x--;
    if(ac[x])continue;
    if(s=="WA"){
      wa[x]++;
    }else{
      ac[x]=1;
    }
  }
  int ok=0,no=0;
  REP(i,N){
    if(ac[i]){
      ok++;
      no+=wa[i];
   }
  }
  cout<<ok<<" "<<no<<endl;;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	fmt.Scan(&k)
	for i := 0; i < len(s); i++ {
		if s[i] != s[k-1] {
			fmt.Print(string('*'))
		} else {
			fmt.Print(string(s[i]))
		}
	}
	fmt.Println()
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template<class A, class B>
inline bool chmax(A &a, const B &b) { return b > a ? a = b, 1 : 0; }

template<class A, class B>
inline bool chmin(A &a, const B &b) { return b < a ? a = b, 1 : 0; }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

//IN
void IN() {}
template<class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

//OUTS
template<size_t> struct int_{};
template<class Tuple, size_t Pos>
ostream& print_tuple(ostream& out, const Tuple& t, int_<Pos>) {
  out << get<tuple_size<Tuple>::value-Pos>(t) << " ";
  return print_tuple(out, t, int_<Pos-1>());
}

template <class Tuple>
ostream& print_tuple(ostream& out, const Tuple& t, int_<1>) {
  return out << get<tuple_size<Tuple>::value-1>(t);
}

template<class... Args>
ostream& operator<<(ostream& out, const tuple<Args...>& t) {
  return print_tuple(out, t, int_<sizeof...(Args)>());
}

#define OUTS(...) cout << make_tuple(__VA_ARGS__) << "\n";

//OUTL
void OUTL() {}
template<class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  VAR(int, a, b);
  OUTL((a - 1) * (b - 1));
  return 0;
}


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

int main() {
    int ans = 0;
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i, n) cin >> s[i];

    s.push_back(0);

    rep(j, n + 1) {
        int tmp = accumulate(s.begin(), s.end(), 0) - s[j];
        if (tmp % 10 != 0) ans = max(ans, tmp);
    }

    put(ans);
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

h,w=get_i
s=array(w,1)
h.times do|i|
  s[i]=get_nsp
end
def link?(s,h,w,x,y)
  dirX=[1,0,-1,0]
  dirY=[0,-1,0,1]
  4.times do|i|
    return true if (dirX[i]+x).between?(0,w-1) and (dirY[i]+y).between?(0,h-1) and s[dirY[i]+y][dirX[i]+x]=="#"
  end
  return false
end
flag=true
h.times do|i|
  w.times do|j|
    if s[i][j]=="#"
      unless link?(s,h,w,j,i)
        flag=false
        break
      end
    end
  end
end
puts yn_judge(flag)

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

using namespace std;

int main(){
    int N,count=0,p,q,r;
    cin >> N;
    for(p = 1;p<=N;p++){
        for(q = 1;q <= p;q++){
            if((p*q)>=N)break;
            for(r = 1;true;r++){
                if((p*q+r)==N){
                    if(p==q)count++;
                    else count += 2;
                    break;
                }
            }
        }
    }
    cout << count << "\n";
}

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

bool is_sequence(int i, int j, int k) {
	return j == i + 1 && k == j + 1;
}

bool is_same_number(int i, int j, int k) {
	return i == j && j == k;
}

bool is_good_set(int i, int j, int k) {
	return is_sequence(i, j, k) || is_same_number(i, j, k);
}

bool is_all_good_set(vector<int> v) {
	return is_good_set(v[0], v[1], v[2]) && is_good_set(v[3], v[4], v[5]) && is_good_set(v[6], v[7], v[8]);
}

int win(vector<int> v) {
	sort(v.begin(), v.end());

	do {
		if (is_all_good_set(v)) {
			return 1;
		}
	} while (next_permutation(v.begin(), v.end()));

	return 0;
}

signed main() {
	int t;
	vector<int> card(9);
	cin >> t;
	vector<int> res(t);

	for (int j = 0; j < t; j++) {
		for (int i = 0; i < 9; i++) {
			cin >> card[i];
		}

		for (int i = 0; i < 9; i++) {
			char s;
			cin >> s;
			if (s == 'R') card[i] += 10;
			else if (s == 'G') card[i] += 20;
			else if (s == 'B') card[i] += 30;
		}

		res[j] = win(card);
	}

	for (auto e:res) cout << e << endl;
}





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

int main() {
    int N; cin >> N;
    vector<long long> A (N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end());

    long long res = A[N-1] - A[0];
    for (int i = 0, j = N-2; i + 1 < j; ++i, --j) res += A[j] - A[i];
    for (int i = 1, j = N-1; i + 1 < j; ++i, --j) res += A[j] - A[i];
    if (N & 1) res += max(A[N/2 + 1] - A[N/2], A[N/2] - A[N/2-1]);
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
int main(){
    ll a,b;
    cin >> a >> b;
    ll start = a * 100 / 8;
    ll end = a * 100 / 7;
    ll ans;
    bool judge= false;
    for(ll i = start; i < end+1; i++){
        if ((int) (i * 0.08) == a && (int) (i * 0.1) == b){
            ans = i;
            judge = true;
            break;
        }
    }
    if(judge) cout << ans << endl;
    else cout << "-1" << endl;

}

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

namespace _0566
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            int[] team = new int[(input + 1)];
            int now = 1;
            int y = 0;
            int[] output = new int[(input + 1)];
            for (int i = 0; i < input * (input - 1) / 2; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x[2] > x[3])
                {
                    team[x[0]] += 3;
                }
                else if (x[2] == x[3])
                {
                    team[x[0]]++;
                    team[x[1]]++;
                }
                else
                {
                    team[x[1]] += 3;
                }
            }
            for (int i = (input - 1) * 3; i >= 0; i--)
            {
                y = 0;
                for (int j = 1; j <= input; j++)
                {
                    if (team[j] == i)
                    {
                        output[j] = now;
                        y++;
                    }  
                }
                now += y;
            }
            for(int i=1;i<=input;i++)
            {
                Console.WriteLine(output[i]);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9624