akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;

void solve()
{
    string s;
    cin >> s;
    int maxi = 0, curr = 0;
    for(char c :s)
    {

        if(c == 'R')
        {
            curr++;
            maxi = max(curr, maxi);
        }
        else
        {
            curr = 0;
        }
    }
    cout << maxi ;
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    solve();
    return 0;
}


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

using namespace std;

int main() {

	long w,a,b;

	cin >> w >> a >> b;

	if (a + w < b) {
		cout << abs(b - a - w) << endl;
	}
	if (a + w >= b && b + w >= a) {
		cout << 0 << endl;
	}
	if (b + w < a) {
		cout << abs(a - b - w) << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

using namespace std;


int main()
{
    int64_t n,k;
    cin >> n >> k;
    
    for(;;){
        if(n == k){
            cout << "0\n";
            return 0;
        }
        else if(n < k){
            cout << min(n, k-n) << '\n';
            return 0;
        }
        else {
            n = n % k;
        }
    }
    return 0;
    /*
    n
    |n-k|
    ||n-k|-k|
    |||n-k|-k|-k|
    
    n == ||n-k|-k|
    
    n = k　のとき  
      k,0,k,0,...
    
    n < k のとき
      n, k-n, n, k-n, ...
 
    n > k のとき
    
    n, n-k
    */
    
    return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

class UnionFind {
public:
    vector<int> par;
    UnionFind(int n) {
        par.resize(n);
        REP (i, 0, n) par[i] = i;
    }
    int Find(int a) {
        return (a == par[a] ? a : par[a] = Find(par[a]));
    }
    bool Union(int a, int b) {
        a = Find(a);
        b = Find(b);
        if (a == b) return false;
        par[a] = b;
        return true;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> v(N);
    REP (i, 0, N) {
        int K;
        cin >> K;
        v[i].resize(K);
        REP (j, 0, K) {
            cin >> v[i][j];
            v[i][j]--;
        }
    }
    UnionFind uf(M);
    for (auto &t : v) {
        REP (i, 1, t.size()) {
            uf.Union(t[0], t[i]);
        }
    }
    set<int> s;
    REP (i, 0, N) {
        s.insert(uf.Find(v[i][0]));
    }
    cout << (s.size() == 1 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        int x=((s[i]-'A')+n)%26;
        char c=x+'A';
        cout<<c;
    }
    return 0;
}
    

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> ps(N);
    vector<int> qs(N);    
    for(int i = 0; i < N; i++)
    {
        cin >> ps.at(i);
    }
    for(int i = 0; i < N; i++)
    {
        cin >> qs.at(i);
    }
    int porder = 1;
    int qorder = 1;
    vector<int> facs(N + 1);
    facs.at(1) = 1;
    for(int i = 2; i <= N; i++){
        facs.at(i) = facs.at(i - 1) * i;
    }
    vector<bool> pused(N + 1);
    for(int i = 0; i < N; i++)
    {
        int count = 0;
        for(int j = 1; j < ps.at(i); j++){
            if(!pused.at(j)){
                count++;
            }
        }
        pused.at(ps.at(i)) = true;
        porder += count * facs.at(N - i - 1);
    }
    vector<bool> qused(N + 1);
    for(int i = 0; i < N; i++)
    {
        int count = 0;
        for(int j = 1; j < qs.at(i); j++){
            if(!qused.at(j)){
                count++;
            }
        }
        qused.at(qs.at(i)) = true;
        qorder += count * facs.at(N - i - 1);
    }
    cout << abs(porder - qorder) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
const long long MAXN=100005;
long long a[MAXN],b[MAXN],n,cnta,cntb;
int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		cnta+=a[i];
	}
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&b[i]);
		cntb+=b[i];
		if(b[i]>a[i]&&((b[i]-a[i])%2!=0))
		{
			cnta+=2;
			cntb++;
		}
	}
	for(long long i=1;i<=n;i++)
	{
		if(a[i]>b[i])
		{
			cnta+=a[i]-b[i];
		}
	}
	if(cnta>cntb)
		printf("No\n");
	else
		printf("Yes\n");
}

Measured memory_bytes: 256
n = int(input())
cnt = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

for _ in range(n):
  b, f, r, v = map(int, input().split())
  cnt[b-1][f-1][r-1] += v

for i in range(4):
  for j in range(3):
    print(' '+' '.join(map(str, cnt[i][j])))

  if i != 3:
    print('#'*20)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#include <vector>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
