akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 10000
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;
long double p[3000];
long double dp[3000][3000]; 
long double ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> p[i];
	dp[0][0] = 1.0;
	for (int i = 0; i < n; i++) {
		dp[i + 1][0] = dp[i][0] * (1.0 - p[i]);
		dp[i + 1][i + 1] = dp[i][i] * p[i];
		for (int j = 1; j <= i; j++) {
			dp[i + 1][j] = dp[i][j - 1] * p[i] + dp[i][j] * (1.0 - p[i]);
		}
	}
	for (int i = n / 2 + 1; i <= n; i++)ans += dp[n][i];
	printf("%.15Lf", ans);
}

Measured memory_bytes: 139136
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 10;

vector<int> adj[bs];
ll dp[40][bs];
ll k;

ll solve() {
	fill(dp[0], dp[0] + bs, 1);
	if(k < 10) return k;
	k -= 10;
	ll ret = 0;
	int u, i;
	for(u = 1; ; u++) {
		bool brk = 0;
		for(i = 0; i < bs; i++) {
			for(auto el: adj[i])
				dp[u][i] += dp[u - 1][el];
			if(!i) continue;
			if(dp[u][i] <= k) k -= dp[u][i];
			else {
				brk = 1; break;
			}
		}
		if(brk) break;
	}

	ret = i;
	while(u >= 1) {
		for(auto el: adj[i]) {
			if(dp[u - 1][el] <= k) k -= dp[u - 1][el];
			else {
				i = el;break;
			}
		}
		ret = ret * 10 + i, u--;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	for(int i = 0; i < bs; i++) {
		for(int j = -1; j <= 1; j++) {
			int x = i + j;
			if(x < 0 || x == 10) continue;
			adj[i].push_back(x);
		}
	}

	cin >> k;
	cout << solve() << '\n';
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class ABC159_A
    {
        static void Main(string[] args)
        {
            int M, N;
            string[] str = Console.ReadLine().Split(' ');
            int m = int.Parse(str[0]);
            int n = int.Parse(str[1]);
            if(m == 1 || m == 0)
            {
                M = 0;
            }
            else
            {
                M = m * (m - 1) / 2;
            }
            if(n == 1 || n == 0)
            {
                N = 0;
            }
            else
            {
                N = n * (n - 1) / 2;
            }
            Console.WriteLine(M + N);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
const int MOD=1000000007;
int main() {
  int N,M,X;
  cin>>N>>M>>X;
  vector<int>C(N);
  vector<vector<int>>A(N,vector<int>(M));
  for(int i=0;i<N;i++){
    cin>>C[i];
    for(int j=0;j<M;j++){
      cin>>A[i][j];
    }
  }
  int MIN=INF;
  for(auto s=0;s<(1<<N);s++){
    int cost=0;
    vector<int>sum(M);
    for(int i=0;i<N;i++){
      if((s>>i)&1){
        cost+=C[i];
        for(int j=0;j<M;j++){
          sum[j]+=A[i][j];
        }
      }
    }
    bool ok=true;
    for(int j=0;j<M;j++){
      if(sum[j]<X){ok=false;}
    }
    if(ok){chmin(MIN,cost);}
  }
  if(MIN==INF){cout<<-1<<endl;}
  else{cout<<MIN<<endl;}
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

typedef long long LL;
int a[103];
int b[103];

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

    int m=100;
    int i=0,j=0;
    while(n>1)
    {
        if(n&1) {a[i++]=m--;n--;}
        else {b[j++]=m--;n>>=1;}
    }

    cout<<2*(i+j)<<endl;
    for(int k=0;k<i;k++) cout<<a[k]<<' ';
    for(int k=j-1;k>=0;k--) cout<<b[k]<<' ';
    for(int k=m+1;k<=100;k++) cout<<k<<' ';

    return 0;
}

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

using namespace std;

int main()
{
	int X, Y;
	cin >> X >> Y;
	int c = X, t = 0;
	string answer = "No";

	for (int i = 0; i <= X; i++, c--, t++) {
		if (2 * c + 4 * t == Y)
			answer = "Yes";
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int main()
{
    char a[101], b[101], temp;
    scanf(" %s %s", &a, &b);
    int len=strlen(a), suma=0, sumb=0, i, rotation=0, res=0;
    for(i=0; i<len; i++)
    {
        suma += a[i];
        sumb += b[i];
    }
    if(suma != sumb)
    {
        printf("No\n");
    }
    else if(strcmp(a, b)==0)
    {
        printf("Yes\n");
    }
    else
    {
        rotation=0;
        while(rotation<len)
        {
            i=len-1;
            temp = a[0];
            a[0]=a[i];
            while(i>1)
            {
                a[i] = a[i-1];
                i--;
            }
            a[i] = temp;
            if(strcmp(a, b)==0)
            {
                printf("Yes\n");
                res=1;
                break;
            }
            rotation++;
        }
        if(res!=1)
        {
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 2056
N = int(input())
S = list(input().strip())

cnt = S[1:].count('E')

res = cnt
for i in range(1,N):
    if S[i] == 'E':
        cnt -= 1
    if S[i - 1] == "W":
        cnt += 1
    res = min(res,cnt)

print(res)

Measured memory_bytes: 8268
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <climits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;
typedef long long ll;
#define ln '\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> bool Max(T1& a, T2 b) { return a<b ? a = b, 1 : 0; }
template<typename T1, typename T2> bool Min(T1& a, T2 b) { return a>b ? a = b, 1 : 0; }

const int N = 500;

void solve() {
  int n, v;
  set<int> st;
  cin >> n;
  rep(i, n) {
    cin >> v;
    if (st.count(v))st.erase(v);
    else st.insert(v);
  }
  cout << st.size() << ln;
}


void init() {
  
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  int TC = 1;
#if 0
  cin >> TC; cin.get();
#endif
  FOR(TI, 1, TC) {
    //cout << "Case #" << TI << ": ";
    solve();
  }
  
  
  return 0;
}



Measured memory_bytes: 4992
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
a, b = ri_()
print((b - a - 1) * (b - a) // 2 - a)

Measured memory_bytes: 62956
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] str = new String[h];
		for(int i = 0; i<h;i++) {
			str[i] = "#"+sc.next()+"#";
		}
		for(int i = 0; i < w+2; i++) {
			System.out.print("#");
		}
		System.out.println();
		for(int i = 0; i < h; i++) {
			
			System.out.print(str[i]);
			System.out.println();
			}
		
		for(int i = 0; i < w+2; i++) {
			System.out.print("#");
		}
	}
}


Measured memory_bytes: 21460
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int n=nextInt();
		int S[]=new int[n];
		int k=-1;
		for(int i=0;i<n;i++){
			S[i]=nextInt();
			if(S[i]==k)
				S[i]=-1;
			else
				if(k!=S[i])
					k=S[i];
		}
		int q=nextInt();
		int T[]=new int[q];
		for(int i=0;i<q;i++)T[i]=nextInt();
		int ans=0;
		Arrays.sort(T);
		for(int i=0;i<n;i++){
			int a=Arrays.binarySearch(T,S[i]);
			if(a<q&&0<=a&&T[a]==S[i])
				ans++;
		}
		System.out.println(ans);
	}
	static boolean isOK(int index,int key,int[]a){
		if (key>=a[index]) return true;
	    else return false;
	}
	static int binary_search(int key,int[] a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.length; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}




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

int main() {
  int n, k;
  cin >> n >> k;
  
  if((n - 1) % (k - 1) == 0){
    cout << (n - 1) / (k - 1) << endl;
  }
  else{
    cout << (n - 1) / (k - 1) + 1 << endl;
  }
}


Measured memory_bytes: 256
n, k = gets.split(" ").map(&:to_i)
loop do
  s = (n - k).abs
  if n > k
    n %= k
  elsif n < k
    nn = k - n
    if nn > n
      break
    end
    n = nn
  else
    n = 0
    break
  end
end
puts n

Measured memory_bytes: 1788
import bisect

n = int(input())
L = sorted(list(map(int,input().split())))

ans = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        k = bisect.bisect_left(L,L[i]+L[j])
        ans += k-j-1
print(ans)

Measured memory_bytes: 44540
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main(){
  ll n,a,b;
  cin >>n >>a >>b;
  ll q[n];
  rep(i,n)cin >> q[i];
  ll ans=0;
  rep(i,n){
    if(i>0)ans+=min((q[i]-q[i-1])*a,b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4368
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define repp(i,a,n)   for(int i=a;i<n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define w(t)          int t;cin>>t;while(t--)
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0),cout<<fixed<<setprecision(15);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
   long  double a,b;
    cin>>a>>b;
    ll ans=a*b;
    cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 3808
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int a[] = new int[n];
		int b[] = a.clone();
		int c[] = new int[n - 1];

		for(int j = 0;j < n;j++) {
			a[j] = sc.nextInt();
		}

		for(int j = 0;j < n;j++) {
			b[j] = sc.nextInt();
		}

		for(int j = 0;j < n - 1;j++) {
			c[j] = sc.nextInt();
		}

		int result = java.util.Arrays.stream(b).sum();
		int beforeEat = -1;
		for(int x : a) {
			if((beforeEat + 1) == x) {
				result += c[x - 2];
			}
			beforeEat = x;
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 27604
#include<iostream>
using namespace std;
int main(){
    int a,b,c=1,d=0;
    cin >> a>>b;
    int L[a];
    for(int i=0;i<a;i++){
        cin >> L[i];
        d += L[i];
        if(d>b){
            break;
        }
        c++;
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>

int A,B,C;
int Diff;
long long int K;

int main(){
#ifdef DEBUG
	printf("DEBUGGING ON\n");
#endif
	scanf("%d %d %d %lld", &A,&B,&C,&K);
	Diff=(K%2==0)?(A-B):(B-A);
	printf("%d\n",Diff);
	

	return (0);
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
is_zero = False
for i in a:
  if i == 0:
    is_zero = True
    break
if is_zero:
  print(0)
else:
  p = 1
  for i in a:
    p = p*i
    if p > 10**18:
      break
  if p > 10**18:
    p = -1
  print(p)
    


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

#define ll long long
using namespace std;

const int N = 305;
int n, a, cnt[3];
double dp[N][N][N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    cout << fixed << setprecision(10);
    for(int i = 0; i < n; i++) {
        cin >> a;
        cnt[a - 1]++;
    }
    for(int k = 0; k <= n; k++) {
        for(int j = 0; j <= n; j++) {
            for(int i = 0; i <= n; i++) {
                if(i == 0 && j == 0 && k == 0) continue;
                double val = 0;
                if(i > 0) val += (1.0 * i / n) * (1 + dp[i - 1][j][k]);
                if(j > 0) val += (1.0 * j / n) * (1 + dp[i + 1][j - 1][k]);
                if(k > 0) val += (1.0 * k / n) * (1 + dp[i][j + 1][k - 1]);
                val += (1.0 * n - i - j - k) / n;
                dp[i][j][k] = (1.0 * n / (i + j + k)) * val;
            }
        }
    }
    cout << dp[cnt[0]][cnt[1]][cnt[2]] << endl;
}

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

using namespace std;

#define ll long long
#define ar array

int n, w, k;
int a[6][6];


int allCount, hits;



void calc(int x, int y){


    int count = 0;
    for (int i = 0; i < n; i++)
    {

        for (int j = 0; j < w; j++)
        {
            //cout << "y " << y << "j " << j << ".. " << (y&(1<<j)) << endl;
            if((y&(1<<j)) > 0 || (x&(1<<i)) > 0){
                count += a[i][j];
            }
        }
    }
    
    if(allCount - count == k) hits++;
}


void solve(){
    

    cin >> n >> w >> k;

    string s;
    allCount = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        int j = 0;
        for (char c : s)
        {
            if(c == '#'){
                a[i][j] = 1;
                allCount++;
            } 
            else a[i][j] = 0;
            j++;
        }
        

        
    }
    
    hits = 0;

    for (int i = 0; i < (1<<n); i++)
    {
        for (int j = 0; j < (1<<w); j++)
        {
            calc(i,j);
        }
        
        
    }
    
    cout << hits <<endl;
}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

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

map<int, bool> mp;

int main(){
    int n,a, ans=0; cin>>n;
    
    while(n--){
        cin>>a;
        if(mp[a] == 0){
            mp[a] = 1;
            ans++;
        }else{
            mp[a] = 0;
            ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4864
#include<stdio.h>

int main(void){
  int a,b,c,temp,i,trial ;

 scanf("%d" ,&trial);

 for(i=0;i<trial;i++){
     scanf("%d %d %d" ,&a,&b,&c);
     if(a < b){
       temp = a;
       a = b;
       b = temp;
     }
     if(a < c){
      temp = a;
      a = c;
      c = temp;
     }

   if(a*a == b*b + c*c){
      printf("YES\n");
   }
   else
    printf("NO\n");
  }

return 0;
}

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

using namespace std;

int main()
{
  string s;
  getline(cin, s);
  for(int i = 0;i < s.size();i++)
  {
    if(s[i] >= 'a'&&s[i] <= 'z')
    {
      s[i] = s[i] - 32;
      cout << s[i];
    }
    else if(s[i] >= 'A'&&s[i] <= 'Z')
    {
      s[i] += 32;
      cout << s[i];
    }
    else
    {
      cout << s[i];
    }
  }
  cout << endl;
}


Measured memory_bytes: 3200
n, a, b, c, d = map(int, input().split())
s = input()

if c == d or "##" in s[a:d-1]:
    print("No")
elif c < d:
    print("Yes")
else:
    if "..." in s[b-2:d+1] and "##" not in s[a:c-1]:
        print("Yes")
    else:
        print("No")


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], M = l[1];

            var dict = new Dictionary<int, Model>();
            for (var i = 0; i < M; i++)
            {
                var v = Console.ReadLine().Split();
                var key = int.Parse(v[0]);
                var val = v[1];
                if (dict.ContainsKey(key))
                {
                    if (dict[key].AC >= 1) continue;
                    if (val == "AC")
                        dict[key].AC = 1;
                    else
                        dict[key].WA++;
                }
                else
                {
                    dict[key] = new Model();
                    if (val == "AC")
                        dict[key].AC = 1;
                    else
                        dict[key].WA++;
                }
            }

            var ac = dict.Count(z => z.Value.AC == 1);
            var wa = dict.Where(z => z.Value.AC == 1).Sum(z => z.Value.WA);
            Console.WriteLine($"{ac} {wa}");
        }
    }

    class Model
    {
        public int Key { get; set; }
        public int AC { get; set; }
        public int WA { get; set; }
    }
}

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

using ll=long long; 

void solve(){
	ll n;
	cin>>n;
	ll ans=1;
	ll mod=1e9+7;
	for(ll i=1; i<=n; i++){
		ans*=i;
		ans%=mod;
	}
	cout<<ans<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
v = tuple(int(i) for i in input().split())

def f(v):
    d = defaultdict(int)
    d[0] = 0

    for i in v:
        d[i] += 1
    return sorted(d.items(), key=lambda x: x[1], reverse=True)

t1 = f(v[::2])
t2 = f(v[1::2])

if t1[0][0] == t2[0][0]:
    if t1[0][1] + t2[1][1] > t1[1][1] + t2[0][1]:
        print(n - t1[0][1] - t2[1][1])
    else:
        print(n - t1[1][1] - t2[0][1])
else:
    print(n - t1[0][1] - t2[0][1])


Measured memory_bytes: 20696
N,K = map(int,input().split())
V = list(map(int,input().split()))
#print(V)
max_v = 0
have_minus = []
for left in range(N):
  for right in range(left,N + 1)[::-1]:
    if len(V[:left]) + len(V[right:]) > K: 
      break
    #print (V[:left], V[right:])
    sum_ = sum(V[:left]) + sum(V[right:])
    have_minus = [num for num in V[:left]+V[right:] if num < 0]
    have_minus.sort()
    #print (f"have_minus={have_minus}" )
    d = max(0,K - (len(V[:left]) + len(V[right:])))
    for i in range(min(d, len(have_minus))):
        sum_ -= have_minus[i]   
    #print (f"sum_ = {sum_}")    
    
    max_v = max(max_v ,sum_)
print(max_v)      
    
    
       
    

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

using namespace std;

string solve(string& S)
{
    sort(S.begin(), S.end());

    return (S[0] == S[1] and S[2] == S[3] and S[1] != S[2]) ? "Yes" : "No";
}

int main()
{
    ios::sync_with_stdio(false);

    string S;
    cin >> S;

    auto ans = solve(S);

    cout << ans << '\n';

    return 0;
}


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

D,X = map(int,input().split())

s = []
for _ in range(N):
  a = int(input())
  for i in range(D+1):
    if a*i+1 > D:
      s.append(i)
      break
  else:
    continue    
      
print(sum(s)+X)

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

bool LinearSearch(long key, vector<long> S){
    long i=0;
    long n = S.size();
    S.at(n-1) = key;
    while(i != n-1){
        if(S.at(i) == key){
            return true;
        }
        i++;
    }
    return false;
}

int main(){
    long n,q;
    cin >> n;
    vector<long> S(n+1);
    for(long i=0; i<n; i++) cin >> S.at(i);
    cin >> q;
    vector<long> T(q);
    for(long i=0; i<q; i++) cin >> T.at(i);

    long count = 0;
    for(long i=0; i<q; i++){
        if(LinearSearch(T.at(i), S)) count++;
    }

    cout << count << endl;
    return 0;
}



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

int main() {
    int a,b;
    cin >> a >> b;
    if(b > a ){
        swap(a,b);
    }
    rep(i,a){
        cout << b;
    }
    cout << endl;
    return 0;
}


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

using namespace std;

typedef long long LL;

int MOD;

inline int Add(int a, int b) {
    return (a + b >= MOD) ? (a + b - MOD) : (a + b);
}
inline int Mul(int a, int b) {
    return (LL)a * b % MOD;
}


const int N = 305, M = 305;

int n, m;
int c[N][N];
int f[N][M];

void Init() {
    for (int i = 0; i <= n; ++i) {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < i; ++j)
            c[i][j] = Add(c[i - 1][j - 1], c[i - 1][j]);
    }
    return;
}

int main() {
    scanf("%d%d%d", &n, &m, &MOD);
    Init();
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            if (i == 1) {
                f[i][j] = j % MOD;
                continue;
            }
            if (j == 1) {
                f[i][j] = 1 % MOD;
                continue;
            }
            f[i][j] = f[i][j - 1];
            for (int k = 1; k <= i; ++k)
                f[i][j] = Add(f[i][j], Mul(c[i][k - 1], Mul(k > 1 ? f[k - 1][j - 1] : 1, k < i ? f[i - k][j] : 1)));
        }
    printf("%d\n", f[n][m]);
    return 0;
}

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

int main()
{
   long long int n,sum=0;
   cin>>n;
   for(long long int i=0;i<=n;i++){
    if(i%3!=0 && i%5 !=0){
        sum=sum+i;
    }

   }
   cout<<sum<<endl;
}



Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 300010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-6
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int n, a[SIZE], m;
int main() {
	io(); cin >> n >> m;
	rep(i, 1, m) {
		int x; cin >> x;
		n -= x;
	}
	cout << (n <= 0 ? "Yes" : "No");
}

Measured memory_bytes: 256
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 305
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");

	int N, K;
	scanf("%d %d", &N, &K);
	vector <int> V(N);
	for (int i = 0; i < N; i++) scanf("%d", &V[i]);
	int res = 0;
	for (int take = 1; take <= min(K, N); take++) {
		for (int left = 0; left <= take; left++) {
			int remain = K - take;
			priority_queue <int> PQ;
			int sum = 0;
			for (int i = 0; i < left; i++) {
				PQ.push(-V[i]);
				sum += V[i];
			}
			for (int j = N - 1; j > N - 1 - (take - left); j--) {
				PQ.push(-V[j]);
				sum += V[j];
			}
			while (remain > 0 and !PQ.empty() and PQ.top() > 0) {
				remain--;
				sum += PQ.top(); PQ.pop();
			}
			res = max(res, sum);
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    vec<ll> A(N);
    rep(i, N) cin >> A[i];
    map<ll,int> mp;
    ll now = 0;
    ll ans = 0;
    mp[0] = 1;
    rep(i,N){
        now+=A[i];
        ans += mp[now];
        ++mp[now];
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] a = new int[n];

        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }

        boolean[] dp = new boolean[k+1];

        for(int i = 0; i < k+1; i++){
            for(int x : a){
                if(i >= x && !dp[i-x]){
                    dp[i] = true;
                }
            }
        }

        System.out.println(dp[k] ? "First" : "Second");
    }
}


Measured memory_bytes: 23124
n = int(input())
li = [int(input()) for i in range(n)]
if 2 not in li:
  print(-1)
else:
  ans = 0
  st = 0
  while st != 1:
    if (st == 0 and ans > 0) or ans > n:
      ans = -1
      break
    st = li[st]-1
    ans += 1
  print(ans)

Measured memory_bytes: 13000
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
char n[4];
int main() {
	scanf("%s", n);
	for(int i = 0; i < 3; i++) {
		if(n[i] == '1') {
			n[i] = '9';
		} else {
			n[i] = '1';
		}
	}
	printf("%s\n", n);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <float.h>
#include <cfloat>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <errno.h>
#include <cerrno>
#include <assert.h>
#include <cassert> 
#include <map>
#include <memory.h>
#include <cctype>
#include <ctype.h>
#include <math.h>
#include <vector> 
#include <cstdio> 
#include <set>
#include <string.h>
#include <stdio.h>
#include <new>
#include <memory>
#include <cmath>
#include <queue>
#include <cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define mp make_pair 
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define pii pair<int,int>  
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int a[150000],c;
int main()
{int n;
 cin>>n;
 fo(i,0,n)
 cin>>a[i];
 fo(i,0,n)
 if(a[i]%2==1)
 c++;
 if(c%2==1)
 {cout<<"NO"<<endl;
 }
 else{ 
  cout<<"YES"<<endl;
 } 
 system("pause"); 
 return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

int N=1<<18;
class StarrySkyTree{
public:
  ll Ma[555555],A[555555];
  void init(){memset(Ma,0,sizeof(Ma)),memset(A,0,sizeof(A));}
  void add(int a,int b,ll x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      while(k){
        k=(k-1)/2;
        Ma[k]=max(Ma[k*2+1]+A[k*2+1],Ma[k*2+2]+A[k*2+2]);
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMax(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return -LLONG_MAX;if(a<=l&&r<=b)return Ma[k]+A[k];
    ll left=getMax(a,b,k*2+1,l,(l+r)/2),right=getMax(a,b,k*2+2,(l+r)/2,r);
    return max(left,right)+A[k];
  }
};

StarrySkyTree t;

void Main() {
  ll n,d,m;
  cin >> n >> d >> m;
  P a[n];
  rep(i,n) cin >> a[i].F >> a[i].S;
  sort(a,a+n);
  rep(i,n) t.add(i,i+1,a[i].S);
  ll ans=0;
  rep(i,n) {
    ll h=t.getMax(i,i+1);
    if(h<=0) continue;
    ll k=upper_bound(a,a+n,P(a[i].F+d*2,MAX))-a;
    ll x=ceil((double)h/m);
    t.add(i,k,-x*m);
    ans+=x;
  }
  pr(ans);
}

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


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
int mod = 1e9+7;

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

    string s1, s2;
    cin>>s1>>s2;

    int n = s1.length();
    int m = s2.length();

    vector<vector<pair<ll, pair<ll, ll>>>> dp(n+1, vector<pair<ll, pair<ll, ll>>>(m+1, {0, {0, 0}}));

    for(ll i=0; i<=n; i++){
    	for(ll j=0; j<=m; j++){
    		if(i && j){

    			if(s1[i-1]==s2[j-1]){
    				dp[i][j] = {dp[i-1][j-1].first+1, {i-1, j-1}};
    			}else{
    				if(dp[i-1][j].first>dp[i][j-1].first){
    					dp[i][j] = {dp[i-1][j].first, {i-1, j}};
    				}else dp[i][j] = {dp[i][j-1].first, {i, j-1}};
    			}
    		}
    	}
    }
    string ans;
    ll i=n, j=m;
    // cout<<dp[i][j].first<<endl;
    while(i && j){
    	// cout<<dp[i][j].second.first<<" "<<dp[i][j].second.second<<endl;
    	if(dp[i][j].second.first==i-1 && dp[i][j].second.second==j-1){
    		ans+=s2[j-1];
    		i--;
    		j--;
    	}else if(dp[i][j].second.first==i-1){
    		i--;
    	}else{
    		j--;
    	}
    }

    reverse(ans.begin(), ans.end());
	cout<<ans;
	return 0;
}		


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

ll dp[111][256][111];
int main() {
  ll n,m,mod=1000000007;
  cin >> n >> m;
  ll a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  memset(dp,0,sizeof(dp));
  dp[0][0][0]=1;
  for(int i=0; i<n; i++) {
    for(int j=0; j<256; j++) {
      for(int k=0; k<n; k++) {
        dp[i+1][j][k]+=dp[i][j][k];
        dp[i+1][j][k]%=mod;
        dp[i+1][j^a[i]][k+1]+=dp[i][j][k];
        dp[i+1][j^a[i]][k+1]%=mod;
      }
    }
  }
  ll x=1,ans=0;
  for(ll i=1; i<n+1; i++) {
    x*=i;
    x%=mod;
    ans+=dp[n][m][i]*x;
    ans%=mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 24832
#include <iostream>

#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::ceil;

int
main()
{
  int N, M;
  cin >> N >> M;
  int A[100];
  int total = 0;
  for (int n = 0; n < N; n++)
  {
    cin >> A[n];
    total += A[n];
  }
  int limit = ceil(double(total) / (M * 4));
  int count = 0;
  for (int n = 0; n < N; n++)
  {
    if (limit <= A[n])
    {
      count++;
    }
  }
  cout << (M <= count ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    lint a,b,c;std::cin>>a>>b>>c;
    std::cout<<(a+b<c&&4*a*b<(c-a-b)*(c-a-b)?"Yes":"No")<<'\n';
}


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

using namespace std;


#define tie() ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long

const int N = 13;

int32_t main()
{
    int t = 1;
//cin >> t;
    while(t--)
    {
    	int n , m , x;
        cin >> n >> m >> x;
        int a[n][m];

        int cost[n];

        for(int i = 0 ; i < n ; i++)
        {
            cin >> cost[i];
            for(int j = 0 ; j < m ; j++)
                cin >> a[i][j];
        }


        int level[m] , cur = 0 , mn = INT_MAX , cond;

        for(int i = 0 ; i < (1 << n) ; i++)
        {
            cur = 0;
            memset(level , 0 , sizeof level);


            bitset <N> b(i);
            for(int i = 0 ; i < n ; i++)
            {
                if(b[i])
                {
                    cur += cost[i];
                    for(int j = 0 ; j < m ;j++)
                        level[j] += a[i][j];
                }
            }

            cond = false;
            for(int i = 0 ; i < m ; i++)
            {
                if(level[i] < x)
                {
                    cond = true;
                    break;
                }
            }

            if(!cond)
                mn = min(mn , cur);
        }

        cout << ((mn == INT_MAX) ? -1 : mn) << endl;
    }
	return 0;
}


Measured memory_bytes: 3564
// https://atcoder.jp/contests/abc145/tasks/abc145_c

#include <iostream>
#include <iomanip>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cmath>

using namespace std;

struct Point
{
    int x;
    int y;
};

bool compare(const Point& a, const Point& b)
{
    if(a.x == b.x)
    {
        return a.y < b.y;
    }
    return a.x < b.x;
}

int main(int argc, const char* argv[])
{
    int n;
    cin >> n;

    vector<Point> points(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> points[i].x >> points[i].y;
    }
    
    sort(points.begin(), points.end(), compare);

    double totalDistance = 0;
    int count = 0;
    do{
        double distance = 0;
        for(int i = 0; i < points.size() - 1; ++i)
        {
            double d = sqrt(pow(points[i + 1].x - points[i].x, 2) + pow(points[i + 1].y - points[i].y, 2));
            distance += d;
        }
        totalDistance += distance;
        count++;
    }while(next_permutation(points.begin(), points.end(), compare));

    cout << fixed << setprecision(15) << totalDistance / count << endl;

    return 0;
}


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

int main(void){
    string s, t;
    cin >> s >> t;

    int ans = 2000;
    for(int i = 0; i <= s.length() - t.length(); i++){
        int tmp_ans = 0;
        for(int j = 0; j < t.length(); j++){
            if(s[i + j] != t[j]) tmp_ans++;
        }
        ans = min(tmp_ans, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        const int WHITE = -10;
        const int GRAY = -9;
        const int BLACK = -8;
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] m = new int[n, n];
            for(int i = 0; i < n; ++i)
            {
                var szarr = Console.ReadLine().Split(' ');
                for(int j=1;j<szarr.Length;++j)
                {
                    m[i, j-1] = int.Parse(szarr[j]);
                }
            }

            int[] color = new int[n];
            int[] d = new int[n];
            int[] p = new int[n];

            prime(n, m, color, d, p);

            int sum = 0;
            for(int i=1;i<p.Length;++i)
            {
                int w = m[i, p[i]];
                if (w != -1)
                {
                    sum += w;
                }
            }
            Console.WriteLine(sum);
        }
        static void prime(int n ,int[,] m, int [] color, int[] d, int[] p)
        {
            for(int i = 0; i < color.Length; ++i) { color[i] = WHITE; }
            for(int i = 0; i < d.Length; ++i) { d[i] = int.MaxValue; }
            d[0] = 0;
            p[0] = -1;
            while(true)
            {
                int u = -1;
                int mincost = int.MaxValue;
                for(int i=0;i<n;++i)
                {
                    if( color[i] != BLACK && d[i] < mincost)
                    {
                        mincost = d[i];
                        u = i;
                    }
                }
                if( mincost == int.MaxValue) { break; }
                color[u] = BLACK;
                for(int v = 0;v<n;++v)
                {
                    if( color[v] != BLACK && m[u,v] != -1)
                    {
                        if( m[u,v] < d[v])
                        {
                            d[v] = m[u, v];
                            p[v] = u;
                            color[v] = GRAY;
                        }
                    }
                }
            }
        }
    }

}



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

typedef long long ll;
typedef pair<int,int> pi;
//627235
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define Forn(i, n) for(int i=1; i<=(n); i++)
#define forn(i, n) for(int i=0; i<(n); i++)
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
 
/*
    快读有锅 
*/

const int MAX=2e5+5; 

int N, ret;
char s[MAX];
string part[MAX];

int main()
{
    scanf("%s", s);
    N=strlen(s);
    part[ret++]+=s[0];
    Forn(i, N-1)
    {
        if(!part[ret].size())
        {
            part[ret]+=s[i];
            continue;
        }
        if(part[ret]!=part[ret-1])
            ret++, part[ret]+=s[i];
        else part[ret]+=s[i];
    }
    printf("%d", ret+(part[ret].size()!=0&&ret-1>=0&&part[ret]!=part[ret-1]));
    return 0;
}

Measured memory_bytes: 11008
public class Main {

	public static void main(String[] args) {
		java.util.Scanner input = new java.util.Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int c = input.nextInt();
		int sum = a + b + c;
		if( ( sum / a == 2 && sum % a == 0 ) ||
				( sum / b == 2 && sum % b == 0 ) || 
				( sum / c == 2 && sum % c == 0 )){
			System.out.println( "Yes" );
		}else{
			System.out.println( "No" );
		}
	}
}

Measured memory_bytes: 10452
#include<iostream>
using namespace std;
#define ll long long

int main()
{
	string s;
	cin>>s;
	if((s[0]==s[1] && s[0]!=s[2]) || (s[1]==s[2] && s[1]!=s[0]) || (s[2]==s[0] && s[2]!=s[1]))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    while (!(h == 0 && w == 0))
    {
        for (int y = 0; y < h; y++)
        {
            for (int x = 0; x < w; x++)
            {
                if ((x == 0 || x == w - 1)||(y==0||y==h-1))
                    cout << "#";
                else
                    cout << ".";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
int dp[1 << 22 + 1][21], v[21][21], full, n;

int dfs(int mask, int i)
{
    if(mask == full)
        return 1;

    if(i == n || mask>full)
        return 0;
        
    if(dp[mask][i]!=-1)
        return dp[mask][i];
        
    dp[mask][i] = 0;
    for(int j=0; j<n; j++)
        if(v[i][j] && !(mask & 1<<j))
            dp[mask][i] = (dp[mask][i] + dfs(mask|(1<<j), i+1))%mod;

    return dp[mask][i];
}
int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>v[i][j];
    memset(dp, -1, sizeof(dp));
    full = (1<<n)-1;
    cout<<dfs(0, 0)<<endl;
    return 0;
}
 

Measured memory_bytes: 688512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int, readline().split()))
B1 = [0 for i in range(60)]
for x in A:
    bA = format(x,"b").zfill(60)
    for i in range(60):
        if bA[i] == "1":
            B1[i] += 1
ans = 0
for i,x in enumerate(B1):
    ans = (ans + 2**(59-i)*x*(N-x)) % (10**9+7)
print(ans)

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

int main() {
	int A,B;
    cin >> A >> B;
    if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0){
      cout << "Possible" << endl;
    }
    else{
      cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
require 'prime'
max = 10000
arr = (1 .. max).select{|i|Prime.instance.prime?(i)}
array = Array.new(max + 2){0}
for i in 0 ... arr.size
    if (arr[i] + arr[i] <= max + 1)
        array[arr[i] * 2] += 1
    end
    for j in (i + 1) ... arr.size
        if (arr[j] + arr[i] > max + 1)
            break
        else
            array[arr[j] + arr[i]] += 2
        end
    end
end
while (n = gets)
    puts array[n.to_i + 1]
end


Measured memory_bytes: 7088
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N, K, X, Y;
	scanf("%d %d %d %d", &N, &K, &X, &Y);

	int ans = 0;
	if(N > K){
		ans += K*X + (N-K)*Y;
	}else{
		ans = N*X;
	}

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

	return 0;

}


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

int main() {
	int N,X;
	cin >> N>>X;
	int sum = 0;
	int val;
	int minimum = INT_MAX;
	int donuts=N;
	for (int i = 0; i < N; i++) {
		cin >> val;
		sum += val;
		if (val < minimum)minimum = val;
	}
	donuts += (int)(X - sum) / minimum;
	cout << donuts << endl;
	return 0;
}

Measured memory_bytes: 3592
# 2019/08/27

n=int(input())
ln=len(str(n))
sft='7530'
cnt=0
def dfs(ln,s):
    global cnt
    if ln==0:
        if '7' in s and '5' in s and '3' in s:
            if '0' in str(int(s)):return
            if n>=int(s):cnt+=1
        return
    for e in sft:
        dfs(ln-1,s+e)
dfs(ln,'')

print(cnt)

Measured memory_bytes: 3064
from collections import Counter
n=int(input())
nums=list(map(int,input().split()))
a=set(nums)
if len(a)==1:
  print(n//2)
else:
  odd=nums[::2]
  even=nums[1::2]
  o=Counter(odd)
  e=Counter(even)
  ans=n-o.most_common()[0][1]-e.most_common()[0][1]
  if o.most_common()[0][0]==e.most_common()[0][0]:
    print(ans+min(o.most_common()[0][1]-o.most_common()[1][1],e.most_common()[0][1]-e.most_common()[1][1]))
  else:  
    print(ans)


Measured memory_bytes: 24672
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main() {
	ll n;
	cin >> n;
	map<string, ll> x;

	for (int i = 0; i < n; ++i){
		string tmp;
		cin >> tmp;
		sort(tmp.begin(), tmp.end());
		x[tmp]++;
	}

	ll ans = 0;
	for (auto i = x.begin(); i != x.end(); ++i){
		ans += i->second * (i->second-1)/2;
	}
	cout << ans;

	
	return 0;
}

Measured memory_bytes: 8064