akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
#include <algorithm>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
  int n; cin >> n;
  while(n--) {
    stack<int> sta[2];
    vi a(10); rep(i, 10) cin >> a[i];
    bool b = true;
    rep(i, 10) {
      int x = a[i];
      if(i == 0) sta[0].push(x);
      else if(sta[1].empty()) {
        if(sta[0].top() < x) sta[0].push(x);
        else sta[1].push(x);
      } else {
        if(sta[0].top() > x && sta[1].top() > x) {
         b = false;
         break;
        } else if(sta[0].top() > sta[1].top()) {
          if(sta[0].top() < x) sta[0].push(x);
          else sta[1].push(x);
        } else {
          if(sta[1].top() < x) sta[1].push(x);
          else sta[0].push(x);
        }
      }
    }
    if(b) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> num(4, 0);
    rep (i, N) {
        char S;
        cin >> S;
        if (S == 'P') {
            num[0]++;
        } 
        if (S == 'W') {
            num[1]++;
        } 
        if (S == 'G') {
            num[2]++;
        } 
        if (S == 'Y') {
            num[3]++;
        } 
    }

    if (num[0] == 0 || num[1] == 0 || num[2] == 0 || num[3] == 0) {
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
const int N = 5010;
const LL inf = 1LL << 60;
int n, l[N], r[N], id[N];
LL f[N][N], g[2][N];
inline bool cmp(const int &a, const int &b) { return l[a] + r[a] < l[b] + r[b]; }
int main() {
	scanf("%d",&n);
	rep(i,1,n) scanf("%d%d", l + i, r + i), swap(l[i], r[i]);
	rep(i,1,n) id[i] = i; sort(id + 1, id + n + 1, cmp);
	f[0][0] = 0; rep(j,1,n) f[0][j] = inf;
	int cl = n >> 1, cr = n >> 1;
	rep(i,1,n) {
		int x = id[i];
		rep(j,0,i) {
			f[i][j] = inf;
			if (j - 1 >= 0) 
				f[i][j] = min(f[i][j], f[i - 1][j - 1] + l[x] + 1LL * (l[x] + r[x]) * (cl - j));
			f[i][j] = min(f[i][j], f[i - 1][j] + r[x] + 1LL * (l[x] + r[x]) * (cr - (i - j)));
		}
		rep(j,i+1,n) f[i][j] = inf;
	}

	if (!(n & 1)) printf("%lld\n",f[n][n / 2]);
	else {
		LL ans = inf;
		g[(n+1)&1][0] = 0; rep(j,1,n) g[(n+1)&1][j] = inf;
		dep(i,n,1) {
			int x = id[i], cur = i & 1;
			rep(j,0,n - i + 1) {
				g[cur][j] = inf;
				if (j - 1 >= 0) g[cur][j] = min(g[cur][j], g[!cur][j - 1] + l[x] + 1LL * (l[x] + r[x]) * (j - 1));
				g[cur][j] = min(g[cur][j], g[!cur][j] + r[x] + 1LL * (l[x] + r[x]) * ((n - i + 1) - j - 1));
			}
			rep(j,n-i+2,n) g[cur][j] = inf;
			int t = n >> 1;
			LL tot = 1LL * t * (l[x] + r[x]); 
			rep(j,0,t) ans = min(ans, tot + f[i - 1][j] + g[!cur][t - j]);
		}
		cout <<ans<<endl; 
	}
	return 0;
}


Measured memory_bytes: 196096
program sample
  implicit none
  integer(8) :: n,i,b
integer(8),allocatable :: a(:)
 
read(*,*) n
allocate(a(n))
do i=1,n
read(*,*) a(i)
end do
 
b=1
do i=1,n
   b=a(b)
   if(b==2)then
      write(*,*) i
      stop
   endif   
end do
 
write(*,*) -1
 
end program sample

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

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

  long long even = 0;
  long long odd = 1;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    long long even0 = even;
    long long odd0 = odd;
    even = 0;
    odd = 0;
    for (int j = a - 1; j <= a + 1; j++) {
      if (j % 2 == 0) {
        even += even0 + odd0;
      } else {
        even += even0;
        odd += odd0;
      }
    }
  }

  cout << even << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >>a>>b>>c;
    if(b-a==c-b)printa("YES");
    else printa("NO");
    return 0;
}

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

