akhauriyash/Code-Regression huggingface dataset:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
S = [list(input()) for _ in range(N)]

minimum = [100] * 26
for i in range(N):
    tmp = [0] * 26
    for s in S[i]:
        tmp[ord(s) - ord('a')] += 1

    for j in range(26):
        minimum[j] = min(minimum[j], tmp[j])

ans = []

for i in range(26):
    for j in range(minimum[i]):
        ans.append(chr(i + ord('a')))

print("".join(ans))


Measured memory_bytes: 9688
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s,t,u;
		cin>>s>>t;
		int n,m;
		cin >> n >>m  ;
		cin>>u;
		if(u==s)n--;else if(u==t)m--;
		cout << n << " " << m ;

	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	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;

ll gcd(ll a, ll b){
  ll big,small;
  if(a>b){
    big=a;
    small=b;
  }else if(a<b){
    big=b;
    small=a;
  }else{
    return a;
  }

  ll rest=1;
  while(1){
    rest=big%small;
    if(rest==0) break;
    big=small;
    small=rest;
  }

  return small;
}

//--------------------------------------------
int main(){
  int N;
  cin >> N;
  ll x;
  cin >> x;
  for(int i=0;i<N-1;i++){
    ll y;
    cin >> y;
    x = x / gcd(x,y) * y;
  }

  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ar array
#define pb push_back
#define forf(i,a,b) for(i = a; i< b; i++)
#define forb(i,a,b) for(i = b; i>=a; i--)
using namespace std;
const int mod = 1e9+7;
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s="";
	char ch;
	for(int i = 0; i<3; i++) for(int j = 0; j<3; j++){
		cin>>ch;
		if(i==j)s.pb(ch);
	}
	cout<<s<<endl;
	return 0;
}

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

void print_info(int array[][10]);

int main (void)
{
	int input,b,f,r,v;
	int A[3][10],B[3][10],C[3][10],D[3][10];
	int i,j;
	
	for(i = 0 ; i < 3 ; i++)
	{
		for(j = 0 ; j < 10 ; j++)
		{
			A[i][j] = 0;
			B[i][j] = 0;
			C[i][j] = 0;
			D[i][j] = 0;
		}
	}
	scanf("%d",&input);
	for(i = 0 ; i < input ; i++)
	{
		scanf("%d %d %d %d",&b,&f,&r,&v);
		switch(b)
		{
			case 1:
				A[f-1][r-1] += v;
				break;
			case 2:
				B[f-1][r-1] += v;
				break;
			case 3:
				C[f-1][r-1] += v;
				break;
			case 4:
				D[f-1][r-1] += v;
				break;
		}
	}
	print_info(A);
	printf("####################\n");
	print_info(B);
	printf("####################\n");
	print_info(C);
	printf("####################\n");
	print_info(D);
	
	return 0;
}

void print_info(int array[][10])
{
	int i,j;
	for(i = 0 ; i < 3; i++)
	{
		for(j = 0 ; j < 10 ; j++)
		{
			printf(" %d",array[i][j]);
		}
		printf("\n");
	}
}


Measured memory_bytes: 2028
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n,y = imap()
ans = [-1,-1,-1]
for a in range(n+1):
    for b in range(n-a+1):
        c = n - a - b
        if 10000*a + 5000*b + 1000*c == y:
            ans = [a,b,c]; break

print(*ans)


Measured memory_bytes: 19664
X,Y=map(int,input().split())
A,B=1,1
mod=10**9+7
if (X+Y)%3 ==0:
    x=(2*Y-X)//3
    y=(2*X-Y)//3
    if min(x,y) >= 0:
      for i in range(min(x,y)):
        A*=(x+y-i)
        A%=mod
        B*=(i+1)
        B%=mod
      print(A*pow(B,mod-2,mod)%mod)
    else:
      print(0)
else:
  print(0)


Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int H, W;
const int MAX_W = 500;

char board[MAX_W][MAX_W + 1];
bool is_remain[26];

struct point{
	int y, x;
};

vector<point> ps[26];

int dist(point a, point b){
	return abs(a.y - b.y) + abs(a.x - b.x);
}

int between(int a, int b, int x){
	return min(a, b) <= x && x <= max(a, b);
}

bool check1(point a, point b, point p){
	return a.x != p.x && !between(a.y, b.y, p.y);
}

bool check2(point a, point b, point p){
	return a.y != p.y && !between(a.x, b.x, p.x);
}

bool check3(point a, point b, point p){
	return ( !( a.x == p.x && between(a.y, b.y, p.y) ) )
			&& ( !( b.y == p.y && between(a.x, b.x, p.x) ) );
}

bool check4(point a, point b, point p){
	return ( !( a.y == p.y && between(a.x, b.x, p.x) ) )
			&& ( !( b.x == p.x && between(a.y, b.y, p.y) ) );
}


