akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define MAX 500
typedef pair<int,int> P;
typedef pair<int,P> Q;

int main(){
  int N,H,a,b;
  string str;

  while(cin >> N >> H, (N | H)){
    set<Q> st;
    for(int i = 0 ; i < H ; i++){
      cin >> str >> a >> b; a--, b--;
      if(str == "xy"){
        for(int j = 0 ; j < N ; j++){
          st.insert(Q(a,P(b,j)));
        }
      }else if(str == "yz"){
        for(int j = 0 ; j < N ; j++){
          st.insert(Q(j,P(a,b)));
        }
      }else{
        for(int j = 0 ; j < N ; j++){
          st.insert(Q(a,P(j,b)));
        }
      }
    }
    cout << N*N*N-st.size() << endl;
  }

  return 0;
}

Measured memory_bytes: 4328
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    K--;
    vector<vector<long long>> dp(H+1, vector<long long>(W, 0));
    dp[0][0] = 1;

    // i 左右に棒がない場合の置き方
    vector<long long> tab0(W, 0);
    for(int i=0; i<W; i++){
        for(int j=0; j<(1<<(W-1)); j++){
            if((j & (1<<i))) continue;
            if(i != 0 && (j & (1<<(i-1)))) continue;
            bool ok = true;
            for(int k=0; k<W-2; k++)
                if((j&(1<<k)) && (j&(1<<(k+1)))){
                    ok = false;
                    break;
                }
            if(ok)
                tab0[i]++;
            tab0[i] %= MOD;
        }
        tab0[i] %= MOD;
    }

    // i <-> i+1 の棒がある場合の置き方
    vector<long long> tab1(W-1, 0);
    for(int i=0; i<W-1; i++){
        for(int j=0; j<(1<<(W-1)); j++){
            if(!(j & (1<<i))) continue;
            bool ok = true;
            for(int k=0; k<W-2; k++)
                if((j&(1<<k)) && (j&(1<<(k+1)))){
                    ok = false;
                    break;
                }
            if(ok)
                tab1[i]++;
            tab1[i] %= MOD;
        }
        tab1[i] %= MOD;
    }

//    for(int i=0; i<W; i++)
//        cerr << i << " " << tab0[i] << endl;
//    cerr << "HOGE" << endl;
//    for(int i=0; i<W-1; i++)
//        cerr << i << " " << tab1[i] << endl;

    for(int i=1; i<=H; i++){
        for(int j=0; j<W; j++){
            if(j != 0)
                dp[i][j-1] += dp[i-1][j] * tab1[j-1];
            dp[i][j-1] %= MOD;

            if(j != W-1)
                dp[i][j+1] += dp[i-1][j] * tab1[j];
            dp[i][j+1] %= MOD;

            dp[i][j] += dp[i-1][j] * tab0[j];
            dp[i][j] %= MOD;
        }
    }
    cout << dp[H][K] << endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
n = len(S)
m = len(T)

ans = 'UNRESTORABLE'
for i in range(n - m + 1):
    for j in range(m):
        if S[i + j] == T[j] or S[i + j] == '?':
            continue
        else:
            break
    else:
        x = S[: i] + T + S[i + m:]
        ans = x.replace('?', 'a')
        
print(ans)

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

int main (){
    ulong N,i,M,A,R,C,H,Answer;
    string name;

    M = 0;
    A = 0;
    R = 0;
    C = 0;
    H = 0;

    cin >> N;

    for(i=1;i<=N;i++){
        cin >> name;
        if(name[0]=='M'){
            M = M+1;
        }else if(name[0]=='A'){
            A = A+1;
        }else if(name[0]=='R'){
            R = R+1;
        }else if(name[0]=='C'){
            C = C+1;
        }else if(name[0]=='H'){
            H = H+1;
        }
        name.clear();
    }

    Answer = M*A*R;
    Answer = Answer + M*A*C  ;
    Answer = Answer + M*A*H ;
    Answer = Answer + M*R*C ;
    Answer = Answer + M*R*H ;
    Answer = Answer + M*C*H ;
    Answer = Answer + A*R*C ;
    Answer = Answer + A*R*H ;
    Answer = Answer + A*C*H ;
    Answer = Answer + R*C*H ;

    cout << Answer <<endl;
}

Measured memory_bytes: 256
program sample
implicit none
integer(8) N,K,A(200000),i,count,Sm,Ss,m
read(*,*)N,K
do i=0,N
 A(i)=i
end do
count=0
do i=K,N+1
   Sm=0
   Ss=0
    Sm=N*i-(i-1)*i/2+Sm
    Ss=Ss+(i-1)*i/2
count=count+Sm-Ss+1
end do
write(*,'(i0)') mod(count,10**9+7)

stop
end program sample

