akhauriyash/Code-Regression huggingface dataset:
using System;

public class Hello
{
    public static void Main()
    {
        var a = int.Parse(Console.ReadLine().Trim());
        var b = int.Parse(Console.ReadLine().Trim());
        var h = int.Parse(Console.ReadLine().Trim());
        Console.WriteLine((a + b) * h / 2);
    }
}


Measured memory_bytes: 11092
import sys
input = sys.stdin.readline
#####segfunc######
def segfunc(x,y):
    return x | y

def init(init_val):
    #set_val
    for i in range(len(init_val)):
        seg[i+num-1]=init_val[i]   
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
n = int(input())
s = list(input())[:-1]
ide_ele = 0
num =2**(n-1).bit_length()
seg=[ide_ele]*(2*num - 1)
s = [2 ** (ord(i) - ord('a')) for i in s]
init(s)
q = int(input())
for i in range(q):
    tmp = input()
    a,b,c = tmp[:-1].split()
    if a == "1":
        update(int(b)-1, 2 ** (ord(c) - ord('a')))
    else:
        if b == c:
            print(1)
        else:
            tmp = query(int(b)-1, int(c))
            tmp = format(tmp, 'b')
            print(tmp.count('1'))


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

int n, m, k;
int main()
{
	int i, j, w;
	cin >> n >> m >> k;
	for (i = 0; i <= n; i++){
		for (j = 0; j <= m; j++) {
			w = i * m + j * n - 2 * i * j;
			if (w == k) {
				cout << "Yes";
				return 0;
			}
		}
	}
    cout << "No" << endl;
    return 0;
}


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

int main(){
  int t[100];
  int c[17],ans[100],time;
  queue<int> q;

  for(int i=0;i<100;i++)t[i] = 17*(i%2) + 3*(i%3) + 19;

  for(int i=0;i<17;i++)c[i] = -1;

  time = 0;
  bool ex = false;
  while(1){
    if( !(time%5) )q.push(time/5);
    int tmp = -1;
    for(int i=0;i<17;i++){
      if(c[i]>=0 && c[i]!=tmp){
	t[c[i]]--;
	tmp = c[i];
      }
      if(!t[c[i]])c[i] = -1;
    }
    while(q.size()){
      int n,i;
      if(q.front()%5 == 1)n = 5;
      else n = 2;
      for(i=0;i+n<=17;i++){
	bool f = true;
	for(int j=i;j<i+n;j++){
	  if(c[j]>=0)f = false;
	}
	if(f){
	  if(q.front() == 99)ex = true;
	  for(int j=i;j<i+n;j++)c[j] = q.front();
	  ans[q.front()] = time - q.front()*5;
	  q.pop();
	  break;
	}
      }
      if(ex)break;
      if(i+n==18)break;
    }
    if(ex)break;
    time++;
  }

  int num;
  while(cin >> num)cout << ans[num] << endl;
}

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

int main() {
   int N;
   cin >> N;
  vector<int> kazu(N);
  for(int i = 0; i  < N; i++){
    cin >> kazu.at(i);
  }
  int sousa = 0;
  for(int i = 0; i < N; i++){
    while(kazu.at(i) % 2 == 0){
      kazu.at(i) /= 2;
      sousa++;
    }
  }
  cout << sousa << endl;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	int ans = 0;
	for (int i = 1; i < n; i++) {
		ans += a[i] - a[i - 1];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            string input;
            while((input = Console.ReadLine()) != null){
                if (input.Length % 2 == 1) {
                    Console.WriteLine("NA");
                }
                else {
                    char[] output = new char[input.Length / 2];
                    bool success = true;
                    for(int i=0; i < input.Length; i += 2){
                        int[] inputData = new [] { input[i] - '0' - 1, input[i + 1] - '0' - 1 };
                        if (inputData[0] < 6 && inputData[1] < 5 && ((inputData[0] | inputData[1]) >> 31) == 0) {
                            char addChar = (char)('a' + (inputData[0] * 5 + inputData[1]));
                            switch (addChar) {
                                case '{': addChar = '.'; break;
                                case '|': addChar = '?'; break;
                                case '}': addChar = '!'; break;
                                case '~': addChar = ' '; break;
                            }
                            output[i / 2] = addChar;
                        }
                        else {
                            success = false;
                            break;
                        }
                    }
                    Console.WriteLine(success ? new string(output) : "NA");
                }
            }
        }
    }
}