int solve(){
	int ans = 0;

	for(;;){
		bool update = false;

		for(int i=0; i<26; i++)if(is_remain[i] && dist(ps[i][0], ps[i][1]) != 1){
			bool ok = false;
			point& a = ps[i][0], b = ps[i][1];
			//ツ療アツチツェツッツク
			if(a.x == b.x){
				bool ok2 = true;
				for(int j=0; j<26; j++)if(i!=j && is_remain[j]){
					ok2 &= check1(a, b, ps[j][0]);
					ok2 &= check1(a, b, ps[j][1]);
				}
				ok |= ok2;
			}
			if(a.y == b.y){
				bool ok2 = true;
				for(int j=0; j<26; j++)if(i!=j && is_remain[j]){
					ok2 &= check2(a, b, ps[j][0]);
					ok2 &= check2(a, b, ps[j][1]);
				}
				ok |= ok2;
			}

			//ツ債カツ湘」
			{
				bool ok2 = true;
				for(int j=0; j<26; j++)if(i!=j && is_remain[j]){
					ok2 &= check3(a, b, ps[j][0]);
					ok2 &= check3(a, b, ps[j][1]);
				}
				ok |= ok2;
			}
			//ツ右ツ可コ
			{
				bool ok2 = true;
				for(int j=0; j<26; j++)if(i!=j && is_remain[j]){
					ok2 &= check4(a, b, ps[j][0]);
					ok2 &= check4(a, b, ps[j][1]);
				}
				ok |= ok2;

			}

			if(ok){
				is_remain[i] = false;
				ans += 2;
				update = true;
			}
		}

		if(!update){
			break;
		}
	}


	return ans;
}

int main(){
	scanf("%d%d\n", &H,&W);
	for(int i=0; i<H; i++){
		scanf("%[^\n]%*c", board[i]);
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++)if(board[i][j] != '.'){
			is_remain[board[i][j] - 'A'] = true;
			ps[board[i][j] - 'A'].push_back((point){i, j});
		}
	}

	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
  
  int N;
  int A;
  int B;
  int max,min;
  scanf("%d %d %d",&N,&A,&B);
  if(N>=1&&N<=100&&A>=0&&A<=N&&B>=0&&B<=N){
  if(A<=B&&N>=A+B){
    max=A;
    min=((A+B)-N)+(N-(A+B));
  }
   else if(A<=B&&N<A+B){
    max=A;
    min=(A+B)-N;
  }
  else if(A>B&&N>=A+B){
    max=B;
     min=((A+B)-N)+(N-(A+B));
  }
  else if(A>B&&N<A+B){
    max=B;
    min=(A+B)-N;
  }
  printf("%d %d",max,min);
  }

  
  return 0;
}

Measured memory_bytes: 128
h, w = map(int, input().split())
m = [['.']*(w+2)]
for _ in range(h):
    m.append(list('.' + input() + '.'))
m.append(['.']*(w+2))

for i in range(1, h+1):
    for j in range(1, w+1):
        if m[i][j] == '#':
            if all(m[i+x][j+y] == '.' for x, y in [(-1, 0), (1, 0), (0, -1), (0, 1)]):
                print('No')
                exit(0)
else:
    print('Yes')

Measured memory_bytes: 3064
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0
for i in range(N):
  A = list(map(int, input().split()))
  tmp = 0
  for j in range(M):
    tmp += A[j]*B[j]
  tmp += C
  if tmp > 0:
    cnt += 1
    
print(cnt)
               



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,ans=0;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
    ans+=(h[i]>=k?1:0);
  }
  cout << ans << endl;
}


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

using namespace std;
#define int long long

signed main(){
    string S;
    cin >> S;
    string s = "CODEFESTIVAL2016";
    
    int cnt = 0;
    for(int i=0;i<S.length();i++){
        if(S[i]!=s[i]) cnt++;
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
    int n, k; std::cin >> n >> k;
    std::string s; std::cin >> s;
    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        cnt += s[i] == s[i + 1];
    }
    std::cout << std::min(cnt + 2 * k, n - 1) << std::endl;
    return 0;
}

Measured memory_bytes: 512
while True:
    try:
        str = list(input())
        #0-4
        state = 0
        joi = 0
        ioi = 0

        for chara in str:
            if state == 0:
                if chara == "J":
                    state = 1
                elif chara == "I":
                    state = 3
                else:
                    state = 0
            elif state == 1:
                if chara == "J":
                    state = 1
                elif chara == "O":
                    state = 2
                elif chara == "I":
                    state = 3
                else:
                    state = 0
            elif state == 2:
                if chara == "J":
                    state = 1
                elif chara == "I":
                    state = 3
                    joi += 1
                else:
                    state = 0
            elif state == 3:
                if chara == "J":
                    state = 1
                elif chara == "O":
                    state = 4
                elif chara == "I":
                    state = 3
                else:
                    state = 0
            elif state == 4:
                if chara == "J":
                    state = 1
                elif chara == "I":
                    state = 3
                    ioi += 1
                else:
                    state = 0

        print(joi)
        print(ioi)

    except EOFError:
        break

Measured memory_bytes: 7444
using System;
class Program
{
    static IO io = new IO();

    static void Main(string[] args)
    {
        io.ReadSplit();
        string[] xInputs = io.String(2);
        bool b = true;
        for (int i = 0; i < 2; ++i) {
            if (!TrueOrFalse(xInputs[i]))
            {
                b = !b;
            }
        }
        if (b)
        {
            Console.WriteLine("H");
        }
        else
        {
            Console.WriteLine("D");
        }
    }
    static bool TrueOrFalse(string str)
    {
        if (str == "H")
        {
            return true;
        }
        return false;
    }
}

