akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(){
    long long N,C;
    cin >> N >> C;
    vector< vector<long long> > D(C, vector<long long>(C));
    vector< vector<long long> > c(N, vector<long long>(N));
    long long inp;
    for(long long i=0; i<C; i++)
        for(long long k=0; k<C; k++){
            cin >> inp;
            D[i][k] = inp;
        }
    for(long long i=0; i<N; i++)
        for(long long k=0; k<N; k++){
            cin >> inp;
            c[i][k] = inp-1;
        }

    vector< vector<long long> > cost(2*N-1, vector<long long>(C));
    for(long long i = 0; i < N; i++){
        for(long long j = 0; j < C; j++){
            cost[i][j] = 0;
            for(long long k = 0; k <= i; k++){
                cost[i][j] += D[c[k][i-k]][j];
            }
        }
    }

    for(long long i = N; i < 2*N-1; i++){
        for(long long j = 0; j < C; j++){
            cost[i][j] = 0;
            for(long long k = 2*N-2; k >= i; k--){
                cost[i][j] += D[c[k-(N-1)][i-(k-(N-1))]][j];
            }
        }
    }

    //for(long long i=0; i<2*N-1; i++){
    //    for(long long k=0; k<C; k++)
    //        cout << cost[i][k] << " ";
    //    cout << endl;
    //}
    
    long long sum = 0;
    long long min = 10000000000;
    long long color[3];
    for(color[0] = 0; color[0] < C; color[0]++){

        for(color[1] = 0; color[1] < C; color[1]++){ 
            if(color[1] == color[0]) continue;

            for(color[2] = 0; color[2] < C; color[2]++){ 
                if(color[2] == color[1] || color[2] == color[0]) continue;
                sum = 0;
                for(long long n = 0; n < 2*N-1; n++){
                   sum += cost[n][color[n%3]]; 
                }
                if(sum < min)
                    min = sum;
                //cout << sum << endl;
            }
        }
    }
        
    cout << min << endl;
    return 0;    
}


Measured memory_bytes: 2560
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
const long long inf = 1LL << 61;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int N = X + Y + Z;
	vector<int> A(N), B(N), C(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i] >> C[i];
	}
	long long base = 0;
	for (int i = 0; i < N; ++i) {
		A[i] -= C[i];
		B[i] -= C[i];
		base += C[i];
	}
	vector<int> p(N);
	for (int i = 0; i < N; ++i) {
		p[i] = i;
	}
	sort(p.begin(), p.end(), [&](int i, int j) { return A[i] - B[i] > A[j] - B[j]; });
	priority_queue<int, vector<int>, greater<int> > que;
	vector<long long> dpl(N + 1, -inf), dpr(N + 1, -inf);
	long long suml = 0, sumr = 0;
	for (int i = 0; i < N; ++i) {
		que.push(A[p[i]]);
		if (i + 1 >= X + 1) {
			suml -= que.top();
			que.pop();
		}
		suml += A[p[i]];
		if (i + 1 >= X) {
			dpl[i + 1] = suml;
		}
	}
	que = priority_queue<int, vector<int>, greater<int> >();
	for (int i = N - 1; i >= 0; --i) {
		que.push(B[p[i]]);
		if (N - i >= Y + 1) {
			sumr -= que.top();
			que.pop();
		}
		sumr += B[p[i]];
		if (N - i >= Y) {
			dpr[i] = sumr;
		}
	}
	long long ans = -inf;
	for (int i = 0; i <= N; ++i) {
		ans = max(ans, dpl[i] + dpr[i]);
	}
	cout << ans + base << endl;
	return 0;
}

Measured memory_bytes: 4092
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main()  {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	S := scanner.Text()

	scanner.Scan()
	fmt.Println(scanner.Text()+S)
}

Measured memory_bytes: 1776
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int money = 100000;
		for(int i=0; i<n; i++)
		{
			money *= 1.05;
			int x = money%1000;
			if(x > 0)
			{
				money = money - x + 1000;
			}
		}
		System.out.println(money);
	}
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 302;
const int LOG = log2(T*T) + 5;