Measured memory_bytes: 5316
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define srt(x) sort((x).begin(), (x).end())
#define rsrt(x) sort((x).rbegin(), (x).rend())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vc = vector<char>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
template<class T>void print(T x) { cout << '\n' << "== " << x << " ==" << '\n'; }
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long double doublepi = M_PI * 2.0;
const long double halfpi = M_PI / 2.0;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long MOD = 1e9 + 7;



const ll MAX = 100010;
using Vertex = pair<ll, ll>;  // (dist, id)
class Edge
{
public:
    ll to;
    ll cost;
    Edge() : to{0}, cost{0} {}
    Edge(ll a, ll b) : to{a}, cost{b} {}
};

vector<vector<Edge> > Graph(MAX, vector<Edge>(0));
vll dist(MAX, inf);

void dijkstra(ll s)
{
    fill(dist.begin(), dist.end(), inf);
    dist[s] = 0;
    priority_queue<Vertex, vector<Vertex>, greater<Vertex> > pq;    

    pq.push(Vertex(0, s));
    while(! pq.empty()) {
        // Enqueue first node
        Vertex now = pq.top(); pq.pop();
        ll vertex = now.second;
        if (dist[vertex] < now.first) continue;
        // Check for each adjacent node
        for (Edge edge : Graph[now.second]) {
            if (dist[edge.to] > dist[now.second] + edge.cost) {
                dist[edge.to] = dist[now.second] + edge.cost;
                pq.push(Vertex(dist[edge.to], edge.to));
            }
        }
    }
}

// TODO: Graph[from].push_back(Edge(to, cost))
int main()
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll V, E, r;
    cin >> V >> E >> r;
    ll s, t, d;
    rep(i, 0, E) {
        cin >> s >> t >> d;
        Graph[s].push_back(Edge(t, d));
    }
    dijkstra(r);
    rep(i, 0, V) {
        if (dist[i] > big)
            cout << "INF" << '\n';
        else
            cout << dist[i] << '\n';
    }
}


Measured memory_bytes: 19424
N = int(raw_input())
a = map(int, raw_input().split())

gray, tya, midori, mizu, ao, ki, daidai, aka, joker = 0, 0, 0, 0, 0, 0, 0, 0, 0

for i in a:
    if 1 <= i <= 399:
        gray = 1
    elif 400 <= i <= 799:
        tya = 1
    elif 800 <= i <= 1199:
        midori = 1
    elif 1200 <= i <= 1599:
        mizu = 1
    elif 1600 <= i <= 1999:
        ao = 1
    elif 2000 <= i <= 2399:
        ki = 1
    elif 2400 <= i <= 2799:
        daidai = 1
    elif 2800 <= i <= 3199:
        aka = 1
    elif 3200 <= i:
        joker += 1

mini = gray+tya+midori+mizu+ao+ki+daidai+aka
maxi = mini + joker

if mini == 0 and joker != 0:
    mini = 1

print mini, maxi


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

namespace Program
{
    public class ABC089D
    {
        static public void Main(string[] args)
        {
            var H = NextInt;
            var W = NextInt;
            var D = NextInt;
            var pos = new Tuple<int, int>[H * W];
            for (int i = 0; i < H; ++i)
            {
                for (int j = 0; j < W; ++j)
                {
                    pos[NextInt - 1] = Tuple.Create(i, j);
                }
            }
            var sum = new int[H * W];
            for (int idx = D; idx < H * W; idx += D)
            {
                for (int off = 0; off < D && idx + off < H * W; ++off)
                {
                    sum[idx + off] = sum[idx - D + off] + Math.Abs(pos[idx - D + off].Item1 - pos[idx + off].Item1) + Math.Abs(pos[idx - D + off].Item2 - pos[idx + off].Item2);
                }
            }

            var Q = NextInt;
            for (int i = 0; i < Q; ++i)
            {
                var L = NextInt;
                var R = NextInt;
                Console.WriteLine(sum[R - 1] - sum[L - 1]);
            }

            Console.WriteLine();
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => int.Parse(Console_.NextString());
        static long NextLong => long.Parse(Console_.NextString());
        static string NextString => Console_.NextString();

        static IEnumerable<long> Prime(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1;
        }
        static IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i < max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        static long GCD(long a, long b)
        {
            long tmpa = a, tmpb = b;
            while (tmpb > 0) { var tmp = tmpb; tmpb = tmpa % tmpb; tmpa = tmp; }
            return tmpa;
        }
    }
}


Measured memory_bytes: 23356
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

ll dp[105][1000005];

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