class IO
{
    private string[] input;
    private int index;
    public void Read()
    {
        input = new string[1];
        input[0] = Console.ReadLine();
        index = -1;
    }
    public void ReadSplit()
    {
        input = Console.ReadLine().Split(' ');
        index = -1;
    }
    public string String()
    {
        index += 1;
        return input[index];
    }
    public string[] String(int count)
    {
        index += 1;
        string[] rv = new string[count];
        Array.Copy(input, index, rv, 0, count);
        return rv;
    }
    public int Int()
    {
        index += 1;
        return int.Parse(input[index]);
    }
    public int[] Int(int count)
    {
        index += 1;
        int[] rv = new int[count];
        for (int i = 0; i < count; ++i)
        {
            rv[i] = int.Parse(input[index + i]);
        }
        return rv;
    }
    public long Long()
    {
        index += 1;
        return long.Parse(input[index]);
    }
    public long[] Long(int count)
    {
        index += 1;
        long[] rv = new long[count];
        for (int i = 0; i < count; ++i)
        {
            rv[i] = long.Parse(input[index + i]);
        }
        return rv;
    }
    public void Write(string str)
    {
        Console.WriteLine(str);
    }
}


Measured memory_bytes: 10964
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    if(a+b==3)
        cout<<"3"<<endl;
    else if(a+b==4)
        cout<<"2"<<endl;
    else
        cout<<"1"<<endl;
    return 0;

}


Measured memory_bytes: 256
ab=[]
cd=[]
n=int(input())
for i in range(n):
	a,b=map(int,input().split())
	ab.append([a,b])
for i in range(n):
	c,d=map(int,input().split())
	cd.append((c,d))
ab.sort()
cd.sort()
ans=0
for i in range(n):
	p=-1
	erase=-1
	for j in range(n):
		if cd[i][0]>ab[j][0]:
			if p<=ab[j][1] and ab[j][1]<cd[i][1]:
				p=ab[j][1]
				erase=j
		elif ab[j]!=(1000,1000):
			break
	if p!=-1:
		ans+=1
		ab[erase]=(1000,1000)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#define m 1000000007
using namespace std;

long long int modExp(int base, long long int x)
{
    if(x==0)
        return 1;
    long long int res;
    if(x&1)
        res=(base*modExp(base,x-1))%m;
    else
    {
        res=modExp(base,x>>1);
        res*=res;
        res%=m;
    }
    return res;
}
int main()
{
    long long int n;
    cin>>n;
    cout<<(modExp(10,n)+(modExp(8,n)-2*modExp(9,n))%m + m)%m<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>

int gcd(long long int a,long long int b);

int main(){
  long long int a = 0,b = 0;

  while(fscanf(stdin,"%d %d",&a,&b) != EOF){
    printf("%d %d\n",gcd(a,b),a*b/gcd(a,b));
  }

  return 0;
}

int gcd(long long int a,long long int b){
  if(b == 0){
    return a;
  }
  else{
    gcd(b,a%b);
  }
}

Measured memory_bytes: 1028
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

ll mod=pow(10,9)+7;
//comb[i]:区間がi個の場合の数
vec comb(10);
ll Comb(int x){
    if(x<0){
        return 1;
    }
    return comb[x];
}

int main(){
    int H,W,K;
    cin>>H>>W>>K;
    comb[0]=1,comb[1]=2;
    for(int i=2;i<=W;i++){
        comb[i]=comb[i-1]+comb[i-2];
    }
    mat dp(110,vec(10));
    //初期化
    dp[0][1]=1;
    for(int i=2;i<=W;i++){
        dp[0][i]=0;
    }
    for(int h=0;h<=H;h++){
        dp[h][0]=dp[h][W+1]=0;
    }

    for(int h=1;h<=H;h++){
        for(int w=1;w<=W;w++){
            dp[h][w]=(((dp[h-1][w]*Comb(w-2)*Comb(W-w-1))%mod+(dp[h-1][w-1]*Comb(w-3)*Comb(W-w-1))%mod)%mod+(dp[h-1][w+1]*Comb(w-2)*Comb(W-w-2))%mod)%mod;
        }
    }
    cout<<dp[H][K]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,sum=0,j=0;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    for(int j=0;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                sum=sum+(arr[j]*arr[k]);
            }
        }

    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int n;
ll y;

int main() {
    cin >> n >> y;
    
    int a, b, c;
    bool flag = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            ll sum = 10000 * i + 5000 * j + 1000 * (n - i - j);
            if (sum == y) {
                flag = 1;
                a = i;
                b = j;
                c = n - i - j;
                break;
            }
        }
        if (flag) break;
    }
    
    if (flag) cout << a << ' ' << b << ' ' << c << endl;
    else cout << "-1 -1 -1" << endl;
}


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

int main(){
    int N;
    cin >> N;
    int max_a = 0;
    int min_a = 1000;
    for (int i = 0; i < N; i++){
        int a;
        cin >> a;
        max_a = max(max_a, a);
        min_a = min(min_a, a);
    }
    cout << max_a - min_a << endl;
}

Measured memory_bytes: 256
func readArrayInt() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

// input
var line = readArrayInt()
let (N, M, X) = (line[0], line[1], line[2])
var C: [Int] = []
var A: [[Int]] = []
(1...N).forEach({ _ in
    line = readArrayInt()
    C.append(line[0])
    A.append(Array(line[1...M]))
})

