akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int main()
{
	int n=gi(),m=gi(),a=gi(),b=gi(),i,j;
	if (!(n%a)&&!(m%b)) return puts("No"),0;
	puts("Yes");
	if (n%a) {
		for (i=1;i<=n;i++,putchar(10))
			for (j=1;j<=m;j++)
				printf("%d ",i%a?1000:-(a-1)*1000-1);
	} else {
		for (i=1;i<=n;i++,putchar(10))
			for (j=1;j<=m;j++)
				printf("%d ",j%b?1000:-(b-1)*1000-1);
	}
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n, k;
  cin >> n >> k;

  int res = 1;
  for (int i = 0; i < n; ++i) {
    res = min(res * 2, res + k);
  }

  cout << res << endl;
  return 0;
}


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

int main() {
    int N,W;
    cin >> N >> W;
    vector<vector<int64_t>> data(N+1, vector<int64_t>(W+1));
  for(int i = 1;i<N+1;i++){
      int64_t w,v;
      cin >> w >> v;
    for(int k = 1;k<W+1;k++){
      if(k-w>=0){
        data.at(i).at(k) = max(data.at(i-1).at(k),data.at(i-1).at(k-w)+v);
      }else{
        data.at(i).at(k) = data.at(i-1).at(k);
    }
    }
  }
  cout << data.at(N).at(W) << endl;
}


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

X=list(map(int, input().split()))
#print(N,X)

L=min(X)
H=max(X)
smallest = 10**18
for p in range(L,H+1):
  sum=0
  #print(p)
  for j in range(N):
    sum=sum+(X[j]-p)**2
  #print(sum)
  if sum<=smallest:
    smallest=sum