int h,w,d;

int g[T][T];
int l[T*T];
int c[T*T];
int niv[T*T];
int anc[T*T][LOG];
ll cost[T*T][LOG];

void build() {
    for(int i = 1; i <= h*w; i++) {
        if(i + d <= h*w) {
            anc[i][0] = i+d;
            cost[i][0] = abs(c[i]-c[i+d]) + abs(l[i]-l[i+d]);
            niv[i+d] = niv[i]+1;
        }
    }

    for(int j = 1; j < LOG; j++)
        for(int i = 1; i <= h*w; i++) {
            anc[i][j] = anc[anc[i][j-1]][j-1];
            cost[i][j] = cost[i][j-1] + cost[anc[i][j-1]][j-1];
        }
}

ll query(int u, int v) {
    ll ans = 0;

    for(int i = LOG-1; i >= 0; i--) {
        if(niv[u] + (1 << i) <= niv[v]) {
            ans += cost[u][i];
            u = anc[u][i];
        }
    }

    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> h >> w >> d;

    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++) {
            cin >> g[i][j];
            l[g[i][j]] = i;
            c[g[i][j]] = j;
        }

    build();
    int q; cin >> q;
    while(q--) {
        int a,b; cin >> a >> b;
        cout << query(a,b) << endl;
    }

    return 0;
}


Measured memory_bytes: 24960
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,ans=0;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  rep(i,60){
    ll tr=0;
    rep(j,n) if(v[j]>>i&1) tr++;
    ll tmp=0;
    tmp=tr*(n-tr);
    tmp%=MOD;
    rep(j,i) tmp=tmp*2%MOD;
    tmp%=MOD;
    ans+=tmp;
    ans%=MOD;
  }
  cout<<ans%MOD<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  vector<int> q(N);
  int s = 0;
  for(int i = 0; i < N; i++) {
    s += a.at(i) - 1;
    q.at(s) = i + 1;
    s -= a.at(i) - 1;
  }
  for(int i = 0; i < N; i++) {
    cout << q.at(i) << " ";
  }
}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int main(void)
{
	int i,n,m;
	scanf("%d%d",&n,&m);
	if(n%2==0)
	{
		printf("%d ",n/2);
		for(i=1;i<m;++i)printf("%d ",n);
		return 0;
	}
	vector<int>ans;
	for(i=1;i<=m;++i)ans.push_back((n+1)/2);
	for(i=1;i<=m/2;++i)
	{
		if(ans.back()==1)ans.pop_back();
		else
		{
			--ans.back();
			while(ans.size()<m)ans.push_back(n);
		}
	}
	for(i=0;i<ans.size();++i)printf("%d ",ans[i]);
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N,A,B;
  cin >> N >> A >> B;
  
  long block;
  if (A + B != 0){
  block = N / (A + B);
  }
  else{
  block = 0;
  }
  
  long amari;
  amari = N - block * (A + B);
  
  long Blast;
  if (amari < A){
    Blast = amari;
  }
  else{
    Blast = A;
  }
  
  long answer;
  answer = (block * A) + Blast;
 
  cout << answer << endl;
  
}


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

int main()
{
    int A,B;
    cin >> A >> B;
    int count=1;
    if(B==1)
    cout << "0" << endl;
    else
    {
        int total=A;
    while(B>A)
    {
        A+=total-1;
        count++;
    }
    cout << count << endl;
    }
    return 0;
}


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

using namespace std;

const int maxLen = 1e5+5;
int a[maxLen];

void solve() {
    int n;
    cin >> n;
    for (int i=0; i< n; ++i) {
        cin >> a[i];
    }
    sort(a, a+n);
    bool cnt1, cnt2;
    cnt1=cnt2 = false;
    int c,d;
    for (int i=n-1; i>=1; --i) {
        if (a[i] == a[i-1]) {
             if (!cnt1){
                 cnt1 = true;
                 i -= 1;
                 c = a[i];
             } else {
                cnt2 = true;
                d = a[i];
                break;
             }
        }
    }
    if (cnt1 && cnt2) {
        cout << (long long) c * d;
    } else {
         cout << 0;
    }

}