// main
func allAchived(_ bits: Int) -> Bool {
    var achieved = Array(repeating: 0, count: M)
    (0..<N).forEach({ place in
        if ((1 << place & bits) > 0) {
            for (i, value) in A[place].enumerated() {
                achieved[i] += value
            }
        }
    })
    for i in 0..<M {
        if (achieved[i] < X) {
            return false
        }
    }
    return true
}

func cost(_ bits: Int) -> Int {
    var cost = 0
    (0..<N).forEach({ place in
        if ((1 << place & bits) > 0) {
            cost += C[place]
        }
    })
    return cost
}

var ans = -1
(1..<(1 << N)).forEach { bits in
    if (allAchived(bits)) {
        ans = ans < 0 ? cost(bits) : min(cost(bits), ans)
    }
}

print(ans)


Measured memory_bytes: 8312
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

//mapの使い方
#include <map>

ll n,x,y;


vi tp(224);
vi ama(224);
/*

void ruiseki(vi &ina,vi &vl,vi &vr){
  for(ll i=0;i<224;i++){
    tp[i]=ina[i]*ama[(i+offset)%224]%2019;
  }
  vl[0]=tp[0];
  for(ll i=1;i<224;i++){
    vl[i]=(vl[i-1]+tp[i])%2019;
  }
  vr[223]=tp[223];
  for(ll i=222;i>=0;i--){
    vr[i]=(vr[i+1]+tp[i])%2019;
  }

}
*/

int main(){
  ll ans=0;
  string s;
  cin>>s;
  n=s.length();
  vi ama(224);
  ama[0]=1;
  for(ll i=1;i<224;i++){
    ama[i]=ama[i-1]*10%2019;
  }
  vi si(n);
  for(ll i=0;i<n;i++){
    si[n-1-i]=s[i]-48;
  }
  
    /*
    for (auto it : nums) {
        long long num = it.second; // it.first が it.second 個ある
        res += num * (num - 1) / 2;
    }
    */
  vi nums2(2019);

  for(ll k=0;k<224;k++){

      //map<long long, long long> nums;
      vi nums(2019);
      ll gk=0;
      nums[0]=1;
      ll offset=0;
      for(ll i=0;i+k<n;i++){
        gk+=ama[i%224]*si[i+k]%2019;
        gk%=2019;
        //何個あるか
        ans+=nums[(2019*2-offset-gk)%2019];

        if (i%224==223){
          //初期化
          /*
          for(ll j=0;j<2019;j++){
            nums2[(j+gk)%2019]=nums[j];
          }
          for(ll j=0;j<2019;j++){
            nums[j]=nums2[j];
          }
          */
          
          //ここでnums[0]の数値がnums[0+gk]に移動する操作をする
          //してないので本当のnums[i]は今はnums[i-gk]にある
          offset+=gk;
          offset%=2019;
          nums[(2019-offset)%2019]++;//本当はnums[0]++をしたい
          //nums[0]++;
          gk=0;
        }
      }
  }

  //offset=n%224;//これを224回やる



  cout<<ans<<endl;


  return 0;
}

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

int main()
{
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  a.push_back(a[0] + k);
  int l = 0;
  for (int i = 0; i < n; i++)
  {
    l = max(l, a[i+1] - a[i]);
  }
  int ans = k - l;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import heapq
heap=[]
from sys import stdin
while(True):
    n = list((stdin.readline().strip().split()))
    if len(n)==2:
        key=int(n[1])
        key*=-1
        heapq.heappush(heap,key)
    else:
        if n[0]=="extract":
            a=heapq.heappop(heap)
            print(a*-1)
        else:
            break


Measured memory_bytes: 45588
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int cnt=0;
    for(int i=0;i<s.length();i++){
      if(s.charAt(i)=='o') cnt++;
    }
    System.out.println(700+(100*cnt));
  }
}

Measured memory_bytes: 21716
n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()
for i in range(0, n-2):
  for j in range(1, n-1):
    for k in range(2, n):
      if l[i] < l[j] and l[j] < l[k]:
        if l[i] + l[j] > l[k]:
          ans += 1

print(ans)

Measured memory_bytes: 68000
#include <iostream>

using namespace std;

