akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#define BMAX 100
#define DMAX 1000000

using namespace std;

struct data { 
	int cost;
	int where;
};

//bool bind[BMAX][BMAX];
int cost[BMAX][BMAX];
int dis[BMAX][BMAX];
bool check[BMAX];

bool operator<( const data& a, const data& b) {
	return a.cost < b.cost;
}

bool operator>( const data& a, const data& b) {
	return a.cost > b.cost;
}

int main () {
	int count = 0;
	while ( true ) {
		int n,m,s,g1,g2;
		cin >> n >> m>> s>> g1>> g2;
		//cout << "Len " << m << n << m << s << endl;
		//cout << "Count: " << count << endl;
		s--;
		g1--;
		g2--;
		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				cost[i][j] = DMAX;
				dis[i][j] = DMAX;
			}
		}

		for ( int i=0; i<n; i++ ) {
			cost[i][i] = 0;
			dis[i][i] = 0;
		}

		for ( int i=0; i<m; i++ ) {
			int x,y,c;
			cin >> x >> y >> c;
			//			cout << x << "\t" << y << "\t" << c << endl;
			cost[x-1][y-1] = c;
			//cost[y-1][x-1] = c;
		}

		/*
		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				cout << cost[i][j] << "\t";
			}
			cout << endl;
		}
		cout << endl;
		*/
		/*
		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				cout << dis[i][j] << "\t";
			}
			cout << endl;
		}
		cout << endl;
		*/

		for ( int i=0; i<n; i++ ) {
			priority_queue<data> flow;

			while(!flow.empty()) {
				flow.pop();
			}

			data now;
			now.cost = 0;
			now.where = i;
			flow.push(now);
			//cout << "Start" << i << endl;
			while ( !flow.empty() ) {
				data now = flow.top();
				flow.pop();

				data next;


				for ( int j=0; j<n; j++ ) {
					check[j] = true;
				}
				check[now.where] = false;

				for ( int j=0; j<n; j++ ) {
					if ( check[j] ) {
						//cout << "search " << now.where << "->" << j << endl;
						check[j] = false;
						//cout << "Raw" << dis[now.where][j] << "\t" << cost[now.where][j] << endl;
						int newDCost = dis[now.where][j] + now.cost ;
						int newCCost = cost[now.where][j] + now.cost ;
						int newCost;
						if ( newDCost < newCCost )
							newCost = newDCost;
						else
							newCost = newCCost;
						//cout << "D " << newDCost << "\tC " << newCCost << endl;
						//cout << dis[i][j] << " " << newCost << endl;
						if ( dis[i][j] > newCost ) {
							//cout << "Pass" << endl;
							if ( dis[i][j] > newCost )
								dis[i][j] = newCost;
							next.cost = newCost;
							next.where = j;
							if ( next.cost != DMAX ) {
								//cout << "New: " << newCost << endl;
								flow.push(next);
							}
						}
						//cout << dis[i][j] << " " << newCost << endl;
					}
				}
				//cout << "Size: " << flow.size() << endl;
			}
		}

		/*
		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				cout << dis[i][j] << "\t";
			}
			cout << endl;
		}
		cout << endl;
		*/

		int min = DMAX;
		int minb;
		for ( int i=0; i<n; i++ ) {
			if ( min > dis[s][i] + dis[i][g1] + dis[i][g2] ) {
				min = dis[s][i] + dis[i][g1] + dis[i][g2];
				minb = i;
			}
		}

		cout << min << endl;
		//cout << min << "\t" << minb << endl;;
	}

}

Measured memory_bytes: 980
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
	int n, a[51],k; cin >> n>>k;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sort(a, a + n,greater<int>()); int sum = 0;
	for (int i = 0; i < k; ++i)
	{
		sum += a[i];
	}
	cout << sum;

}

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

#define I cin
#define O cout
#define EN endl
#define ln cout<<endl
#define pb(a) push_back(a)

typedef long long int llint;

int n;
int i, j;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int gcd(int a, int b)
{
  return (b ? gcd(b, a % b) : a);
}

int lcm(int a, int b)
{
  return a / gcd(a, b) * b;
}

int main()
{
  I >> n;

  int cnt4 = 0, cnt2 = 0;

  for(i = 0; i < n; i++) {
    int a;
    I >> a;
    if(a % 4 == 0)
      cnt4++;
    else if(a % 2 == 0)
      cnt2++;
  }

  O << (n / 2 <= cnt4 + cnt2 / 2 ? "Yes" : "No") << EN;
  
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[100001];
int cnt[2];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		cnt[a[i]%2]++;
	}
	printf("%s\n",cnt[1]%2==0?"YES":"NO");
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        for (int x = a; x <= b; x++) {
            if (c % x ==0) {
                count++;
            }
        }
        System.out.println(count);
    }
}


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

