akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

bool is_month(int t){
    if(t<=12 && t>0)return true;
    else return false;
}

int main(){
    string S;cin >> S;
    int first,second;
    first = (S[0]-'0')*10 + (S[1] - '0');
    second = (S[2]-'0')*10 + (S[3]-'0');
    if(is_month(first)){
        if(is_month(second))cout << "AMBIGUOUS";
        else cout << "MMYY";
    }else if(is_month(second))cout << "YYMM";
    else cout << "NA";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3620
def examE():
    N = I()
    X = LI()
    L = I(); Q = I()
    n = N.bit_length()+1
    dp = [[0] * n for _ in range(N)]
    for i in range(N):
        dp[i][0] = bisect.bisect_right(X, X[i] + L) - 1
    for i in range(1, n):
        for j in range(N):
            if dp[j][i - 1] < N:
                index = dp[dp[j][i - 1]][i - 1]
                if index == j:
                    dp[j][i] = N
                else:
                    dp[j][i] = index
            else:
                dp[j][i] = N
    def fast_day(a, b):
        if a > b:
            a, b = b, a
        res = 0
        for i in range(n):
            if a >= b:
                return res
            c = max(0, bisect.bisect_left(dp[a], b) - 1)
            #最低かかる2**?の日数
            a = dp[a][c]
            #そこまで行く
            res += 2 ** c
    for _ in range(Q):
        a, b = map(int, input().split())
        print(fast_day(a - 1, b - 1))
#    print(dp)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examE()


Measured memory_bytes: 101228
#include<bits/stdc++.h>
#define fr(i,n) for(int i=0;i<(n);++i)
#define foor(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,n) for(int i=(n);i--;)
#define roof(i,b,a) for(int i=(b);i>=(a);--i)
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x))
#define Reverse(x) reverse(all(x))
#define PQ priority_queue
#define print(x) cout<<(x)<<endl
using namespace std;            typedef vector<int>  vi;
typedef long long ll;           typedef vector< ll>  vl;
typedef unsigned long long ull; typedef vector<ull>  vu;
typedef double dbl;             typedef vector<dbl>  vd;
typedef string str;             typedef vector<str>  vs;
typedef pair<int,int>pii;       typedef vector<pii>vpii; typedef map<int,int>mii;
typedef pair< ll, ll>pll;       typedef vector<pll>vpll; typedef map< ll, ll>mll;
typedef pair<dbl,dbl>pdd;       typedef vector<pdd>vpdd; typedef map<dbl,dbl>mdd;
typedef pair<str,str>pss;       typedef vector<pss>vpss; typedef map<str,str>mss;
typedef pair< ll,int>pli;       typedef vector<pli>vpli; typedef map< ll,int>mli;
typedef pair<dbl,int>pdi;       typedef vector<pdi>vpdi; typedef map<dbl,int>mdi;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
template<typename T>set<T>&operator<<(set<T>&s,const T t){s.insert(t);return s;}
template<typename T,typename U>PQ<T,vector<T>,U>&operator<<(PQ<T,vector<T>,U>&q,const T t){q.push(t);return q;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T>istream&operator>>(istream&s,vector<T>&v){fr(i,v.size()){s>>v[i];}return s;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
const int MD=1e9+7;
vpli dijkstra(const int N,const vpli E[],const int s,const ll inf){vpli d;fr(i,N)d<<pli{inf,i};d[s].first=0;PQ<pli,vpli,greater<pli>>pq;pq<<(d[s]=pli{0,s});while(pq.size()){pli a=pq.top();pq.pop();int v=a.second;if(d[v].first>=a.first){for(pli e:E[v]){if(d[v].first+e.first<d[e.second].first){d[e.second]=pli{d[v].first+e.first,v};pq<<pli{d[v].first+e.first,e.second};}}}}return d;}
ll gcd(const ll a,const ll b){return a?gcd(b%a,a):b;}
ll pow(const ll a,const ll n,const int m){ll t;return n?(n&1?a>=0?a%m:~-m+~a%m:1)*(t=pow(a,n>>1,m),t*t%m)%m:1;}
ll C2(const int n){return(ll)n*~-n/2;}
ll sum(const vl a){ll s=0;for(ll e:a){s+=e;}return s;}
template<typename T>T max(const vector<T>a){T m=a[0];for(ll e:a){m=max(m,e);}return m;}
template<typename T>T min(const vector<T>a){T m=a[0];for(ll e:a){m=min(m,e);}return m;}
// (int) * (int) => (int)
// (int) / (int) => (int)

main(){cin.tie(0);ios::sync_with_stdio(false);
	ll N;
	cin>>N;
	str S;
	cin>>S;
	reverse(S.begin(),S.begin()+N);
	map<pss,ll>m1,m2;
	fr(i,1<<N){
		pss s,t;
		fr(j,N){
			(i>>j&1?s.first:s.second)+=S[j];
			(i>>j&1?t.first:t.second)+=S[j+N];
		}
		++m1[s];
		++m2[t];
	}
	ll z=0;
	for(auto s:m1){
		z+=s.second*m2[s.first];
	}
	print(z);
}


Measured memory_bytes: 108288
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

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


void solve() {
	int n, m; cin >> n >> m;
	if (n == m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	string S; cin >> S;
	vll lsum(N+1), rsum(N+1);
	for (int i = 0; i < N; i++) {
		lsum[i+1] = lsum[i] + (int)(S[i] == '#');
	}
	for (int i = N-1; i >= 0; i--) {
		rsum[i] = rsum[i+1] + (int)(S[i] == '.');
	}
	int minv = INF;
	for (int i = 0; i <= N; i++) {
		chmin(minv, lsum[i] + rsum[i]);
	}
	cout << minv << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 6784
n = int(input())
a = list(map(int,input().split()))

ans = 0
for i,f in enumerate(a):
    if i == 0:
        continue
    if a[i-1] > f:
        sa = a[i-1] - f
        a[i] += sa
        ans += sa
#print(a)
print(ans)

Measured memory_bytes: 32184
s=input()
char=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
check=False
for c in char:
    if not c in s:
        print(c,end='')
        check=True
        break
if  check==False:
    print('None',end='')

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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define REP(i, n) FOR(i, 0, n)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 2e9;
const ll MOD = 1e9+7;
//const ll MOD 998244353;

int main(void){
	int a, b;
	cin >> a >> b;
	if(b*2 >= a){
		co(0);
	}else{
		co(a-b*2);
	}

	return 0;
}


Measured memory_bytes: 256
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(aov(a),x)-a.begin())
#define UB(a,x) (upper_bound(aov(a),x)-a.begin())
typedef long long LL;
typedef unsigned long long ULL;
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n)
    {
        vi a[2];
        rep(i,2)
        {
            rep(j,n)
            {
            cin>>x;
            a[i].pb(x);
            }
        }
        s=c=0;
        for(i=0;i<n;i++)
        {
            c=0;
            for(j=0;j<=i;j++)
            {
                c+=a[0][j];
            }
            for(j=i;j<n;j++)
            {
                c+=a[1][j];
            }
            if(c>s) s=c;
        }
        cout<<s<<en;
    }
}



Measured memory_bytes: 256
def main():
    N = int(input())
    P = list(map(int, input().split()))    
    cnt = 0
    i = 0
    while i < N:
        if i + 1 == P[i]:
            if i == N - 1:
                cnt += 1
                i += 1
            else:
                if i + 2 == P[i+1]:
                    cnt += 1
                    i += 2
                else:
                    cnt += 1
                    i += 1
        else:
            i += 1

    print(cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 52332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int a,b;
	cin >> a >> b;
	for(int i= 0;i<=100000;i++)
	{
		//for(int j = 0;j<=100;j++)
		
			int A = double(i)*0.08;
			int B = double(i)*0.10;
			//cout<<A<<' '<<B<<endl;
			if(a==A&&B==b)
			{
				cout<<i<<endl;
				return 0;
			}
		
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using Vl = vector<ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;

int dp[1000000];
int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll res = INF * INF;
    chmin(res, a % 2 * b * c);
    chmin(res, a * (b % 2) * c);
    chmin(res, a * b * (c % 2));
    cout << res << endl;
}



Measured memory_bytes: 3196
import itertools as it

ans=[]

while 1:
    n,m=map(int,input().split())
    if n==0 and m==0:
        break
    A=list(map(int,input().split()))
    Ac=list(it.combinations(A,2))
    
    max=0
    flag=0

    for i in Ac:
        if sum(i)>=max and sum(i)<=m:
            max=sum(i)
            flag=1
        
    if flag==0:
        print("NONE")
    else:
        print(max)


Measured memory_bytes: 50628
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=200005;
int T,N,Cnt,cnt[5];
long long num[MAXN];
long long A[MAXN];
void Check(int t){
	if(t==N){
		printf("Yes\n");
		return ;
	}
	if(t*3==N){Cnt=0;
		num[1]=num[2]=num[3]=-1;
		for(int i=1;i<=N;i++){
			if(A[i]==num[1])continue;
			if(A[i]==num[2])continue;
			num[++Cnt]=A[i];
		}
		if(Cnt!=2){
			printf("No\n");
			return ;
		}
		printf("Yes\n");
		return ;
	}
	printf("No\n");
}
void Solve(){
	int Ok=0;
	for(int i=1;i<=N;i++)
		if(!A[i])Ok++;
	if(Ok){
		Check(Ok);
		return ;
	}
	if(N%3){
		printf("No\n");
		return ;
	}Cnt=0;
	num[1]=num[2]=num[3]=-1;
	for(int i=1;i<=N;i++){
		if(A[i]==num[1])continue;
		if(A[i]==num[2])continue;
		if(A[i]==num[3])continue;
		num[++Cnt]=A[i];
	}
	if(Cnt!=3){
		printf("No\n");
		return ;
	}
	if((num[1]^num[2])!=num[3]){
		printf("No\n");
		return ;
	}memset(cnt,0,sizeof(cnt));
	for(int i=1;i<=N;i++){
		if(A[i]==num[1])cnt[1]++;
		if(A[i]==num[2])cnt[2]++;
		if(A[i]==num[3])cnt[3]++;
	}
	if(cnt[1]==cnt[2]&&cnt[2]==cnt[3]){
		printf("Yes\n");
		return ;
	}
	printf("No\n");
}
int main(){
	//freopen("circle.in","r",stdin);
	//freopen("circle.out","w",stdout);
		scanf("%d",&N);
		for(int i=1;i<=N;i++)
			scanf("%lld",&A[i]);
		Solve();

}
/*
2
4
1 1 1 1
48
18 17 17 3 17 3 3 18 17 3 17 3 18 3 17 18 3 18 18 3 18 3 18 17 3 18 17 17 3 18 17 17 3 3 18 3 18 17 3 18 17 18 17 18 17 17 3 18
*/

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

using namespace std;

#define pb push_back
#define pp pop_back
#define F first
#define S second
#define endl "\n"

typedef long long ll;
typedef long double ld;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}     
int main () {
	INeedIt();
	double a, b;
	cin>>a>>b;
	double ans=a/b;
	cout<<fixed<<setprecision(10)<<ans;
	return 0;
}
 

Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

ll n,m;

int main() {
 	qr(n); qr(m);
 	n-=n/m*m;
 	pr2(min(n,m-n));
	return 0;
}



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

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

int h, w, n;
vector<int> c;
int x[100][100];

int main(){
    cin >> h >> w >> n;
    rep(i, n){
        int a;
        cin >> a;
        rep(j, a){
            c.push_back(i + 1);
        }
    }
    int i = 0, j = 0;
    rep(k, h * w){
        x[i][j] = c[k];
        if(i % 2){
            if(j == 0){
                ++i;
            }
            else{
                --j;
            }
        }
        else{
            if(j == w - 1){
                ++i;
            }
            else{
                ++j;
            }
        }
    }
    rep(i, h){
        rep(j, w){
            cout << (j ? " " : "") << x[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
	for(string s;cin>>s;){
		for(int len=s.size();;len=s.size()){
			int i;
			if((i=s.find("mew"))!=-1) s.replace(i,3,"X");
			if((i=s.find("mXew"))!=-1) s.replace(i,4,"X");
			if((i=s.find("meXw"))!=-1) s.replace(i,4,"X");
			if((i=s.find("mXeXw"))!=-1) s.replace(i,5,"X");
			if(len==s.size()) break;
		}
		cout<<(s=="X"?"Cat":"Rabbit")<<endl;
	}
}

Measured memory_bytes: 1216
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int gcd(int a, int b){
  if(b==0) return a;
  return gcd(b, a%b);
}
int main()
{
	string s; cin>>s; int n=s.size();
  int c[2]={};
  for(int i=0; i<n; i++){
    c[s[i]-'0']++;
  }
  cout<<2*min(c[0], c[1])<<endl;
  
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC147A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c;
			var word = Console.ReadLine().Split(' ');
			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			c = int.Parse(word[2]);

			if (22 <= a + b + c)
				Console.WriteLine("bust");
			else
				Console.WriteLine("win");

		}
	}
}


Measured memory_bytes: 11092
import sys
def input():
	return sys.stdin.readline().strip()

N, K = list(map(int, input().split()))
S = input()

total_loss = 1

for i in range(1, N):
	if S[i] != S[i - 1]:
		total_loss += 1

total_loss = max(1, total_loss - 2*K)
print(N - total_loss)

Measured memory_bytes: 39664
/*  ex3_3
    supercomputerjoi    */

#include <stdio.h>
#include <math.h>

int main(void){

    int num, base;
    int digits;

    // input N
    scanf("%d", &num);

    // input K
    scanf("%d", &base);

    // calculate log_K^N + 1= logN / logK + 1
    digits = log(num) / log(base) + 1;

    //print digits
    printf("%d\n", digits);

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    rep(i, n - 1){
        if(a[i] == a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <cstring>
#include <deque>

using namespace std;

#define MAX_YX 10

int park[MAX_YX][MAX_YX];

int n;
int sy, sx;

int dy[] = {-2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2};
int dx[] = {-1, 0, 1, -2, 2, -2, 2, -2, 2, -1, 0, 1};
bool dfs(int y, int x, int t) {
//	cout << x << ", " << y << endl;
	if (t == n) {
		if ((park[y][x] >> (n-1)) & 1) return true;
		else return false;
	}
	for (int i = 0; i < 12; i++) {
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (0 <= ny && ny < MAX_YX && 
		    0 <= nx && nx < MAX_YX && ((park[ny][nx] >> t) & 1)) {
			if (dfs(ny, nx, t+1)) return true;
		} 
	}
	return false;
}

int main() {
	while (cin >> sx >> sy, sx || sy) {
		cin >> n;
		memset(park, 0, sizeof(park));
		for (int i = 0; i < n; i++) {
			int spx, spy; cin >> spx >> spy;

			for (int j = spy-1; j <= spy+1; j++) {
				for (int k = spx-1; k <= spx+1; k++) {
					if (0 <= j && j < MAX_YX && 0 <= k && k < MAX_YX) {
						park[j][k] |= (1 << i);
					}
				}
			}
		}

		if (dfs(sy, sx, 0)) {
			cout << "OK" << endl;
		} else {
			cout << "NA" << endl;
		}

	}
	return 0;
}

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

int main(){
    int s;
    cin >> s;
    int L = s / 100;
    int R = s % 100;
    string ans = "AMBIGUOUS";
    //YYMM
    if(L > 12 || L == 0){
        if(R <= 12 && R > 0){
            ans = "YYMM";
        }else{
            ans = "NA";
        }
    }
    //MMYY
    if(R > 12 || R == 0){
        if(L <= 12 && L > 0){
            ans="MMYY";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int result = 0;
  if (a.size() > b.size()) {
    result = 1;
  } else if (a.size() < b.size()) {
    result = -1;
  } else {
    for (int i = 0; i < a.size(); i++) {
      int x = a[i] - '0';
      int y = b[i] - '0';
      if (x > y) {
        result = 1;
        break;
      } else if (x < y) {
        result = -1;
        break;
      }
    }
  }

  if (result == 1) {
    cout << "GREATER" << endl;
  } else if (result == -1) {
    cout << "LESS" << endl;
  } else {
    cout << "EQUAL" << endl;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

const string YES = "YES";
const string NO = "NO";

int main()
{
  int64_t A, B;
  int64_t V, W;
  int64_t T;
  cin >> A >> V >> B >> W >> T;

  if (B < A) swap(A, B);

  if (A + T * V >= B + T * W) {
    cout << YES << endl;
  }
  else {
    cout << NO << endl;
  }

  return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(){
    
int a,b;
    while(1){
    scanf("%d %d",&a,&b);
    if(a==0 && b==0){
        break;
    }
    else{
        for(int i=0 ; i<a ; i++){
            for(int j=0 ; j<b ; j++){
                if(i==0 || i==a-1 || j==0 || j==b-1 ){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}

	
	
	
	return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int num[2005];
int main() {
    int n, cnt = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &num[i]);
    }
    sort(num, num + n);
    /*for (int i = 0; i < n; i++) {
        printf("%5d", i);
    }
    printf("\n");
    for (int i = 0; i < n ; i++) {
        printf("%5d", num[i]);
    }
    printf("\n");*/
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            int x = lower_bound(num + j + 1, num + n, num[i] + num[j]) - num - 1;
            // printf("%d %d %d %d %d\n", i, j, num[i] + num[j], x, x - j);
            cnt += x - j;
        }
    }
    printf("%d", cnt);
    return 0;
}

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

const int MAXN=1e5+5;

int n;
int a[MAXN],cnt[MAXN];

int main()
{
	int i,ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",a+i);
	for(i=1;i<=n;i++)
	{
		if(a[i]>n) ans++;
		else cnt[a[i]]++;
	}
	for(i=1;i<=n;i++)
		if(cnt[i]>=i) ans+=cnt[i]-i;
		else ans+=cnt[i];
	printf("%d",ans);
	return 0;
}


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

int main() {
    int N;
  	string S;
    cin >> N >> S;
    long long r = 0, g = 0, b = 0;
    for (int i=0; i<N; ++i) {
        if (S.at(i) == 'R') ++r;
        else if (S.at(i) == 'G') ++g;
        else ++b;
    }
    long long sub = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (S.at(i) == S.at(j)) continue;
            int k = j*2-i;
            if (k >= N || S.at(k) == S.at(i) || S.at(k) == S.at(j)) continue;
            ++sub;
        }
    }
    cout << r*g*b - sub << endl;
}

Measured memory_bytes: 3152
class Array
  def sb
    sort_by.with_index{ |e, index| [yield(e), index] }
  end
end

while true do
  mm, tt, pp, rr = gets.split.map(&:to_i)
  break if mm + tt + pp + rr == 0
  wa = Array.new(tt).map{Array.new(pp,0)}
  solved = Array.new(tt, 0)
  time = Array.new(tt, 0)
  rr.times do
    m, t, p, j = gets.split.map(&:to_i)
    t -= 1
    p -= 1
    if j == 0
      solved[t] += 1
      time[t] += m + wa[t][p] * 20
    else
      wa[t][p] += 1
    end
  end
  teams = (0...tt).to_a.reverse
  result = teams.sb{|x| time[x]}.sb{|x| - solved[x]}
  tt.times do |i|
    t = result[i]
    if i != 0
      s = result[i-1]
      print time[s] == time[t] && solved[s] == solved[t] ? '=' : ','
    end
    print t + 1
  end
  puts
end

Measured memory_bytes: 6160
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    int a, b, ans=-1; cin >> a >> b;
    if(a < 10 && b < 10) ans = a * b;
    cout << ans << "\n";
    return 0;
}

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

ll solve() {
    ll N;
    cin >> N;
    string s;
    vector<int> num_min(26, 10000);
    for ( int i = 0; i < N; i++ ) {
        cin >> s;
        vector<int> num(26); 
        for ( char c : s ) {
            num[(int)(c-'a')]++;
        }
        for ( int j = 0; j < 26; j++ ) {
            num_min[j] = min(num[j], num_min[j]);
        }
    }
    
    for ( int i = 0; i < 26; i++ ) {
        for ( int j = 0; j < num_min[i]; j++ ) {
            cout << (char)('a'+i);
        }
    }
    cout << "\n";
    ll ans=0;
    return ans;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    string s;
      cin>>s;
  int n=s.size();
  rep(i,n){
    if(i%2==0){cout<<s[i];}
  }
  return 0;
}


Measured memory_bytes: 512
n,q=[int(i) for i in input().split()]
s=input()
AC=[0]*n
cnt=0
for i in range(1,n):
    if s[i-1:i+1]=="AC":
        cnt+=1
    AC[i]=cnt
for i in range(q):
    l,r=[int(j) for j in input().split()]
    print((AC[r-1]-AC[l-1]))

Measured memory_bytes: 6164
a, b, c = map(int,input().split())
m = max(a,b,c)
a = abs(a-m)
b = abs(b-m)
c = abs(c-m)
cnt = 0
cnt += a//2 + b//2 + c//2
a -= a//2 * 2
b -= b//2 * 2
c -= c//2 * 2
if a + b + c == 2:
    cnt += 1
elif a + b + c == 1:
    cnt += 2

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


string s;

int main(){
	cin >> s;
	
	char cr[4] = {'A','C','G','T'};
	
	int cnt = 0;
	int b = 0;
	for(int i = 0; i < s.size(); i++){
		bool a = 0;
		for(int j = 0; j < 4; j++){
			if(s[i] == cr[j]) a = 1;
		}
		if(a) b++;
		else b = 0;
		cnt = max(cnt,b);
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  string S;
  cin >> S;
  
  if (S[S.size()-1] == 's')
    S += "es";
  else
    S += "s";

  cout << S << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    int N, M, K;
    cin >> N >> M >> K;

    set<int> s;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=M;j++){
            int n = i * M - j * i + (N - i) * j;
            s.insert(n);
        }
    }
    if(s.count(K) == 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

int main()
{
  int N, cnt=0;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A.at(i);
  rep(i, N){
    while(A.at(i)%2==0){
      cnt++;
      A.at(i)/=2;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;
import java.lang.System;
import java.io.*;
class Main{

  private static int top;
  private static String[] s=new String[1000];

  public static void initialize(){
    top=0;
    return;
  }

  public static boolean isEmpty(){
    if(top==0)
      return true;
    return false;
  }

  public static boolean isFull(){
    if(top>=1000)
      return true;
    return false;
  }

  public static void push(String str){
    if(isFull()) System.out.println("Error");
    s[++top]=str;
  }

  public static String pop(){
    if(isEmpty()) System.out.println("Error");
    return s[top--];
  }

  public static void main(String args[]) throws Exception{
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      String line= br.readLine();
      int a,b;
      s[0]=null;

      //while ((line = br.readLine()) != null) {
        //System.out.println(line);
        String[] str = line.split(" ");
        for(int i=0;i<str.length;i++){
          //System.out.println(str[i]);
          if(str[i].equals("+")){
            b=Integer.parseInt(pop());
            a=Integer.parseInt(pop());
            push(String.valueOf(a+b));
            //System.out.println(a+b);
          }
          else if(str[i].equals("-")){
            b=Integer.parseInt(pop());
            a=Integer.parseInt(pop());
            push(String.valueOf(a-b));
            //System.out.println(a-b);
          }
          else if(str[i].equals("*")){
            b=Integer.parseInt(pop());
            a=Integer.parseInt(pop());
            push(String.valueOf(a*b));
            //System.out.println(a*b);
          }
          else{
            push(str[i]);
          }
        }

      //System.out.println("done");
      }
      //System.out.println("done");
      String answer=pop();
      System.out.println(answer);
    //}
  }
}



Measured memory_bytes: 24460
#include <stdio.h>

int main(void) {
	int n,i,j;
	int a;
	int exist[10001]={0};
	int smalla[10];
	int smalla_num;
	int result[3]={1000000000,1000000000,1000000000};
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%d",&a);
		exist[a]=1;
	}
	smalla_num=0;
	for(i=0;i<=10000 && smalla_num<10;i++) {
		if(exist[i])smalla[smalla_num++]=i;
	}
	for(i=0;i<smalla_num;i++) {
		for(j=0;j<smalla_num;j++) {
			char buffer[100];
			int now;
			if(i==j)continue;
			sprintf(buffer,"%d%d",smalla[i],smalla[j]);
			sscanf(buffer,"%d",&now);
			if(now<=result[2])result[2]=now;
			if(now<=result[1]){result[2]=result[1];result[1]=now;}
			if(now<=result[0]){result[1]=result[0];result[0]=now;}
		}
	}
	printf("%d\n",result[2]);
	return 0;
}

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

int x[105], y[105], n, vis[205], T, ans = 0, lk[205];
vector<int> e[105];

bool Find(int u) {
  for (auto &v : e[u]) {
    if (vis[v] == T) continue;
    vis[v] = T;
    if (lk[v] == 0 || Find(lk[v])) {
      lk[v] = u;
      return 1;
    }
  }
  return 0;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", x + i, y + i);
  }
  for (int j = 1; j <= n; j++) {
    int a, b;
    scanf("%d %d", &a, &b);
    for (int i = 1; i <= n; i++)
      if (x[i] < a && y[i] < b) e[i].push_back(j);
  }
  for (int i = 1; i <= n; i++) {
    T = i;
    if (Find(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, a[10010], b[10010], suma, sumb, num, numa, numb;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        suma += a[i];
    }
    for (ll i = 0; i < n; i++) {
        cin >> b[i];
        sumb += b[i];
    }
    num = sumb - suma;
    for (ll i = 0; i < n; i++){
        if (a[i] > b[i]){
            numb += a[i] - b[i];
        } if (a[i] < b[i]){
            numa += (b[i] - a[i] + 1) / 2;
            numb += (b[i] - a[i]) % 2;
        }
    }
    if (num < numa || num < numb){
        cout << "No" << endl;
        return 0;
    }
    cout << ((num - numa) * 2 == (num - numb) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var A = GetLongs(N);

		var cnt = new long[101010];
		for(long i = 0; i < N; i++)
			cnt[A[i]]++;

		long S = A.Sum();
		long Q = GetLong();
		var ans = new long[Q];
		for(long i = 0; i < Q; i++)
		{
			long B = GetLong();
			long C = GetLong();
			S += (C - B) * cnt[B];
			cnt[C] += cnt[B];
			cnt[B] = 0;
			ans[i] = S;
		}		
		WriteLine(string.Join("\n", ans));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

int top, st[1000];

void push(int x)
{
    top++;//加算して
    st[top] = x;//その位置に積める
}

int pop(void)
{
    top--;
    return st[top+1];//さっきまでtopが指していたもの
}

int main(void)
{
    int a,b;
    top = 0;
    char s[100];

    while(scanf("%s", s) != EOF)
    {
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }else if(s[0] == '-'){
            a = pop();
            b = pop();
            push(b - a);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }else{
            push(atoi(s));
        }
    }

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

    return 0;
}


Measured memory_bytes: 2056
#include<stdio.h>
#include<iostream>

int main(){
int a,i,b=0;
std::string s;
std::cin>>a>>s;
for(i=0;i<a-2;i++){
    if(s.at(i)=='A' && s.at(i+1)== 'B' &&s.at(i+2)=='C'){
b++;
    }
} 
std::cout << b << std::endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int a[100000];

struct Row {
  int r_val, r_index, l_val, l_index;
};

void set(Row row){
  if ( (row.r_val + row.l_val) % 2 == 0){
    a[row.r_index] = a[row.l_index] = (row.r_val + row.l_val) / 2;
  } else if ( row.r_val % 2 == 0){
    a[row.r_index] = (row.r_val + row.l_val) / 2;
    a[row.l_index] = (row.r_val + row.l_val) / 2 + 1;
  } else {
    a[row.r_index] = (row.r_val + row.l_val) / 2 + 1;
    a[row.l_index] = (row.r_val + row.l_val) / 2;
  }
}

int main(){
  string s;
  cin >> s;
  for ( int i = 0; i < s.length(); i++ ){
    a[i] = 0;
  }

  Row row;
  row.r_val = row.l_val = 0;
  for ( int i = 0; i < s.length() - 1; i++){
    if ( s[i] == 'R' && s[i+1] == 'R'){
      row.r_val ++;
    }
    if ( s[i] == 'R' && s[i+1] == 'L'){
      row.r_val ++;
      row.r_index = i;
      row.l_index = i+1;
      if ( i == s.length() - 2){
        row.l_val ++;
        set(row);
      }
    }
    if ( s[i] == 'L' && s[i+1] == 'L'){
      row.l_val ++;
      if ( i == s.length() - 2){
        row.l_val ++;
        set(row);
      }
    }
    if ( s[i] == 'L' && s[i+1] == 'R'){
      row.l_val ++;
      set(row);

      // init
      row.r_val = row.l_val = 0;
    }

  }

  for ( int i = 0; i < s.length(); i++){
    cout << a[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
module Main where

unMaybe :: Maybe Integer -> Integer
unMaybe Nothing = -1
unMaybe (Just a) = a

maybeFold :: (a -> a -> Maybe a) -> a -> [a] -> Maybe a
maybeFold op acc (x:xs) = case op acc x of
	Nothing -> Nothing
	Just a -> maybeFold op a xs
maybeFold op acc [] = Just acc

maybeMul :: Integer -> Integer -> Maybe Integer
maybeMul a b = case a * b > 10^18 of
	True -> Nothing
	False -> Just $ a * b
	

catchZero :: [Integer] -> [Integer]
catchZero ns = case 0 `elem` ns of
	True -> [0]
	False -> ns

main :: IO ()
main = do
	nS <- getLine
	let n = read nS
	interact 	$ show
				. unMaybe
				. maybeFold (maybeMul) 1
				. catchZero
				. map (read) 
				. take n 
				. words



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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " << str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


int N, M;
vector<vector<int>> edges;
vector<int> dp;

int dfs(int now)
{
	if(dp[now] != -1)return dp[now];
	int res = 0;
	for(auto next : edges[now])res = max(res, dfs(next) + 1);
	dp[now] = res;
	return res;
}

//メイン関数
int main()
{
	cin >> N >> M;
	edges.resize(N);
	dp.resize(N, -1);
	REP(i, M)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		edges[a].push_back(b);
	}

	REP(i, N)if(dp[i] == -1)dfs(i);

	cout << *max_element(dp.begin(), dp.end()) << endl;
	cin >> N;

	return 0;
}


Measured memory_bytes: 8192
import math
a,b,x = map(int,input().split())
if x >= a**2*b/2:
    deg = (2*(a*a*b-x))/a**3
    print(math.degrees(math.atan(deg)))
else:
    deg = a*b*b/(2*x)
    print(math.degrees(math.atan(deg)))

Measured memory_bytes: 9280
#include <bits/stdc++.h>
using namespace std;
int n,ip1,fa;
bool vis[200050];
struct point{int father,c0,size;long long ans;vector<int>Link;}tree[200050];
struct node{
    int sit;
    double val;
    friend bool operator < (node x,node y) {return x.val<y.val;}
    friend bool operator > (node x,node y) {return x.val>y.val;}
}now;
priority_queue<node>q;
int main(){
    scanf("%d",&n);
    for (int i=2;i<=n;++i)
        scanf("%d",&tree[i].father),
        tree[tree[i].father].Link.push_back(i);
    for (int i=1;i<=n;++i){
        scanf("%d",&ip1);
        if(ip1==0) tree[i].c0=1;
        tree[i].size=1;
    }
    for (int i=2;i<=n;++i)
        q.push((node){i,1.0*tree[i].c0/tree[i].size});
    while(!q.empty()){
        now=q.top();q.pop();
        if(!vis[now.sit]){
            //cout<<now.sit<<endl;
            fa=tree[now.sit].father;
            tree[fa].ans+=tree[now.sit].ans+1LL*(tree[fa].size-tree[fa].c0)*tree[now.sit].c0;
            tree[fa].c0+=tree[now.sit].c0;
            tree[fa].size+=tree[now.sit].size;
            for (int i=tree[now.sit].Link.size()-1;i>=0;--i)
                if(!vis[tree[now.sit].Link[i]])
                    tree[fa].Link.push_back(tree[now.sit].Link[i]),
                    tree[tree[now.sit].Link[i]].father=fa;
            vis[now.sit]=1;
            tree[now.sit].Link.clear();
            if(fa!=1) q.push((node){fa,1.0*tree[fa].c0/tree[fa].size});
        }
    }
    printf("%lld",tree[1].ans);
    return 0;
}

Measured memory_bytes: 39664
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 3e3 + 6, M = 1e9 + 7;
ll a[N][N], dp[N][N][4][2];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, m, k;
    cin >> n >> m >> k;
    while (k--)
    {
        ll r, c, v;
        cin >> r >> c >> v;
        a[r][c] = v;
    }
    for (ll i = 1; i <= n; i++)
        for (ll j = 1; j <= m; j++)
        {
            ll mx = 0;
            for (ll k = 0; k < 4; k++)
                for (ll l = 0; l < 2; l++)
                    mx = max(mx, dp[i - 1][j][k][l]);
            dp[i][j][0][0] = max(mx, dp[i][j - 1][0][0]);
            for (ll k = 1; k < 4; k++)
                dp[i][j][k][0] = max(dp[i][j - 1][k][0], dp[i][j - 1][k][1]);
            dp[i][j][1][1] = mx + a[i][j];
            for (ll k = 1; k < 4; k++)
                dp[i][j][k][1] = max({dp[i][j][k][1], dp[i - 1][j][k - 1][1] + a[i][j], dp[i][j][k - 1][0] + a[i][j]});
        }
    ll mx = 0;
    for (ll k = 0; k < 4; k++)
        for (ll l = 0; l < 2; l++)
            mx = max(mx, dp[n][m][k][l]);
    cout << mx;
}

Measured memory_bytes: 637448
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 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() {
    int n, k; cin >> n >> k;
    vector<ll> A(n); rep(i, n) cin >> A[i];

    ll GCD = A[0], mx = A[0];
    for(int i=1; i<n; i++){
        GCD = __gcd(GCD, A[i]);
        chmax(mx, A[i]);
    }
    bool fg = true;
    if(k <= mx && k%GCD == 0) cout << "POSSIBLE" << ln;
    else cout << "IMPOSSIBLE" << ln;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    ll n;cin>>n;
    ll ans = n*(n-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
const ll maxn=1e5+3;
const ll mod=1e9+7;
vector<vector<int>> g(maxn);
int main()
{	
	fast;
	int n,m,i,j,k,a,b;
	cin>>n>>m;
	int h[n+1];
	for(i=1;i<=n;i++)
		cin>>h[i];
	for(i=0;i<m;++i){
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	int cnt=0;
	for(i=1;i<=n;++i){
		int f = 0;
		if(g[i].empty()){
			++cnt;
			continue;
		}
		for(int x : g[i]){
			if(h[x]>=h[i]){
				f=1;
				break;
			}
		}
		if(f==0)
			++cnt;
		
		
	}
	cout<<cnt;
}

Measured memory_bytes: 8676
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int main()
{
  while(true){
    int n,m;
    int res = 0;
    scanf("%d%d", &n, &m);
    if(n == 0 && m == 0 )break;
    vector<int> p;
    for(int i = 0; i < n; ++i){
      int t; scanf("%d", &t); p.push_back(t);
    }
    sort(p.begin(),p.end(),greater<int>() );
    int s=0;
    for(int i = 0; i < n; ++i){
      if((i+1)%m==0){
	//cout << " s = " << s << endl;
	res += s;
	s=0;
	continue;
      }
      s+=p[i];
    }
    res += s;
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 0