int main()
{
    int k, x;
    cin >> k >> x;
    int n = 2*k-1;
    int arr[n];
    int a = 1;
    for(int i=0; i<n; i++)
    {
        arr[i] = x-k+a;
        a++;
    }
    for(int i=0; i<n; i++)
    {
        cout << arr[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	N := nextInt()
	x := 0.0
	for i := 0; i < N; i++ {
		x += 1 / nextFloat64()
	}
	fmt.Fprintln(out, 1/x)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


Measured memory_bytes: 640
#include <stdio.h>
#include <set>
using namespace std;

int N, P[100100], R[100100];

int main()
{
	scanf ("%d", &N);
	for (int i = 1; i <= N; i++) scanf ("%d", &P[i]), R[P[i]] = i;

	set<int> pos = { 0, N + 1, R[N] };
	long long ans = 0;
	for (int i = N - 1; i >= 1; i--){
		int r = R[i];
		auto I = pos.lower_bound(r);
		auto J = I; J--;
		long long intv = 0;
		if (*J != 0){
			auto K = J; K--;
			intv += 1ll * (*J - *K) * (*I - r);
		}
		if (*I != N + 1){
			auto K = I; K++;
			intv += 1ll * (*K - *I) * (r - *J);
		}
		ans += intv * i;
		pos.insert(r);
	}

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

	return 0;
}

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

int     main() {
        int N;
        cin >>N;
        vector<int> A(N+1);
        vector<int> B(N+1);
        vector<int> C(N);
        for (int i=1; i<=N; i++)
                cin >>A.at(i);
        for (int i=1; i<=N; i++)
                cin >>B.at(i);
        for (int i=1; i<N; i++)
                cin >>C.at(i);
        int S=0;
        S=B.at(A.at(1));
        for (int i=2; i<=N; i++) {
                S +=B.at(A.at(i));
                if (A.at(i)-A.at(i-1)==1)
                        S += C.at(A.at(i-1));
        }
        cout <<S <<endl;
        return 0;
};

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    H, W, K = [int(x) for x in input().split()]
    S = [list(input().strip()) for _ in range(H)]

    ans = float("inf")

    for n in range(2 ** (H - 1)):
        tmp = 0
        wn = [0] * 10

        for i in range(H):
            if n >> i & 1:
                tmp += 1

        for i in range(W):
            f = False
            ni = 0
            for j in range(H):
                if wn[ni] + int(S[j][i]) > K:
                    tmp += 1
                    f = True
                    break
                else:
                    wn[ni] += int(S[j][i])
                if n >> j & 1:
                    ni += 1
            ff = False
            if f:
                if i == 0:
                    tmp = float("inf")
                    break
                for j in range(H):
                    wn[j] = 0
                ni = 0
                for j in range(H):
                    wn[ni] += int(S[j][i])
                    if wn[ni] > K:
                        tmp = float("inf")
                        ff = True
                        break
                    if n >> j & 1:
                        ni += 1
            if ff:
                break

        ans = min(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45744
#include<iostream>
using namespace std;
int main(){
  int W,H,x,y,r;
  cin >>W>>H>>x>>y>>r;
  
  if(x-r <0 || x+r >W || y-r <0 || y+r >H)cout<<"No"<<endl;
  else if(x-r >=0 || x+r <=W || y+r >=0 || y+r <=H)cout<<"Yes"<<endl;
  
  return 0;
}


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

template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;} else return false;}
int tb[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(){
  int n, m; cin >> n >> m;
  vector<int> dp(11000, -INT_MAX);
  vector<int> A(m);
  for(int i = 0; i < m; i++){
    cin >> A[i];
  }
  sort(A.rbegin(), A.rend());
  dp[0] = 0;
  for(int i = 1; i <= n; i++){
    int k = -INT_MAX;
    for(int j = 0; j < m; j++){
      if(i - tb[A[j]] < 0) continue;
      else if(i - tb[A[j]] > 0){
        chmax(k, dp[i-tb[A[j]]]+1);
      }
      else if(i - tb[A[j]] == 0) k = 1;
    }
  	dp[i] = k;
  } 
  while(n > 0){
    for(int i = 0; i < m; i++){
      if(n - tb[A[i]] < 0) continue;
      if(dp[n - tb[A[i]]] == dp[n] - 1){
        cout << A[i];
        n -= tb[A[i]];
        break;
      }
    }
  }
}

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

int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << x2 + y1 - y2 << " " << y2 + x2 - x1 << " " << x1 + y1 - y2 << " " << y1 + x2 - x1 << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    if (s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if (s == "Cloudy"){
        cout << "Rainy" << endl;
    }else if (s == "Rainy"){
        cout << "Sunny" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
cnt=0
if a[0]>=x:
    cnt+=a[0]-x
    a[0]=x
for i in range(n-1):
    if a[i]+a[i+1]>x:
        temp=a[i]+a[i+1]-x
        #print(a[i+1],temp)
        a[i+1]-=temp
        cnt+=temp

print(cnt)

Measured memory_bytes: 63856
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define IOS ios_base :: sync_with_stdio(0)
char Buffer[1 << 16];void up(void){fread(Buffer,1,(1 << 16),stdin);}int cnt = 0;void sc(int &x){while (!('0' <= Buffer[cnt] && Buffer[cnt] <= '9')){++cnt;if (cnt == (1 << 16)) up(),cnt = 0;}x = 0;while ('0' <= Buffer[cnt] && Buffer[cnt] <= '9'){x = x * 10 + Buffer[cnt] - '0';++cnt;if (cnt == (1 << 16)) up(),cnt = 0;}}
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define CF
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
int main(void)
{
    #ifdef CF
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    string str;
    fi>>str;
    set < char > s;
    for (auto it : str)
        s.insert(it);
    int cnt = 1;
    if (s.count('N') && !s.count('S')) cnt = 0;
    if (s.count('S') && !s.count('N')) cnt = 0;
    if (s.count('W') && !s.count('E')) cnt = 0;
    if (s.count('E') && !s.count('W')) cnt = 0;
    fo << (cnt ? "Yes" : "No") << '\n';
    return 0;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long R = GetLong();
		long C = GetLong();
		long K = GetLong();
		var item = new long[R, C];
		for(long i = 0; i < K; i++)
				item[GetLong() - 1, GetLong() - 1] = GetLong();

		var dp = new long[R, C, 4];  // dp[0, 0, 0] = 0;
		if(item[0, 0] != 0)
			dp[0, 0, 1] = item[0, 0];
			
		for(long i = 0; i < R; i++)
		{
			for(long j = 0; j < C; j++)
			{
				for(long k = 0; k <= 3; k++)
				{
					if(j < C - 1)
					{
						chmax(ref dp[i, j + 1, k], dp[i, j, k]);
						if(k < 3 && item[i, j + 1] != 0)
							chmax(ref dp[i, j + 1, k + 1], dp[i, j, k] + item[i, j + 1]);
					}
					if(i < R - 1)
					{
						chmax(ref dp[i + 1, j, 0], dp[i, j, k]);
						if(item[i + 1, j] != 0)
							chmax(ref dp[i + 1, j , 1], dp[i, j, k] + item[i + 1, j]);
					}
				}
			}
		}

		long ans = 0;
		for(long i = 0; i <= 3; i++)
			chmax(ref ans, dp[R - 1, C - 1, i]);

		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

int count(int N) {
  int cnt=0;
  for (int i = 1;i<=N;i++) {
    if (N%i==0) cnt++;
  }
  return cnt;
}

int main() {
  int N;
  cin >> N;
  int ans=0;
  for (int i = 1;i<=N;i++) {
    if (i%2==1) {
      if (count(i) == 8) ans++;
    }
  }
  cout << ans << endl;
    
  
}


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

const int MAX_V=101010;

int par[MAX_V]; //　親
int rnk[MAX_V]; // rank, 木の深さ

// V要素で初期化
void init(){
  for(int i=0;i<MAX_V;i++){
    par[i]=i;
    rnk[i]=0;
  }
}

// 木の根を求める
int find(int x){
  if (par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

// ｘとｙの属する集合を併合
void unite(int x, int y){
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rnk[x] < rnk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

// ｘとｙが同じ集合に属するかどうか
bool same(int x, int y){
  return find(x) == find(y);
}

vector<pair<int,int> > V;
vector<pair<int,pair<int,int> > > E;

int main(){
    init();
    int N,M,K; cin>>N>>M>>K;
    rep(i,N){
        int c; cin>>c;
        V.push_back({c,i});
    }
    sort(V.begin(),V.end());
    rep(i,N-1) if(V[i].first!=0){
        if(V[i].first==V[i+1].first) unite(V[i].second,V[i+1].second);
    }
    rep(i,M){
        int a,b,w; cin>>a>>b>>w; a--,b--;
        E.push_back({w,{a,b}});
    }
    sort(E.begin(),E.end());
    int cnt=0;
    ll sum=0;
    rep(i,M){
        int w=E[i].first, u=E[i].second.first, v=E[i].second.second;
        if(!same(u,v)){
            unite(u,v);
            sum+=w;
            cnt++;
        }
        if(cnt>=K-1) break;
    }
    if(cnt<K-1) cout<<-1<<endl;
    else cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4084
s = input()
is_acgt = []

for item in s:
  if item == "A" or item == "C" or item == "G" or item == "T":
    is_acgt.append(1)
  else:
    is_acgt.append(0)


ans = 0
count = 0
for item in is_acgt:
  if item == 1:
    count += 1
    ans = max(ans, count)
  else:
    count = 0
  
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main(){
    long long N,K;
    long long a[100000];
    cin>>N>>K;
    for(int i=0;i<N;++i)cin>>a[i];
    sort(a, a + N, less<int>());
    long long ans=100000000000000;
    for(int i=0;i<N-K+1;++i){
        if(a[i+K-1]-a[i]<ans){
            ans=a[i+K-1]-a[i];
        }
    }
    cout<<ans<<endl;
    

    
}


Measured memory_bytes: 1024
#include <stdio.h>


int main(void)
{
	char op[10];
	int  i = 0, j;
	int a[10000];
	int b[10000];
	int  ops[10000];
	do{
		scanf("%d%s%d", &a[i], op, &b[i]);
		
		ops[i] = op[0];
		i++;
	

	} while (op[0] != '?');
	for (j = 0; j < i - 1; j++){
		if (ops[j] == '+') printf("%d\n", a[j] + b[j]);
		if (ops[j] == '-') printf("%d\n", a[j] - b[j]);
		if (ops[j] == '*') printf("%d\n", a[j] * b[j]);
		if (ops[j] == '/') printf("%d\n", a[j] / b[j]);

	
	}

	return 0;
}

Measured memory_bytes: 1752
#include<bits/stdc++.h>
#define int int64_t
using namespace std;

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

    int n;
    cin >> n;
    int a[n+1];
    vector<int> adj[n+1];
    for(int i = 2; i <= n; i++) {
        cin >> a[i];
        adj[a[i]].push_back(i);
    }
    for(int i = 1; i <= n; i++) {
        cout << adj[i].size() << "\n";
    }

    return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K; 
  string S;
  cin >> S;
  vector<int> Nums;
  int now = 1;
  int cnt = 0;
  
  for(int i=0;i<N;i++){
    if(S[i]==(char)('0'+now)) cnt++;
    else{
      Nums.push_back(cnt);
      now=1-now;
      cnt=1;
    }
  }
  if(cnt!=0) Nums.push_back(cnt);
  if(Nums.size()%2==0) Nums.push_back(0);
  int Add=2*K+1;
  vector<int> sum(Nums.size()+1);
  sum[0]=0;
  for(int i=0;i<Nums.size();i++){
      sum[i+1]=sum[i]+Nums[i];
  }
  int ans=0;
  for(int i=0;i<Nums.size();i+=2){
      int left=i;
      int right=min(i+Add,(int)Nums.size());
      int tmp=sum[right]-sum[left];
      ans=max(ans,tmp);
  }
	cout <<ans<<endl;
}

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

#define endl '\n'

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

    int n, m; cin >> n >> m;
    int a[n], soma=0; for (int i=0; i<n; i++){cin >> a[i]; soma+=a[i];}
    sort(a, a+n);

    int c=0, frac = (soma + 4*m - 1)/(4*m);
    for (int i=n-1; i>=0; i--){
        if (a[i] < frac) break;
        c++;
    }
    if (c < m) cout << "No\n";
    else cout << "Yes\n";
}

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

string one=".,!? ";
string les=".adgjmptw";

int main()
{
	int N;
	cin >> N;
	while(N--)
	{
		string s;
		cin >> s;
		char n='_';
		int l=0;
		for(int i=0; i<s.size(); i++)
		{
			int d=s[i]-'0';
			if(d==0)
			{
				if(n=='_') continue;
				if(n=='.') cout << one[l];
				else cout << (char)(n+l);
				n='_';
				l=0;
			}
			else
			{
				if(n=='_')
				{
					n=les[d-1];
				}
				else
				{

					int mod=3;
					if(d==1) mod=5;
					if(d==7||d==9) mod=4;
					l++;
					l%=mod;
				}
			}
		}

		cout << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	// Value
	int bowl_size,penki_num;
	int val;

	// Input
	cin >> bowl_size >> penki_num;

	// Cal
	val = penki_num;
	val *= std::pow(penki_num-1,bowl_size-1);

	// Output
	cout << val << endl;

	// Fin
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int bit = 0;
  while(!(bit & 8)) {
    int thisans = s[0]-48;
    rep(i, 3) {
      if(bit & (1<<i)) thisans += s[i+1] - 48;
      else thisans = thisans - (s[i+1] - 48);
    }
    if(thisans == 7) break;
    ++bit;
  }
  
  rep(i, 3) {
    cout << s[i] - 48;
    if(bit & (1<<i)) cout << "+";
    else cout << "-";
  }
  cout << s[3] - 48 << "=7" << endl;
  return 0;
}


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

int main(){
 	char a,b;
  	cin  >> a >> b;
  	if(a == b) {
     	printf("=\n"); 
    } else if(a < b) {
       	printf("<\n");
    } else {
     	printf(">\n");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


string s;

int main(){
	cin >> s;
	
	int cnt = 700;
	for(int i = 0; i < 3; i++){
		if(s[i] == 'o') cnt+=100;
	}
	
	cout << cnt << endl;
	
	return 0;
}

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

using namespace std;
int const N = 5e5;
int cc[N];
vector<int > adj[N];

void dfs(int u,int p = 0){
    cc[u]+=cc[p];
    for(auto v:adj[u]){
        if(v==p)continue;
        dfs(v,u);
    }
}
int main() {
    int n,m;
    cin>>n>>m;
    for(int i=0,a,b;i<n-1;i++){
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i=0;i<m;i++){
        int p,x;
        cin>>p>>x;
        cc[p]+=x;
    }
    dfs(1);
    for(int i=1;i<=n;i++)cout<<cc[i]<<' ';
    return 0;
}

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

int main(){
   int n,m;
   cin >> n >> m;
   int wc[n],ac_cnt=0,wa_cnt=0;
   bool ac[n];
   for(int i=0;i<n;i++){
      wc[i]=0;
      ac[i]= false;
   }
   for(int i=0;i<m;i++){
      int p;
      cin >> p;
      string s;
      cin >>s;

      if(s == "WA"){
         wc[p-1]++;
      }else if(s == "AC"){
         if(!ac[p-1]){
            ac_cnt++;
            ac[p-1] = true;
            wa_cnt+= wc[p-1];
         }
      }
   }

   cout << ac_cnt << " " <<wa_cnt << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int,int>
#define all(A) A.begin(), A.end()
#define fi first
#define se second
#define MP make_pair
#define rep(i,n) for(register int i=0;i<(n);++i)
#define repi(i,a,b) for(register int i=int(a);i<=(b);++i)
#define repr(i,b,a) for(register int i=int(b);i>=(a);--i)
template<typename T>
inline T read(){
    T s=0,f=1; char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f=-1;ch = getchar();}
    while(isdigit(ch)) {s=(s<<3)+(s<<1)+ch-48;ch = getchar();}
    return s*f;
}
#define gn() read<int>()
#define gl() read<ll>()
template<typename T>
inline void print(T x) {
    if(x<0) putchar('-'), x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
////////////////////////////////////////////////////////////////////////
const int N=2e5+100;
map<string,int> mp;
////////////////////////////////////////////////////////////////////////
int main(){
    int n=gn();
    mp["AC"]=0;
    mp["WA"]=0;
    mp["TLE"]=0;
    mp["RE"]=0;
    for(int i=0;i<n;++i){
        string k;
        cin>>k;
        mp[k]++;
    }
    printf("AC x %d\n",mp["AC"]);
    printf("WA x %d\n",mp["WA"]);
    printf("TLE x %d\n",mp["TLE"]);
    printf("RE x %d\n",mp["RE"]);
}
/**
* In every life we have some trouble
* When you worry you make it double
* Don't worry,be happy.
**/

Measured memory_bytes: 3660
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
    char a[100005];
    int n,q,i,j,k,b[100005],len,ans;
    cin>>n>>q;
    getchar();
    scanf("%s",a);
    len =strlen(a)-1;
    memset(b,0,sizeof(b));
    ans=0;
    for(k=1; k<=len; k++)
    {
        if(a[k]=='C'&&a[k-1]=='A')
        {
            ans++;
            b[k+1]=ans;
        }
        else
            b[k+1]=b[k];
    }
    while(q--)
    {
        cin>>i>>j;
        cout<<b[j]-b[i]<<endl;;
    }
    return 0;
}


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

int H,W;
string S[12];
// 点対称かどうかは，ペアの組だけ考慮すればよい
int pir[12], ok[12];

void solve(){
  fill(ok,ok+H,-1);
  rep(i,H) if(ok[i]==-1){
    rep(j,H) if(ok[j]==-1&&i!=j){
      int cnt=0;
      rep(k,W){
        if(S[i][k]!=S[j][pir[k]]) break;
        cnt++;
      }
      if(cnt==W){
        ok[i]=ok[j]=1;
        break;
      }
    }
  }
  int cnt=0, ind=-1;
  rep(i,H){
    if(ok[i]!=-1) cnt++;
    else ind=i;
  }
  if(cnt==H){
    cout<<"YES\n";
    exit(0);
  }
  if(cnt==H-1&&H%2==1){
    rep(i,W) if(S[ind][i]!=S[ind][pir[i]]) return;
    cout<<"YES\n";
    exit(0);
  }
  return;
}

void loop(int x,int flag){
  if(x==W){
    solve();
  }else if(pir[x]!=-1){
    loop(x+1,flag);
  }else{
    for(int i=x+1;i<W;i++) if(pir[i]==-1){
      pir[x]=i;
      pir[i]=x;
      loop(x+1,flag);
      pir[x]=pir[i]=-1;
    }
    if(flag){
      pir[x]=x;
      loop(x+1,0);
      pir[x]=-1;
    }
  }
  return;
}


int main(){
  cin>>H>>W;
  rep(i,H) cin>>S[i];
  fill(pir,pir+W,-1);
  int flag=(W%2==1);
  loop(0,flag);
  cout<<"NO\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(10);
	string s,t;
	cin>>s>>t;
	string k;
	for(int a=0;a<s.size();a++)
	k.push_back(t[a]);
	if(k==s)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3584
n, k = gets.chomp.split(" ").map(&:to_i)

ans = 0
(1..n).each do |b|
  x = n / b
  r = n % b
  ans += x * [0, b - k].max
  ans += [0, r - k + 1].max
end
ans -= n if k == 0
puts ans

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] points = new int[n][d];
		int res = 0;
		
		for (int i = 0; i < n; i++) {
			int[] point = new int[d];
			for (int j = 0; j < d; j++) {
				point[j] = sc.nextInt();
			}
			points[i] = point;
		}
		
		for (int i = 0; i < n - 1; i++) {
			for (int j = i+1; j < n;j++) {
				double sum = 0.0;
				for (int k = 0; k < d; k++) {
					sum += (points[i][k] - points[j][k])*(points[i][k] - points[j][k]);
				}
				sum = Math.sqrt(sum);
				if ((sum - (int)sum) == 0) {res++;}
			}
		}
		
		System.out.println(res);
		
		sc.close();
	}

}


Measured memory_bytes: 23892
from itertools import combinations

N=int(input())
A=[i for i in map(int,input().split())]

def gcd(x,y):
    while y!=0:
        x , y = y , x%y
    return x

ans=A[0]
for i in range(1,len(A)):
    ans=min(ans,gcd(ans,A[i]))
print(ans)

Measured memory_bytes: 14100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
    int n, ans = 0, a;
	cin >> n;
	rep(i, n - 1){
		int b; cin >> b;
		if(!i) ans += b;
		else ans += min(a,b);
		a = b;
	}
	ans += a;
	cout << ans << endl;
}

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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  string s;
  cin >> s;
  long long answer = 0;
  int current = 0;
  for (auto c : s) {
    if (c == 'B') {
      ++current;
    } else {
      answer += current;
    }
  }
  cout << answer << endl;
  return 0;
}


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

int main(){
	int r,c,sum1=0,sum2[100],array[100][100];
	cin>>r>>c;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>array[i][j];
			sum2[j]=0;	
		}
	}
	sum2[c]=0;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cout<<array[i][j]<<" ";
			sum1+=array[i][j];
			sum2[j]+=array[i][j];
		}
		cout<<sum1<<endl;
		sum2[c]+=sum1;
		sum1=0;
	}
	for(int i=0;i<c+1;i++){
		cout<<sum2[i];
		if(i!=c)cout<<" ";
	}
	cout<<endl;
}


Measured memory_bytes: 3084
#!/usr/bin/env python3
import sys
import functools
# from math import gcd
# from fractions import gcd

def gcd(x,y):
    if x<y:
        x,y=y,x
    #x>y
    if y==0:
        return x
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
 
def solve(N: int, A: "List[int]"):
    L = [0] * (N)
    R = [0] * (N)
 
    for i in range(1, N):
        L[i] = gcd(L[i-1], A[i-1])
    for i in reversed(range(0,N-1)):
        R[i] = gcd(R[i+1], A[i+1])
 
    # print(L)
    # print(R)
 
    ans = 0
    for i in range(N):
        ans = max(ans, gcd(L[i], R[i]))
 
    print(ans)
 
    return
 
 
# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 17324