Measured memory_bytes: 2928
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[200000];
  for(int i=0;i<N;i++){
    cin >> A[i];
    }
  int big=-2000000000;
  int sma=A[0];
   for(int i=1;i<N;i++){
    big=max(big,A[i]-sma);
    sma=min(sma,A[i]);
  } 
  cout << big << endl;
  return 0;
}   



Measured memory_bytes: 3832
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>

using namespace std;

#define N 1000

int lcs(string X, string Y){
	int i,j,c[N+1][N+1],n,m;
	int maxl = 0;
	m = X.size();
	n = Y.size();

	X = ' ' + X;
	Y = ' ' + Y;

	for(i=1;i<=m;i++) c[i][0] = 0;
	for(j=0;j<=n;j++) c[0][j] = 0;

	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			if(X[i] == Y[j]){
				c[i][j] = c[i-1][j-1] + 1;
			}else{
				c[i][j] = max(c[i-1][j],c[i][j-1]);
			}
			maxl = max(maxl,c[i][j]);
		}
	}
	return maxl;
}

int main(void){

	string s1,s2;
	int i,n;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		cin >> s1 >> s2;
		cout << lcs(s1,s2) << endl;
		//printf("%d\n",lcs(s1,s2));
	}
	return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
// sort(arr, arr+n, greater<int>());
// const long double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}



	int main(void)
	{
		fast();
		ll x;
		cin>>x;
		ll c=0;
		ll an = 100;
		while(1)
		{
			if(an<x)
			{
				// an=an+(an*0.01);
				an=an+(an*double(double(1)/double(100)));
				c++;
			}
			else
			{
				break;
			}
		}
	    cout<<c<<endl;
	    return 0;
	}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <stack>
#define SIZE 12

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

char str[SIZE];

int main()
{
	scanf("%s",&str);
	int n=strlen(str);
	ll ret=0;
	for(int S=0;S<1<<(n-1);S++)
	{
		ll now=0;
		ll sum=0;
		for(int i=0;i<n;i++)
		{
			now*=10LL;
			now+=str[i]-'0';
			if(i<n-1&&(S>>i&1))
			{
				sum+=now;
				now=0;
			}
		}
		sum+=now;
		ret+=sum;
	}
	printf("%lld\n",ret);
	return 0;
}


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