using namespace std;
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; }

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int n;
int C[2][110];
ll sum, ans;

int main(void){
	cin>>n;
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < n; j++) cin>>C[i][j];

	sum += C[0][0];
	for (int i = 0; i < n; i++) sum += C[1][i];

	ans = sum;
	for (int i = 0; i < n - 1; i++) {
		sum -= C[1][i];
		sum += C[0][i + 1];
		ans = max(ans, sum);
	}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	long long int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<long long int>as;
	vector<long long int>bs;
	vector<long long int>cs;
	for (int i = 0; i < a; i++) {
		long long int in;
		cin >> in;
		as.push_back(in);
	}
	for (int i = 0; i < b; i++) {
		long long int in;
		cin >> in;
		bs.push_back(in);
	}
	for (int i = 0; i < c; i++) {
		long long int in;
		cin >> in;
		cs.push_back(in);
	}
	sort(as.begin(), as.end(), greater<long long int>());
	sort(bs.begin(), bs.end(), greater<long long int>());
	sort(cs.begin(), cs.end(), greater<long long int>());
	vector<long long int >get;
	long long int ans = 0;
	for (int i = 0; i < x; i++) {
		get.push_back(as[i]);
		ans = ans + as[i];
	}
	for (int i = 0; i < y; i++) {
		get.push_back(bs[i]);
		ans = ans + bs[i];
	}
	sort(get.begin(), get.end());
	long long int p = cs.size();
	for (int i = 0; i < min(p, x + y); i++) {
		if (cs[i] > get[i]) {
			ans = ans + cs[i]-get[i];
		}
	}
	cout << ans;
 }


Measured memory_bytes: 4852
a,b = map(int, input().split())
s=input()
if s[b-1]=='A':
    s=s[:b-1]+'a'+s[b:]
elif s[b-1]=='B':
    s = s[:b - 1] + 'b' + s[b :]
else:
    s=s[:b-1]+'c'+s[b:]

print(s)

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template <class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template <class T> inline void amax(T & a, T const & b) { a = max(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }


ll solve(int N, ll K, vll& a) {
    ll cnt[40][2];
    memset(cnt, 0, sizeof(cnt));

    for (int i=0; i<N; ++i) {
        for (int b=0; b<40; ++b) {
            cnt[b][!!(a[i] & 1LL << b)]++;
        }
    }

    int H=1<<20;
    vll upper(H,0), lower(H,0);
    rep(i,H){
        ll u=0, l=0;
        for (int b=0; b<20; ++b){
            u += cnt[20+b][!(i & 1<<b)] << b;
            l += cnt[b][!(i & 1<<b)] << b;
        }
        upper[i] = u<<20; lower[i] = l;
    }

    int Kh = K >> 20, Kl = K % H;
    ll best = 0;
    ll l_best = 0;
    for (int l=0; l<=Kl; ++l) {
        amax(l_best, lower[l]);
    }
    ll l_best_full = l_best;
    for (int l=Kl+1; l<H; ++l) {
        amax(l_best_full, lower[l]);
    }
    ll u_best = 0;
    for (int u=0; u<Kh; ++u) {
        amax(u_best, upper[u]);
        amax(best, u_best + l_best_full);
    }
    amax(u_best, upper[Kh]);
    amax(best, u_best + l_best);

    return best;
}

int main() {
    int N; ll K; scanf("%d%lld",&N,&K);
    vll a(N); rep(i,N) scanf("%lld", &a[i]);
    cout << solve(N,K,a) << endl;
    return 0;
}


Measured memory_bytes: 17408
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

const int MAXP = 800000;
int dp[MAXP + 10];

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    ll x = 1000;
    for(int i=0; i+1<N; i++) {
        if(A[i] < A[i+1]) {
            ll d = x / A[i];
            x = (x % A[i]) + d * A[i+1];
        }
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3596
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let t: String = read();
    let p: String = read();

    let t: Vec<char> = t.chars().collect();
    let p: Vec<char> = p.chars().collect();

    let lt = t.len();
    let lp = p.len();

    for i in 0..lt {
        if i + lp > lt {
            break;
        }
        let mut j: usize = 0;
        while j < lp && t[i + j] == p[j] {
            j += 1;
        }
        if j == lp {
            println!("{}", i);
        }
    }
}



Measured memory_bytes: 5024
#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 INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;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() {
    ll L,R; cin >> L >>R;
    vector<ll> list;

    ll ans = INF;
    if(R - L > 2018) ans = 0;
    else{
        for(ll i=L; i<=R; i++){
        ll num = i % 2019;
        list.push_back(num);
        }
        rep(i, list.size()-1){
            for(int j=i+1; j<list.size(); j++){
             chmin(ans, list[i] * list[j] % 2019);
            }
        }
    }
    
    cout << ans << ln;
}


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