int main() {

	solve();
    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
#define pb push_back
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int r;
    cin >> r;
    if (r < 1200) cout << "ABC" << endl;
    else if (r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}



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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);}

void Main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    REP(i, 10) {
        REP(j, 10) {
            REP(k, 10) {
                int c = 0;
                string si = to_string(i);
                string sj = to_string(j);
                string sk = to_string(k);
                REP(i, n) {
                    if (c == 0 && s.substr(i, 1) == si) {
                        c++;
                    } else if (c == 1 && s.substr(i, 1) == sj) {
                        c++;
                    } else if (c == 2 && s.substr(i, 1) == sk) {
                        c++;
                    }
                }
                if (c == 3) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    ll N,K; cin >> N >> K; //整数NをK進法に
    int ans=1;
    ll tmp=N;
    while(K<=tmp){
        tmp/=K;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: chars,
    }
    // 1桁の場合、演算を考慮しなくてよい
    if S.len() == 1{
        println!("{}",S[0]);
    // 2桁以上の場合、演算子のパターンを全列挙して実際に計算する
    }else{
        // 演算子パターンの生成
        let mut ops:Vec<String> = vec!["+".to_string()," ".to_string()];
        let mut tmp:Vec<String> = vec![]; 
        for _ in 0..S.len()-2{
            for op in ops.iter(){
                tmp.push(format!("{}{}",op, "+"));
                tmp.push(format!("{}{}",op, " "));
            }
            ops = tmp;
            tmp = vec![];
        }
        // 計算
        let mut ans:u64 = 0;
        for op in ops{
            let mut exp = S[0].to_string();
            for (i,c) in op.chars().enumerate(){
                exp = format!("{}{}{}", exp, c, S[i+1]);
            }
            // evalしたかったけど無理っぽいので自力でやる
            exp = exp.replace(" ","");
            let nums:Vec<&str> = exp.split('+').collect();
            for num in nums{
                let x:u64 = num.parse().unwrap();
                ans += x;
            }
        }
        println!("{}",ans);
    }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    rep(i, n + 1) {
        int num = i, sum = 0;
        while (num) {
            sum += num % 10;
            num /= 10;
        }
        if (a <= sum && sum <= b) ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef int q;
typedef double w;
typedef string e;
int main(){
    e x;
    q g,z;
    cin>>z>>g>>x;
    g-=1;
    if(x.at(g)=='A')
    {x.at(g)=x.at(g)+32;
    cout<<x;}
    else if(x.at(g)=='B')
    {x.at(g)=x.at(g)+32;
    cout<<x;}
    if(x.at(g)=='C')
    {x.at(g)=x.at(g)+32;
    cout<<x;}
return 0;}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using Graph=vector<vector<int>>;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int roundup(int a,int b){return	(a-1)/b+1;}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}


signed main(){
	int n;cin>>n;
	vector<int> a(n),s(n+1,0);
	rep(i,n){
		cin>>a[i];
		s[i+1]=s[i]+a[i];
	}
	sort(All(s));
	int ans=0,k=0;
	rep(i,n){
		if(s[i]==s[i+1]) k++;
		else{
			ans+=(k+1)*k/2;
			k=0;
		}
	}
	ans+=(k+1)*k/2;
	cout<<ans<<endl;
}


Measured memory_bytes: 3328
def main():
    H, W = map(int, input().split())
    S = tuple(input() for _ in [0] * H)

    sq = ['0' * (W + 2)]
    apnd = sq.append
    for s in S:
        apnd('0' + s + '0')
    else:
        apnd('0' * (W + 2))

    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if sq[i][j] == '.':
                n = 0
                if sq[i-1][j-1] in '#': n += 1
                if sq[i-1][j] in '#': n += 1
                if sq[i-1][j+1] in '#': n += 1
                if sq[i][j-1] in '#': n += 1
                if sq[i][j+1] in '#': n += 1
                if sq[i+1][j-1] in '#': n += 1
                if sq[i+1][j] in '#': n += 1
                if sq[i+1][j+1] in '#': n += 1
                print(n, end='')
            else:
                print(sq[i][j], end='')
        print()

main()


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

ll solve(ll w[], ll v[], ll n, ll W, ll V){
    ll dp[n+1][V+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=V;j++){
            if(i==0 || j==0){
                dp[i][j] = (j==0)?0:INT_MAX;
            }
            else{
                if(j>=v[i-1]){
                    dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i-1]]+w[i-1]);
                }
                else{
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
    }

    long _max=0;
    for(long  i=0;i<=n;i++){
        for(long j=0;j<=V;j++){
            if(dp[i][j]<=W){
                _max = max(_max, j);
            }
        }
    }
    return _max;
}


int main() {
    ll n, W, V=0;
    cin >> n>>W;
    ll v[n], w[n];
    for(ll i=0;i<n;i++){
        cin >> w[i] >> v[i];
        V+=v[i];
    }
    cout << solve(w, v, n, W, V)<< endl;
    return 0;    
}


Measured memory_bytes: 82488
#include<cstdio>
#include<cstring>
using namespace std;
const int MXN=100010;

int n,a,b;
char s[MXN];

int main()
{
  scanf("%d%d%d%s",&n,&a,&b,s);
  for(int i=0;i!=n;++i)
    switch(s[i])
      {
      case 'a':
	if(a>0)
	  {
	    --a;
	    printf("Yes\n");
	  }
	else if(b>0)
	  {
	    --b;
	    printf("Yes\n");
	  }
	else
	  printf("No\n");
	break;

      case 'b':
	if(b>0)
	  {
	    --b;
	    printf("Yes\n");
	  }
	else
	  printf("No\n");
	break;

      case 'c':
	printf("No\n");
      }
}


Measured memory_bytes: 640
def rotate(dice,d):
    if d == "N":
        temp = dice[0]
        dice[0] = dice[1]
        dice[1] = dice[5]
        dice[5] = dice[4]
        dice[4] = temp
    elif d == "E":
        temp = dice[0]
        dice[0] = dice[3]
        dice[3] = dice[5]
        dice[5] = dice[2]
        dice[2] = temp
    elif d == "W":
        temp = dice[0]
        dice[0] = dice[2]
        dice[2] = dice[5]
        dice[5] = dice[3]
        dice[3] = temp
    elif d == "S":
        temp = dice[0]
        dice[0] = dice[4]
        dice[4] = dice[5]
        dice[5] = dice[1]
        dice[1] = temp
    return dice

dice = input().split()
dArr = list(input())
for i in range(len(dArr)):
    dice = rotate(dice,dArr[i])
print(dice[0])

Measured memory_bytes: 7552
#include <iostream>

using namespace std;

int main()
{
    int k;
    int n;
    cin >> k >> n;
    
	int arr[n];

    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    
	int total = arr[n-1] - arr[0];
  
	for(int i=1;i<n;i++){
	   total = min(total,arr[i-1] + k - arr[i]);
	}
	cout<<total;
}


Measured memory_bytes: 1024
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let N: usize = sc.read();
    let H: usize = sc.read();
    let W: usize = sc.read();
    println!("{}", (N - W + 1) * (N - H + 1));
}

Measured memory_bytes: 2056
import itertools

N = int(input())
M = list(map(int, input().split()))

count = 0
p = itertools.combinations(M, 3)
for l in p:
  a = l[0]
  b = l[1]
  c = l[2]
  if ((a == b) or (b == c) or (c == a)):
    continue
  if ((a + b > c) and (b + c > a) and (c + a > ｂ)):
    count += 1
print(count)

Measured memory_bytes: 9376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  
  int count = 0;
  vector<int> A(M);
  for (int i = 0; i < M; i++) {
    cin >> A.at(i);
    count += A.at(i);
	}
  
  if (count <= N)
    cout << N - count << endl;
  else
    cout << -1 <<endl;
}

Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EYutori solver = new EYutori();
        solver.solve(1, in, out);
        out.close();
    }

    static class EYutori {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int k = in.nextInt();
            int c = in.nextInt();
            char[] s = in.next().toCharArray();
            ArrayList<Integer> saisoku = new ArrayList<>();
            ArrayList<Integer> saichi = new ArrayList<>();
            int time = -1;
            for (int i = 0; i < n; i++) {
                if (s[i] == 'o' && time < i) {
                    time = i + c;
                    saisoku.add(i + 1);
                }
                if (saisoku.size() == k) {
                    break;
                }
            }

            time = 10000000;
            for (int i = n - 1; i >= 0; i--) {
                if (s[i] == 'o' && i + c < time) {
                    time = i;
                    saichi.add(i + 1);
                }
                if (saichi.size() == k) {
                    break;
                }
            }

            //out.println(saisoku);
            saichi.sort(Comparator.naturalOrder());

            for (int i = 0; i < saisoku.size(); i++) {
                int x = saisoku.get(i);
                int y = saichi.get(i);
                if (x == y) {
                    out.println(x);
                }
            }
            //out.println(saichi);

        }

    }
}