int main(){
  int a,b,c;
  int d;
  cin >> a >> b >> c;
  
  d = 100*a+10*b+c;
  
  if( d % 4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<tuple<int,int,ll>> E(2010); // source, dest, weight
    for (int i=0;i<M;i++) {
        int a, b, c;
        cin >> a >> b >> c;
        E[i] = make_tuple(a,b,-c);
    }
    vector<pair<int,ll>> V(1010); // predecessor, distance
    V[1] = make_pair(0,0);
    for (int j=2;j<=N;j++) {
        V[j] = make_pair(0,1LL<<60);
    }
    for (int j=1;j<N;j++) {
        for (int i=0;i<M;i++) {
            int source, dest; ll cost;
            tie(source, dest, cost) = E[i];
            if (V[dest].second > V[source].second + cost) {
                V[dest].second = V[source].second + cost;
                V[dest].first = source;
            }
        }
    }
    vector<bool> negloop(1010,false);
    for (int j=1;j<=N;j++) {
        for (int i=0;i<M;i++) {
            int source, dest; ll cost;
            tie(source, dest, cost) = E[i];
            if (V[source].second + cost < V[dest].second) {
                V[dest].second = V[source].second + cost;
                negloop[dest] = true;
            }
            if (negloop[source]) negloop[dest] = true;
        }
    }
    if (negloop[N]) cout << "inf" << endl;
    else cout << -V[N].second << endl;

    return 0;
}


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

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

using namespace std;

bool pal(const string& s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

int main() {
  string S;
  cin >> S;
  string a = S.substr(0, (S.size() - 1) / 2);
  string b = S.substr((S.size() + 3) / 2 - 1);
  //  cout << a << " " << b << endl;
  cout << (pal(S) && pal(a) && pal(b) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

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

	if (K % 2 == 0) { cout << (K / 2) * (K / 2) << endl; }
	else { cout << (K + 1) / 2 * (K - 1) / 2 << endl; }
}

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

int N;
int count=0;

int main(){
  cin >> N;
  for(int donut=0;donut<=25;++donut){
    for(int cake=0;cake<=14;++cake){
      int total = 7*donut + 4*cake;
      if(total == N) ++count;
    }
  }
  if(count > 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MD=998244353;

int madd(int x,int y) {
	if (x+y<MD) return x+y; else return x+y-MD;
}
int msub(int x,int y) {
	if (x-y>=0) return x-y; else return x-y+MD;
}
int mmul(int x,int y) {
	return int(ll(x)*y % MD);
}
int mpow(int x,int p) {
	int res=1;
	while (p>0) {
		if (p%2) res=mmul(res,x);
		x=mmul(x,x);
		p/=2;
	}
	return res;
}
int minv(int x) {
	return mpow(x,MD-2);
}
int mdiv(int x,int y) {
	return mmul(x,mpow(y,MD-2));
}

int const MAXN=2.2e6;
int fact[MAXN];
int invfact[MAXN];
void mfact_init() {
	fact[0]=invfact[0]=1;
	rep(i,1,MAXN) {
		fact[i]=mmul(fact[i-1],i);
		invfact[i]=minv(fact[i]);
	}
}
inline int mcomb(int x,int y) {
	if (x<y) return 0;
	return mmul(fact[x],mmul(invfact[x-y],invfact[y]));
}
inline int mdistr(int x,int y) {
	return mcomb(x+y-1,y-1);
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	mfact_init();

	int N,M;
	cin>>N>>M;
	
	int res=0;
	rep(i,0,min(N,M)+1) if ((3*M-i)%2==0) {
		int add=mmul(mcomb(N,i),mdistr((3*M-i)/2,N));
		res=madd(res,add);
	}
	rep(i,0,min(N,M)+1) if ((M-i)%2==0) {
		int sub=mmul(mcomb(N,i),mdistr((M-i)/2,N));
		res=msub(res,mmul(sub,N));
	}
	rep(i,0,min(N,M)+1) if ((M-i)%2==0) {
		int add=mmul(mcomb(N-1,i),mdistr((M-i)/2,N-1));
		res=madd(res,mmul(add,N));
	}
	cout<<res<<'\n';
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=100010, LOG=20;

ll n, T, u, v, x, y, t, a, b, ans;
ll A[MAXN], dp[MAXN];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	cin>>A[n+1]>>T;
	for (int i=1; i<=n; i++) cin>>A[i];
	int pnt=n+1;
	ll mn=INF;
	for (int i=n; i; i--){
		while (2*(A[pnt-1]-A[i])>=T){
			pnt--;
			mn=min(mn, 2*A[pnt]+dp[pnt+1]);
		}
		dp[i]=T+dp[pnt];
		dp[i]=min(dp[i], mn - 2*A[i]);
		
	}
	cout<<A[n+1]+dp[1]<<"\n";
	
	return 0;
}


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

#define ll long long
int main() {
  ll X; cin >> X;
  
  ll n = 1;
  while (true) {
    if (n * (n+1)/ 2 >= X) {
      cout << n << endl;
      return 0;
    }
    n++;
  }
  
}

Measured memory_bytes: 3644
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    long[] p = new long[a];
    long[] q = new long[b];
    long[] r = new long[c];

    for (int i = 0; i < a; i++) {
      p[i] = sc.nextLong();
    }

    for (int i = 0; i < b; i++) {
      q[i] = sc.nextLong();
    }

    for (int i = 0; i < c; i++) {
      r[i] = sc.nextLong();
    }

    Arrays.sort(p);
    Arrays.sort(q);
    Arrays.sort(r);

    long[] data = new long[x+y+c];
    int count = 0;

    for (int i = a-x; i < a; i++) {
      data[count] = p[i];
      count++;
    }

    for (int i = b-y; i < b; i++) {
      data[count] = q[i];
      count++;
    }

    for (int i = 0; i < c; i++) {
      data[count] = r[i];
      count++;
    }

    Arrays.sort(data);

    long sum = 0;

    for (int i = count-1; i >= count-x-y; i--) {
      sum += data[i];
    }

    System.out.println(sum);


  }

}


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

int main() {
  
  int n;
  int sum = 1;
  cin >> n;
  vector<string> a(n);
  
  for (int i = 0; i<n;i++){
    cin >> a.at(i);
  }
    sort(a.begin(), a.end());
  
  for (int i = 1;i<n;i++){
    if(a.at(i) != a.at(i-1)){
      sum = sum +1;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 9548
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
const ll M=1e5+5;
ll a[M],ans[M];
inline ll read()
{
	ll x=0,f=1; char ch=0;
	while(!isdigit(ch)) f=(ch=='-'?-1:1),ch=getchar();
	while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*f;
}
int main()
{
	ll n=read(),sum=0,s=0;
	for(register ll i=1;i<=n;i++){
		a[i]=read(); a[i]*=2; sum+=a[i];
		if(i%2) s+=a[i];
	}
	sum=sum/2-s+a[n]; ans[n]=sum;
	for(register ll i=n-1;i>=1;i--){
		ans[i]=a[i]-ans[i+1];
	}
	for(register ll i=1;i<=n;i++){
		printf("%lld ",ans[i]);
	}
	return 0;	
}

Measured memory_bytes: 2816
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n,r,ans=0;
    cin>>n>>r;
    if(n>=10) ans=r;
    else ans=100*(10-n)+r;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

class ModInt:

    def __init__(self, mod=1000000007, mem_size=3000000):
        self.mod = mod
        self.mem_factorial = [0] * mem_size
        self.mem_size = mem_size
        self.mem_inv = [0] * mem_size
        self.mem_invfactorial = [0] * mem_size
        self.mem_factorial[0] = 1
        self.mem_inv[1] = 1
        self.mem_invfactorial[0] = 1
        for i in range(1, mem_size):
            self.mem_factorial[i] = self.mem_factorial[i-1]*i % mod
            if i > 1:
                self.mem_inv[i] = (-1) * (mod//i) * (self.mem_inv[mod % i]) % mod
            self.mem_invfactorial[i] = self.mem_invfactorial[i-1] * self.mem_inv[i] % mod

    def inverse(self, x):
        if x < self.mem_size:
            return self.mem_inv[x]
        mod = self.mod
        return int(pow(x, mod-2, mod))

    def factorial(self, x):
        return self.mem_factorial[x]

    def invfactorial(self, x):
        return self.mem_invfactorial[x]


    def comb(self, m, n):
        mod = self.mod
        a = self.factorial(m)
        b = self.invfactorial(n)
        c = self.invfactorial(m - n)
        ret = a * b * c % mod
        return ret

mod = 1000000007

modint = ModInt(mod)


def r_sum(r, c):
    a = modint.factorial(c + r + 1) * (r + 1)
    b = modint.invfactorial(c + 1) * modint.invfactorial(r + 1)
    ret = a * b
    return ret % mod


def F(r, c):
    ret = 0
    for i in range(c + 1):
        ret += r_sum(r, i)
    return ret % mod

r_from, c_from, r_to, c_to = map(int, input().split())

ans = F(r_to, c_to)
ans -= F(r_to, c_from - 1)
ans -= F(r_from - 1, c_to)
ans += F(r_from - 1, c_from - 1)
ans %= mod

print(ans)


Measured memory_bytes: 112348
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    h, w = LI()
    s = LSR(h)
    for i in range(h):
        for j in range(w):
            if s[i][j] == "snuke":
                print(chr(ord("A") + j) + str(i + 1))
                return
        
    return


#main
if __name__ == '__main__':
    solve()


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

using namespace std;

#define endl '\n'

int main(){

  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);
  
  int n,m;
  cin >> n >> m;

  int h[n+1];

  for(int i=1;i<=n;i++)
    cin >> h[i];

  bool good[n+1];

  for(int i=1;i<=n;i++)
    good[i] = true;

  while(m--){
    int a,b;
    cin >> a >> b;
    if(h[a] > h[b])
      good[b] = false;
    else if(h[b] > h[a])
      good[a] = false;  
    else
      good[a] = good[b] = false;
  }

  int ans = 0;

  for(int i=1;i<=n;i++)
    if(good[i])
      ans++;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		string S;
		cin >> S;

		int N = (int)S.size();
		vector<int> a( N );

		for( int i = 0; i < N-1; ++i ) {
			if( S[i] != 'R' || S[i+1] != 'L' ) { continue; }

			for( int j = i; j >= 0 && S[j] == 'R'; --j ) {
				if( (i-j)%2 == 0 ) { a[i] += 1; }
				else { a[i+1] += 1; }
			}

			for( int j = i+1; j < N && S[j] == 'L'; ++j ) {
				if( (j-i)%2 == 0 ) { a[i] += 1; }
				else { a[i+1] += 1; }
			}
		}

		for( int i = 0; i < N; ++i ) {
			cout << a[i] << "\n "[i < N-1];
		}
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	set<string> s;
	string last;
	for(int i=0;i<n;i++)
	{
		string s1;cin>>s1;
		if(i==0){last=s1; s.insert(s1);continue;}
		if(s1[0]!=last.back()||s.find(s1)!=s.end())
		{
			cout<<"No"<<endl;
			return 0;
		}
		last=s1;
		s.insert(s1);
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,Ans;
  int A[2000];
int solve(int i ,int m){
  if(m==0){
    return 1;
  }
  if(i>=n){
    return 0;
  }
  Ans=solve(i+1,m-A[i])|solve(i+1,m);
  return Ans;
}

int main(){
  int q,m,i;

  scanf("%d",&n);
  for( i=0;i<n;i++){
  scanf("%d",&A[i]);
}
scanf("%d",&q);
for(i=0;i<q;i++){
  scanf("%d",&m);
if  (solve(0,m))printf("yes\n");
else printf("no\n");
}

  return 0;
}

Measured memory_bytes: 584
S = raw_input()

formulas = [S[0]]
for i in range(1,len(S)):
    f1 = formulas[:]
    f2 = formulas[:]
    f1 = map(lambda f: f + S[i], f1)
    f2 = map(lambda f: f + '+' + S[i], f2)
    formulas = f1 + f2

all_sum = 0
for formula in formulas:
    arr = map(int, formula.split('+'))
    all_sum += sum(arr)
print all_sum


Measured memory_bytes: 2692
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INF = 100000000000;
 
int main() {
		int A,B,Q;
		cin >> A >> B >> Q;
		vector<ll> s(A+2), t(B+2);
 
		s[0] = -INF;
		for (int i=1; i<=A; i++) cin >> s[i]; s[A+1] = INF;
		t[0] = -INF;
		for (int i=1; i<=B; i++) cin >> t[i]; t[B+1] = INF;
		
		for (int i=0; i<Q; i++) {
				ll x; cin >> x;
				auto sitr = upper_bound(s.begin(), s.end(), x);
				auto titr = upper_bound(t.begin(), t.end(), x);
 
				int sidx = distance(s.begin(), sitr);
				int tidx = distance(t.begin(), titr);
 
				vector<ll> sroute{s[sidx-1], s[sidx]};
				vector<ll> troute{t[tidx-1], t[tidx]};
 
				long ans = INF;
				for (auto S: sroute) {
						for (auto T: troute) {
								long d1 = abs(S-x) + abs(T-S);
								long d2 = abs(T-x) + abs(S-T);
								ans = min(min(ans, d1), d2); 
						}
				}
				cout << ans << endl;
		}
}

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

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

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

int n, k;

ll f(vector<int> v) {
	ll ret = 0, res = 1;
	int i;
	for(i = 0; i < k; i++) {
		res *= v[i];
	}
	ret = res;

	for(; i < n; i++) {
		res *= v[i];
		res /= v[i-k];
		ret = max(ret, res);
	}
	return ret;
}

int main() {
	while(cin >> n >> k) {
		if(n == 0 && k == 0) break;

		vector<int> v(n);
		rep(i, n) cin >> v[i];

		ll x = f(v);
		ll ans = -INF;

		rep(i, n) {
			REP(j, i+1, n) {
				swap(v[i], v[j]);
				ans = max(ans, f(v) - x);
				swap(v[i], v[j]);
			}
		}

		if(ans >= 0) cout << ans << endl;
		else cout << "NO GAME" << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
module Main where

main :: IO ()
main = do
    n <- readLn
    let s = f "" n
    putStrLn $ s

f :: String -> Int -> String
f "" 0 = "0"
f s  0 = s
f s n | n `mod` 2 == 0 = f ('0' : s) (n `div` (-2))
      | otherwise      = f ('1' : s) ((n - 1) `div` (-2))


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define ll long long int
 
using namespace std;
int main(){
 
ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    cin>>a>>b;
    cout<<a*b/__gcd(a,b);
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ac = [0 for _ in range(n)]
pen = [0 for _ in range(n)]

for _ in range(m):
  p, s = input().split()
  p = int(p) - 1
  if s == 'WA':
    if ac[p] == 0:
      pen[p] += 1
  else:
    ac[p] = 1

for p in range(n):
  if ac[p] == 0:
    pen[p] = 0
print(str(sum(ac)) + ' ' + str(sum(pen)))

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

vector<int> odd(100010,0);
vector<int> even(100010,0);

int main(){
    int n;
    cin >> n;
    int res = 0;
    rep(i,n){
        int v;cin >> v;
       if(i%2==0){
           even[v]++;
       }else{
           odd[v]++;
       }
    }
    int max_odd = 0,max_even = 0;
    int second_odd = 0,second_even = 0;

    rep(i,100001) {
        if(odd[max_odd]<odd[i]) {
            second_odd = max_odd;
            max_odd = i;
        }
        else if(odd[second_odd] < odd[i]) {
            second_odd = i;
        }
        if(even[max_even] < even[i]) {
				second_even = max_even;
				max_even = i;
		}
		else if (even[second_even] < even[i]) {
				second_even = i;
		}
    }

    if(max_odd != max_even) {
        res = accumulate(odd.begin(), odd.end(), 0) - odd[max_odd];
		res += accumulate(even.begin(), even.end(), 0) - even[max_even];
    }else{
        int tmp;
        tmp = accumulate(odd.begin(), odd.end(), 0) - odd[max_odd];
		tmp += accumulate(even.begin(), even.end(), 0) - even[second_even];
 
		res = accumulate(odd.begin(), odd.end(), 0) - odd[second_odd];
	    res += accumulate(even.begin(), even.end(), 0) - even[max_even];
 
		if (tmp < res) res = tmp;
    }

    
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int a,b,c,k,j;
    cin>>a>>b>>c;
    k=a;
    j=0;
    while(1){
        if(c%k==0){
            j += 1;
        }
    if(k==b)break;
    k+=1;
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const LL INF = 1LL << 60;
typedef pair <int, int> PR;
priority_queue <PR> qua;
#define mst(x) memset(x, 0, sizeof(x))
vector <int> vec;
LL n, x;
LL g[55]; //总厚度
LL f[55]; //p的厚度

void Init() {
	mst(g);
	mst(f);
	scanf("%lld %lld", &n, &x);
}

int main() {
	Init();
	g[1] = 5, f[1] = 3;
	for(int i = 2; i <= 50; i++) {
		g[i] = g[i - 1] * 2 + 3;
		f[i] = f[i - 1] * 2 + 1;
	}
	LL res = 0;
	if(x <= n) res = 0;
	else {
		for(int i = n; i >= 1; i--) {
			if(x >= g[i] + n - i) {
				x -= (g[i] + n - i);
				res += f[i];
				if(x) x--, res++;
				n = i;
			}
		}
		if(x - n == 1) res++;
		else if(x - n == 2) res += 2;
		else if(x - n >= 3) res += 3;
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] arr = new int[]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
            int k = in.nextInt();
            out.println(arr[k - 1]);
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 24916
S = input()
T = [c for c in S]
if int(T[0]) * 1000 + int(T[1]) * 100 + int(T[2]) * 10 + int(T[3]) <= 2018 or  (int(T[0]) * 1000 + int(T[1]) * 100 + int(T[2]) * 10 + int(T[3]) == 2019 and int(T[5]) * 1000 + int(T[6]) * 100 + int(T[8]) * 10 + int(T[9]) <= 430 ):
  print('Heisei')
  exit()
print('TBD')  

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

int main() {
  int N, A, rest;
  cin >> N >> A;
  rest = N % 500;
    
  if (rest <= A) {
    cout << "Yes" << endl;
  }
  
  else if (rest > A) {
    cout << "No" << endl;
  }
  
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();
		int check=0;
		for(int i=1;i<=100;i++) {
			if((a*i)%b==c) {
				check=1;
				break;
			}
		}
		System.out.println((check==1)? "YES":"NO");

	}
}

Measured memory_bytes: 21972
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;
	if(N%2==1){
		cout << "No" << endl;
		return 0;
	}
	bool flag=1;
	for(int i=0; i<N/2; ++i){
		if(S[i]!=S[i+N/2]){
			flag=0;
		}
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int X;
  
  if(K >= (A + B)){
    X = A + B*(K-A)*0 + (K-A-B)*(-1);
    
  cout << X << endl;
  }
  
   else if(A > K){
     cout << K << endl;
   }       
  else{
    cout << A << endl;
  }
      }

Measured memory_bytes: 3644
#include<stdio.h>
#define N 100
 
int main(){
  int i, j, k, key, n, A[N];
  scanf("%d", &n);
  for(i = 0; i < n ; i++)scanf("%d", &A[i]);
  for(i = 1; i <= n; i++){
    key = A[i];
    j = i - 1;
    for(k=0; k < n; k++){
      printf("%d", A[k]);
      if(k < n-1)printf(" ");
    }
    printf("\n");
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }
  }
  return 0;
}


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

typedef long long int ll;
ll n, k, a[1007];

int main() {
    scanf("%lld %lld", &n, &k);
    for(ll i = 0; i < n; ++i) scanf("%lld", &a[i]);
    sort(a, a + n);

    ll cnt = 0;
    for(ll i = 0; i < k; ++i) cnt += a[i];

    printf("%lld\n", cnt);
    return 0;
}

Measured memory_bytes: 3784
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>

#define MAX_INT 2147483647
#define long long long int

using std::vector;
using std::map;
using std::string;
using std::pair;
using std::cin;
using std::cout;

// @author: pashka

int dist(int a, int b, int n) {
    a %= n;
    b %= n;
    int x = abs(a - b);
    return std::min(x, n - x);
}

int main() {
    std::ios::sync_with_stdio(false);

    string a, b;
    cin >> a >> b;
    int n = a.size();

    {
        bool ok = false;
        for (int i = 0; i < n; i++) {
            if (b[i] == '1') {
                ok = true;
                break;
            }
        }
        if (!ok) {
            ok = true;
            for (int i = 0; i < n; i++) {
                if (a[i] == '1') {
                    ok = false;
                    break;
                }
            }
            if (!ok) {
                cout << "-1\n";
            } else {
                cout << "0\n";
            }
            return 0;
        }
    }


    int res = MAX_INT;

    for (int shift = 0; shift < n; shift++) {
        int s = 0;

        vector<int> l(n);
        l[0] = 0;
        while (b[(n - l[0]) % n] == '0') {
            l[0]++;
        }
        for (int i = 1; i < n; i++) {
            l[i] = b[i] == '1' ? 0 : l[i - 1] + 1;
        }

        vector<int> r(n);
        r[n - 1] = 0;
        while (b[(n - 1 + r[n - 1]) % n] == '0') {
            r[n - 1]++;
        }
        for (int i = n - 2; i >= 0; i--) {
            r[i] = b[i] == '1' ? 0 : r[i + 1] + 1;
        }

        vector<int> p(n, 0);
        for (int i = 0; i < n; i++) {
            if (a[i] != b[i]) {
                s++;
                p[l[i]] = std::max(p[l[i]], r[i]);
            }
        }
        int min = MAX_INT;
        int rr = 0;
        for (int ll = n - 1; ll >= 0; ll--) {
            min = std::min(min, ll + 2 * rr + dist(n - ll, n - shift, n));
            min = std::min(min, rr + 2 * ll + dist(rr, n - shift, n));
            rr = std::max(rr, p[ll]);
        }
        s += min;

//        cout << a << "\n";
//        cout << b << "\n";
//        cout << s << " " << min << "\n";

        res = std::min(res, s);
        b = b.substr(1, n) + b[0];
    }

    cout << res;


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 200'009;

char s[N];
int f[N][2];

int main() {
  scanf("%s", s + 1);
  int n = (int)strlen(s + 1);
  const int inf = -1'000'000'000;
  f[0][0] = 0;
  f[0][1] = 0;
  f[1][0] = 1;
  f[1][1] = inf;
  for (int i = 2; i <= n; ++i) {
    f[i][1] = 1 + f[i - 2][0];
    f[i][0] = 1 + f[i - 1][1];
    if (s[i] != s[i - 1]) {
      f[i][0] = max(f[i][0], 1 + f[i - 1][0]);
    }
  }
  printf("%d\n", max(f[n][0], f[n][1]));
}


Measured memory_bytes: 1920
def solve():
    n = int(input())
    print(n+n**2+n**3)
# testcases = int(input())
# for i in range(testcases):
#     n = int(inpuy())
#     for io ionr age(tsettesfcases:
#         iif n==132:
#             the n 
solve()

Measured memory_bytes: 9056
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
	int n;
	int a[20][20];
	while(scanf("%d", &n), n){
		memset(a, 0, sizeof a);
		int y = n / 2 + 1;
		int x = n / 2;
		for(int k = 1; k <= n * n; ++k){
			if(a[y][x] != 0){
				y = (y + 1) % n;
				x = (x + n - 1) % n;
			}
			a[y][x] = k;
			y = (y + 1) % n;
			x = (x + 1) % n;
		}
		
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < n; ++j){
				printf("%4d", a[i][j]);
			}
			puts("");
		}
	}
}

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

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

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

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

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

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

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

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

fn main(){

    input!{
        a: u8,
        b: u8,
    }

    let mut ab: String = String::new();
    let mut ba: String = String::new();

    for i in 0..b{
        ab += &a.to_string();
    }

    for j in 0..a{
        ba += &b.to_string();
    }

    if ab >= ba {
        println!("{}", ba);
    } else {
        println!("{}", ab);
    }

}

Measured memory_bytes: 4352
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, W = LI()
    vw = [LI() for _ in range(N)]

    vw.sort(key=lambda x: x[0]/x[1], reverse=True)
    ans = 0
    i = 0
    while i < N and W - vw[i][1] > 0:
        ans += vw[i][0]
        W -= vw[i][1]
        i += 1

    if i < N:
        ans += vw[i][0] * W / vw[i][1]

    print(ans)

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 25992
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;

void main()
{
  int m = readln.chomp.split.back.to!int;
  string s = readln.chomp;
  int l = 0, r = 1;
  // bool[string] set;
  bool[ulong[2]] set;
  auto hasher = new RollingHash(s);
  foreach (i; 0 .. m)
  {
    string v = readln;
    auto f = function(char c, ref int w) {
      if (c == '+')
      {
        ++w;
      }
      else
      {
        --w;
      }
    };
    if (v[0] == 'L')
    {
      f(v[1], l);
    }
    else
    {
      f(v[1], r);
    }
    set[hasher.substr(l, r)] = true;
    // set[s[l..r]] = true;
  }
  writeln = set.length;
}

class RollingHash
{
  enum ulong MOD1 = 1_000_000_007;
  enum ulong MOD2 = 1_000_000_009;
  enum ulong B1 = 1_009;
  enum ulong B2 = 1_007;

  ulong[] b1s, b2s;
  ulong[] array1;
  ulong[] array2;
  this(string s)
  {
    array1 ~= 0;
    array2 ~= 0;
    b1s ~= 1;
    b2s ~= 1;
    foreach (c; s)
    {
      array1 ~= ((array1.back + ulong(c)) * B1) % MOD1;
      array2 ~= ((array2.back + ulong(c)) * B2) % MOD2;
      b1s ~= (b1s.back * B1) % MOD1;
      b2s ~= (b2s.back * B2) % MOD2;
    }
  }

  ulong[2] substr(uint l, uint r)
  {
    ulong h1 = (array1[r] - ((b1s[r - l] * array1[l]) % MOD1) + MOD1) % MOD1;
    ulong h2 = (array2[r] - ((b2s[r - l] * array2[l]) % MOD2) + MOD2) % MOD2;
    return [h1, h2];
  }
}

Measured memory_bytes: 42616
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;

bool operator<(const Point &a, const Point &b) {
    return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

struct Line: public vector<Point> {
    Line() {}
    Line(const Point &a, const Point &b) {
        push_back(a);
        push_back(b);
    }
};

struct Circle {
    Point p;
    double r;
    Circle() {}
    Circle(const Point &p, const double r): p(p), r(r) {}
};

int main() {
    double x, y;
    scanf("%lf %lf", &x, &y);
    Point p1(x, y);

    scanf("%lf %lf", &x, &y);
    Point p2(x, y);

    Point e(real(p2)-real(p1), imag(p2)-imag(p1));
    e /= abs(e);

    size_t q;
    scanf("%zu", &q);
    for (size_t i=0; i<q; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        Point p(x, y);

        double r=dot_prod(p-p1, e);
        Point h=p1+r*e;
        Point z=p+2.0*(h-p);
        printf("%.12f %.12f\n", real(z), imag(z));
    }

    return 0;
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  ll sum=0;
  for(int i=1;i<=n;i++){
    if((i%3!=0)&&(i%5!=0)){
      sum+=i;
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
using namespace std;
const int N=1e3+10;
int max(int a,int b){return a>b?a:b;}
int main(){
    int n,dp[N][N];
    string a,b;
    scanf("%d",&n);
    while(n--){
        cin>>a>>b;
        a='!'+a;
        b='@'+b;
        for(int i=0;i<a.size();i++)dp[i][0]=0;
        for(int i=0;i<b.size();i++)dp[0][i]=0;
        for(int i=1;i<a.size();i++)for(int j=1;j<b.size();j++){
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            if(a[i]==b[j])dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
        }
        printf("%d\n",dp[a.size()-1][b.size()-1]);
    }
}


Measured memory_bytes: 7164
def insertionSort(A, N):
    print(' '.join(map(str, A)))
    for i in range(1, N):
        value = A[i]
        j = i - 1
        while j >= 0 and A[j] > value:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = value
        print(' '.join(map(str, A)))


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    insertionSort(A, N)


Measured memory_bytes: 5604
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	long long n,a[200000],i,m,b;
	scanf("%lld",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	m=0; b=0; b=a[0];
	for(i=0;i<n-1;i++){
		if(a[i]>a[i+1]){
			m+=b-a[i+1];
			a[i+1]=a[i];
		}
		else{
			b=a[i+1];
		}
	}	
	printf("%lld\n",m);	
	return 0;
}

Measured memory_bytes: 3292
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  if (S == "AAA" or S == "BBB") {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#define INT long long int
using namespace std;

INT v[3], f;

int main()
{
    for(int i = 0 ; i < 3 ; i++ )
    {
        cin>>v[i];
    }
    sort(v, v+3);
    if( v[2]%2 == 0 || v[1]%2 == 0 || v[0]%2 == 0 ) cout<<0<<endl;
    else cout<<(v[0]*v[1]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define stoink stack<ll>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define vgw vector<vector<pair<ll,ll> >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000000
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin >> n;
	vec arr(n);
	ll i;
	ll ans;
	for ( i = 0 ; i < n ; i++) {
		cin >> arr[i];
	}
	ans = arr[0];
	for(i = 1 ; i < n;i++) {
		ans = __gcd ( ans, arr[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> a(n-1);
  for(int i = 0; i < n-1; i++) cin >> a[i];
  
  vector<int> b(n+1);
  b[0] = 0;
  
  for(int i = 0; i < n-1; i++) b[a[i]] += 1;
  
  for(int i = 1; i < n + 1; i++) cout << b[i] << endl;
}


Measured memory_bytes: 4796
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;

    vector<int> x(n);
    REP(i, n) cin >> x[i];
    
    ll ans = INF;
    ll temp = 0;
    for(int i = 1; i <= 100; i++) {
        temp = 0;
        for(int j = 0; j < n; j++) {
            temp += pow(abs(x[j]-i), 2);     
        }
        chmin(ans, temp);
    }


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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
    return x>y;
}
const int N=10005;
const int mod=1e9+7;
int main()
{
    std::ios::sync_with_stdio(false);
    int n,l;
    cin>>n>>l;
    string a;
    priority_queue<string,vector<string>,greater<string> >q;
    for(int i=0;i<n;i++){
        cin>>a;
        q.push(a);
    }
    while(q.size()>0){
        string b=q.top();
        cout<<b;
        q.pop();
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    long a, b, r, lcm, x, y;
    while (scanf("%ld %ld",&a,&b) != EOF) {
        x=a;
        y=b;
        for (;;) {
            r=x%y;
            if (r==0)
                break;
            x=y;
            y=r;
        }
        lcm=a*b/y;
        printf("%-ld %-ld\n",y,lcm);
    }
    
    return 0;
}

Measured memory_bytes: 596