    ll n;
    int k;
    cin >> n >> k;

    if (n == 1) {
        cout << 1 << "\n";
        return 0;
    }

    vector <int> vec;

    ll m = 1;
    while (m * m < n) {
        m++;
        vec.push_back(1);
    }

    while (m <= n) {
        ll tmp = n / m;
        vec.push_back(n / tmp - m + 1);
        m = n / tmp + 1;
    }

    int sz = vec.size();
    for (int i = 0; i < sz; i++) {
        dp[1][i] = vec[i];
        if (i) {
            dp[1][i] += dp[1][i-1];
            dp[1][i] %= MOD;
        }
    }

    for (int i = 2; i <= k; i++) {
        for (int j = 0; j < sz; j++) {
            dp[i][j] = dp[i-1][sz - j - 1] * vec[j] % MOD;
            if (j) {
                dp[i][j] += dp[i][j-1];
                dp[i][j] %= MOD;
            }
        }
    }

    cout << dp[k][sz-1] << "\n";

    return 0;
}


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

int f[110][10];
ll p[110][11];
int cnt[110];

int main() {
    int n;
    cin>>n;
    rep(i,n){
        rep(j,10){
            cin>>f[i][j];
        }
    }
    rep(i,n){
        rep(j,11){
            cin>>p[i][j];
        }
    }

    ll ans=-1LL<<60;
    rep(bit,1<<10){
        if(bit==0) continue;
        rep(i,n) cnt[i]=0;
        rep(i,10){
            if(bit & 1<<i){
                rep(j,n){
                    if(f[j][i]==1) cnt[j]++;
                }
            }
        }
        ll tmp=0;
        rep(i,n){
            tmp+=p[i][cnt[i]];
        }
        ans=max(ans,tmp);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include <stdio.h>
long long a, b,c;
int main()
{
	while (~scanf("%lld%lld", &a, &b))
	{
	    if (2 * a >= b)
		{
			printf("%lld\n", b / 2);
		}
		else
		{
			c = b - 2 * a;
			c = c / 4;
			printf("%lld\n", a + c);
		}
	}
	return 0;
}

Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    A, B, C, X = map(int, readlines())

    cnt = 0
    for i in range(A+1):
        s0 = i * 500
        if s0 > X:
            break

        for j in range(B+1):
            s1 = s0 + j * 100
            if s1 > X:
                break

            for k in range(C+1):
                s = s1 + k * 50
                if s == X:
                    cnt += 1
                elif s > X:
                    break

    print(cnt)


main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	int n;
	cin >> n;
	cout << n*800 - n/15 * 200 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int mod = 1000000007;
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int m = std.nextInt();
        int[] as = new int[m];
        int[] dp = new int[n + 1];
        boolean[] none = new boolean[n + 1];
        for (int i = 0; i < m; i++) {
            int no = std.nextInt();
            none[no] = true;
        }

        dp[0] = 1;
        if (!none[1]) {
            dp[1] = 1;
        }

        for (int i = 0; i < n - 1; i++) {
            if (!none[i + 2]) {
                dp[i + 2] = dp[i + 1] + dp[i];
                dp[i + 2] %= mod;
            }
        }

        System.out.println(dp[n]);
    }
}


Measured memory_bytes: 47548
import java.io.*;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
    //Solution by Sathvik Kuthuru
    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        for(int tt = 1; tt <= t; tt++) solver.solve(tt, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            int x = scan.nextInt();
            out.println(360 * x / gcd(x, 360) / x);
        }

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

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 32916
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから
void solve(){
  string s;
  cin>>s;
  int n=s.size();
  int ans=1000;
  rep(i,n-2){
    string t=s.substr(i,3);
    int x=stoi(t);
    chmin(ans,abs(753-x));
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	//cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long h,sum=0;
	cin>>h;
	int cnt=0;
	while(h>0)
    {
        h/=2;
        cnt++;
    }
    cnt--;
    for(int i=cnt;i>=0;i--){
        sum+=pow(2,i);
    }
    cout<<sum<<endl;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL){
    x = x->left;
  }
  return x;

}

Node treeSearch(Node x, int k){

  if(x == NIL || k == x->key)
    return x;
  if(k < x->key)
    return treeSearch(x->left, k);
  else
    return treeSearch(x->right, k);

}