struct edge{
	ll x;
	ll y;
	bool operator<(const edge& e)const{
		return x+y<e.x+e.y;
	}
	bool operator>(const edge& e)const{
		return x+y>e.x+e.y;
	}


};
struct road{ll cost;int to;};
int n;
ll k;
ll b[270005]={};
vector<ll> a;
vector<P> pa;
ll biget(int i){
	ll res=0;
	while(i>0){
		res+=b[i];
		i=i&(i-1);
	}
	return res;
}
void biadd(int s){
	while(s<=n+1){
		b[s]++;
		s+=s&-s;
	}
}
ll c[200005];

int main() {
	cin>>n>>k;
	a.resize(n+1);
	a[0]=0;
	pa.push_back(P(0,0));
	rep(i,1,n+1){
		cin>>a[i];
		a[i]+=a[i-1];
		pa.push_back(P(a[i]-i*k,i));
	}
	sort(pa.begin(),pa.end());
	ll ans=0;
	rep(i,0,n+1){
		c[pa[i].second]=i;
	}
	rep(i,0,n+1){
//		cout<<c[i]<<endl;
		ans+=biget(c[i]+1);
		biadd(c[i]+1);
//		cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 9068
import std.stdio, std.string, std.conv;
import std.math;

void main() {
    auto input = getStdin!(string[]);
    foreach (line; input) {
    	auto c = line.split(" ");
    	int a = c[0].to!(int);
    	int b = c[2].to!(int);
    	string op = c[1];
    	if (op == "?") break;
    	switch (op) {
    		case "+":
    			writefln("%d", a + b); break;
    		case "-":
    			writefln("%d", a - b); break;
    		case "*":
    			writefln("%d", a * b); break;
    		case "/":
    			writefln("%d", a / b); break;
    		default:
    			break;
    	}
    }
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}

Measured memory_bytes: 2504
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    double r; cin >> r;
    double ans = 2 * r * M_PI;
    cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 3776
#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);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int total=0;
    for(int i=0;i<N;i++){
        if(i%2==0){
            total+=a.at(i);
        }
        else{
            total-=a.at(i);
        }
    }
    cout << total <<endl;
}

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

const int INF = 1e9;
int A,B,C;

int dfs(vector<int> &l, int n, int a=0, int b=0, int c=0){
	int res = INF;
	int mpa = 0, mpb = 0, mpc = 0;
	if(a>0) mpa = 10;
	if(b>0) mpb = 10;
	if(c>0) mpc = 10;
	
	if(n < l.size()){
		res = min(res, dfs(l, n+1, a+l[n], b, c) + mpa);
		res = min(res, dfs(l, n+1, a, b+l[n], c) + mpb);
		res = min(res, dfs(l, n+1, a, b, c+l[n]) + mpc);
		res = min(res, dfs(l, n+1, a, b, c));
		return res;
	}
	else{
		if(a==0 || b==0 || c==0) return INF;
		return abs(a-A) + abs(b-B) + abs(c-C);
	}
}
int main(){
	int n;
	cin >> n >> A >> B >> C;
	vector<int> l(n);
	rep(i,n) cin >> l[i];
	
	cout << dfs(l,0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>

int main(){
  char ch;

  while(1){
    scanf("%c", &ch);
    if(isalpha(ch)){
      if(islower(ch)) printf("%c", toupper(ch));
      else printf("%c", tolower(ch));
     }else printf("%c", ch);
    if(ch=='\n')break;
  }
  return 0;
}



Measured memory_bytes: 2572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] a = new int[n];
		long sum = 0,x = 0,y = 0,ans = Long.MAX_VALUE;
		for(int i=0;i<n;i++){
			a[i] = scanner.nextInt();
			sum += a[i];
		}
		for(int i=0;i<n-1;i++){
			x += a[i];
			y = sum - x;
			long z = Math.abs(x - y);
			ans = Math.min(ans, z);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 66452
#include<cstdio>
#include<algorithm>
using namespace std;const int N=1e5+10;typedef long long ll;const ll mod=1e9+7;
int cnt[N];char mde[N];int n;
int main()
{
	scanf("%d",&n);
	scanf("%s",mde+1);
	for(int i=1;i<=n;i++)
		cnt[mde[i]-'a'+1]++;
	ll ans=1;
	for(int i=1;i<=26;i++)
		(ans*=cnt[i]+1)%=mod;
	printf("%lld",(ans+mod-1)%mod);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
 
const ll C_MAX = (ll)1e18;
 
int main()
{
	ll A, ret, ib;
	long double B;
 
	cin >> A >> B;
	ib = B * 100 + 0.5;
	A *= ib;
	A /= 100;
 
	cout << A << endl;
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  bool flag = true;
  if(s[0] != 'A')flag = false;
  int index=1, c_count = 0;
  while(index < s.size()){
    char c = s[index];
    //cout << (int)c << endl;
    if((index >= 2 && index < s.size() -1)){
      if(c == 'C'){
        c_count++;
      }else if(c <97 || c > 122){
        flag = false;
      }
    }else if(c <97 || c > 122){
        flag = false;
    }
    index++;
  }
  if(flag && c_count == 1)cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  double x1, x2, x3, x4, y1, y2, y3, y4;
  scanf("%d", &n);
  while(n--){
    scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
    if((x1 - x2) * (y3 - y4) == (y1 - y2) * (x3 - x4))puts("YES");
    else puts("NO");
  }
  return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define tests(t) int t; cin >> t; while(t--)
#define ll long long
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 200005
using namespace std;

int main()
{
   	int n;
    cin>>n;
    int arr[n+1],dp[n+1];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    //dp[2]=min(abs(arr[2]-arr[0]),abs(arr[2]-abs[1]));
    for(int i=2;i<n;i++)
    {
    	dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	
    cout<<dp[n-1]<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
int p = 998244353;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
int kai_size = 400001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int RE() {
	vel v(3, 2);
	return v.at(4);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, kai_size) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, kai_size) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
int per(int n, int r) {
	int ans = kai[n] * ink[n - r];
	ans %= p;
	return ans;
}
signed main() {
	int n; cin >> n;
	vel r(n);
	vel l(n);
	V<pin> list_l(n);
	V<pin> list_r(n);
	rep(i, n) {
		cin >> l[i] >> r[i];
		list_l[i] = mkp(l[i], i);
		list_r[i] = mkp(r[i], i);
	}
	sor(list_l);
	auto itrl = list_l.begin();
	auto itrr = list_r.begin();
	sor(list_r);
	reverse(list_l.begin(), list_l.end());
	veb is_use(n,false);
	int ret = 0;
	bool is_nex_r = true;
	int now_pot = 0;
	int ans0 = 0;
	rep(i, n) {
		if (is_nex_r) {
			while (is_use[(*itrr).second]) {
				itrr++;
			}
			is_use[(*itrr).second] = true;
			int num = (*itrr).second;
			if (now_pot < l[num]) { ans0 += l[num] - now_pot; now_pot = l[num]; }
			else if (r[num] < now_pot) { ans0 += now_pot - r[num]; now_pot = r[num]; }
			is_nex_r = false;
		}
		else{
			while (is_use[(*itrl).second]) {
				itrl++;
			}
			is_use[(*itrl).second] = true;
			int num = (*itrl).second;
			if (now_pot < l[num]) { ans0 += l[num] - now_pot; now_pot = l[num]; }
			else if (r[num] < now_pot) { ans0 += now_pot - r[num]; now_pot = r[num]; }
			is_nex_r = true;
		}
	}
	ans0 += abs(now_pot);
	ret = ans0;
	itrl = list_l.begin();
	itrr = list_r.begin();
	is_use = veb(n, false);
	is_nex_r = false;
	now_pot = 0;
	ans0 = 0;
	rep(i, n) {
		if (is_nex_r) {
			while (is_use[(*itrr).second]) {
				itrr++;
			}
			is_use[(*itrr).second] = true;
			int num = (*itrr).second;
			if (now_pot < l[num]) { ans0 += l[num] - now_pot; now_pot = l[num]; }
			else if (r[num] < now_pot) { ans0 += now_pot - r[num]; now_pot = r[num]; }
			is_nex_r = false;
		}
		else {
			while (is_use[(*itrl).second]) {
				itrl++;
			}
			is_use[(*itrl).second] = true;
			int num = (*itrl).second;
			if (now_pot < l[num]) { ans0 += l[num] - now_pot; now_pot = l[num]; }
			else if (r[num] < now_pot) { ans0 += now_pot - r[num]; now_pot = r[num]; }
			is_nex_r = true;
		}
	}
	ans0 += abs(now_pot);
	mmax(ret, ans0);
	cout << ret << Endl;
	return 0;
}


Measured memory_bytes: 11264
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		char[] s = sc.next().toCharArray();
		int n = s.length;
		boolean N, E, W, S;
		N = E = W = S = false;
		for (int i = 0; i < n; i++) {
			if (s[i] == 'N') {
				N = true;
			}
			if (s[i] == 'E') {
				E = true;
			}
			if (s[i] == 'W') {
				W = true;
			}
			if (s[i] == 'S') {
				S = true;
			}
		}

		if (N == S && W == E) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 8660
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

const int SIZE = 100010;
 
vector<int> G[SIZE];
int deg[SIZE];
int ord[SIZE];
 
int main() {
	int n, m;
    cin >> n >> m;
	
    rep(i, n-1+m) {
        int a, b;
        cin >> a >> b;
		a--;  b--;
		deg[a]++;
		G[b].push_back(a);
    }
	
	queue<int> Q;

	rep(v, n) {
		if(deg[v] == 0) {
			Q.push(v);
		}
	}

	int sz = 0;
	while(!Q.empty()) {
		int v = Q.front();
        Q.pop();
		ord[v] = sz++;
		rep(i, G[v].size()) {
			int u = G[v][i];
			deg[u]--;
			if(deg[u] == 0) {
                Q.push(u);
            }
		}
	}

	rep(i, n) {
		int mn = SIZE;
        int pos = -1;
		rep(j, G[i].size()) {
			int u = G[i][j];
			if(mn > ord[u]) {
				mn = ord[u];
				pos = u;
			}
		}
		cout << pos + 1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b,c;
    cin >> a >> b >> c ;
    for(int k=1;k<=b;k++){
        if(a*k%b==c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define SQ 500
#define INF 1e9+7

using namespace std;

ll n,m,a,b;
ll ans[N];
pi ar[N];
ll seg[4*N];
ll lazy[4*N];

void relax(ll low,ll high,ll pos)
{
    if(lazy[pos])
    {
        seg[pos] += lazy[pos];

        if(low!=high)
        {
            lazy[pos*2+1]+=lazy[pos];
            lazy[pos*2+2]+=lazy[pos];
        }
        lazy[pos]=0;
    }

    return;
}

void update(ll low,ll high,ll pos,ll slow,ll shigh,ll val)
{
    relax(low,high,pos);

    if(low>=slow&&high<=shigh)
    {
        lazy[pos] += val;
        relax(low,high,pos);
        return;
    }
    if(low > shigh||high<slow)
        return;

    ll mid = (low+high)/2;
    update(low,mid,pos*2+1,slow,shigh,val);
    update(mid+1,high,pos*2+2,slow,shigh,val);
    return;
}

ll query(ll low,ll high,ll pos,ll slow)
{
    relax(low,high,pos);

    if(low == slow && high == low)
        return seg[pos];
    if(low>slow||high<slow)
        return 0;
    ll mid = (low+high)/2;

    return query(low,mid,pos*2+1,slow)+query(mid+1,high,pos*2+2,slow);
}

bool cmp(const pi &a,const pi &b)
{
    if(a.second-a.first == b.second-b.first)
        return a < b;

    return a.second-a.first>b.second-b.first;
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> m;

    rep(i,0,n)
    {
        cin >> ar[i].first >> ar[i].second;
        update(0,m,0,ar[i].first,ar[i].second,1);
    }

    sort(ar,ar+n,cmp);

    ll cur = 0;

    for(int length=m;length>=1;length--)
    {
        while(cur < n && ar[cur].second-ar[cur].first+1>=length)
        {
            update(0,m,0,ar[cur].first,ar[cur].second,-1);
            cur++;
        }

        ans[length] = cur;

        for(int i = 0;i <= m;i += length)
        {
            ans[length] += query(0,m,0,i);
        }
    }

    rep(i,1,m+1)
        cout << ans[i] << "\n";

    return 0;
}


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


signed main()
{
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n;
 cin>>n;

 vector<int> v;
 unordered_map<int,int> mp;
 int x,sum = 0;
 for(int i = 0;i < n;i++)
 {
   cin>>x;
   v.push_back(x);
   mp[x]++;
   sum+=x;
 }
 int q,b,c;
 cin>>q;
for(int i = 0;i < q;i++)
{
  cin>>b>>c;
  sum-=b*mp[b];
  sum+=c*mp[b];
  mp[c]+=mp[b];
  mp[b] = 0;
  cout<<sum<<"\n";
  

}
 return 0;
}


Measured memory_bytes: 8028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    long double l;
    cin >> l;
    long double ans = pow(l/3,3);
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	ll n,d;
	cin>>n>>d;
	ll a[n][d];
	for(ll i=0;i<n;i++)
		for(ll j=0;j<d;j++)
			cin>>a[i][j];
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		
		for(ll j=i+1;j<n;j++)
		{
			ll x=0;
			for(ll k=0;k<d;k++)
			{
				x+=((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
			}
			if(floor(sqrt(x))==ceil(sqrt(x)))
				ans++;
		}
			
	}
	cout<<ans;
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

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

int n,q;
int c[500005],pre[500005],ans[500005];
vector<pair<int,int>> qs[500005];
int bit[2000005];

int sum(int pos){
    int res=0;
    while(pos>0){
        res+=bit[pos];
        pos-=pos&-pos;
    }
    return res;
}

void add(int pos,int val){
    while(pos<=n){
        bit[pos]+=val;
        pos+=pos&-pos;
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>q;
    for(int i=1;i<=n;i++)cin>>c[i];
    for(int i=1;i<=q;i++){
        int l,r;
        cin>>l>>r;
        qs[r].emplace_back(l,i);
    }
    for(int i=1;i<=n;i++){
        add(i,1);
        if(pre[c[i]])add(pre[c[i]],-1);
        pre[c[i]]=i;
        for(pair<int,int> &p:qs[i]){
            ans[p.second]=sum(i)-sum(p.first-1);
        }
    }
    for(int i=1;i<=q;i++)cout<<ans[i]<<'\n';

    return 0;
}

Measured memory_bytes: 33288
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int geta=500000000;

signed main() {
	int X;
	cin >> X;
	int t=1;
	while(true){
		if(t*(t+1)/2LL>=X)break;
		t++;
	}
	cout<<t<<endl;
}
	
	

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const ll INF = 1LL << 50;
const double EPS = 1E-10;

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

size_t tpos;
size_t lpos;

void do_a(const vector<string> &text){
	lpos = 0;
}

void do_e(const vector<string> &text){
	lpos = text[tpos].size();
}

void do_p(const vector<string> &text){
	lpos = 0;
	tpos = max(0, (int)tpos - 1);
}

void do_n(const vector<string> &text){
	lpos = 0;
	tpos = min((int)tpos + 1, (int)text.size() - 1);
}

void do_f(const vector<string> &text){
	if(lpos == text[tpos].size()){
		if((int)tpos < (int)text.size() - 1){
			lpos = 0;
			tpos++;
		}
	}else{
		lpos++;
	}
}

void do_b(const vector<string> &text){
	if(lpos != 0){
		lpos--;
	}else{
		if(tpos > 0){
			tpos--;
			lpos = text[tpos].size();
		}
	}
}

void do_d(vector<string> &text){
	if(lpos != text[tpos].size()){
		text[tpos].erase(lpos, 1);
	}else{
		if((int)tpos < (int)text.size() - 1){
			text[tpos]+=text[tpos+1];
			text.erase(text.begin() + tpos+1);
		}
	}
}

void do_k(vector<string> &text, string &buffer){
	if(lpos == text[tpos].size()){
		if((int)tpos < (int)text.size() - 1){
			buffer = "\n";
			do_d(text);
		}
	}else{
		buffer = string(text[tpos].begin() + lpos, text[tpos].end());
		text[tpos].erase(text[tpos].begin() + lpos, text[tpos].end());
	}
}

void do_y(vector<string> &text, string &buffer){
	if(buffer != ""){
		if(buffer == "\n"){
			string a(text[tpos].begin() + lpos, text[tpos].end());
			text[tpos].erase(lpos);
			text.insert(text.begin() + tpos + 1, a);
			tpos++;
			lpos = 0;
		}else{
			if(lpos == text[tpos].size()){
				text[tpos] += buffer;
				lpos = text[tpos].size();
			}else{
				text[tpos].insert(text[tpos].begin() + lpos, buffer.begin(), buffer.end());
				lpos += buffer.size();
			}
		}
	}
}

void output(const vector<string> &text){
	rep(i, (int)text.size()) cout << text[i] << endl;
}

int main(){
	string line;
	vector<string> text;
	string buffer;
	while(getline(cin, line) && line != "END_OF_TEXT"){
		text.push_back(line);
	}
	tpos = lpos = 0;
	char command;
	while(cin >> command && command != '-'){
		switch(command){
		case 'a':
			do_a(text);
			break;
		case 'e':
			do_e(text);
			break;
		case 'p':
			do_p(text);
			break;
		case 'n':
			do_n(text);
			break;
		case 'f':
			do_f(text);
			break;
		case 'b':
			do_b(text);
			break;
		case 'd':
			do_d(text);
			break;
		case 'k':
			do_k(text, buffer);
			break;
		case 'y':
			do_y(text, buffer);
			break;
		default:
			assert(false);
		}
		
	}
	output(text);
	return 0;
}

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

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int out = INT_MAX;
	for(int i = 0; i <= 100000; i++){
		out = min(a * max(0, x - i) + b * max(0, y - i) + 2 * c * i, out);
	}
	cout << out << endl;
}


Measured memory_bytes: 3564
n=int(input())
da=list(map(int,input().split()))
sum=[0 for i in range(2001)]
ans=0
da=sorted(da)
for i in range(n):
    for j in range(2001):
        if j > da[i]:
            ans+=sum[j]
    for j in range(i):
        sum[da[i]+da[j]]+=1
print(ans)

Measured memory_bytes: 42220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(){
    ll a;
    string b;
    cin >> a >> b;
    ll c = (b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0');  
    cout << (a*c)/100 ;

    return 0;
}

Measured memory_bytes: 3644
PROGRAM ATCODER

implicit none
integer(16) :: n, a, i, nx, s, k, j, ans
integer(16), allocatable :: x(:), dp(:,:,:)

read(*,*) n, a
allocate (x(n))
read(*,*) (x(i), i=1,n)

nx = n*max(maxval(x),a)
allocate (dp(0:n,0:n,0:nx)) ! dp(j,k,s)→(1~j枚のカード,k枚えらぶ,合計はs)となる選び方の総数

do j = 0, n
	do k = 0, n
    	do s = 0, nx
        	if (s == 0 .and. k == 0 .and. j == 0) then 
            	dp(j,k,s) = 1
        	else if (j >= 1 .and. s < x(j)) then
            	dp(j,k,s) = dp(j-1,k,s)
            else if (j >= 1 .and. k >= 1 .and. s >= x(j)) then
            	dp(j,k,s) = dp(j-1,k,s) + dp(j-1,k-1,s-x(j))
            else
            	dp(j,k,s) = 0
            end if
        end do
    end do
end do

ans = 0
do k = 1,n
	ans = ans + dp(n,k,a*k)
end do

write(*,'(i0)') ans

END PROGRAM ATCODER

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

    if ( A+B > C+D ) {
    cout << "Left" << endl;
  }
  if ( A+B == C+D) {
    cout << "Balanced" << endl;
  }
    if ( A+B < C+D) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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

    rep(i,N){
        double x0,y0,r0,x1,y1,r1;
        cin >> x0 >> y0 >> r0 >> x1 >> y1 >> r1;

        double dx = x0 - x1;
        double dy = y0 - y1;
        double d = sqrt(dx*dx+dy*dy);

        if(d > r0 + r1){
            cout << 0 << endl;
        }else if(d + r1 < r0){
            cout << 2 << endl;
        }else if(d + r0 < r1){
            cout << -2 << endl;
        }else{
            cout << 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3152
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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


int dfs(long long n, int lim){//後ろに数を付け加えてできる七五三数の数
    if(n > lim) return 0;
    int ret(0);
    bool hs7(false), hs5(false), hs3(false);
    long long m(n);
    while(m){
        if(m % 10 == 7) hs7 = true;
        if(m % 10 == 5) hs5 = true;
        if(m % 10 == 3) hs3 = true;
        m /= 10;
    }
    if(hs7 && hs5 && hs3) ++ret;
    ret += dfs(n*10 + 7, lim);
    ret += dfs(n*10 + 5, lim);
    ret += dfs(n*10 + 3, lim);
    return ret;
}
 
 
int main(){
    int N; std::cin >> N;
    std::cout << dfs(0LL, N) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int n, k, s;
    cin >> n >> k >> s;
    if(s!=1e9){
        for (int i = 0; i < k; i++)
        {
            cout << s << " ";
        }
        for (int i = k; i < n; i++)
        {
            cout << s + 1 << " ";
        }
        cout << endl;
    }
    else{
        for (int i = 0; i < k; i++)
        {
            cout << s << " ";
        }
        for (int i = k; i < n; i++)
        {
            cout << 1 << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();

		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < H; i++) {
			String S = sc.next();
			sb.append(S+"\n");
			sb.append(S+"\n");
		}

		System.out.print(sb.toString());


	}

}


Measured memory_bytes: 39320
#include<stdio.h>
void trace(int A[],int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void insertionSort(int A[],int N){
  int j,i,v;
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
  }
}

int main(){
  int N,i,j;
  int A[100];
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);
  trace(A,N);
  insertionSort(A,N);
  return 0;
}



Measured memory_bytes: 2128
#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;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, K; cin >> N >> K;
    vec H(N + 2, 0); REP(i, N) cin >> H[i + 1];

    mat dp(N + 2, vec(K + 1, INF));
    REP(j, K + 1) dp[0][j] = 0;
    FOR(i, 1, N + 2) REP(j, K + 1){
        REP(l, i){
            if(j + l > K) break;
            Min(dp[i][j + l], dp[i - l - 1][j] + llabs(H[i] - H[i - l - 1]));
        }
    }
    //mdebug(dp);
    Out(dp[N + 1][K] / 2);

    return 0;
}


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




int main()
{
	int n;
	cin >> n;
	vector<int> stairs(n, 0);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &stairs[i]);
	}

	int maxStairHeight = stairs[0] - 1;
	for (auto stairHeight : stairs)
	{
		if (maxStairHeight < stairHeight)
		{
			maxStairHeight = max(maxStairHeight, stairHeight - 1);
		}
		else if (maxStairHeight > stairHeight)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 640
import collections
import sys
input=sys.stdin.readline

n=int(input())
ans=[0]*n
tmp=[]
for x in range(1,int(n**0.5)+1): #可能なすべてのx,y,zについてx^2+y^2+z^2+xy+yz+zxの値を求める
   for y in range(1,int(n**0.5)+1):
       for z in range(1,int(n**0.5)+1):
           tmp.append(x**2+y**2+z**2+x*y+y*z+z*x)
cnt=collections.Counter(tmp) #x^2+y^2+z^2+xy+yz+zxの値の個数を数える
for i in range(1,n+1): #各iについて、x^2+y^2+z^2+xy+yz+zxの値がiであるものの個数が答えとなる
   print(cnt[i])

Measured memory_bytes: 50668
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
using ll = long long;
     
int main(){
	int r,g,b;
	cin >> r >> g >> b;
	int s = 100*r + 10 *g + b;
	if(s % 4==0)cout << "YES" << endl;
	else cout << "NO" <<endl;
	return 0;
}


Measured memory_bytes: 256
def partition(arr, p, r):
    x = int(arr[r][1])
    i = p - 1
    for j in range(p, r):
        if int(arr[j][1]) <= x:
            i += 1
            arr[i], arr[j] = arr[j], arr[i]
    arr[i + 1], arr[r] = arr[r], arr[i + 1]
    return i + 1
def quickSort(arr, p, r):
    if p < r:
        q = partition(arr, p, r)
        quickSort(arr, p, q - 1)
        quickSort(arr, q + 1, r)
def merge(arr, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = [i for i in range(n1 + 1)]
    R = [i for i in range(n2 + 1)]
    for i in range(n1):
        L[i] = arr[left + i]
    for i in range(n2):
        R[i] = arr[mid + i]
    L[n1] = ['last', 10**9 + 1]
    R[n2] = ['last', 10**9 + 1]
    i = 0
    j = 0
    for k in range(left, right):
        if int(L[i][1]) <= int(R[j][1]):
            arr[k] = L[i]
            i += 1
        else:
            arr[k] = R[j]
            j += 1
def mergeSort(arr, left, right):
    if left + 1 < right:
        mid = (left + right)//2
        mergeSort(arr, left, mid)
        mergeSort(arr, mid, right)
        merge(arr, left, mid, right)
n = int(input())
a = [list(input().split()) for i in range(n)]
b = [i for i in a]
mergeSort(b, 0, n)
quickSort(a, 0, n - 1)
print('Stable' if a == b else 'Not stable')
for i in a:
    print(' '.join(i))


Measured memory_bytes: 27116
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    int la,ra,lb,rb,lc,rc,ld,rd;
    double t;
    la = 0;
    ra = 0;
    lb = 0;
    rb = 0;
    lc = 0;
    rc = 0;
    ld = 0;
    rd = 0;
    while(cin >> t){
	if(t >= 1.1) la++;
	else if( t >= 0.6) lb++;
	else if(t >= 0.2) lc++;
	else ld++;
	cin >> t;
	if(t >= 1.1) ra++;
	else if( t >= 0.6) rb++;
	else if(t >= 0.2) rc++;
	else rd++;
    }
    printf("%d %d\n",la,ra);
    printf("%d %d\n",lb,rb);
    printf("%d %d\n",lc,rc);
    printf("%d %d\n",ld,rd);
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<long long> a(n+1),b(n);
	long long sm=0;
	for(int i=0;i<n+1;i++)
	{
		cin >> a.at(i);
	}
	for(int i=0;i<n;i++)
	{
		cin >> b.at(i);
		if(a.at(i)>=b.at(i))
		{
			sm+=b.at(i);
		}
		else
		{
			sm+=a.at(i);
			b.at(i)-=a.at(i);
			if(a.at(i+1)>=b.at(i))
			{
				a.at(i+1)-=b.at(i);
				sm+=b.at(i);
			}
			else
			{
				sm+=a.at(i+1);
				a.at(i+1)=0;
			}
		}
	}
	cout << sm << endl;
	return 0;
}


Measured memory_bytes: 4836
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int a, b;
    cin >> a >> b;

    cout << (b % a == 0 ? a + b : b - a) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
#define N 200005
#define LL long long
using namespace std;

int n;
int a[N];
LL ans;
priority_queue<int>q;
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	q.push(a[n]);
	for(i=n-1;i>=1;i--)
	{
		ans+=q.top();
		q.pop();
		q.push(a[i]);
		q.push(a[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
#define MAX 3000
 
int dp[MAX+1][MAX+1];
string getLCS(string& s, string& t, int len)
{
        string LCS;
        int i = 0, j = 0;
        while(len > 0)
        {
            if(s[i] == t[j])
            {
                LCS.push_back(s[i]);
                i++;
                j++;
                len--;
            }
            else
            {
                if(dp[i][j+1] > dp[i+1][j])
                    j++;
                else i++;
            }
        }
        return LCS;
}
 
int lenLCS(string& s, string& t, int i, int j)
{
        if(i >= s.length() || j >= t.length())
            return 0;
        
        if(dp[i][j] != -1)
            return dp[i][j];
 
        if(s[i] == t[j])
            return dp[i][j] = 1 + lenLCS(s,t,i+1,j+1);
        else 
        {
            return dp[i][j] = max(lenLCS(s,t,i,j+1), lenLCS(s,t,i+1,j));
        }
}
 
string solve(string s, string t)
{
        memset(dp, -1, sizeof dp);
        int len = lenLCS(s,t,0,0);
        return getLCS(s,t,len);
}

int main()
{
	string s,t;
	cin>>s>>t;
	cout<<solve(s,t);
}

Measured memory_bytes: 39208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long yokin = 100;
		// 目標金額
		long purpose = sc.nextLong();
		// 経過年度
		int year = 0;

		while(true) {
			if(yokin >= purpose) {
				System.out.println(year);
				break;
			}

			yokin = (long) (yokin * 1.01);
			year++;
		}

		sc.close();
	}


}


Measured memory_bytes: 35716
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn usize() -> usize {
    read()
}

fn vec_usize(n: usize) -> Vec<usize> {
    let mut vec = Vec::new();
    for _ in 0..n {
        vec.push(usize())
    }
    vec
}

fn main() {
    let n = usize();
    let mut hs = vec_usize(n);

    if hs.len() == 1 {
        println!("Yes");
        return;
    }
    hs.reverse();
    let mut h = hs[0];
    for i in 1..hs.len() {
        if hs[i] > h + 1 {
            println!("No");
            return;
        }
        if hs[i] > h {
            h = hs[i] - 1;
        } else {
            h = hs[i];
        }
    }
    println!("Yes");
}


Measured memory_bytes: 2916
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	int D = b - a;
	int sum = 0;
	for (int i = a;i <= b;++i) {
		if (c % i == 0) {
			sum += 1;
		}
		else {
			sum += 0;
		}
	}
	std::cout << sum << std::endl;
	return 0;
}


Measured memory_bytes: 3104
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
# elif L == 0:
#     print(0)
else:
    ans = float("inf")
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(((i % 2019) * (j % 2019)) % 2019, ans)
    print(ans)


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

int main(){
    int N;
    int A[200];
    cin >> N;
    for(int i =0; i < N; i++){
        cin >> A[i];
    }
    bool even = true;
    int count = 0;
    while(even){
        for(int i = 0; i < N; i++){
            if(A[i] % 2 != 0){
                even = false;
                break;
            }
             A[i] /= 2;
            }
            if(even){
                count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  char num[6];
  int f=0;
  cin >> num;
  for(int i=1;i<=2;i++){
    if((num[i-1]==num[i]&&num[i]==num[i+1]))
      f=1;
  }
  if(f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
nr = 0
ng = 0
nb = 0
for i in range(n):
    if s[i] == "R":
        nr += 1
    elif s[i] == "G":
        ng += 1
    else:
        nb += 1
        
ans = nr * ng * nb
#print(ans)
for i in range(1,(n-1)//2+1):
    for j in range(n-i*2):
        if s[j] != s[j+i] and s[j] != s[j+i*2] and s[j+i] != s[j+i*2]:
            ans -= 1
            
print(ans)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;
vector<int> dx = {1,0};
vector<int> dy = {0,1};


int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    
    rep(i,tx-sx) cout << 'R';
    rep(i,ty-sy) cout << 'U';
    rep(i,tx-sx) cout << 'L';
    rep(i,ty-sy) cout << 'D';
    cout << 'D';
    rep(i,tx-sx+1) cout << 'R';
    rep(i,ty-sy+1) cout << 'U';
    cout << 'L';
    cout << 'U';
    rep(i,tx-sx+1) cout << 'L';
    rep(i,ty-sy+1) cout << 'D';
    cout << 'R';
}

Measured memory_bytes: 3532