int main() {
  int x,y;
  cin>>x>>y;
  vector<int> a={0,1,3,1,2,1,2,1,1,2,1,2,1};
  if(a[x]==a[y]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int main() {
	int n;
	int b, f, r, v;
	int appartment[4][3][10];

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

	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> b >> f >> r >> v;
		appartment[b-1][f-1][r-1] += v;
	}

	for(int i=0; i<4; i++) {
		for(int j=0; j<3; j++) {
			for(int k=0; k<10; k++) {
				cout << " " << appartment[i][j][k];
			}
			cout << endl;
		}
		if(i==3) break;

		for(int j=0; j<20; j++) {
			cout<<'#';
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	ll n, ans = 0;
	cin >> n;
	ans = (n * (n - 1)) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int N;
vector<ll> A;

const ll INF=2e18;

bool cmp(ll af,ll ar,ll bf,ll br){
    ll vala=ar,valb=br;
    while(af<bf){
        if(ar<=br) break;
        br*=4;
        bf--;
    }
    while(af>bf){
        if(ar>=br) break;
        ar*=4;
        af--;
    }
    if(af==bf) return ar<br;
    else return af<bf;
}

void solve(bool minus,vector<ll> &res){
    vector<ll> B=A;
    if(minus) rep(i,N) B[i]*=2;
    else reverse(B.begin(),B.end());

    vector<pair<ll,ll>> four(N);
    rep(i,N){
        ll val=abs(B[i]);
        ll num=0;
        ll rest=0;
        while(val>0){
            val/=4;
            num++;
        }
        ll f=1;
        num--;
        rep(j,num) f*=4;
        rest=abs(B[i])-f;
        four[i]=mkp(num,rest);
        //cout<<i<<" "<<four[i].first<<" "<<four[i].second<<endl;
    }

    res.resize(N+1,0);
    ll pre=0;
    vector<int> back(N,0);
    rep(i,N) back[i]=i-1;
    vector<ll> diff(N,0);
    for(int i=1;i<N;i++){
        if(four[i-1]>=four[i]){
            res[i+1]=pre;
            continue;
        }

        int now=i;
        int ori=-1;
        ll sum=0;
        ll adv=(four[now].first-four[now-1].first);
        if(four[now-1].second<four[now].second) adv++;

        while(now>0){
            int tar=back[now];
            if(tar+1<now){
                if(tar>=0){
                    sum+=adv*(now-tar);
                    diff[tar]+=adv;
                }else sum+=adv*(now);
                back[i]=back[now];
                now=back[now];
            }else{
                ll nexadv=(four[now].first+diff[now]-(four[now-1].first+diff[now-1]));
                if(nexadv<0) break;
                diff[now-1]+=nexadv;
                if(cmp(diff[now-1],four[now-1].second,diff[now],four[now].second)){
                    diff[now-1]++;
                    nexadv++;
                };
                if(nexadv==0) break;
                adv=nexadv;
                //chmin(adv,nexadv);
                sum+=adv;
                back[i]=now-1;
                now=now-1;
            }
        }

        res[i+1]=pre+sum;
        pre+=sum;
    }

    if(minus==false) reverse(res.begin(),res.end());
    //rep(i,N+1) cout<<i<<" "<<res[i]<<endl;
}

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

  cin>>N;
  A.resize(N);
  rep(i,N) cin>>A[i];

  vector<ll> lsum(N+1,0),rsum(N+1,0);
  solve(true,lsum);
  //exit(0);
  solve(false,rsum);
  //exit(0);

  ll ans=INF;
  for(int i=0;i<=N;i++){
      ll res=lsum[i]+rsum[i];
      res*=2;
      res+=i;
      //cout<<i<<" "<<lsum[i]<<" "<<rsum[i]<<" "<<res<<endl;
      chmin(ans,res);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 12032
s = input()
t = input()
d = {i:[] for i in "abcdefghijklmnopqrstuvwxyz"}
for i in range(len(s)):
    d[s[i]].append(i)
for i in t:
    if len(d[i]) == 0:
        print(-1)
        exit()

def binary_search(arr, k):
    l, r = 0, len(arr)-1
    while l <= r:
        m = l+r >> 1
        if arr[m] < k:
            l = m+1
        else:
            r = m-1
    return l

a, b = 0, 0
for i in t:
    j = binary_search(d[i], a)
    if len(d[i]) <= j:
        a = 0
        b += 1
        j = binary_search(d[i], 0)
    a = d[i][j] + 1
print(b * len(s) + a)


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

using namespace std;

inline vector<int> factorize(int x)
{
	vector<int> ret;
	
	for (int i = 1; i * i <= x; i++){
		if (x % i == 0){
			ret.push_back(i);
			if (i * i != x) ret.push_back(x / i);
		}
	}
	
	return (ret);
}

int main()
{
	int N, W;
	int cnt = 0;
	bool manage[100001] = {0};
	
	scanf("%d %d", &N, &W);
	
	for (int i = 1; i <= W - 1; i++){
		manage[i] = true;
		cnt++;
	}
	
	for (int i = W; i <= N; i++){
		vector<int> v;
		
		if (i - W){
			v = factorize(i - W);
			
			for (int j = 0; j < v.size(); j++){
				int mini = (i - W + v[j]) / v[j], maxi = i / v[j];
				if (mini == 1 || maxi - mini >= 1) continue;
				else {
					cnt -= manage[v[j]];
					manage[v[j]] = false;
				}
			}
		}
		
		v = factorize(i);
		
		for (int j = 0; j < v.size(); j++){
			int mini = (i - W + v[j]) / v[j], maxi = i / v[j];
			if (mini == 1 || maxi - mini >= 1){
				cnt += !manage[v[j]];
				manage[v[j]] = true;
			}
		}
		
		printf("%d%c", cnt, " \n"[i == N]);
	}
	
	return (0);
}

Measured memory_bytes: 1312
#include <iostream>

using namespace std;
using ll = long long;
const ll INF = 1LL << 50;

int main(){
	int N,M;
	int a[2005]={},b[2005]={};
	ll c[2005];
	ll dist[1005]={};
	cin >> N >> M;
	
	for(int i=0;i<M;i++){
		cin >> a[i] >> b[i] >> c[i];
		c[i] = -c[i];
	}
	
	for(int i=0;i<1005;i++){
		dist[i]=INF;
	}
	dist[0] = 0;
	
	for(int i=0;i<N-1;i++){// 最短経路の最大の長さN-1を調べる。(閉路がなければここで調べきられる)
		for(int j=0;j<M;j++){//全ての辺について調べる
			if(dist[a[j]-1] == INF) continue;// 始辺の方の頂点がまだ更新されていなければ、continue
			
			if(dist[b[j]-1] > dist[a[j] - 1] + c[j]){// 短くなれば更新
				dist[b[j]-1] = dist[a[j] - 1] + c[j];
			}
		}
	}
	
	ll ans = dist[N-1];
	
	bool negative[1005];
	
	for(int i=0;i<N;i++){
		negative[i] = false;
	}
	
	for(int i=0;i<N;i++){// 閉路があれば、どこからかtrueになり、ゴール(頂点N-1)もtrueになる。
		for(int j=0;j<M;j++){
			if(dist[a[j]-1] == INF)continue;
		
			if(dist[b[j]-1] > dist[a[j]-1] + c[j]){
				dist[b[j]-1] = dist[a[j]-1] + c[j];
				negative[b[j] - 1]=true;// 一回通ったところはtrueに
			}
			
			if(negative[a[j]-1] == true){// 更新されなくても親頂点が一回通っていれば子頂点も一回通っている
				negative[b[j]-1] = true;
			}
		}
	}
	
	if(negative[N-1]){
		cout << "inf" << endl;
	}else{
		cout << -ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

type pair struct { // f=first, s=second
	f string
	s int
	i int
}

func main() {
	scanInit()

	n := nextInt()
	s := make([]pair, n)

	for i := 0; i < n; i++ {
		s[i].f = nextStr()
		s[i].s = nextInt()
		s[i].i = i + 1
	}

	sort.Slice(s, func(i, j int) bool {
		if s[i].f == s[j].f {
			return s[i].s > s[j].s
		}
		return s[i].f < s[j].f
	})

	for _, v := range s {
		fmt.Println(v.i)
	}
}

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


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int isP(char str[]) 
{ 
    int l = 0; 
    int h = strlen(str) - 1; 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        {  
            return 0; 
        } 
    } 
    return 1; 
} 
int main()
{
    char s1[100];
    cin>>s1;
    int l=strlen(s1);
    int l1=(l-1)/2;
    int l2= (l+3)/2;
    char a1[l1];
    char a2[l-l2+1];
    for(int i=0;i<l1;i++)
    a1[i]=s1[i];
    int j=0;
    for(int i=l2-1;i<l;i++)
    a2[j++]=s1[i];
    a2[l-l2+1]='\0';
    //cout<<a1<<endl<<a2;
    int aa1=isP(a1);
    int aa2=isP(a2);
    int aa3=isP(s1);
    if(aa1==1 && aa2==1 && aa3==1)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main (void)
{
   int n;
 
   scanf("%6d",&n);
   int a[n+1];
   int b[n+1];
   memset(b, 0, sizeof(b));
   
   for(int i = 2; i <= n; i++) {
     scanf("%d",&a[i]);
     b[a[i]]++;
   }

   for (int i = 1; i <= n; i++) {
     printf("%d\n", b[i]);
   }
  
   return 0;
}


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

vector<int64_t> memo(100, 0);

int64_t lucas(int i){
    if(memo.at(i) != 0){
        return memo.at(i);
    }else{
        return memo.at(i) = lucas(i - 1) + lucas(i - 2);
    }
}

int main(){
    int N;
    cin >> N;
    
    memo.at(0) = 2;
    memo.at(1) = 1;
    
    cout << lucas(N) << endl;
}

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

namespace ConsoleApplication1
{
    class Node
    {
        internal int d;
        internal List<int> adj;

        public Node()
        {
            d = -1;
            adj = new List<int>();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Node[] nodes = new Node[n + 1];

            for (int i = 0; i < n; i++)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                nodes[input[0]] = new Node();

                for (int j = 0; j < input[1]; j++)
                {
                    nodes[input[0]].adj.Add(input[2 + j]);
                }
            }

            nodes[1].d = 0;

            Queue<Node> Q = new Queue<Node>();
            Q.Enqueue(nodes[1]);

            while (Q.Count > 0)
            {
                Node temp = Q.Dequeue();

                for (int i = 0; i < temp.adj.Count; i++)
                {
                    if (nodes[temp.adj[i]].d == -1)
                    {
                        nodes[temp.adj[i]].d = temp.d + 1;
                        Q.Enqueue(nodes[temp.adj[i]]);
                    }
                }
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 1; i <= n; i++)
            {
                sb.AppendLine(i + " " + nodes[i].d);
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 10196
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1))%mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n,int k) {
	//nのk桁目
	rep(i, k-1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	string S,ans="Yes";
	cin >> S;
	int N = S.size();
	rep(i,(N-1)/2) {
		if (S[i] != S[N - 1 - i])
			ans = "No";
	}
	rep(i, (N - 1) / 4) {
		if (S[i] != S[(N - 1) / 2 - 1 - i])
			ans = "No";
	}
	rep(i, (N - 1) / 4) {
		if (S[(N+3)/2-1+i] != S[N-i-1])
			ans = "No";
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int s = scan.nextInt();//3600
    int m = s / 60;//60
    int hour = m / 60;//1
    int second = s-m*60;
    int minute = m-hour*60;
    System.out.println(hour+":"+minute+":"+second);
    }
}


Measured memory_bytes: 26288
H,W,K=map(int,input().split())

M=[[0 for i in range(W)] for f in range(H)]
A=[[0 for i in range(W)] for f in range(H)]

for i in range(H):
    M[i]=list(input())

f=1
s=1
for i in range(W):
    c=0
    for j in range(H):
        if(M[j][i]=="#"):
            c+=1
    if(c==0):
        f+=1
    else:
        t=0
        for j in range(H):
            if(M[j][i]=="#"):
                t+=1
                if(t>1):
                    s+=1     
            for k in range(f):
                A[j][i-k]=s
        f=1
        s+=1
for i in range(W-1,-1,-1):
    if(A[0][i]!=0):
        for j in range(i,W):
            for k in range(H):
                A[k][j]=A[k][i]
        break

for i in range(H):
    for j in range(W):
        print(A[i][j],end=" ")
    print()

Measured memory_bytes: 55384
#include <iostream>
using namespace std;
bool so[10001];

int main(){

  so[0] = so[1] = 1;
  for(int i=2;i<=10000;i++) {
    if(so[i] == 0) {
      for(int j=2;j<=10000/i;j++) so[i*j] = 1;
    }
  }


  int n;
  while(cin >> n) {
    int ans = 0;
    for(int i=1;i<=n;i++) {
      if(so[i] == 0 && so[n-i+1] == 0) ans++;
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007

int extgcd(int a,int b,int& x,int& y){
  int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
int mod_inverse(int a,int m){
  int x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

signed main(){
  int n,m;
  cin>>n>>m;
  int x[n],y[m];
  for(int i=0;i<n;i++) cin>>x[i];
  for(int i=0;i<m;i++) cin>>y[i];
  int ans=0;
  int t[n];
  for(int i=0;i<n-1;i++) t[i]=((i+1)*(n-(i+1))*(m-1))%MOD;
  for(int i=0;i<n-1;i++) (t[i]*=x[i+1]-x[i])%=MOD;
  int tmp=0;
  for(int i=0;i<n-1;i++) (tmp+=t[i])%=MOD;
  (tmp*=mod_inverse(m-1,MOD))%=MOD;
  for(int i=0;i<m-1;i++){
    int res=tmp;
    (res*=(i+1))%=MOD;
    (res*=(m-(i+1)))%=MOD;
    (res*=(y[i+1]-y[i]))%=MOD;
    (ans+=res)%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		int ans = 700;

		for (int i = 0; i < 3; i++){
			if(S.charAt(i) == 'o'){
				ans += 100;
			}	
		}
		
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
bool check(string s)
{
	for(int i=0;i<s.size();i++)
		if(s[i]!=s[s.size()-i-1])
			return false;
	return true;
}
int main()
{
	string s;
	cin>>s;
	if(check(s)&&check(s.substr(0,s.size()/2))&&check(s.substr(s.size()/2+1,s.size()/2)))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

class Tree{
public:
    int N;
    vector<vector<int>> G;

    Tree(int n){
        N = n;
        G.resize(N);
    }

    void make_edge(int s, int t){
        G[s].push_back(t);
        G[t].push_back(s);
    }

    P find_farthest(int n, int par){
        P ret = P(1, n);
        for(int i = 0; i < (int)G[n].size(); i++){
            if(G[n][i] != par){
                P tmp = find_farthest(G[n][i], n);
                tmp.first++;
                ret = max(ret, tmp);
            }
        }

        return ret;
    }

    int dfs(int n, int par){
        int mx = 0;
        for(int i = 0; i < (int)G[n].size(); i++){
            int nx = G[n][i];
            if(nx != par){
                mx = max(mx, dfs(nx, n) + 1);
            }
        }

        return mx;
    }

    int tyokkei(){
        P p = find_farthest(0, -1);
        //cout << "leaf = " << n << endl;
        return dfs(p.second, -1);
    }
};

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

    if(N == 1){
        cout << "First" << endl;
        return 0;
    }

    Tree tr = Tree(N);
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tr.make_edge(a, b);
    }

    int x = tr.tyokkei();
    //cout << "x = " << x << endl;

    if(x % 3 != 1){
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }

    return 0;
}


Measured memory_bytes: 20224
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    a = set()

    for _ in range(n):
        ai = ni()
        if ai not in a:
            a.add(ai)
        else:
            a.remove(ai)

    print(len(a))


if __name__ == '__main__':
    main()


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

int main(){
    long long n; cin >> n;
    if (n%2) cout << 0; else {
        long long ans = 0;
        long long x = 5;
        int p = 1;
        while (1){
            long long tp = n / x;
            if (tp <= 1) break;
            ans += (tp / 2);
            x = x*5;
        }
        cout << ans;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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 long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,k;
    string s;
    cin >> n >> k >> s;
    vector<ll> p;
    ll c1=0,c2=0;
    for (ll i=0;i<n;i++){
        if (s[i]=='0'){
            if (c1==0){
                c2++;
                continue;
            }
            p.push_back(c1);
            c2++;
            c1=0;
        }else{
            if (c2==0){
                c1++;
                continue;
            }
            p.push_back(c2);
            c2=0;
            c1++;
        }
    } 
    if (c1)p.push_back(c1);
    if (c2)p.push_back(c2);
    ll ans=0,c=0,count=0;
    if (s[0]=='0'){
        for (ll i=0;i<p.size();i++){
            if (i%2==0){
                c++;
            }
            count+=p[i];
            if (c>k){
                count-=p[i-(k*2)];
                if (i-(k*2)-1>=0)count-=p[i-(k*2)-1];
                c--;
            }
            ans=max(count,ans);
        }
    }else{
        for (ll i=0;i<p.size();i++){
            if (i%2){
                c++;
            }
            count+=p[i];
            if (c>k){
                count-=p[i-(k*2)];
                if (i-(k*2)-1>=0)count-=p[i-(k*2)-1];
                c--;
            }
            ans=max(count,ans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4380
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn = 1 << 15 | 1;
const int Mod = 998244353;
const int G = 3;

void Chkadd(int &x, const int &y) { if ((x += y) >= Mod) x -= Mod; }
void Chksub(int &x, const int &y) { if ((x -= y) < 0) x += Mod; }

int Cadd(int x, int y) { Chkadd(x, y); return x; }
int Csub(int x, int y) { Chksub(x, y); return x; }

int Power(int a, int k)
{
	int x = 1;
	for (; k; k >>= 1)
	{
		if (k & 1) x = 1ll * x * a % Mod;
		a = 1ll * a * a % Mod;
	}
	return x;
}

int wn[maxn], iv[maxn];

void Prepare(int N)
{
	int g = Power(G, (Mod - 1) / N);
	wn[0] = 1;
	for (int i = 1; i <= N; ++ i) wn[i] = 1ll * wn[i - 1] * g % Mod;
	for (int i = 0; i <= N; ++ i) iv[i] = wn[N - i];
}

void Transform(int n, int *a, int *wn, bool f)
{
	for (int i = 0, j = 0; i < n; ++ i)
	{
		if (i < j) swap(a[i], a[j]);
		for (int t = n >> 1; (j ^= t) < t; t >>= 1);
	}
	int *b = a + n;
	for (int i = 2, m = 1, t = n >> 1; i <= n; i = (m = i) << 1, t >>= 1)
	{
		for (int *j = a; j != b; j += i)
		{
			int *x = j, *y = x + m, *z = y;
			for (int *p = wn; x != z; ++ x, ++ y, p += t)
			{
				int tmp = 1ll * *y * *p % Mod;
				*y = Csub(*x, tmp);
				Chkadd(*x, tmp);
			}
		}
	}
	if (f)
	{
		int inv = Power(n, Mod - 2);
		for (int *i = a; i != b; ++ i)
			*i = 1ll * *i * inv % Mod;
	}
}

char A[maxn], B[maxn];
int fac[maxn], inv[maxn];
int a[maxn], b[maxn], c[maxn];

int main()
{
	scanf("%s%s", A, B);
	int n = strlen(A), x = 0, y = 0;
	for (int i = 0; i < n; ++ i)
		if (A[i] == '1') B[i] == '1' ? ++ x : ++ y;
	n = x + y;
	
	fac[0] = 1;
	for (int i = 1; i <= n + 1; ++ i) fac[i] = 1ll * fac[i - 1] * i % Mod;
	inv[n + 1] = Power(fac[n + 1], Mod - 2);
	for (int i = n + 1; i >= 1; -- i) inv[i - 1] = 1ll * inv[i] * i % Mod;
	
	for (int i = 0; i <= x; ++ i) a[i] = inv[i + 1];
	int N = 1;
	while (N <= x * 2) N <<= 1;
	Prepare(N);
	
	b[0] = 1;
	for (int k = y; k; k >>= 1)
	{
		if (k & 1)
		{
			copy(a, a + N, c);
			Transform(N, c, wn, 0);
			Transform(N, b, wn, 0);
			for (int i = 0; i < N; ++ i)
				b[i] = 1ll * b[i] * c[i] % Mod;
			Transform(N, b, iv, 1);
			fill(b + x + 1, b + N, 0);
		}
		Transform(N, a, wn, 0);
		for (int i = 0; i < N; ++ i)
			a[i] = 1ll * a[i] * a[i] % Mod;
		Transform(N, a, iv, 1);
		fill(a + x + 1, a + N, 0);
	}
	
	int ans = 0;
	for (int i = 0; i <= x; ++ i) Chkadd(ans, b[i]);
	ans = 1ll * ans * fac[x] % Mod * fac[n] % Mod * fac[y] % Mod;
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <utility>
#include <cmath>
#include <cstdio>

using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;
LL MOD = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N, 0);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    LL maxim = 1000000;
    maxim *= maxim;
    vector<LL> DP(N, maxim);
    DP[0] = 0;
    for(int i=1; i<N; i++) {
        for(int j=1; j<=K; j++) if(i-j>=0)
            DP[i] = min(DP[i], DP[i-j] + abs(A[i] - A[i-j]));
            //DP[i] = min(DP[i-1] + abs(A[i-1] - A[i]) , DP[i-2] + abs(A[i-2] - A[i]));
    }
    cout << DP[N-1] << endl;

    return 0;
}

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

using namespace std;

const int MAX_N = (1 << 17);
const int MAX_LG = 16;

int n;

long long score[MAX_N], dp[MAX_N];
int points[MAX_LG][MAX_LG];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", &points[i][j]);
    }
  }
  for (int mask = 0; mask < (1 << n); ++mask) {
    for (int i = 0; i < n; ++i) {
      if (((1 << i) & mask) == 0) {
        for (int j = 0; j < n; ++j) {
          if (((1 << j) & mask) > 0) {
            score[mask | (1 << i)] += points[i][j];
          }
        }
      }
    }
  }
  for (int i = 1; i < (1 << n); ++i) {
    score[i] /= 2;
  }
  for (int mask = 0; mask < (1 << n); ++mask) {
    int mask1 = mask;
    dp[mask] = score[mask];
    while (mask1 > 0) {
      dp[mask] = max(dp[mask], dp[mask1] + dp[mask ^ mask1]);
      mask1 = (mask1 - 1) & mask;
    }
  }
  printf("%lld", dp[(1 << n) - 1]);
  return 0;
}


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


int main() {
  int N, M;
  cin >> N >> M;
  vector<int> prob(N, 0), penal(N, 0);
  int right = 0, wrong = 0;
  rep(i, M) {
    int p;
    string S;
    cin >> p >> S;
    if (prob[p - 1] == 0 && S == "WA") {
      penal[p - 1]++;
    } else if (prob[p - 1] == 0 && S == "AC") {
      prob[p - 1] = 1;
      wrong += penal[p - 1];
      right++;
    } else {
      continue;
    }
  }
  cout << right << " " << wrong << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  if (N==1) {
    cout << "Hello World" << endl;
  }
  else {
    int A, B;
    cin >> A >> B;
    cout << A+B << endl;
  }
}

Measured memory_bytes: 3528
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	s_list = list(S())
	s_list2 = []
	s_list2.append(s_list.pop(0))
	for s in s_list:
		if s_list2[-1] != s:
			s_list2.append(s)
	print(len(s_list2)-1)



if __name__ == '__main__':
    main()

Measured memory_bytes: 28344
n = int(input())
n2 = n
i = 1
while True:
    if (n2 > 26**i):
        n2 = n2 - 26**i
        i = i + 1
    else:
        break

lst = []

for j in range(i - 1):
    k = j + 1
    n = n - 26**k
n = n - 1
for j in range(i):
    k = i - j - 1
    x = n//(26**k)
    lst.append(x)
    n = n - 26**k*x
for j in range(len(lst)):
    if (j != len(lst) - 1):
        print(chr(int(97 + lst[j])), end = '')
    else:
        print(chr(int(97 + lst[j])))


Measured memory_bytes: 9204
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scn  = new Scanner(System.in);
		int n = scn.nextInt();
		int x = scn.nextInt();
		int t = scn.nextInt();
		int fac = n/x;
		if(n%x!=0)
			fac++;
		System.out.println(fac*t);

	}



}


Measured memory_bytes: 35784
#include <cstdio>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void) {
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d\n", (a + b) % 24);
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
 int a;
  int b;
  int c;
  int max;
  
  cin >> a;
  cin >> b;
  cin >> c;
  
  max = a;
  
  if (max<b) max=b;
  if (c>max) max=c;

  cout << 10*max+a+b+c-max;
  
  cout<<endl;
  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

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

	      	  string x;
	      	  cin >> x;

	      	  int n=x.size();
	      	  REP(i,n){
	      		  if(x[i]=='9'){
	      			  cout << "Yes" << endl;
	      			  return 0;
	      		  }
	      	  }

	      	cout << "No" << endl;

	          return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, k, t, a[200009];
int pos_f[200009], pos_l[200009], cnt[200009], nxt[200009], pre[200009];
int from[200009];   //from[i] means the first positon of answer s, if start from i.
bool vis[200009], ck[200009], stl[200009];
stack<int> stk;
vector<int> vec, ans;

int fun(int cur)
{
	if (cur >= n) return cur;
	if (stl[cur]) return from[cur];
	if (nxt[cur] < 0) {
		from[cur] = cur;
	}
	else {
		int retval = fun(nxt[cur] + 1);
		from[cur] = retval;
	}
	stl[cur] = true;
	return from[cur];
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	k--;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (!vis[a[i]]) {
			vis[a[i]] = true;
			pos_f[a[i]] = i;
			//t++;
		}
		pos_l[a[i]] = i;
	}
	memset(pre, 0xff, sizeof(pre));
	memset(nxt, 0xff, sizeof(nxt));
	for (int i = 0; i < n; i++) {
		if (pre[a[i]] < 0) {
			pre[a[i]] = i;
		}
		else {
			nxt[pre[a[i]]] = i;
			pre[a[i]] = i;
		}
	}
	for (int i = 0; i < n; i++) {
		fun(i);
	}
	int G = 0, PRE = -1;
	t++;
	for (int i = 1; i <= n; i++) {
		int V;
		if (PRE >= 0) {
			V = a[PRE];
			G = pos_f[V] + 1;
		}
		else {
			G = 0;
		}
		if (G >= n) PRE = -1;
		else PRE = from[G];
		if (PRE == n) break;
		t++;
	}
	k = k % t;
	G = 0, PRE = from[0];
	for (int i = 1; i <= k; i++) {
		int V;
		if (PRE >= 0) {
			V = a[PRE];
			G = pos_f[V] + 1;
		}
		else {
			G = 0;
		}
		if (G >= n) PRE = -1;
		else PRE = from[G];
	}
	memset(vis, 0, sizeof(vis));
	for (int i = G; i < n; i++) {
		if (!vis[a[i]]) {
			stk.push(a[i]);
			vis[a[i]] = true;
		}
		else {
			while (1) {
				int tmp = stk.top();
				stk.pop();
				vis[tmp] = false;
				if (a[i] == tmp) {
					break;
				}
			}
		}
	}
	while (!stk.empty()) {
		int tmp = stk.top();
		stk.pop();
		ans.pb(tmp);
	}
	reverse(ans.begin(), ans.end());
	for (int i = 0; i < (int)ans.size(); i++) {
		cout << ans[i] << " ";
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 9776
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

/*---------------------------------------------------*/

int solve(int n,vi v[],int k,int name[]){
  int find_name=-1,cnt;
  bool find=false;
  rep(i,n){
    cnt=0;
    rep(j,v[i].size()){
      rep(l,k){
	if(v[i][j]==name[l])cnt++;
      }
    }
    if(find&&cnt==k)return -1;
    if(cnt==k){
      find_name=i+1;
      find=true;
    }
  }
  return find_name;
}

int main(){
  int n,m,a,name[100];
  while(cin>>n){
    if(n==0)break;
    vector<int>v[n];
    rep(i,n){cin>>m;rep(j,m){cin>>a;v[i].pb(a);}}
    int k;
    cin>>k;
    rep(i,k)cin>>name[i];
    cout<<solve(n,v,k,name)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3136
## C - Welcome to AtCoder
N ,M = map(int, input().split())
AC = [0] + [0] * N
WA = [0] + [0] * N
for m in range(M):
    p, S = map(str, input().split())
    if S == 'WA' and AC[int(p)] != 1:
        WA[int(p)] += 1
    else:
        AC[int(p)] = 1
print(' '.join([str(x) for x in [sum(AC), sum([WA[i] for i in range(N+1) if AC[i] == 1 ])] ]) )

Measured memory_bytes: 6116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> sp,sn;
    rep(i,n){
        ll a;
        cin>>a;
        if(a>=0) sp.push_back(a);
        else sn.push_back(-a);
    }
    sort(all(sn));

    ll ans=1LL<<60;
    for(int i=0;i<=k;i++){
        if(i>sp.size() || k-i>sn.size()) continue;
        ll pn,nn;
        if(i==0){
            pn=0;
            nn=sn[k-1];
        }
        else if(i==k){
            pn=sp[k-1];
            nn=0;
        }
        else{
            pn=sp[i-1];
            nn=sn[k-i-1];
        }

        ll tmp=min(2*pn+nn,pn+2*nn);
        //cout<<i<<" "<<tmp<<endl;
        ans=min(ans,tmp);
    }  

    cout<<ans<<endl;

}


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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> cnt(M);
	for(int i = 0;i < N;i++){
		int K;
		cin >> K;
		for(int j = 0 ;j < K;j++){
			int A;
			cin >> A;--A;
			cnt[A]++;
		}
	}
	cout << count(cnt.begin(), cnt.end(), N) << endl;
	return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
	int N,K;
	cin >> N >> K;
		
	if((N-1)*(N-2)/2<K){
		cout << -1 << endl;
		return 0;
	}
	
	cout << N-1 + (N-1)*(N-2)/2-K << endl;
	for(int i=1;i<=N-1;i++){
		cout << i << " " << N << endl;
	}
	int aa=(N-1)*(N-2)/2-K;
	if(aa==0)	return 0;
	for(int i=1;i<=N-1;i++){
		for(int j=i+1;j<=N-1;j++){
			cout << i << " " << j << endl;
			aa--;
			if(aa==0)	return 0;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int n;
    std::cin >> n;
    long double sum = 0, x;
    std::string cur;
    for (int i = 0; i < n; i++)
    {
        std::cin >> x >> cur;
        if (cur == "BTC") { sum += (x * 380000.0); }
        else
        {
            sum += x;
        }
    }

    std::cout << std::setprecision(20) << sum << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
const int M=101000;
#define A(a,b) y[++t]=b,N[t]=F[a],F[a]=t
int n,i,u,v,x,t,y[2*M],N[2*M],F[2*M],Q[2*M];
inline int DFS(int u,int f) {
	int K=0,P=0,S=0;
	for (int j=F[u];j;j=N[j])if(y[j]!=f)S|=((K=DFS(y[j],u))&P),P|=K;
	return(P|((1<<Q[S]+1)-1))+1;
}
int main() {
	scanf("%d",&n);
	for (i=0;i<n-1;i++) scanf("%d%d",&u,&v),A(u,v),A(v,u);
	for (Q[0]=-1,i=2;!(i>>17);i++) Q[i]=Q[i>>1]+1;
	printf("%d\n",Q[DFS(1,0)]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)2e3 + 5;
const int MOD = (int)1e9 + 7;
ll n, k, a[MAXN], dp[MAXN], mx[MAXN], cnt[MAXN];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n >> k)
	{
		memset(mx, 0, sizeof(mx)), memset(cnt, 0, sizeof(cnt)), memset(dp, 0, sizeof(dp));
		for (ll i = 1; i <= n; ++i) cin >> a[i];
		for (ll i = n; i >= 1; --i)
		{
			cnt[a[i]]++;
			for (ll j = 1; j < a[i]; ++j)
				dp[i] += cnt[j];
		}
		for (ll i = 1; i < MAXN; ++i)
			for (ll j = 1; j < i; ++j)
				mx[i] += cnt[j];
		ll sum = 0;
		for (ll i = 1; i <= n; ++i)
			sum = (sum + (dp[i] * k) % MOD + (((k - 1)*k / 2) % MOD* mx[a[i]]) % MOD) % MOD;
		cout << sum << endl;
	}
}
/*
2 2
2 1

3 5
1 1 1

10 998244353
10 9 8 7 5 6 3 4 2 1
*/

Measured memory_bytes: 384
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        xs: [i64; n],
    }

    let mut sorted = xs.clone();
    sorted.sort();

    let left: usize = (n / 2) - 1;
    let right: usize = left + 1;

    for &x in xs.iter() {
        if x <= sorted[left] {
            println!("{}", sorted[right]);
        } else {
            println!("{}", sorted[left]);
        }
    }
}


Measured memory_bytes: 10364
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
vector<vector<long long>> comb(int n, int r) {
  vector<vector<long long>> v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}
int main() {
    ll N, A, B; cin >> N >> A >> B;
    map<ll,ll> mp;
    rep(i, N) {
        ll v; cin >> v;
        mp[v]++;
    }
    double avg = 0;
    ll cnt = A;
    bool mode1 = false;
    P num2;
    if(mp.rbegin()->second >= A) mode1 = true;
    for (auto it=mp.rbegin();it!=mp.rend();it++) {
        //printf("%lld %lld\n", it->first, it->second);
        ll num = it->second;
        if(num < cnt) {
            cnt -= num;
            avg += it->first * num;
        } else {
            avg += it->first * cnt;
            num2 = (P){num, cnt};
            cnt = 0;
        }
        if(cnt == 0) {
            avg /= A;
            break;
        }
    }
    printf("%.10f\n", avg);
    vector<vector<long long>> v = comb(51, 51);
    if(mode1) {
        ll num = mp.rbegin()->second;
        ll ans = 0;
        //printf("num:%lld\n", num);
        for(ll i=A; i<=B; i++) {
            ans += v[num][i];
        }
        cout << ans << endl;
    } else {
        ll n = num2.first;
        ll r = num2.second;
        ll ans = v[n][r];
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val JoinN: Int = readLine()!!.toInt()
    val (Day: Int, Chocolate: Int) = readLine()!!.split(" ").map(String::toInt)
    val EatA: Array<Int> = Array<Int>(JoinN, { readLine()!!.toInt() })
    var AllEat: Int = 0
    for (i in 0 until JoinN) {
        var isOver = false
        var count = 0
        while (!isOver) {
            val targetday = count++ * EatA[i] + 1
            if (targetday > Day) {
                isOver = true
                break
            }
            AllEat++
        }
    }
    println(AllEat + Chocolate)
}


Measured memory_bytes: 37708