Node treeSuccessor(Node x){

  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL)
    y=z;
  else 
    y=treeSuccessor(z);
  if(y->left != NIL)
    x=y->left;
  else
    x=y->right;
  if(x != NIL)
    x->parent = y->parent;
  if(y->parent == NIL)
    root=x;
  else if(y ==(y->parent)->left)
    (y->parent)->left=x;
  else
    (y->parent)->right=x;
  if(y != z)
    z->key=y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key)
      x=x->left;
    else 
      x=x->right;
}

  z->parent=y;
  if(y==NIL)
    root=z;
  else if(z->key < y->key)
    y->left=z;
  else
    y->right=z;

}

void inorder(Node x){

  if(x!=NIL){
    inorder(x->left);
    printf(" %d", x->key);
    inorder(x->right);
  }


}
void preorder(Node x){

  if(x!=NIL){
    printf(" %d", x->key);
    preorder(x->left);
    preorder(x->right);
  }

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  root=NIL;

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};
}

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

macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};
}

fn main() {
    input!{
        n: usize,
        d: usize,
        x: [[isize; d]; n]
    }

    let mut cnt = 0;
    for i in 0..(n-1) {
        for j in (i+1)..n {
            let sqsum = x[i].iter()
                .zip(&x[j]).fold(0, |sum, (a,b)| sum + (a-b).pow(2));
            let dist = (sqsum as f64).sqrt();
            if dist.ceil() == dist {
                cnt += 1;
            }
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2636
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,K;
	cin>>N>>K;
	vector<int> h(N);
	FDS(i,N){
		cin>>h[i];
	}
	VSORT(h);
	vector<int> ruiseki(N);
	for(int i=0; i<N-1;i++){
		ruiseki[i+1]=h[i+1]-h[i]+ruiseki[i];
	}
	int ans=INF;
	for(int i=0; i<N-K+1; i++){
		ans=min(ans,h[i+K-1]-h[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
n = int(input())

sum = (1 + n) * n // 2

sho_3 = n // 3
sho_5 = n // 5
sho_15 = n // 15

s_3 = (sho_3 * 3 + 3) * sho_3 // 2
s_5 = (sho_5 * 5 + 5) * sho_5 // 2
s_15 = (sho_15 * 15 + 15) * sho_15 // 2


print(sum - s_3 - s_5 + s_15)


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;

    vector<int> x(N),y(N),h(N);
    rep(i,N) cin >> x[i]>>y[i]>>h[i];
    vector<int> p(N);
    rep(i,N)p[i]=i;
    sort(p.begin(),p.end(),[&](int a,int b){
        return h[a]>h[b];
    });
    //-----------------------------------
    int ansh,ansx,ansy;
    rep(cx,101){
        rep(cy,101){
            bool istrue=true;
            ansh= abs(cx - x[p[0]])+abs(cy - y[p[0]])+h[p[0]];
            repd(i,1,N){
                int er=abs(cx - x[p[i]])+abs(cy - y[p[i]]);
                if(ansh== er + h[p[i]])continue;
                if(h[p[i]] == 0 && ansh<er) continue;
                istrue=false;
                break;
            }
            if(istrue) {
                ansx=cx, ansy=cy;
                goto ANSWER;
            }
        }
    }
ANSWER:
    cout << ansx<<" "<<ansy<<" "<<ansh <<endl;
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int num(ll a){
	int ans = 0;
	while(a > 0){
		a/=10;
		ans++;
	}
	return ans;
}
int main(){
	cin >> n;
	ll ans = sqrt(n);
	for(ll i = ans; i >= 1; i--){
		if(n%i==0){
			int res = num(i);
			int res2 = num(n/i);
			cout << max(res, res2) << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  vector<P> A(5);
  for(int i = 0; i < 5; i++){
    cin >> A.at(i).second;
    A.at(i).first = A.at(i).second % 10;
    if(A.at(i).first == 0) A.at(i).first = 10;
  }
  sort(ALL(A), greater<P>());
  ll ans = 0;
  for(int i = 0; i < 5; i++){
    ll num = A.at(i).second;
    if(i != 4) ans += (num + 9) / 10 * 10;
    else ans += num;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    A, B, C, K = map(int, input().split())

    ans = 0

    # A
    if A >= 1:
        if K >= A:
            ans = A
        else:
            ans = K

    # C
    tmp = K - A - B
    if tmp >= 1:
        ans -= tmp

    print(f'{ans}')

if __name__ == '__main__':
    main()



Measured memory_bytes: 9176
S = input()
l = len(S)

count = 0
for i in range(0, l):
    if i % 2 == 0:
        if S[i] == "0":
            count += 1
    else:
        if S[i] == "1":
            count += 1

times = min(count, l - count)
print(times)


Measured memory_bytes: 3188
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int r, d, x;
  scanf("%d%d%d", &r, &d, &x);
  for (int i = 0; i < 10; i++)
  {
    x = r * x - d;
    printf("%d\n", x);
  }
  return 0;
}


Measured memory_bytes: 128
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
int a[M];
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)
    {
        cin>>a[i];
    }
    int ses=0;
    int last=0;
    f(i,1,n)
    {
        if(a[i]<last)
        {
            ses+=(last-a[i]);
        }
        else
        {
            last=a[i];
        }
    }
    cout<<ses<<"\n";
    return 0;

}





































Measured memory_bytes: 5080
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define vsort(v) sort(v.begin(),v.end)
using namespace std;
signed main() {
	int n, m, a = 0, b = 0;
	cin >> n >> m;
	rep(i, n) {
		int in;
		cin >> in;
		a += in;
	}
	rep(i, m) {
		int in;
		cin >> in;
		b += in;
	}
	cout << a * b << endl;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
const int MAXN=410;
const ll INF=4e18;
int n;
ll a[MAXN];
ll memo[MAXN][MAXN];
ll pref[MAXN];
ll ps(int x,int y){
	if(x>y) return 0ll;
	return pref[y]-pref[x-1];
}
ll dp(int lo,int hi){
	if(lo==hi) return 0;
	ll &ret=memo[lo][hi];
	if(ret!=-1) return ret;
	if(hi-lo==1) return ret=a[lo]+a[hi];
	ret=INF;
	for(int i=lo;i<=hi;i++){
		ret=min(ret,ps(lo,i)+dp(lo,i)+ps(i+1,hi)+dp(i+1,hi));
	}
	return ret;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	memset(memo,-1,sizeof(memo));
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pref[i]=pref[i-1]+a[i];
	}
	cout<<dp(1,n);
	return 0;
}


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

int N;
const int MAX_N = 1.0e5 + 100;
int a[MAX_N], b[MAX_N], c[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    int dp[N + 1][3];
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
    for (int i = 0; i < N; i++) {
        dp[i+1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
        dp[i+1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
        dp[i+1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
    }

    int ans = max(dp[N][0], max(dp[N][1], dp[N][2]));

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


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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> v(N, vector<int>(2));
  for (int i = 0; i < N; i++) cin >> v[i][0] >> v[i][1];

  int ans = 0;
  for (int i = 0; i < N; i++) ans += v[i][1] - v[i][0] + 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


int n=0;

queue<lli> que;
int main(void){
	scanf("%d",&n);
	rep(i,n){
		lli a;
		scanf("%lld",&a);
		que.push(a);
	}
	
	lli ans=que.front()-1;
	que.pop();
	lli x = 2;
	while(!que.empty()){
		lli p=que.front();
		if(p==x){
			x++;
		}
		else if(p%x==0){
			ans += (p-x)/x;
			que.pop();
		}
		else{
			ans += p/x;
			que.pop();
		}
	}
	
	printf("%lld\n",ans);
	return 0;
}






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


int main()
{
    int a[5],k;
    for(int i = 0;i < 5;i++) scanf("%d",&a[i]);
    scanf("%d",&k);
    for(int i = 0;i < 5;i++)
    {
        for(int j = 0;j < 5;j++)
        {
            if(abs(a[i] - a[j]) > k) return 0 * puts(":(");
        }
    }
    puts("Yay!");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int s[][] = new int[h+2][w+2];
        for(int i = 0;i<h+2;i++){
            for(int j = 0;j<w+2;j++){
                s[i][j] = 0;
            }
        }
        for(int i = 0;i<h;i++){
            String kariS = sc.next();
            for(int j = 0;j<w;j++){
                if(kariS.charAt(j)=='#'){
                    s[i+1][j+1] = 1;
                }
            }
        }
        for(int i = 1;i<(h+1);i++){
            for(int j = 1;j<(w+1);j++){
                if(s[i][j] == 1){
                    if((s[i-1][j]==0) && (s[i][j-1]==0) && (s[i+1][j]==0) && (s[i][j+1]==0)){
                        System.out.println("No");
                        return;
                    }
                }
            }
        }
        System.out.println("Yes");
        sc.close();
    }
}

Measured memory_bytes: 22484
#include <cstdio>
#include <cstring>

using namespace std;


// 0								1
// (0, 0) (1, 0) (2, 0) (3, 0)		(0, 0) (1, 0)
// (0, 1) (1, 1) (2, 1) (3, 1)		(0, 1) (1, 1)
//									(0, 2) (1, 2)
//									(0, 3) (1, 3)
const int dy[2][8] = {{0,0,0,0,1,1,1,1},{0,0,1,1,2,2,3,3}}, dx[2][8] = {{0,1,2,3,0,1,2,3},{0,1,0,1,0,1,0,1}};
const int ddy[4] = {-1,0,1,0}, ddx[4] = {0,1,0,-1};
int table[100][100];

void dfs(int x,int y,int w,int h){
	int now = table[y][x];
	table[y][x] = 0;
	for(int i = 0;i < 4;i++){
		if(x + ddx[i] >= 0 && x + ddx[i] < w && y + ddy[i] >= 0 && y + ddy[i] < h && table[y + ddy[i]][x + ddx[i]] != 0 && now == table[y + ddy[i]][x + ddx[i]]){
			dfs(x + ddx[i],y + ddy[i],w, h);
		}
	}
}


int main(void){
	int sx, sy, gx, gy, n, c, d, x, y, i, j, w, h;
	char ans[3];
	while(1){
		scanf("%d%d",&w,&h);
		if(w == 0 && h == 0){
			break;
		}
		strcpy(ans,"NG");
		scanf("%d%d%d%d%d",&sx,&sy,&gx,&gy,&n);
		sx--; sy--; gx--; gy--;
		memset(table,0,sizeof(table));
		for(i = 0;i < n;i++){
			scanf("%d%d%d%d",&c,&d,&x,&y);
			for(j = 0;j < 8;j++){
				table[y + dy[d][j] - 1][x + dx[d][j] - 1] = c;
			}
		}
/*		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				printf("%d ",table[i][j]);
			}
			printf("\n");
		}*/
		if(table[gy][gx] != 0){
			dfs(sx, sy, w, h);
			if(table[gy][gx] == 0){
				strcpy(ans,"OK");
			}
		}
		printf("%s\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1060
import java.util.*;

public class Main {
	final static int MOD = 1000000007;
	
	public static void main(String[] args) {
		MyScanner in = new MyScanner();
		int n = in.nextInt();
		int[] h = in.nextIntArray(n);
		int[] array = new int[n];
		
		for (int i = 0; i < h.length-1; i++) {
			if (h[i] >= h[i+1]) {
				array[i+1] = array[i]+1;
			}
		}
		
		Arrays.sort(array);
		System.out.println(array[array.length-1]);
	}
	
	static class MyScanner {
		static Scanner sc = new Scanner(System.in);
		
		String next() {
			return sc.next();
		}
		
		String nextLine() {
			return sc.nextLine();
		}
		
		int nextInt() {
			return Integer.parseInt(sc.next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextInt();
			}
			return array;
		}
		
		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextDouble();
			}
			return array;
		}
		
		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}
			return array;
		}
		
		String[] nextLineArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLine();
			}
			return array;
		}
		
		int[][] nextIntMatrix(int n, int m) {
			int[][] matrix = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextInt();
				}
			}
			return matrix;
		}
		
		double[][] nextDoubleMatrix(int n, int m) {
			double[][] matrix = new double[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextDouble();
				}
			}
			return matrix;
		}
		
		long[][] nextLongMatrix(int n, int m) {
			long[][] matrix = new long[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextLong();
				}
			}
			return matrix;
		}
	}
}

Measured memory_bytes: 48696
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
        int n;
        cin >> n;
        string s, t;
        cin >> s >> t;
        int ret = 0;
        bool flag;
        rep(i, n) {
                flag = true;
                int sp = s.size() - 1 - i;
                int tp = 0;
                while (sp < s.size() && tp < t.size()) {
                        if (s[sp] != t[tp]) {
                                flag = false;
                        }
                        ++ sp;
                        ++ tp;
                }
                if (flag) ret = i + 1;
        }
        //s.resize(s.size() - ret);
        //string ans = s + t;
        //D(ans);
        D(s.size() - ret + t.size());
        return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    string s, t, u, v, w;
    int n, count;
    cin >> n >> s;
    REP(i, n-2){
        t = s[i];
        u = s[i+1];
        v = s[i+2];
        w = t+u+v;
        if(w=="ABC"){
            count++;
        }
    }
    cout << count; 
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
     
long long int a[10001];
int main(void)
{
    int n,count=0;
    int tmp;
    cin >> n;
    for(int i = 1; i <=n; i++){
      cin >> a[i];
      tmp = a[i];
      while(tmp % 2 == 0){
          count++;
          tmp = tmp/2;
      }
    }
    
    cout << count;
    return 0;

}

Measured memory_bytes: 384
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
ll mod=1000000007;

ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}

int main(){
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,m;
    cin>>n>>m;
    map<int,vector<string> > ma;
    forn(i,m){
        int a;
        string s;
        cin>>a>>s;
        ma[a].pb(s);
    }
    int ans=0,pen=0;
    for(auto it=ma.begin();it!=ma.end();it++){
        int val=it->F;
        int co=0,fl=0;
        forn(j,ma[val].size()){
            if(ma[val][j]=="AC"){
                fl=1;
                break;
            }
            else{
                co++;
            }
        }
        if(fl==1){
            ans++;
            pen+=co;
        }
    }
    cout<<ans<<" "<<pen;

	return 0;
}


Measured memory_bytes: 15872
#include <iostream>

using namespace std;

int main()
{
  string s,t;
  int cnt=0;
  cin>>s>>t;
  for(int i=0;i<3;i++)
  {
      if(s[i]==t[i])
      {
          cnt++;
      }
  }
  cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> d(10, 0);
	int a;
	for (int i = 0; i < k; i++) {
		cin >> a;
		d[a] = 1;
	}
	int cc = -1;
	int nn = n;
	int ii = 10;

	while (cc == -1) {
		if (cc == -1) {
			cc = 0;
		}
		for (int i = 0; ; i++) {
			int aa = nn % 10;
			bool h = true;
			//cout << aa << endl;
			if (d[aa] == 0) {
				cc += aa*ii/10;
				nn /= 10;
				h = false;
			} else {
				for (int j = aa; j < 10; j++) {
					if (d[j] == 0) {
						nn /= 10;
						nn *= 10;
						nn += j;
						nn *= ii/10;
						h = false;
						cc = -1;
						ii = 10;
						break;
					}
				}
				if (!h) {
					break;
				}
			}
			if (h) {
				nn /= 10;
				nn = (nn+1)*ii;
				cc = -1;
				ii = 10;
				break;
			}
			//cout << cc << ' ' << ii << ' ' << nn << endl;
			ii *= 10;
			if (cc >= n) {
				break;
			}
		}
	}
	cout << cc << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>

int main() {

	string p;
	cin >> p;
	if (p[0] != 'A' || (p[1] >= 'A'&&p[1] <= 'Z')) {
		cout << "WA" << endl; return 0;
	}
	int x = 0;
	for (int i = 2; i < p.size() - 1; i++) {
		if ((p[i] >= 'A'&&p[i] <= 'Z')) {
			if (p[i] == 'C')x++;
			else {
				cout << "WA" << endl; return 0;
			}
			if (x>1) {
				cout << "WA" << endl; return 0;
			}
		}
	}
	if (!x) {
		cout << "WA" << endl; return 0;
	}
	if((p[p.size()-1] >= 'A'&&p[p.size()-1] <= 'Z')) {
		cout << "WA" << endl; return 0;
	}

	cout << "AC" << endl;

	return 0;
}

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


//------------------------------------------------
int main() {
    //無限大
    const ll INF = 1LL << 60;

    //DPテーブル初期化
    ll dp[100010];
    rep(i,100010) dp[i] = INF;
    dp[0] = 0;

    //main
    int N;
    cin >> N;

    ll h[100010];
    rep(i,N) cin >> h[i];

    rep(i,N){
        chmin(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
        if (i>1) chmin(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
    }

    //answer
    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,a,b) for(int i=(a);i>=(b);i--)

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

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


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

  if (a+b == c || a+ c== b || a == b + c) cout << "Yes\n"; else cout <<"No\n";
}


Measured memory_bytes: 256