int x,a,b;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>x>>a>>b;
	x = x - a;
	cout<<x - b * (x / b)<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

struct SegmentTree
{
	int n;
	vector<int> v;
	
	SegmentTree(int n0) {
		n = 1;
		while (n < n0) {
			n *= 2;
		}
		v.resize(2 *n -1);
		/*
		for (int i = 0; i < a.size(); i++) {
			v[i + n - 1] = a[i];
		}
		for (int i = n - 2; i >= 0; i--) {
			v[i] = v[2 * i + 1] + v[2 * i + 2];
		}
		*/
	}

	void update(int x, int val) {
		x += n - 1;
		v[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			v[x] = v[2 * x + 1] + v[2 * x + 2];
		}
	}

	int query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) {
			r = n;
		}

		if (r <=a || b <= l) {
			return 0;
		}

		if (a <= l && r <= b) {
			return v[k];
		}

		int mid = (l + r) / 2;
		int vl = query(a, b, 2 * k + 1, l, mid);
		int vr = query(a, b, 2 * k + 2, mid, r);

		return vl + vr;

	}

};


int main() {
	int n, q;
	cin >> n >> q;
	vector<int> c(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		c[i]--;
	}
	priority_queue<tl3,vector<tl3> ,greater<tl3>> pq;

	SegmentTree st(n);
	

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		l--;
		pq.push(make_tuple(r, l, i));
	}

	vector<int> ans(q);
	vector<int> b(n,-1);
	
	int last = 0;
	while (!pq.empty()) {
		int r = get<0>(pq.top());
		int l = get<1>(pq.top());
		int qi = get<2>(pq.top());

		pq.pop();
		while (last < r) {
			int col = c[last];
			if (b[col] != -1) {
				st.update(b[col], 0);
			}
			st.update(last, 1);
			b[col] = last;
			last++;
		}

		ans[qi] = st.query(l, r);
		

	}

	for (int ai : ans) {
		cout << ai << endl;
	}

}

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

#define fi first
#define se second

const int N = 1010;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int m;
int d[N][N];
char c[N][N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n >> m;
        int dx[4] = {1, -1, 0, 0};
        int dy[4] = {0, 0, 1, -1};
        queue < pair < int, int > > q;
        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                        cin >> c[i][j];
                        if(c[i][j] == '#'){
                                q.push({i, j});
                        } else{
                                d[i][j] = 1e9;
                        }
                }
        }

        int res = 0;
        while(!q.empty()){
                int x = q.front().fi;
                int y = q.front().se;
                q.pop();
                for(int i = 0; i < 4; i++){
                        int nx = x + dx[i];
                        int ny = y + dy[i];
                        if(d[x][y] + 1 < d[nx][ny]){
                                d[nx][ny] = d[x][y] + 1;
                                q.push({nx, ny});
                        }
                }
                res = max(res, d[x][y]);
        }
        cout << res << "\n";
}


Measured memory_bytes: 10112
n = int(input())
ss = [input() for _ in range(n)]
mp = {c:0 for c in "MARCH"}
ans = 0

for i in range(n):
    if ss[i][0] in "MARCH":
        mp[ss[i][0]] += 1
for i in range(2**5):
    cnt = 0
    tmp = 1
    j = i
    for k in range(5):
        if j % 2 == 1:
            cnt += 1
            tmp *= mp["MARCH"[k]]
        j //= 2
    if cnt == 3:
        ans += tmp

print(ans)

Measured memory_bytes: 56664
#include <stdio.h>
typedef long long ll;
typedef long double ld;
#define p 2019