Measured memory_bytes: 48348
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int N) {
    int W, H; cin >> W >> H;
    vector<vector<bool>> mp(W, vector<bool>(H, false));
    REP(i, N) {
        int x, y; cin >> x >> y;
        mp[x - 1][y - 1] = true;
    }
    int s, t; cin >> s >> t;
    int ans = 0;
    REP(x, W - s + 1) {
        REP(y, H - t + 1) {
            int cnt = 0;
            REP(i, s) REP(j, t) {
                cnt += mp[x + i][y + j];
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    while (cin >> n, n) {
        solve(n);
        //return 0;
    }
}

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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/

int main()
{

    ll n, s=0, ans=-inf;
    string ss;
    cin >> n;
    cin >> ss;
    ans=max(ans,s);
    for(ll i=0;i<ss.size();i++)
    {

        if(ss[i]=='I') s++;
        else s--;
        ans=max(ans,s);
    }
    ans=max(ans,s);
    cout << ans;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

#2345
#import numpy as np

from itertools import combinations

def main():
	n=II()

	for i in range(10**3):
		if i*(i+1)==2*n:
			break
	else:
		print("No")
		exit(0)
	k=i+1

	ans=[[] for _ in range(k)]

	for i,a in enumerate(combinations(range(k),2)):
		ans[a[0]].append(i+1)
		ans[a[1]].append(i+1)
	#print(ans)

	print("Yes")
	print(k)
	for a in ans:
		print(k-1,*a)



if __name__ == "__main__":
	main()

Measured memory_bytes: 12624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans = 0;
    rep(i, n) {
        ll now = 1;
        now *= lower_bound(all(a), b[i]) - a.begin();
        now *= n - (upper_bound(all(c), b[i]) - c.begin());
        ans += now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>

int main(void){
	
	int high[10],i,j,k,max1=0,max2=0,max3=0;
	
	for(i=0;i<10;i++)
		scanf("%d",&high[i]);
		
	for(i=0;i<10;i++){
		if(max1<high[i])
			max1=high[i];
	}
	
	i=j;
	
	while(max1!=high[j])
		j++;
	
	for(i=0;i<10;i++){
		if(max2<high[i] && i!=j){
			max2=high[i];
		}
	}
	
	k=0;
	
	while(max2!=high[k])
		k++;
		
	for(i=0;i<10;i++){
		if(max3<high[i] && i!=j && i!=k){
			max3=high[i];
		}
	}
			
	printf("%d\n%d\n%d\n",max1,max2,max3);
	
	return 0;
	
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ar              array
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("ip1.txt", "r", stdin);
	freopen("op1.txt", "w", stdout);
#endif
}
bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b);
int gcd(int a, int b) ;
int prime(int n);
int power(int x, int y);
int lcm(int a, int b);
int32_t main()
{
	k_007();
	int n, r;
	cin >> n >> r;
	if (n >= 10)
	{
		cout << r << endl;
	}
	else
	{
		cout << r + 100 * (10 - n) << endl;
	}
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

Measured memory_bytes: 3696
#include<iostream>
using namespace std;
int main() {
	int N;
	long long int count = 0;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			count = count +i;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main(){
  int N, tmp;
  bool f = true;
  cin >> N;
  for (int i=0; i<N; i++){
    cin >> tmp;
    if (tmp % 2 == 0 && ((tmp % 3 != 0) && (tmp % 5 != 0))){
      f = false;
      break;
    }
    
  }
  
  cout << (f ? "APPROVED" : "DENIED") << endl;
  return 0;
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cs_A = [0] * (N+1)
    cs_B = [0] * (M+1)
    for i in range(N):
        cs_A[i+1] = cs_A[i] + A[i]
    for i in range(M):
        cs_B[i+1] = cs_B[i] + B[i]

    ans = 0
    for i in range(N+1):
        if cs_A[i] > K:
            break
        j = bisect_left(cs_B, K - cs_A[i] + 1) - 1
        if j == M+1:
            j = M
        ans = max(i+j, ans)
    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;

ll s;

ll l(ll n)
{
    ll ans = 0;
    while (n)
    {
        ans++;
        n /= 10;
    }
    return ans - 1;
}

ll solve(ll n)
{
    ll ans = n, mod = 10;
    while (mod <= n)
    {
        ans += (1 << l(n/mod))*(n % mod) + solve(n/mod);
        mod *= 10;
    }
    return ans;
}

int main()
{
    cin >> s;
    cout << solve(s) << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::HashMap;

use std::cmp::{max, min};

fn main() {
    let k: u64 = read();
    if k % 5 == 0 || k % 2 == 0 {
        println!("-1");
        return;
    }

    let mut v = 0;
    let mut cnt = 0;
    let mut init = true;
    while v != 0 || init {
        v = (v * 10 + 7) % k;
        cnt += 1;
        init = false;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2152
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	
	private static final Scanner sc = new Scanner(System.in);
	
	public static void main(String... args) {
		new Main().run();
	}
	
	public void run() {
		List<Time> ts = new ArrayList<Time>();
		final int N = sc.nextInt();

		for (int i = 0; i < N; i++) {
			ts.add(new Time(sc.nextInt(), sc.nextInt()));
		}
		
		final int M = sc.nextInt();
		for (int i = 0; i < M; i++) {
			ts.add(new Time(sc.nextInt(), sc.nextInt()));
		}
		
		Collections.sort(ts);
		Set<Time> tset = new TreeSet<Time>(ts); 
		Object[] tss = tset.toArray();
		for (int i = 0; i < tss.length - 1; i++) {
			System.out.print(tss[i] + " ");
		}

		System.out.println(tss[tss.length - 1]);
	}
	
	public class Time implements Comparable<Time> {
		int h, m;
		
		Time(int h, int m) {
			this.h = h;
			this.m = m;
		}

		@Override
		public String toString() {
			return String.format("%d:%02d", this.h, this.m);
		}
		
		@Override
		public int compareTo(Time t) {
			return (this.h * 60 + this.m) - (t.h * 60 + t.m);
		}
	}
}

Measured memory_bytes: 20984
import sys
input=sys.stdin.readline

N,D,A=map(int,input().split())
L=[]
for i in range(N):
    x,h=map(int,input().split())
    L.append([x,h])
L.sort()

import math

ans=0
S=0
P=0
RL=[0]
RC=[0]
cnt=0
for i in range(N):
    for j in range(P,len(RL)):
        if RL[P]<L[i][0]:
            cnt+=RC[P]
            P+=1
        else:
            break
    if L[i][1]-S+cnt>0:
        ans+=math.ceil((L[i][1]-S+cnt)/A)
        
        RL+=[L[i][0]+2*D]
        RC+=[math.ceil((L[i][1]-S+cnt)/A)*A]
        S+=math.ceil((L[i][1]-S+cnt)/A)*A
    #print(i,ans,P,RL,RC,S,cnt)
print(ans)

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

#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

# define ll long long
# define ull unsigned ll

# define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define mod 1000000007
using namespace std;
typedef pair<int, int> pi;

//////////////////////////////////////////////////////////////
//const ll INF = 0xFFFFFFFFFFFFFFFL;
//clock_t time_p = clock();
//
//void abhigyan10() {
//    time_p = clock() - time_p;
//    cerr << "Time Taken : " << (float) (time_p) / CLOCKS_PER_SEC << "\n";
//}
//
//ll seed;
//mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
//
//inline ll rnd(ll l = 0, ll r = INF) {
//    return uniform_int_distribution<ll>(l, r)(rng);
//}
//
//#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
//#define preciset(x) cout<<setprecision(x)<<fixed;
//////////////////////////////////////////////////////////

ll pow(ll base, ll power) {
    ll result = 1;     // Initialize result

    base = base % mod; // Update base if it is more than or
    // equal to p

    if (base == 0)
        return 0; // In case base is divisible by p;

    while (power > 0) {
        // If power is odd, multiply base with result
        if (power & 1)
            result = (result * base) % mod;

        // power must be even now
        power = power >> 1; // power = power/2
        base = (base * base) % mod;
    }
    return result;
}

void forces() {
    int n, k;
    cin >> n >> k;

    map<ll, ll> myMap;
    for (int i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        ++myMap[(x % k)];
    }

    for (auto x: myMap)
        cout << x.first << " " << x.second << '\n';


    cout << '\n';

}

void atCoder() {
    int n;
    cin >> n;
    map<string, ll> arr;

    arr["AC"] = 0;
    arr["WA"] = 0;
    arr["TLE"] = 0;
    arr["AC"] = 0;

    for (int i = 0; i < n; ++i) {
        string x;
        cin >> x;
        ++arr[x];
    }

    cout << "AC x " << arr["AC"] << '\n';
    cout << "WA x " << arr["WA"] << '\n';
    cout << "TLE x " << arr["TLE"] << '\n';
    cout << "RE x " << arr["RE"] << '\n';


}

int main() {
    fastio;

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    freopen("error.txt", "w", stderr);
#endif

    int test = 1;
//    cin >> test;

    while (test--) {
//        forces();
        atCoder();
    }

    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>

#define MOD 1000000007LL

using namespace std;

int main() {
    string S;
    cin >> S;
    while (S.size() % 3 != 0) {
        S = "0" + S;
    }
    reverse(S.begin(), S.end());
    long long mod[13] = {1};
    int sgn = 1;
    while (!S.empty()) {
        string s = S.substr(0, 3);
        reverse(s.begin(), s.end());
        S = S.substr(3);
        bool q[3];
        for (int i = 0; i < 3; ++i) {
            if (s[i] == '?') q[i] = true;
            else q[i] = false;
        }
        long long a[3] = {};
        long long add[13] = {};
        for (int i = 0; i < 10; ++i) {
            if (q[0]) a[0] = i;
            else a[0] = s[0] - '0';
            for (int j = 0; j < 10; ++j) {
                if (q[1]) a[1] = j;
                else a[1] = s[1] - '0';
                for (int k = 0; k < 10; ++k) {
                    if (q[2]) a[2] = k;
                    else a[2] = s[2] - '0';
                    add[(100 * a[0] + 10 * a[1] + a[2]) % 13]++;
                    add[(100 * a[0] + 10 * a[1] + a[2]) % 13] %= MOD;
                    if (!q[2]) break;
                }
                if (!q[1]) break;
            }
            if (!q[0]) break;
        }
        long long newmod[13] = {};
        for (int i = 0; i < 13; ++i) {
            for (int j = 0; j < 13; ++j) {
                if (sgn > 0) {
                    newmod[(i + j) % 13] += mod[i] * add[j];
                    newmod[(i + j) % 13] %= MOD;
                } else {
                    int m = ((i - j) % 13 + 13) % 13;
                    newmod[m] += mod[i] * add[j];
                    newmod[m] %= MOD;
                }
            }
        }
        for (int i = 0; i < 13; ++i) {
            mod[i] = newmod[i];
        }
        sgn *= -1;
    }
    cout << mod[5] << endl;

    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N, M;
    cin >> N >> M;

    vector<ll > a(M, 0);
    vector<ll > b(M, 0);

    for(ll i = 0; i < M; i++) cin >> a[i] >> b[i];

    for(ll i = 0; i < N; i++){
        ll cn = 0;
        for(ll j = 0; j < M; j++){
            if(i == a[j]-1) cn++;
            if(i == b[j]-1) cn++;
        }         
        cout << cn << endl;
    } 

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
#define si scanf
#define so printf
#define N 100100
#define INF  
template<typename TP>inline bool rd(TP& r)
{
	r=0;
	char tmp=getchar();
	while(tmp<'0'||tmp>'9')
	{
		if(tmp==EOF)
			return 0;
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		r=(r<<3)+(r<<1)+tmp-'0';
		tmp=getchar();
	}
	return 1;
	
} 
int n;
long long a[N],b[N],xr,dif,got;
int ac[N],tot;
int get(int x)
{
	if(ac[x]==x)
		return x;
	ac[x]=get(ac[x]);
	return ac[x];
}
map<long long,int> ns;
bool nodif;
int vis[N]; 
int main()
{
	rd(n);
	for(int i=1;i<=n;++i)
	{
		rd(a[i]),xr^=a[i];
		if(ns.count(a[i])==0)
			ns[a[i]]=++tot;
			
	}
	a[n+1]=xr;
	if(ns.count(a[n+1])==0)
		ns[a[n+1]]=++tot;
	for(int i=1;i<=n;++i)
	{
		rd(b[i]);
		if(ns.count(b[i])==0)
			ns[b[i]]=++tot;
	}
	for(int i=1;i<=tot;++i)
		ac[i]=i;
	nodif=1;
	for(int i=1;i<=n;++i)
		if(a[i]!=b[i])
		{
			++dif;
			nodif=0;
			ac[get(ns[a[i]])]=get(ns[b[i]]);
			if(b[i]==xr&&!got)
			{
				--dif;
				got=1;
			}
		}
	if(nodif)
	{
		so("0\n");
		return 0;
	}
	sort(a+1,a+n+1+1);
	sort(b+1,b+n+1);
	int j=1,jumped=0;
	for(int i=1;i<=n;++i,++j)
		if(a[j]!=b[i]&&a[j+1]==b[i]&&jumped==0)
		{
			jumped=1;
			++j;
		}
		else if(a[j]!=b[i])
		{
			so("-1\n");
			return 0;
		}
	for(int i=1;i<=tot;++i)
		if(!vis[get(i)]&&ac[i]!=i)
			++dif,vis[get(i)]=1;
	so("%d\n",dif);
	return 0;
} 

Measured memory_bytes: 10112
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	while(true)
	{
		int d[3] = {0};
		vint v(5);
		rep(i, 5)
		{
			cin >> v[i];
			if(!v[i]) return 0;
			d[--v[i]]++;
		}

		rep(i, 5)
		{
			if((d[(v[i] + 1) % 3] && d[(v[i] + 2) % 3]) || (!d[(v[i] + 1) % 3] && !d[(v[i] + 2) % 3]))
				cout << 3 << endl;
			else if(d[(v[i] + 1) % 3])
				cout << 1 << endl;
			else
				cout << 2 << endl;
		}
	}
}

Measured memory_bytes: 0