print(smallest)
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string s; cin >> s;
  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j < alpha.size(); j++){
      if(s[i] == alpha[j]){
        cout << alpha[(j + n) % (int)alpha.size()];
        break;
      }
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1000000000100000000;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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(){
	string s; cin >> s;
  	int len = s.size();
 
  	ll sum = 0;
    bool move_up = false;
    rep(i, len){
      //cout << "sum:" << sum << " ";
      int index = len-1-i;
      int num = (s[index] - '0') % 10;
      if(move_up)num++;
      //cout << "num:" << num << ln;
      if(num < 5 || num== 5 && (i==len-1 || s[max(0, index-1)] - '0' < 5)){
        sum += num;
        move_up = false;
      }
      else{
      	sum += 10 - num;
        move_up = true;
      }
    }
    if(move_up)sum++;
  	cout << sum << ln;
}

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

#define db double

struct Poi {
	db x, y;
	void r() { cin >> x; cin >> y; }
	void w() { cout << x << ' ' << y << '\n'; }
	Poi operator -(Poi p) {
		return {x - p.x, y - p.y};
	}
	Poi operator +(Poi p) {
		return {x + p.x, y + p.y};
	}
	Poi operator *(db d) {
		return {x * d, y * d};
	}
	db dot(Poi p) {
		return x * p.x + y * p.y;
	}
	db len2() { return x * x + y * y; }
	Poi proj(Poi p, Poi q) {
		db s = (*this - p).dot(q - p) / (q - p).len2();
		return p + (q - p) * s;
	}
};

int main() {
	ios :: sync_with_stdio(false);
	cout << fixed << setprecision(12);

	Poi p, q; p.r(); q.r();
	int T; cin >> T;
	while(T --) {
		Poi t; t.r();
		t.proj(p, q).w();
	}
	return 0;
}

Measured memory_bytes: 3288
n=gets.to_i
a=gets.split.map &:to_i
ans=0
(0...n).each do |i|
	(i+1...n).each do |j|
		(j+1...n).each do |k|
			x,y,z=[a[i],a[j],a[k]].sort
			if x!=y&&y!=z&&x+y>z
				ans+=1
			end
		end
	end
end
puts ans

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<ll,pair<ll,ll> > p;

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

#define MAX_N 100100

int N;
ll A[MAX_N];
ll dp[MAX_N][2];
int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i,N) {
        cin >> A[i];
    }
    
    dp[0][0] = A[0]/2;
    dp[0][1] = A[0] - (A[0]/2)*2; //残り枚数
    FOR(i,1,N) {
        dp[i][0] = dp[i-1][0];
        dp[i][1] = A[i];
        dp[i][0] += min(dp[i-1][1],A[i]);
        dp[i][1] -= min(dp[i-1][1],A[i]);
        dp[i][0] += dp[i][1]/2;
        dp[i][1] -= (dp[i][1]/2)*2;
    }
    
    cout << dp[N-1][0] << endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int a[3];
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a, a + 3);

  auto solve = [](int x, int y, int z) {
    int ans = 1000000;
    int imax = (z - x) / 2;
    int jmax = min(z - x, z - y);
    int kmax = (z - y) / 2;
    for (int j = 0; j <= jmax; j++) {
      for (int i = 0; i <= imax; i++) {
        for (int k = 0; k <= kmax; k++) {
          if (x + 2 * i + j == z && y + 2 * k + j == z) {
            ans = min(ans, i + j + k);
          }
        }
      }
    }
    return ans;
  };

  int ans = 0;
  const int sum = a[0] + a[1] + a[2];
  if (a[2] * 3 % 2 != sum % 2) {
    ans = 1 +
          min(solve(a[0] + 1, a[1], a[2] + 1), solve(a[0], a[1] + 1, a[2] + 1));
  } else {
    ans = solve(a[0], a[1], a[2]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int m,d,ans=0;
	cin>>m>>d;
	FORQ(i,1,m){
		FORQ(j,1,d){
			int t=j;
			if(j/10*(j%10)==i&&j/10>=2&&j%10>=2){
				//cerr<<i<<" "<<j<<endl;
				ans++;
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  string s;
  cin >> s;

  int n = s.size();
  vector<vector<ll>> dp(n+1, vector<ll>(13, 0));
  dp[0][0] = 1;
  rep(i, n) {
    int c = (s[i] == '?') ? -1 : s[i] - '0';
    rep(j, 10) {
      if (c == -1 or c == j)
      rep(k, 13) { // 前の剰余の状態
        dp[i+1][(k * 10 + j) % 13] += dp[i][k];
      }
    }
    rep(t, 13) dp[i+1][t] %= MOD;
  }

  cout << dp[n][5] << endl;
}


Measured memory_bytes: 15640
import heapq

N, Q = map(int,input().split())

events = []

for _ in range(N):
    S, T, X = map(int,input().split())

    events.append([S-X, 1, X])
    events.append([T-X, 0, X])

for _ in range(Q):
    D = int(input())
    events.append([D,2,0])

events.sort()

closed = set()
que = []

idx = 0
for time, flag, position in events:
    if flag == 0:
        closed.remove(position)
    elif flag == 1:
        heapq.heappush(que, position)
        closed.add(position)
    else:
        while len(que) > 0 and que[0] not in closed:
            heapq.heappop(que)

        if len(que) > 0:
            print(que[0])
        else:
            print(-1)

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

int main() {
	int n, m; cin >> n >> m;
	dsu d(n);
	while (m--) {
		int u, v; cin >> u >> v;
		d.merge(u - 1, v - 1);
	}
	cout << d.groups().size() - 1 << '\n';
	return 0;
}

Measured memory_bytes: 8800
using System;

class P
{
public static void Main()
{
            //????????????????????????
            string x = Console.ReadLine();

            //?????????????????????????????????
            var split = x.Split(' ');

            //??????????´?????????°??????????????????
            int a = Int32.Parse(split[0]);
            int b = Int32.Parse(split[1]);
            int c = Int32.Parse(split[2]);

            //?????¶??????
            if (a < b & b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
}
}

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

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

  while (N--) {
    int x, y, b, p;
    cin >> x >> y >> b >> p;

    int fee = 0;
    fee += x * b;
    fee += y * p;
    if (b >= 5 && p >= 2) {
      fee *= 0.8;
    } else {
      if (b < 5) {
        b = 5;
      }
      if (p < 2) {
        p = 2;
      }
      int disc_fee = (x*b + y*p) * 0.8;
      if (disc_fee < fee) {
        fee = disc_fee;
      }
    }

    cout << fee << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int arr[]=new int[n];
    for(int i=0;i<n;i++)
      arr[i]=sc.nextInt();
    int sum=0;
    int count=0;
    for(int i=0;i<n;i++)
    {
      sum=sum+arr[i];
      if(sum == x)
      {
        count++;
        break;
      }
      else if(sum > x)
        break;
      else
      {
        count++;
      }
    }
    count++;
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

#define x first
#define y second

#define INF 0x3f3f3f3f

using namespace std;

const int maxn = 1e5 + 10;

typedef long long LL;
typedef pair<int,int>PII;

int a[maxn],b[maxn],x[maxn],y[maxn];

int n,m,p;

int main(void) {
	scanf("%d%d%d",&n,&m,&p);
	for(int i = 1; i <= n; i ++) {
		scanf("%d",&a[i]);
		x[i] = a[i];
	}
	for(int i = 1; i <= m; i ++) {
		scanf("%d",&b[i]);
		y[i] = b[i];
	}
	sort(x + 1, x + 1 + n);
	sort(y + 1,y + 1 + m);
	int res = x[1] + y[1];
	int k,o,u;
	for(int i = 1; i <= p; i ++) {
		scanf("%d%d%d",&k,&o,&u);
		res = min(res,a[k] + b[o] - u);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long H, long long W, vector<string> A){
	bool flg = true;
	ll c = 0;
	rep(i, H) {
		rep(j, c) if (A[i][j] == '#') flg = false;
		for (ll j = c; j < W; j++) {
			if (A[i][j] == '.') {
				if (j == c) flg = false;
				c = j-1;
				break;
			}
			if (j == W-1) c = j;
		}
		for (ll j = c+1; j < W; j++) {
			if (A[i][j] == '#') flg = false;
		}
	}
	if (flg) cout << "Possible" << endl; else cout << "Impossible" << endl;
}

int main(){	
	long long W;
	long long H;
	scanf("%lld",&H);
	vector<string> A(H-1+1);
	scanf("%lld",&W);
	for(int i = 0 ; i <= H-1 ; i++){
		cin >> A[i];
	}
	solve(H, W, A);
	return 0;
}



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

int cnt;

void insertionSort(vector<int>& a, int n, int g)
{
    int v, j;
    
    for (int i = g; i < n; i++) {
        v = a[i];
        j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j+g] = a[j];
            cnt++;
            j -= g;
        }
        a[j+g] = v;
    }
}

int main(void)
{
    int n;
    vector<int> a, b;
    vector<int>::iterator itr;
    
    cin >> n;
    for (int i = 0; i < n; i++) { int tmp; cin >> tmp; a.push_back(tmp); }
    for (int k = 1; k <= (n > 100 ? n / 9 : n); k = 3 * k + 1) b.push_back(k);
    reverse(b.begin(), b.end());
    cout << b.size() << endl;
    for (itr = b.begin(); itr != b.end(); itr++) { if (itr != b.begin()) cout << " "; cout << *itr; }
    cout << endl;
   
    cnt = 0;
    for (itr = b.begin(); itr != b.end(); itr++) insertionSort(a, n, *itr);
    cout << cnt << endl;
    for (itr = a.begin(); itr != a.end(); itr++) cout << *itr << endl;
    
    return 0;

}



Measured memory_bytes: 6980
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct req{
	int a,b;
};

const bool operator< (const req &r1, const req &r2) {
	return (r1.b==r2.b)?r1.a>r2.a:r1.b>r2.b;
}

const bool operator> (const req &r1, const req &r2) {
	return (r1.a==r2.a)?r1.b>r2.b:r1.a>r2.a;
}

int n,m;
priority_queue<req,vector<req>,greater<req> > req_q;
priority_queue<req> calc_q;

int main() {
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int a,b;
		cin >> a >> b;
		req_q.push((req){a,b});
	}

	int ans = 0;
	while(!req_q.empty()) {
		req r = req_q.top();	req_q.pop();
		//cout << r.a << "," << r.b << endl;
		if(!calc_q.empty()) {
			req c = calc_q.top();
			//cout << "  " << c.a << "," << c.b << endl;
			if(c.b<=r.a) {
				while(!calc_q.empty()) calc_q.pop();
				ans++;
			}
		}
		calc_q.push(r);
	}
	ans++;

	cout << ans << endl;
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n, k;
    cin >> n >> k;

    vector<int64_t> v(n);
    for (auto&& vv : v) {
        cin >> vv;
    }

    int64_t ans = numeric_limits<int64_t>::min();
    for (auto l : irange(0L, n + 1)) {
        for (auto r : irange(0L, n + 1)) {
            if (l + r > n) {
                continue;
            }

            if (l + r > k) {
                continue;
            }

            vector<int64_t> items;
            items.insert(items.end(), v.begin(), v.begin() + l);
            items.insert(items.end(), v.end() - r, v.end());
            sort(items.begin(), items.end());

            int64_t s = 0;
            auto c = k - l - r;
            for (auto p : items) {
                if (p < 0 && c > 0) {
                    --c;
                    continue;
                }
                s += p;
            }

            ans = max(ans, s);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			double a = stdIn.nextDouble();
			if(a <= 48.0) {
				System.out.println("light fly");
			}
			else if(a <= 51.0) {
				System.out.println("fly");
			}
			else if(a <= 54.0) {
				System.out.println("bantam");
			}
			else if(a <= 57.0) {
				System.out.println("feather");
			}
			else if(a <= 60.0) {
				System.out.println("light");
			}
			else if(a <= 64.0) {
				System.out.println("light welter");
			}
			else if(a <= 69.0) {
				System.out.println("welter");
			}
			else if(a <= 75.0) {
				System.out.println("light middle");
			}
			else if(a <= 81.0) {
				System.out.println("middle");
			}
			else if(a <= 91.0) {
				System.out.println("light heavy");
			}
			else {
				System.out.println("heavy");
			}
			
		}
	}
}

Measured memory_bytes: 19264
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int D;
  cin >> N;
  cin >> D;
  int c=0;
  long long z;
  long long x; 
  long long y;
  for(int i=0;i<N;i++){
    cin >> x;
    cin >> y;
    z= x*x + y*y ;
    if( sqrt(z) <= D){
      c++;
  }
  }
  cout<< c ;
  return 0;
}


Measured memory_bytes: 3676
#include<iostream>
using namespace std;
int main()
{ 
     int   a1,a2,a3,sum;
     
     cin>>a1;
     cin>>a2;
     cin>>a3;
     
     sum = a1 + a2 + a3;
     if(sum>=22)
     { 
          cout<<"bust";
     }
     else 
     {
         cout<<"win";
     }
      return 0;
} 


Measured memory_bytes: 3588
#include <stdio.h>

int main(void)
{
    int a, b, c;
    int i, cnt = 0;

    scanf("%d %d %d", &a, &b, &c);

    for(i=a;i<=b;i++) {
        if(c % i == 0) cnt++;
    }

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

    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main() {
  int N, M;
  cin >> N >> M;
  rep(i, M) {
    int a;
    cin >> a;
    N -= a;
  }
  cout << max(-1, N) << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <ctime>

using namespace std;

char a[15];
vector<char> ans;

int main()
{
	while (~scanf("%s", a)) {
		int len = strlen(a);
		for (int i = 0; i < len; i++) 
		{
			if (a[i] == '1' || a[i] == '0')
			{
				ans.push_back(a[i]);
			}
			else 
			{
				if (ans.empty())continue;
				ans.pop_back();
			}
		}
		for (int i = 0; i < ans.size(); i++) 
		{
			printf("%c", ans[i]);
		}
		printf("\n");
	}

	//system("pause");
	return 0;
}

	
	




	


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MODA 1000000007 
#define MODB  998244353

//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODA;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){ //除算のみO(log mod)なので注意。割る数が小さいならnCrのinvを使うこと
		ll exp = mod - 2;
		while(exp > 0){ 
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

//さらにnCrのために、x!とその逆元を配列で持つ
const int NMAX = 500000; // 10^7くらいまではいけそう
ll fact[NMAX], finv[NMAX], inv[NMAX];

void ncr_init(){ //はじめにinitすること
	fact[0] = fact[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i = 2; i < NMAX; i++){
		fact[i] = fact[i-1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i-1]* inv[i] % mod;
	}
}
ll ncr(int n, int r){
	if(n<r) return 0;
	if(n<0 || r<0) return 0;
	return fact[n] * (finv[n-r] * finv[r] % mod) % mod;
}
//

int main() {
	modint ans = 0;
	ll tmp;
	int n; cin >> n;
	ncr_init();
	for(int i = 1; i * 3 <= n; i++){
		int now = n - i * 3;
		ans += ncr(now + i-1, i-1);
	}
	cout << ans.x << endl;
}

Measured memory_bytes: 15348
Y=str(input())#1行に沢山の数値(または文字)が並んでいる場合にリストに格納していく
X=[]
X=list(Y) #数値YをリストXに格納

n=len(X)
m=0
if n%2==0:
    for i in range (0,n):
        if X[i]==X[n-i-1]:
            m=m+1
        else:
            m=m
    a=(n-m)/2
elif n%2==1:
    for i in range(0,n):
        if X[i]==X[n-i-1]:
            m=m+1
        else:
            m=m
    a=(n-m)/2
print(int(a))


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int p[20004];
	for (i = 0; i < n; i++)
		scanf("%d", &p[i]);
	int a[20004], b[20004];
	a[0] = 1;
	for (i = 1; i < n; i++)
		a[i] = a[i - 1] + 30004;
	b[n - 1] = 1;
	for (i = n - 2; i >= 0; i--)
		b[i] = b[i + 1] + 30004;
	for (i = 0; i < n; i++)
		b[p[i] - 1] += i;
	for (i = 0; i < n - 1; i++)
		printf("%d ", a[i]);
	printf("%d\n", a[n - 1]);
	for (i = 0; i < n - 1; i++)
		printf("%d ", b[i]);
	printf("%d\n", b[n - 1]);
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define rev(countName, right, left, down) for (ll countName = right - 1; countName >= left; countName -= down)

int solve1(void)
{
    ll n, ans;

    cin >> n;

    vector<int> x(n);

    rep(i, 0, n, 1)
    {
        cin >> x[i];
    }

    rep(i, 1, 101, 1)
    {
        ll sum = 0;
        rep(k, 0, n, 1)
        {
            sum += pow(abs(x[k] - i), 2);
        }

        if (i == 1)
        {
            ans = sum;
        }
        else
        {
            ans = min(ans, sum);
        }
    }

    return ans;
}

int main(void)
{
    cout << solve1() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;  
typedef unsigned long long ull;         
typedef vector < pii > vpii;                                   	
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;
 
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
 
const int inf = 1e9, maxn = 2e5 + 48, mod = 998244353, N = 1e5 + 512;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 300;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;
 
int n, a[N], ans;

main () {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			for (int k = j + 1; k <= n; ++k)
				if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k]) {
					vi v;
					v.pb(a[i]);
					v.pb(a[j]);
					v.pb(a[k]);
					sort(all(v));
					if (v[0] + v[1] > v[2]) 
						++ans; 					
				}

	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  int64_t N;
  cin >> N;

  int64_t T[N];
  for(int64_t i=0;i<N;i++)
    cin >> T[i];

  int64_t M;
  cin >> M;

  int64_t P[M][2];

  for(int64_t i=0;i<M;i++)
    for(int64_t j=0;j<2;j++)
      cin >> P[i][j];


  int64_t _T[N];

  for(int64_t i=0;i<M;i++) {
    for(int64_t j=0;j<N;j++)
      _T[j] = T[j];

    _T[P[i][0]-1] = P[i][1];

    int64_t ans = 0;
    for(int64_t j=0;j<N;j++)
      ans += _T[j];
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
console.log((args=>{
  const [n,S] = args.trim().split`\n`;
  const N = n|0, w = Array(N+1).fill(0);
  for ( let i = N; i--;) w[i] = w[i+1] + (S[i]==='.');
  let b = 0, min = 2e5;
  for ( let i = 0; i < N; i++ ) min = Math.min(min,w[i]+b), b+=S[i]==='#';
  return `${Math.min(min,b)}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 34732
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 1; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

std::map<ll, ll> prime_factorization(ll n)
{
    std::map<ll, ll> ret;
    ll ntmp = n;
    for (ll i = 2; i * i <= n; i++)
    {
        if (ntmp % i)
            continue;
        while (ntmp % i == 0)
        {
            ret[i]++;
            ntmp /= i;
        }
    }
    if (ntmp != 1)
    {
        ret[ntmp]++;
    }
    return ret;
}

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

    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto ret = prime_factorization(g);
    cout << ret.size() + 1 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
int n,d;
int main()
{
	ios::sync_with_stdio(false);
	cin>>d>>n;
	if (n==100) n=101;
	cout<<n;
	for (int i=0;i<d;++i) cout<<"00";
	return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
#define MAX_N 300

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


  ll n,m,l;
  cin >> n >> m >> l;

  ll distance[n][n];
  REP(i, n){
    REP(j, n)
      distance[i][j] = LLINF;
  }

  ll a,b,c;
  REP(i, m){
    cin >> a >> b >> c;
    if(c <= l){
      a--;
      b--;
      distance[a][b] = distance[b][a] = c;
    }
  }

  ll q;
  cin >> q;
  vector<pll> query(q);
  REP(i, q)
    cin >> query[i].FI >> query[i].SE;


  REP(k, n){
    REP(i, n){
      REP(j, n)
        distance[i][j] = min(distance[i][j], distance[i][k]+distance[k][j]);
    }
  }

  ll fuel[n][n];
  REP(i, n){
    REP(j, n){
      if(distance[i][j] <= l)
        fuel[i][j] = 1;
      else
        fuel[i][j] = LLINF;
    }
  }

  REP(k, n){
    REP(i, n){
      REP(j, n)
        fuel[i][j] = min(fuel[i][j], fuel[i][k]+fuel[k][j]);
    }
  }

  ll s,t;
  REP(i, q){
    s = query[i].FI;
    t = query[i].SE;
    s--;
    t--;
    if(distance[s][t] != LLINF)
      cout << fuel[s][t]-1 << endl;
    else
      cout << -1 << endl;
  }

}


Measured memory_bytes: 3328
#include<stdio.h>
int main(){
  int a[100][100],i,j,k,b[100],n,m,c[100][100],d=0;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      c[i][j]=a[i][j]*b[j];
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      d=d+c[i][j];
    }
    printf("%d\n",d);
    d=0;
  }
  return 0;
}

Measured memory_bytes: 676
import java.util.*;

public class Main{
public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int []a = new int[N];
    int sum = 0;
    for(int i=0;i<N;i++) {
        a[i] = scan.nextInt();
        sum ^= a[i];
    }
    scan.close();

    for(int i=0;i<N;i++) {
        System.out.println(String.valueOf(sum ^ a[i]));
    }
    
}
}


Measured memory_bytes: 60132
#include<iostream>
#include<map>
#include<string>
#include<utility>
#include<vector>
#include<cctype>
#include<cmath>
#include<algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b; i>=a; i--)
#define all(a)  a.begin(), a.end()
#define MAX 10
typedef long long ll;
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  for(int i=a; i<=b;i++){
    if(i % k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

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

signed main(){
    int n; cin >> n;
    map<string, int> cnt;
    rep(i,n){
        string s; cin >> s;
        cnt[s]++;
    }
    int mx = 0;
    for (auto p : cnt) mx = max(mx,p.second);
    for (auto p : cnt){
        if (mx != p.second) continue;
        else cout << p.first << endl;
    }
    return 0;
}

Measured memory_bytes: 26752
A1 = input().split()
A2 = input().split()
A3 = input().split()

hit_example = [7,56,73,84,146,273,292,448]
b = 0
ans = "No"

N = int(input())
for i in range(N):
  x = int(input())
  if int(A1[0]) == x:
    b += 256
  elif int(A1[1]) == x:
    b += 128
  elif int(A1[2]) == x:
    b += 64
  elif int(A2[0]) == x:
    b += 32
  elif int(A2[1]) == x:
    b += 16
  elif int(A2[2]) == x:
    b += 8
  elif int(A3[0]) == x:
    b += 4
  elif int(A3[1]) == x:
    b += 2
  elif int(A3[2]) == x:
    b += 1

for val in hit_example:
  if val & b == val:
    ans = "Yes"
    break
    
print(ans)

Measured memory_bytes: 3064
#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>;
int main(){
  int n,m;
  cin >> n >> m;
  if(n%500 > m) {
    printf("No");
  }
  else{
    printf("Yes");
  }
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(){

	int a,b,c,s;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a>b){s=a; a=b; b=s;}
	if(b>c){s=b; b=c; c=s;}
	if(a>b){s=a; a=b; b=s;}
	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}

Measured memory_bytes: 596
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, l = MAP()
s = [STR() for _ in range(n)]
s.sort()
print(''.join(s))

Measured memory_bytes: 59628
#include<cstdio>

int l, r, m;

bool search(int A[], int n, int key) {
    l = 0;
    r = n;
    while (l < r) {
        m = (l + r) / 2;
        if (A[m] == key) return true;
        else if (key < A[m]) r = m;
        else l = m + 1;
    }
    return false;
}

int main() {
    int n, S[100000], q, key;
    int i;
    int sum = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &S[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &key);
        if (search(S, n, key)) sum++;
    }
    printf("%d\n", sum);
}


Measured memory_bytes: 2956
n=int(input())
v=[]
u=0
e=0

A=[[0 for j in range(n)]for i in range(n)]

for i in range(n):
    S=input().split()
    if S[1]!=0:
        for j in range(int(S[1])):
            A[i][int(S[2+j])-1]=1

for i in range(n):
    for j in range(n):
        if j!=n-1:
            print(A[i][j],end=" ")
        else:
            print(A[i][j],end="\n")



Measured memory_bytes: 6392
import Control.Monad
import Data.Array
main = do
  n <- readLn
  a <- listArray ((1,1),(n,n)) . concat 
    <$> replicateM n (map read . words <$> getLine) 
  print $ maybe (-1) sum $ sequence [
      if x > a!(i,j)
        then Just (a!(i,j))
        else Nothing |
      i <- [1..n], j <- [i+1..n],
      let x = minimum $ (10^9+1) : [
                a!(i,k) + a!(k,j) |
                k <- [1..n], k/=i && k/=j],
      x /= a!(i,j)]

Measured memory_bytes: 66940
K = int(input())
X = 1
temp = 7
ans = 1

if K == 7 or K == 1:
  print(ans)
  exit()

for i in range(10**6+1):
  X = X * 10 % K
  temp += X * 7
  temp %= K
  ans += 1
  if temp == 0:
    print(ans)
    break
  if i == 10**6:
    print(-1)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#if 1
    #define uint unsigned int
    #define u8 unsigned char
    #define u16 unsigned short
    #define u32 unsigned int
    #define u64 unsigned long
    #define s8 char
    #define s16 short
    #define s32 int
    #define s64 long
    #define f32 float
    #define f64 double
    #define forin(_x,_y) for(auto& _x: _y)
    #define iter(_i,_c) for(size_t _i=0; _i<_c; ++_i)
    #define rangeloop(_i,_begin,_end) for(size_t _i=_begin; _i<_end; ++_i)

    using namespace std;

    char ctoi(char a){return a-'0';}

    template<class T> T max(const vector<T> &x){return *std::max_element(x.begin(), x.end());}
    template<class T> T min(const vector<T> &x){return *std::min_element(x.begin(), x.end());}
    template<class T> size_t argmax(const vector<T> &x){auto iter = std::max_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T> size_t argmin(const vector<T> &x){auto iter = std::min_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T> T sum(const vector<T> &x){ return std::accumulate(x.begin(), x.end(),0);}
    template <class T> void sort(vector<T> &x){sort(x.begin(), x.end());}
    template <class T, class Compare> void sort(vector<T> &x, Compare comp){sort(x.begin(), x.end(),comp);}
    template<class T> void len(const vector<T> &x){return x.size();}
    template<class T> ostream& operator<<(ostream& os, const vector<T> &x){os<<'[';forin(y,x)os<<y<<" ";os<<']'; return os;}

    template<class T, size_t SIZE> T max(const array<T,SIZE> &x){return *std::max_element(x.begin(), x.end());}
    template<class T, size_t SIZE> T min(const array<T,SIZE> &x){return *std::min_element(x.begin(), x.end());}
    template<class T, size_t SIZE> size_t argmax(const array<T,SIZE> &x){auto iter = std::max_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T, size_t SIZE> size_t argmin(const array<T,SIZE> &x){auto iter = std::min_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T, size_t SIZE> T sum(const array<T,SIZE> &x){ return std::accumulate(x.begin(), x.end(),0);}
    template<class T, size_t SIZE> void sort(array<T,SIZE> &x){sort(x.begin(), x.end());}
    template<class T, size_t SIZE, class Compare> void sort(array<T,SIZE> &x, Compare comp){sort(x.begin(), x.end(),comp);}
    template<class T, size_t SIZE> ostream& operator<<(ostream& os, const array<T,SIZE> &x){os<<'[';forin(y,x)os<<y<<" ";os<<']'; return os;}

#endif

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

    uint N,M;
    cin>>N>>M;
    set<int> ACs;
    vector<int> penalties(N);
    iter(i,M){
        int p;
        string S;
        cin>>p>>S;
        auto it = ACs.find(p);
        if (it == ACs.end()) {
            //not found
            if (S=="AC") ACs.insert(p);
            else penalties[p]++;
        }
    }

    auto AC_num = ACs.size();
    auto penalty_num =0;
    forin(p, ACs){
        penalty_num+=penalties[p];
    }

    cout<<AC_num<<" "<<penalty_num;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	string s; cin >> s;
	LL repaint[2] = {0,0};
	rep(i, 0, s.length()) {
		if(i%2 == (s[i]-'0'))	repaint[0]++;
		if(i%2 != (s[i]-'0'))	repaint[1]++;
	}
	pll(min(repaint[0], repaint[1])); nl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String example = scanner.nextLine();
        if (example.endsWith("s")) {
            System.out.println(example + "es");
        } else {
            System.out.println(example + "s");
        }
    }
}


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

int main() {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if(M1 == M2){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>X(N);
  int sum = 0;
  for (int i = 0; i < N; i ++) {
    cin >> X[i];
    sum += X[i];
  }
  int kj = sum / N;
  if ((sum % N) * 2 >= N) kj ++;
  int ans = 0;
  for (int i = 0; i < N; i ++) {
    ans += ((X[i] - kj) * (X[i] - kj));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <iomanip>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

// i??\???????????´???j??§2?????\????????????????????°k??????????£????????????§???
ll dp[35][55][10];
ll E[20][35], F[20][35];

int main() {
	ll c, d, w, x;
	while(cin >> c >> d >> w >> x) {
		if(c == 0 && d == 0 && w == 0 && x == 0) break;

		memset(E, 0, sizeof(E));
		rep(i, c) {
			rep(j, d) cin >> E[i][j];
		}

		memset(F, 0, sizeof(F));
		rep(i, c) {
			rep(j, d) cin >> F[i][j];
		}

		// rep(i, c) {
		// 	rep(j, d) {
		// 		cout << "(" << E[i][j] << ", " << F[i][j] << ") ";
		// 	}
		// 	cout << endl;
		// }

		memset(dp, 0, sizeof(dp));

		rep(i, d) {
			rep(j, w + 1) {
				rep(k, x + 1) {
					dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);

					rep(s, c) {
						if(E[s][i] == 0) continue;

						ll sum = E[s][i];
						ll res = F[s][i];

						if(j + res <= w) {
							dp[i+1][j+res][k] = max(dp[i+1][j+res][k], dp[i][j][k] + sum);
						}

						REP(t, s + 1, c) {
							if(E[t][i] == 0) break;

							sum += E[t][i];
							res += F[t][i];

							if(j + res <= w && k + 1 <= x) {
								dp[i+1][j+res][k+1] = max(dp[i+1][j+res][k+1], dp[i][j][k] + sum);
							}
						}
					}
				}
			}
		}

		// rep(i, d + 1) {
		// 	cout << " ----- day : " << i << endl;
		// 	rep(j, w + 1) {
		// 		rep(k, x + 1) {
		// 			cout << setw(3) << dp[i][j][k] << " ";
		// 		}
		// 		cout << endl;
		// 	}
		// }
		
		ll ans = 0;
		// rep(i, d + 1) {
			rep(j, w + 1) {
				rep(k, x + 1) {
					ans = max(ans, dp[d][j][k]);
				}
			}
		// }

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1324
//38
#include<iostream>

using namespace std;

int main(){
  for(;;){
    char g[3][3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
	cin>>g[i][j];
	if(g[i][j]=='0')return 0;
      }
    }
    for(int i=0;i<3;i++){
      if(g[i][0]!='+'&&g[i][0]==g[i][1]&&g[i][0]==g[i][2]){
	cout<<g[i][0]<<endl;
	goto next;
      }
      if(g[0][i]!='+'&&g[0][i]==g[1][i]&&g[0][i]==g[2][i]){
	cout<<g[0][i]<<endl;
	goto next;
      }
    }
    if(g[1][1]!='+'){
      if((g[0][0]==g[1][1]&&g[2][2]==g[1][1])||(g[0][2]==g[1][1]&&g[2][0]==g[1][1])){
	cout<<g[1][1]<<endl;
	goto next;
      }
    }
    cout<<"NA"<<endl;
    continue;
  next:
    ;
  }
  return 0;
}

Measured memory_bytes: 0
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)

a.sort_by!{|e| e}

count = 0

(0...n-2).each do |i|
  (i+1...n).each do |j|
    if a[i] == a[j]
      next
    end
    (j+1...n).each do |k|
      if a[i] == a[k]
        next
      end
      if a[j] == a[k]
        next
      end
      #puts("#{i},#{j},#{k}")
      #puts("#{a[i]},#{a[j]},#{a[k]}")
      if a[i] + a[j] > a[k]
        count += 1
      end
    end
  end
end

p count

Measured memory_bytes: 14400
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define rollcall cout<<"I'm Sucu."<<endl
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll
#define Endl endl

signed main(){
    int n,m,d;
    cin >> n >> m >> d;
    double G=2;
    if(d==0)G=1;
    G*=(n-d);
    G/=n;
    G*=(m-1);
    G/=n;
    printf("%.8f\n",G);
    return 0;
}   


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

int main(){
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<ll>> cnt(501, vector<ll>(501, 0)), acc(501, vector<ll>(501, 0));
    rep(i, 0, M){
        ll l, r;
        cin >> l >> r;
        cnt[l][r-l]++;
    }
    rep(i, 0, 501){
        acc[i][0] = cnt[i][0];
        rep(j, 1, 501){
            acc[i][j] = acc[i][j-1] + cnt[i][j];
        }
    }
    rep(i, 0, Q){
        ll p, q;
        cin >> p >> q;
        ll res = 0;
        rep(i, p, q+1){
            res += acc[i][q-i];
        }
        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 4864
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if (a>b){
swap(a,b);}
 if(a>c){
swap(a,c);
} if(c<b){
swap(c,b);
}
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}



Measured memory_bytes: 3096