int main() {
	ll L, R, i, j, ans;
	scanf("%lld %lld", &L, &R);

	ans = (L * R) % p;
	for (i = L; i < R; i++) {
		for (j = L + 1; j <= R; j++) {
			if ((i * j) % p < ans)ans = i * j % p;
			if (ans == 0) { printf("0"); return 0; }
		}
	}
	printf("%lld", ans);
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(void)
{
  int d,i,j,k,l,n,ans;
  cin>>d>>n;
  ans=1;
  for(i=0;i<d;i++)
  {
    ans*=100;
  }
  if(n!=100){ans*=n;}
  else{ans=ans*(n+1);}
  cout<<ans;
  
  
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    int h, n; cin >> h >> n;
    int sum = 0;
    rep(i, n){
        int a; cin >> a;
        sum += a;
    }
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

using namespace std;

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

constexpr ll LL_MOD = 1000000009;
constexpr int I_MOD = 1000000007;
constexpr double EPS = numeric_limits<double>::epsilon();
constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> void scan(vector<T> &v);
void scan(vector<string> &v, bool isWord = true);
boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
  int n;
  cin >> n;
  auto ans = scan();

  vector<bitset<100000>> v(4);
  v[1][1] = true;
  v[2][0] = true;
  v[3][0] = true;
  v[3][1] = true;

  for (int i = 2; i < n; i++) {
    for (auto &b : v) {
      if (ans[i - 1]) {
        b[i] = (b[i - 1]) ? b[i - 2] : !b[i - 2];
      } else {
        b[i] = (b[i - 1]) ? !b[i - 2] : b[i - 2];
      }
    }
  }

  bool isAns = false;
  bitset<100000> ret;
  for (const auto &b : v) {
    bool last = false, first = false;

    if (ans[n - 1]) {
      last = b[n - 1] == (b[0] == b[n - 2]);
    } else {
      last = b[n - 1] == (b[0] != b[n - 2]);
    }

    if (ans[0]) {
      first = b[0] == (b[n - 1] == b[1]);
    } else {
      first = b[0] == (b[n - 1] != b[1]);
    }

    if (last && first) {
      isAns = true;
      ret = b;
      break;
    }
  }

  if (!isAns) {
    cout << "-1\n";
    return 0;
  }

  string str = ret.to_string();
  reverse(begin(str), end(str));
  for_each(begin(str), end(str), [](auto &c) { c = (c == '1') ? 'S' : 'W'; });
  cout << str.substr(0, n) << "\n";
  return 0;
}

template <class T> void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
int a,b,c;
cin >> a >> b >> c;
if((a<c && c<b) || ( a>c && c>b)) cout << "Yes" << endl;
else cout << "No" << endl;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b;
    cin >> a >> b;
    if (abs(a - b) % 2 == 0) {
        cout << ((a + b) / 2) << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

def sig(n):
        if n>=0:
                return n
        else:
                return 0

sum_A = sum(A)
for i in range(N):
        hoge = B[i]
        A[i+1] = sig(A[i+1]-sig((B[i]-A[i])))
        A[i] = sig((A[i]-B[i]))

sum_remain = sum(A)
print(sum_A - sum_remain)

Measured memory_bytes: 18624
#include <iostream>
#include <string>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  
  string str_a(b, '0' + a);
  string str_b(a, '0' + b);
  
  if (str_a < str_b) {
    cout << str_a << endl;
  } else {
    cout << str_b << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
typedef long long ll;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int main(){
	int t;
	ll a,b,c,d,k;
	scanf("%d",&t);
	for(;t--;){
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if(b>a||b>d){puts("No");continue;}
		if(a<c){
			if(b==d){puts("Yes");continue;}
			k=(c-a-1)/(d-b)+1;
			a+=k*(d-b);
		}
		k=(a-c+b-1)/b;
		if(a<k*b){puts("No");continue;}
		a-=k*b;
		d=gcd(d,b);
		k=(c-a)/d+1;
		puts(a+d*k<b?"No":"Yes");
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
	static long Lucas(int k){
		long Li = 2;
		long Lj = 1;
		long Lk = 0;
		if(k==1)return 1;
		if(k==2)return 3;
		for(int i=0; i<k-1; i++){
			Lk = Lj + Li;
			Li = Lj;
			Lj = Lk;
		}
		return Lk;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println(Lucas(n));
	}
}

Measured memory_bytes: 23892
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int com(const void *a,const void *b){
	if(*(double*)a > *(double*)b) return 1;
	if(*(double*)a < *(double*)b) return -1;
}

double temp(int t,int x){
	double temp;
	
	temp=(double)t-((double)x*0.006);
	
	return temp;
}

int main(){
	int i;
	int N,T,A;
	
	scanf("%d",&N);
	scanf("%d %d",&T,&A);
	
	int Hi[N];
	double Temperature[N],copy[N];
	
	for(i=0;i<N;i++){
		scanf("%d",&Hi[i]);
		Temperature[i]=fabs((double)A-temp(T,Hi[i]));
		copy[i]=Temperature[i];
	}
	
	qsort(Temperature,N,sizeof(double),com);
	
	i=0;
	while(copy[i]!=Temperature[0]){
		i++;
	}
	
	i++;
	
	printf("%d",i);
	
	return 0;
}

Measured memory_bytes: 252
N,M,C = map(int,input().split())
B = li = list(map(int,input().split()))
A = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    A.append(array)
ans = 0

for cnt in range(N):
    sum = 0
    for idx in range(M):
        sum += B[idx]*A[cnt][idx]
    if sum+C > 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 3064
mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line().split_whitespace().map(|s| s.to_string()).collect()
    }

    pub struct Reader {
        buf: VecDeque<String>
    }

    impl Reader {
        pub fn new() -> Reader {
            Reader {buf: VecDeque::new()}
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T where T: FromStr, T::Err: Debug {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn nextN<T>(&mut self, n: usize) -> Vec<T> where T: FromStr, T::Err: Debug {
            let mut vec: Vec<T> = Vec::with_capacity(n);
            for i in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}

fn main() {
    let mut reader = reader::Reader::new();
 
    let h: usize = reader.next();
    let w: usize = reader.next();
 
    let a: Vec<String> = reader.nextN(h);
 
    for i in 0..w+2 {
        print!("#");
    }
    print!("\n");
    for s in a {
        println!("#{}#", s);
    }
    for i in 0..w+2 {
        print!("#");
    }
    print!("\n");
}

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

bool erow[101];
bool ecol[101];
char table[101][101];
int main(void) {
    for (int i = 0; i < 101; i++) {
        erow[i] = true; ecol[i] = true;
    }

    int h, w; cin >> h >> w;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++) {
            char c; cin >> c;
            table[i][j] = c;
            if (c == '#')
                erow[i] = ecol[j] = false;
        }

    //cout << endl;

    for (int i = 0; i < h; i++)
        if (!erow[i]) {
            for (int j = 0; j < w; j++) {
                if (!ecol[j])
                    cout << table[i][j];
            }
            cout << endl;
        }

    return 0;
}

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

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

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

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

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

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

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

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

fn get_one_digit(n: i32) -> i32 {
    let one_digit = n % 10;
    return one_digit;
}

fn main() {
    input! {
        n: i32,
        a: i32,
        b: i32
    }
    let mut sum = 0;
    for x in 1..n+1 {
        let mut d = x.clone();
        let mut tmp_sum = 0;
        loop {
            let one_digit = get_one_digit(d);
            tmp_sum = tmp_sum + one_digit;
            d = d / 10;
            if d == 0 {
                break;
            }
        }
        if a <= tmp_sum && tmp_sum <= b {
            sum = sum + x;
        }
    }
    println!("{}", sum);
}

Measured memory_bytes: 4352
# coding: utf-8
# Your code here!
x = []
for i in range(3):
    p, q = map(int, input().split())
    x.append(p)
    x.append(q)
ans = []
for i in range(4):
    ans.append(x.count(i + 1))
ans.sort()
if ans == [1, 1, 2, 2]:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


int main(){
  
  int n;
  cin>>n;
  int h[n];
  REP(i,n){
    cin>>h[i];
  }
  int ans = 0;
  int temp = 0;
  REP(i,n){
    if(i==0){
      continue;
    }
    if(h[i-1]>=h[i]){
      temp++;
      if(i==n-1){
        ans = max(ans, temp);
      }
    }else{
      ans = max(ans, temp);
      temp = 0;
    }
  }
  
  cout<<ans<<endl;
      
  return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  string s;
  cin >> s;

  if (s.back() == 's') s += "es";
  else s += "s";
  cout << s << '\n';
}

Measured memory_bytes: 3668
import sys

def main():
    input = sys.stdin.readline
    mod = 998244353
    
    a, b, c, d = map(int, input().split())
    dp = [[0]*(d+1) for _ in range(c+1)]
    for i in range(a, c+1):
        for j in range(b, d+1):
            if i == a and j == b:
                dp[i][j] = 1
                continue
            if j == b:
                dp[i][j] = dp[i-1][j]*j%mod
                continue
            if i == a:
                dp[i][j] = dp[i][j-1]*i%mod
                continue
            dp[i][j] = (dp[i-1][j]*j+dp[i][j-1]*i+mod-dp[i-1][j-1]*(i-1)*(j-1)%mod)%mod
    print(dp[c][d])        
            

if __name__ == "__main__":
    main()

Measured memory_bytes: 138368
#include <bits/stdc++.h>
    #define ll  long long int
    #define N 100000
    #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
    #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
    #define po pop_back
    #define pb push_back
    #define lb lower_bound
    #define fi first
    #define se second
    #define debug(x) cout << #x << " = " << x << endl
    #define ub upper_bound
    #define ibs ios_base::sync_with_stdio(false)
    #define cti cin.tie(0)
    #define all(x) x.begin(),x.end()
    #define PI 3.14159265
    #define cot cout.tie(0)
    using namespace std;
      /**
        * @author :: Sawlani
        *
        */
         ll n;
         double p[3000];
         double dp[3000][3000];
        double rec(ll i,ll head)
        {

            if(i>n&&(head>(n/2)))
             return 1;
             else if(i>n)
                return 0;
            if(dp[i][head]>-1)
                return dp[i][head];
            return dp[i][head]=p[i]*rec(i+1,head+1)+(1.0-p[i])*rec(i+1,head);

        }
        int main()
        {
            cin >>  n;

            cout << fixed << setprecision(10);

           memset(dp,-1,sizeof(dp));
            f(i,1,n)  cin >> p[i];


          cout <<   rec(1,0);

        }


Measured memory_bytes: 70912
#素因数分解して列挙する関数、約数列挙ではない！
from collections import Counter
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    fct = Counter(fct)
    return fct

N = int(input())
fct = factorize(N)
ans = 0
for v in fct.values():
    n = 1
    i = 0
    while n<=v:
        i += 1
        n += i+1
    ans += i
print(ans)

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll       long long int
#define fast     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define MOD      1000000007
#define pb       push_back
#define PI 3.1415926
#define ordered_set tree<ll, null_type,less_equal<>, rb_tree_tag,tree_order_statistics_node_update> 
int32_t main() 
{ fast
	ll n;
	cin>>n;
	ll a[n+1]={0},b[n];
	for(int i=0;i<n-1;i++)
 {
 	cin>>b[i];
 	a[b[i]]++;
 }
 for(int i=1;i<=n;i++){
 	cout<<a[i]<<endl;
 }

  }

Measured memory_bytes: 6780
#include <iostream>

using namespace std;
const int N = 2e5 + 1;
long long a[N] , avail[N];
int n , q;
int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    long long sum = 0;
    for (int i = 1; i <= n; i++){
        sum = sum + a[i];
        avail[a[i]]++;
    }
    cin >> q;
    while (q--){
        int b , c , sl;
        cin >> b >> c;
        sum = sum - 1LL * b * avail[b];
        sum = sum + 1LL * c * avail[b];
        sl = avail[b];
        avail[b] = 0;
        avail[c] += sl;
        cout << sum << "\n";
    }
    return 0;
}

Measured memory_bytes: 5200
#include "bits/stdc++.h"
using namespace std;

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

	vector<int> player(n);
	for (auto &e : player) {
		cin >> e;
	}
	
	sort(player.rbegin(), player.rend());

	long long int ans = 0;
	for (int k = 1; k < n; k++) {
		ans += player[floor(k / 2)];
	}

	cout << ans << endl;
}

Measured memory_bytes: 4044
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int main() {
	int N, M;
	cin >> N >> M;
	vint city(N + 1, 0);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		city[a]++; city[b]++;
	}
	for (int i = 1; i <= N; i++) cout << city[i] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int N; cin >> N; int all, ans, a[N];
cin >> a[0]; all=a[0];
REP(i, N-1){ cin >> a[i+1]; all=all^a[i+1]; }
REP(i, N){ ans=all^a[i]; cout << ans << " "; }
}

Measured memory_bytes: 4388
import collections
import math
S = [int(i) for i in input()]
guusuu = S[1::2]
kisuu = S[0::2]
if len(S)==1:
    print(0)
else:
    if len(S)%2==0:
        if guusuu.count(1)>=kisuu.count(1):
            print(len(guusuu)-guusuu.count(1)+len(kisuu)-kisuu.count(0))
        else:
            print(len(guusuu)-guusuu.count(0)+len(kisuu)-kisuu.count(1))
    else:
        if guusuu.count(1)>=kisuu.count(1):
            print(len(guusuu)-guusuu.count(1)+len(kisuu)-kisuu.count(0))
        else:
            print(len(guusuu)-guusuu.count(0)+len(kisuu)-kisuu.count(1))

Measured memory_bytes: 5016
#include<stdio.h>

int main(){
    int a,b,c=0,i=1,j=0,k=0,set[200]={};
    
    while(scanf("%d %d",&a,&b)!=EOF){
        while(!(1<=c&&c<=9)){
            c=(a+b)/i;
            i=i*10;
            j++;
        }
        set[k]=j;
        k++;
        j=c=0;
        i=1;
    }
    
    for(i=0;i<k;i++){
        printf("%d\n",set[i]);
    }
    
    return 0;
}

Measured memory_bytes: 1800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int R = Integer.parseInt(sc.next());
        sc.close();
        
        //Rの値で条件分岐
        if(R < 1200) {
        	System.out.println("ABC");
        }else if(R < 2800) {
        	System.out.println("ARC");
        }else {
        	System.out.println("AGC");
        }
	}
}

Measured memory_bytes: 21588
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long 
using namespace std;

int gcd(int a,int b){
  if(a<b){
    int tmp=a;
    a=b;
    b=tmp;
  }
  int r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}

int main(){
  int64 n,start;
  cin>>n>>start;
  int64 x[n],dis[n];
  rep(i,n){
    cin>>x[i];
    dis[i]=abs(x[i]-start);
  }
  int64 ans=dis[0];
  rep1(i,n){
    ans=gcd(ans,dis[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> pos(n + 1);
    rep(i, n) pos[a[i]] = i + 1;
    multiset<int> s = {0, 0, n + 1, n + 1};
    int ans = 0;
    for (int p = n; p > 0; p--)
    {
        auto x = s.lower_bound(pos[p]);
        auto y = x, w = x, z = x;
        x--;
        w--, w--;
        z++;
        int q = (*x - *w) * (*y - pos[p]) + (pos[p] - *x) * (*z - *y);
        ans += p * q;
        s.insert(pos[p]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[2005][2005];
int nodes[2005][2005];
int x_edges[2005][2005];
int y_edges[2005][2005];
void gao(int arr[2005][2005], int i, int j) {
    arr[i][j] = arr[i - 1][j] + arr[i][j - 1] - arr[i - 1][ j - 1];
}
int gao2(int arr[2005][2005], int x1, int y1, int x2, int y2) {
    return arr[x2][y2] - arr[x1 - 1][y2] - arr[x2][y1 - 1] + arr[x1 - 1][y1 - 1];;
}
int main() {
    int n, m, q;
    std::ios::sync_with_stdio(false);
    cin >> n >> m >> q;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> s[i][j];
            gao(nodes, i, j);
            gao(x_edges, i , j);
            gao(y_edges, i, j);
            if (s[i][j] == '1') {
                nodes[i][j]++;
                if (s[i - 1][j] == '1') {
                    x_edges[i][j]++;
                }
                if (s[i][j - 1] == '1') {
                    y_edges[i][j]++;
                }
            }
        }
    }
    while (q--) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int ans = gao2(nodes, x1, y1, x2, y2);
        ans -= gao2(x_edges, x1 + 1, y1, x2, y2);
        ans -= gao2(y_edges, x1, y1 + 1, x2, y2);
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 52864
#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;

int main()
{
  int N; cin >> N;
  int H, ans = 0, max = -1;
  for (int i = 0; i < N; i++) {
    cin >> H;
    if (H >= max){
      ans++;
      max = H;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  string s;
  while (true) {
    getline(cin, s);
    if (s == "END OF INPUT")
      break;
    string result;
    int count = 0;
    for (int i = 0; i < s.size(); i++) {
      if (('a' <= s[i] && s[i] <= 'z') ||
          ('A' <= s[i] && s[i] <= 'Z')) {
        count++;
      } else if (count == 0 && s[i] == ' ') {
        result += '0';
      } else if (s[i] == ' ') {
        result += (char)(count+'0');
        count = 0;
      }
    }
    result += (char)(count+'0');

    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 1188