akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 100050;

int N, M;
int A[MAX_N], B[MAX_N], C[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> M;

    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
    }

    for (int i = 1; i <= M; i++) {
        std::cin >> B[i] >> C[i];
    }

    std::vector<int> proc;
    for (int i = 1; i <= M; i++) {
        proc.push_back(i);
    }
    std::sort(proc.begin(), proc.end(),
        [&](const int i, const int j) { return C[i] > C[j]; }
    );

    std::vector<int> card;
    int cnt = 0;
    for (int i : proc) {
        for (int j = 0; j < B[i]; j++) {
            card.push_back(C[i]);
            cnt++;
            if (cnt == N) {
                break;
            }
        }
        if (cnt == N) {
            break;
        }
    }

    for (int i = 1; i <= N; i++) {
        card.push_back(A[i]);
    }

    std::sort(card.begin(), card.end(), std::greater<int>());

    long long ret = 0;
    for (int i = 0; i < N; i++) {
        ret += card[i];
    }

    std::cout << ret << std::endl;

    return 0;
}

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

int n, y;
int main() {  
  cin >> n >> y;
  rep(i,n + 1) {
    rep(j,n + 1 -i){
      int k = n - i - j;
      if ( i * 10000 + j * 5000 + k * 1000  == y) {
        cout <<  i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout <<  -1 << " " << -1 << " " << -1 << endl;
   
  return 0;
}

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

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

  int cnt = 0;
  for(int x = a; x <= b; x++){
    if(c % x == 0) cnt++;
  }

  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long a, b; 
	while (true) {
		cin >> a >> b;
		if (a == 0 && b == 0) return 0;
		for (int h = 1; h <= a; h++) {
			if (h == 1 || h == a){
				for (int i = 1; i <= b; i++) {
					cout << '#';
				}
			}
			else {
				cout << '#';
				for (int i = 1; i <= b - 2; i++) {
					cout << '.';
				}
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3072
e, y = gets.chomp.split.map(&:to_i)
year = nil
case e
when 0
    if y < 1912
        year = "M" + (y - 1867).to_s
    elsif y < 1926
        year = "T" + (y - 1911).to_s
    elsif y < 1989
        year = "S" + (y - 1925).to_s
    else
        year = "H" + (y - 1988).to_s
    end
when 1
    year = y + 1867
when 2
    year = y + 1911
when 3
    year = y + 1925
when 4
    year = y + 1988
end
puts year



Measured memory_bytes: 8916
H, W = map(int, input().split())

m = []
for i in range(H):
    m.append(list(input().strip()))

for h in range(H):
    for w in range(W):
        if m[h][w] != '#':
            continue
        # left
        if w - 1 >= 0:
            if m[h][w - 1] == '#':
                continue
        # right
        if w + 1 < W:
            if m[h][w + 1] == '#':
                continue
        # top
        if h - 1 >= 0:
            if m[h - 1][w] == '#':
                continue
        # right
        if h + 1 < H:
            if m[h + 1][w] == '#':
                continue
        print('No')
        exit()

print('Yes')



Measured memory_bytes: 3064
from heapq import heappush, heappop

N, K = map(int, input().split())
a, b = (
    zip(*(map(int, input().split()) for _ in range(N - 1))) if N - 1 else
    ((), ())
)

MOD = 10**9 + 7

G = [set() for _ in range(N + 1)]
for x, y in zip(a, b):
    G[x].add(y)
    G[y].add(x)
q = []
v = [False for _ in range(N + 1)]
heappush(q, (1, 1))
ans = K
v[1] = True
while q:
    i, c = heappop(q)
    X = {x for x in G[i] if not v[x]}
    for l, j in enumerate(X):
        heappush(q, (j, 2))
        ans = (ans * (K - c - l)) % MOD
        v[j] = True

print(ans)


Measured memory_bytes: 126040
# ABC044C - 高橋君とカード / Tak and Cards (ARC060C)
def main():
    N, A = tuple(map(int, input().rstrip().split()))
    X = tuple(map(int, input().rstrip().split()))
    x = max(X)
    # dp[i][j][k] := patterns to make k by j cards from X1, X2, ..., Xi
    dp = [[[0] * (N * 50 + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    dp[0][0][0] = 1
    for i in range(N):
        for j in range(N):
            for k in range(N * 50 + 1):
                if dp[i][j][k]:
                    dp[i + 1][j][k] += dp[i][j][k]
                    dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]
    ans = sum(dp[N][i][i * A] for i in range(1, N + 1))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 91740
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        
        System.out.println(Math.min(b/a, c));
    }
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  int a[n],i;
  double b[n],sum=0.0;
  for(i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i]+0.0;
    b[i]=1/b[i];
    sum+=b[i];
  }
  sum=1/sum;
  cout<<sum<<endl;
  return 0;
}


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

using namespace std;
using ll = int64_t;
using VL = vector<ll>;
using VD = vector<double>;
using VVL = vector<VL>;
using VVD = vector<VD>;

#define FOR(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i < (i ## xxxx_end); ++i)
#define FORD(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i > (i ## xxxx_end); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPD(i, n) FORD(i, n - 1, -1)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template<class T, class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return 1; } return 0; }

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}

#define INF 1000000000000
#define MOD 1000000007

ll N;
VD A;
VVD dp;

void solve() {
    cin >> N;
    A = VD(N);
    for(auto& i : A) {
        cin >> i;
    }
    dp = VVD(N + 1, VD(N + 1, 0));  // dp[i][j] i枚目まででj枚表の確率
    dp[0][0] = 1.0;
    REP(i, N) {
        REP(j, i + 1) {
            dp[i + 1][j] += dp[i][j] * (1 - A[i]);
            dp[i + 1][j + 1] += dp[i][j] * A[i];
        }
    }
    // print(dp);
    double ans = 0.0;
    FOR(i, (N / 2) + 1, N + 1) {
        ans += dp[N][i];
    }
    cout << fixed <<setprecision(10) << ans << endl;
}

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

Measured memory_bytes: 70784
n = int(input())
s = input()
a = set()
aa = set()
aaa = set()
for i in range(n):
    x = s[i]
    for yy in aa:
        aaa.add(yy+x)
    for y in a:
        aa.add(y+x)
    a.add(x)
print(len(aaa))

Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<int>a(n + 1);
    rep(i,n)cin >> a[i + 1];
    vector<int>c(n + 1);
    vector<int>b;
    for(int i = n; i >= 1; i--){
        int s = 0;
        for(int j = i; j <= n; j+= i){
            s += c[j];
        }
        if(s % 2 != a[i]){
            c[i]++;
            b.push_back(i);
        }
    }
    cout << b.size() << "\n";
    for(int i = 0; i < b.size(); i++){
        cout << b[i] << " \n"[i == b.size() - 1];
    }
}

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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<int, P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;

void solve(){
    int N, L;
    cin >> N >> L;
    vector<int> A(N), ans;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    stack<int> fs, bs, num;
    fs.push(INF);
    bs.push(INF);
    for(int i=0;i<L;i++){
        bs.push(min(bs.top(),A[i]));
        num.push(A[i]);
    }
    ans.push_back(bs.top());
    for(int i=L;i<N;i++){
        if(num.size() >= L){
            while(!num.empty()){
                bs.pop();
                fs.push(min(fs.top(),num.top()));
                num.pop();
            }
        }
        num.push(A[i]);
        bs.push(min(bs.top(),A[i]));
        fs.pop();
        ans.push_back(min(bs.top(), fs.top()));
    }
    for(int i=0;i<N-L+1;i++){
        if(i > 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

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



Measured memory_bytes: 11504
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int N;
  int a[110];
  int Alice = 0;
  int Bob = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  sort(a,a+N);
  reverse(a,a+N);
  for(int i = 0; i < N; i++){
    if(i%2 == 0){
      Alice += a[i];
    }else{
      Bob += a[i];
    }
  }
  cout << Alice-Bob << endl;
  return 0;
}


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

bool is_prime(int n)
{
    if (n == 1 || n == 0) {
        return false;
    }
    for (int i = 2; i < n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main()
{
    int q;
    std::cin >> q;

    std::vector<int> l(q), r(q);
    for (int i = 0; i < q; i++) {
        std::cin >> l[i] >> r[i];
    }

    int l_min = *std::min_element(l.begin(), l.end());
    int r_max = *std::max_element(r.begin(), r.end());

    std::vector<long long> dp(r_max + 1);
    dp[0] = 0;

    for (int i = 1; i <= r_max; i++) {
        dp[i] = dp[i - 1] + (is_prime(i) && (is_prime((i + 1) / 2)));
    }

    for (int i = 0; i < q; i++) {
        std::cout << dp[r[i]] - dp[l[i] - 1] << std::endl;
    }
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// mint
template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};

// fact
template<typename INT>
struct factorial {
  std::vector<INT> fact, ifact;
  void init(int64_t N) {
    fact.resize(N+1); ifact.resize(N+1);
    fact[0] = fact[1] = INT(1);
    for(int i = 2; i <= N; ++i) fact[i] = fact[i-1]*i;
    ifact[N] = fact[N].inv();
    for(int i = N-1; i >= 0; --i) ifact[i] = ifact[i+1]*(i+1);
  }
  INT comb(int64_t n, int64_t k) { 
    if(k > n || k < 0) return INT(0);
    return fact[n]*ifact[k]*ifact[n-k];
  }
  INT hcomb(int64_t n, int64_t k) { return comb(n+k-1, k); }
};

int64_t const MOD = 1e9+7;
using mint = mod_int<MOD>;
factorial<mint> F;

int main() {
  int N, K; std::cin >> N >> K;
  F.init(N);
  for(int i = 1; i <= K; ++i) {
    std::cout << (F.hcomb(i, K-i)*F.hcomb(i+1, N-K-(i-1))).v_;
    std::cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
long long int x,k,d,big,amari;
  scanf("%lld %lld %lld",&x,&k,&d);
  
  
  big=pow(10,15);
  if(big/k >= d){
  
  
  if(x>=k*d) printf("%lld",x-k*d);
  else if(x<=-k*d) printf("%lld",-x-k*d);
  else 
  {
  if((labs(x)/d)%2==k%2) printf("%lld",llabs(llabs(x)-(llabs(x)/d)*d));
  else printf("%lld",llabs(llabs(x)-(llabs(x)/d+1)*d));
  }
  }
  
  else
  {
    
    
   if((labs(x)/d)%2==k%2) printf("%lld",llabs(llabs(x)-(llabs(x)/d)*d));
  else printf("%lld",llabs(llabs(x)-(llabs(x)/d+1)*d));
  } 
  
return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=5010,mod=1e9+7;
int h[N],f[N][N],g[N],sz[N];
int head[N],ecnt,n;
struct ed { int to,next; }e[N<<1];
void ad(int x,int y) {
    e[++ecnt]=(ed){y,head[x]}; head[x]=ecnt;
    e[++ecnt]=(ed){x,head[y]}; head[y]=ecnt;
}
void dfs(int u,int last) {
    sz[u]=1,f[u][1]=1;
    for(int k=head[u];k;k=e[k].next) {
        int v=e[k].to; if(v==last) continue;
        dfs(v,u);
        for(int j=0;j<=sz[u];++j)
            for(int k=0;k<=sz[v];++k)
                g[j+k]=(g[j+k]+f[u][j]*(ll)f[v][k])%mod;
        sz[u]+=sz[v];
        for(int j=0;j<=sz[u];++j) f[u][j]=g[j],g[j]=0;
    }
    for(int j=1;j<=sz[u];++j) f[u][0]=(f[u][0]-f[u][j]*(ll)h[j])%mod;
}
int main() {
    rd(n);
    for(int i=1,x,y;i<n;++i) rd(x),rd(y),ad(x,y);
    h[2]=1; for(int i=4;i<=n;i+=2) h[i]=h[i-2]*(ll)(i-1)%mod;
    dfs(1,0);
    printf("%d",((mod-f[1][0])%mod+mod)%mod);
    return 0;
}


Measured memory_bytes: 97280
import sys
from collections import Counter

n = int(sys.stdin.readline().strip())

S = []
for _ in range(n):
    s_i = sys.stdin.readline().strip()
    S.append(s_i)

intersec = Counter(S[0])
for i in range(n):
    now = Counter(S[i])
    tmp = {}
    for char, count in intersec.items():
        if char not in now:
            continue
        else:
            tmp[char] = min(count, now[char])
    intersec = tmp

ans = ""
for (n_i, count) in sorted(intersec.items()):
    ans += n_i * count

print(ans)

Measured memory_bytes: 39536
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define INF (int)1e14+5
#define nax (ll)2e5+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
 
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
// look for  all edge cases
//search for a pattern



//dp[l][r] -> 
ll dp[405][405];


int main(){
	fast;
	int n;
	cin >> n;
	memset(dp,INF,sizeof(dp));
	vector<ll> v(n+1);
	for(int i =1 ; i<=n;i++){
		cin >> v[i];
	}
	int len = 0;
	for(int i=  1;i<=n;i++){
		dp[i][i] = 0;
	}
	//cout<<"\n";
	
	vector<ll> pre(n+1,0);
	for(int i = 1; i<=n;i++){
		pre[i]  = pre[i-1] + v[i];
	}
	
	for( ; len < n-1 ; len++){
		for(int i = n ; i > len+1; --i){
			int j = i-len-1;
			//deb(j);
			//deb(i);
			//dp[j][i] = min(v[j] + pre[i] - pre[j]+dp[i-len][i] ,dp[j][j+len] +v[i] + pre[j+len] - pre[j-1]);
			//deb(dp[j][j+len]+dp[i][i]);
			//deb(dp[j][j]+dp[i-len][i]);
			//deb(dp[j][i]);
			for(int k = j;k <= i-1;k++){
				//debi;
				dp[j][i] = min(dp[j][i],pre[k] - pre[j-1] + pre[i] - pre[k] + dp[j][k] + dp[k+1][i]);
			}
			//deb(dp[j][i]);
		}
	}
	//newline;
	cout<<dp[1][n];
	
	return 0;
}

	


Measured memory_bytes: 1536
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL N, A, B;
LL ans;

int main()
{
	in >> N >> A >> B;
	if (A > B)
	{
		out << 0 << std::endl;
		return 0;
	}
	if (N == 1 && A != B)
	{
		out << 0 << std::endl;
		return 0;
	}
	if (N == 1)
	{
		out << 1 << std::endl;
		return 0;
	}
	N -= 2;
	ans = N*(B - A) + 1;
	out << ans << std::endl;
	return 0;
}

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

for i in range(1, N):
  a[i] += a[i-1]

res = abs(a[0] - (a[-1]-a[0]))
for i in range(N-1):
  res = min(res, abs(a[i] - (a[-1] - a[i])))

print(res)

Measured memory_bytes: 24832
#include<iostream>
#include<fstream>
#include<stack>
#include<string>
#include <stdlib.h>

using namespace std;

int getTop(stack<int> &s) {
	int tmp = s.top();
	s.pop();
	return tmp;
}

int main() {
	ifstream fin("in.txt");

	string in;
	stack<int> s;

	int ans = 0;

	while (cin >> in){
		if(in == "+") {
			ans = getTop(s) + getTop(s);
			s.push(ans);
		}
		else if (in == "-") {
			int tmp = getTop(s);
			ans = getTop(s) - tmp;
			s.push(ans);
		}
		else if (in == "*") {
			ans =  getTop(s) * getTop(s);
			s.push(ans);
		}
		else if (in == "/") {
			double tmp = (double)getTop(s);
			double tmp2 = getTop(s) / tmp;
			s.push(1.0 / tmp2);
		}
		else s.push(atoi(in.c_str()));		

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc133_d.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<ll> c(N);
  ll tot = 0;
  rep(i, N) {
    cin >> c[i];
    tot += c[i];
  }

  vector<ll> x(N);
  ll tmp = 0;
  for (int i = 1; i < N; i+= 2) {
    tmp += c[i];
  }
  x[0] = tot - 2 * tmp;

  rep(i, N - 1) { x[i + 1] = (c[i] - x[i] / 2) * 2; }
  rep(i, N) { cout << x[i] << ' '; }
}

Measured memory_bytes: 4768
#include <iostream>
#include <unordered_map>
using namespace std;
typedef long long lli;
#define MOD 1000000007
lli n,a,b,c,d;
lli dp[1001][1001];
bool bl[1001][1001];


lli exeuclid(lli a,lli aa,lli x,lli xx,lli y,lli yy){
	lli q;
	if(a == 0) return aa > 0 ? xx : -xx;
	q = aa / a;
	return exeuclid(aa - q * a,a,xx - q * x,x,yy - q * y,y);
}

lli invarse(lli x){
    static unordered_map<lli,lli> dp;
    if(dp[x]) return dp[x];
	return dp[x] = (exeuclid(MOD,x,0,1,1,0) + MOD) % MOD;
}


lli factrial(lli x){
	static lli dp[100000];
	if(dp[x]) return dp[x];
	if(x == 0) 	return dp[x] = 1;
				return dp[x] = (factrial(x-1) * x) % MOD;
}
lli pow(lli a,lli n,lli mod = 1000000007){
	lli ret = 1;
	for(;n!=0;n=n>>1){
		if(n&1) ret = (ret * a) % mod;
		a = (a * a) % mod;
	}
	return ret;
}
lli f(lli n,lli k,lli x){
    lli ret = factrial(n);ret %= MOD;
    ret *= invarse(factrial(n-x*k));ret %= MOD;
    ret *= invarse(pow(factrial(k),x));ret %= MOD;
    ret *= invarse(factrial(x));ret %= MOD;
    return ret;
}
lli dfs(lli i,lli j){
    if(bl[i][j]) return dp[i][j];
    bl[i][j] = true;
    if(i < a) return dp[i][j] = j ? 0 : 1;
    dp[i][j] = dfs(i-1,j);
    for(lli k = c;k <= d && j-k*i >= 0;k++){
        dp[i][j] += dfs(i-1,j-k*i)*f(j,i,k);
        dp[i][j] %= MOD;
    }
    return dp[i][j];
}
int main(int argc, char const *argv[]) {
    cin >> n >> a >> b >> c >> d;
    cout << dfs(b,n) << endl;
    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
ll N;

ll count(const string& s)
{
    ll res = 0;
    rep(i, s.size() - 1)
    {
        if (s[i] == 'A' && s[i + 1] == 'B') {
            ++res;
        }
    }
    return res;
}

signed main()
{
    cin >> N;
    ll a = 0, b = 0, c = 0;
    ll cnt = 0;
    rep(i, N)
    {
        string s;
        cin >> s;
        cnt += count(s);
        if (s.front() == 'B' && s.back() == 'A') {
            ++a;
        } else if (s.back() == 'A') {
            ++b;
        } else if (s.front() == 'B') {
            ++c;
        }
    }
    ll add = 0;
    if (b + c == 0) {
        add = max(0ll, a - 1);
    } else {
        add = a + min(b, c);
    }
    cnt += add;

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import Data.List (sort)
import Control.Applicative ((<$>))
import Control.Monad (replicateM)

int2list :: (Read a, Show a, Integral a) => a -> [a]
int2list n = (map (read . (: "")) . show) n

list2int :: (Read a, Show a, Integral a) => [a] -> a
list2int ns = (read . concat . map show) ns

diff :: (Read a, Show a, Integral a) => a -> a
diff n = maxn - minn
    where
        nlist = sort $ int2list n
        minn = list2int nlist
        maxn = list2int $ reverse nlist

main :: IO ()
main = do
    n <- read <$> getLine
    ds <- replicateM n $ show . diff . read <$> getLine
    putStr $ unlines ds

Measured memory_bytes: 3952
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define pb push_back
#define mp make_pair
#define err(x) cout<<#x<<"= "<<x<<endl;
#define rep(i,n) for(int i =0; i< n; i++)
#define ff first
#define ss second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define SIZE 100010

int main(){
	ios::sync_with_stdio(false);
	ll r,x,k,n;
	cin>>k;
	cout<<50<<endl;
	n= 50;
	r = k%50; x = k/50;

	rep(i,r){
		cout<<100+x-r<<' ';
	}
	rep(i,50-r){
		cout<<49+x-r<<' ';
	}
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
//printf("%.10f\n", n);
ll res0[1234567]; char test[501][501];
signed main() {
	ll n, x = 0, z = 0, ans = INF; cin >> n;
	vector<ll> exist(n);
	rep(h, n) {
		rep(i, n) {
			cin >> test[h][i];
			if (test[h][i] == '#') {
				exist[i] = 1; x++;
			}
		}
	}
	if (x == 0) { cout << "-1\n"; return 0; }
	if (x == n * n) { cout << "0\n"; return 0; }
	rep(h, n) {
		ll cnt = 0; z = 0;
		rep(i, n) {
			if (test[h][i] == '.') {
				if (exist[h] == 1 || z != 0) { cnt++; }
				else { cnt += 2; z++; }
			}
			//cout << h << ' ' << cnt << endl;
		}
		ans = min(ans, cnt);
	}
	ll ok = 0;
	rep(h, n) {
		ll gh = 0;
		rep(i, n) {
			if (test[i][h] == '#') { gh++; }
		}
		if (gh == n) { ok++; }
	}
	cout << ans + n - ok << endl;
    return 0;
}

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

int main() {
    ll n,q;
    cin>>n>>q;
    vector<tuple<ll,ll,ll>> event;
    for(ll i=0;i<n;i++) {
        ll s,t,x;
        cin >>s>>t>>x;
        event.push_back(make_tuple(s-x,1,x));
        event.push_back(make_tuple(t-x,-1,x));
    }
    sort(event.begin(),event.end());
    set<ll> stop;
    ll i=0;
    for(ll j=0;j<q;j++) {
        ll d;
        cin>>d;
        while(i<2*n && get<0>(event[i])<=d) {
            if(get<1>(event[i])==1) {
                stop.insert(get<2>(event[i]));
            }else {
                stop.erase(get<2>(event[i]));
            }
            i++;
        }
        if(stop.empty()) {
            cout << -1 << endl;
        }else {
            cout << (ll)*stop.begin() << endl;
        }
    }
}


Measured memory_bytes: 21096
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(void)
{
  int n, l;
cin >> n >> l;

vector<int> apple_taste(n);
vector<int> absolute_taste(n);
int min = 101;
int total = 0;

for (int i = 0; i < n; i++)
{
	apple_taste[i] = l + (i+1) - 1;
	absolute_taste[i] = abs(apple_taste[i]);
	if (absolute_taste[i] < abs(min))
	{
		min = apple_taste[i];
	}	
}

for (int i = 0; i < n; i++)
{
	total += apple_taste[i];
}

cout << total - min;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;
int A[100010];
int n;
int main()
{
    cin >> n;
    REP(i, n)
        cin >> A[i];
    vector<ll> v;
    ll sum1 = 0,sum2=0;
    for (int i = 0; i < n; i++)
    {   if(i%2==0)
        sum1 += A[i];
        else
        sum2 += A[i];
    }
    v.push_back((sum1 - sum2));
    for (int i = 1; i < n-1; i++)
    {
        int s = v[i - 1];
        v.push_back(2*A[i-1] - s);
    }
     v.push_back(2 * A[n - 1] - v[0]);
    for (int i = 0; i < n; i++)
    {
        cout << v[i] << " ";
    }
   
    printf("\n");

    return 0;
}

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

int a, b, c, d;

int main(){
    cin >> a >> b >> c >> d;
    if(a < b){
        if(c < d){
            cout << a + c << endl;
        }else{
            cout << a + d << endl;
        }
    }else{
        if(c < d){
            cout << b + c << endl;
        }else{
            cout << b + d << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections

def solve(N:int,A:list,Q:int,B:list,C:list) -> None:
    total = sum(A)
    A = [str(a) for a in A]
    counter = collections.Counter(A)
    for b,c in zip(B,C):
        number = counter[str(b)]
        total = total - (number * b) + (number * c)
        print(total)
        counter[str(b)] = 0
        counter[str(c)] += number

def main():
    N = int(input())
    A = list(map(int,input().split()))
    Q = int(input())
    B = []
    C = []
    for _ in range(Q):
        b,c = map(int,input().split())
        B.append(b)
        C.append(c)
    # solve()
    solve(N,A,Q,B,C)

if __name__ == "__main__":
    main()


Measured memory_bytes: 40316
using System;

class AtCoder
{

    public static string Solve(string strs)
    {
        int count = 0;

        for (int i = 0; i < strs.Length; ++i)
        {
            foreach (char c in strs)
            {
                if (c == strs[i])
                {
                    ++count;
                }
            }
            if (count % 2 != 0)
            {
                return "No";
            }
            count = 0;
        }
        return "Yes";
    }

    static void Main()
    {
        string strs = Console.ReadLine();

        string answer = Solve(strs);
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 11092
x, n = map(int, input().split())
p_list = list(map(int, input().split()))

diffs = dict()
for i in range(100 + 2):
    diffs[i] = abs(x - i)
for p in p_list:
    diffs[p] = float('inf')

min_diff = float('inf')
min_num = float('inf')
for i in range(100 + 2):
    if min_diff > diffs[i]:
        min_diff = diffs[i]
        min_num = i
print(min_num)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

struct Edge {
	int to;
};
using Graph = vector<vector<Edge>>;
using P = pair<long, long>;
/* Lowlink: グラフの関節点・橋を列挙する構造体
	作成: O(E+V)
	関節点の集合: vector<int> aps
	橋の集合: vector<P> bridges
*/
struct LowLink {
	const Graph &G;
	vector<int> used, ord, low;
	vector<int> aps;  // articulation points
	vector<P> bridges;
	LowLink(const Graph &G_) : G(G_) {
		used.assign(G.size(), 0);
		ord.assign(G.size(), 0);
		low.assign(G.size(), 0);
		int k = 0;
		for(int i = 0; i < (int)G.size(); i++) {
			if(!used[i]) k = dfs(i, k, -1);
		}
		sort(aps.begin(), aps.end());		   // 必要ならソートする
		sort(bridges.begin(), bridges.end());  // 必要ならソートする
	}
	int dfs(int id, int k, int par) {  // id:探索中の頂点, k:dfsで何番目に探索するか, par:idの親
		used[id] = true;
		ord[id] = k++;
		low[id] = ord[id];
		bool is_aps = false;
		int count = 0;	// 子の数
		for(auto &e : G[id]) {
			if(!used[e.to]) {
				count++;
				k = dfs(e.to, k, id);
				low[id] = min(low[id], low[e.to]);
				if(par != -1 && ord[id] <= low[e.to]) is_aps = true;
				if(ord[id] < low[e.to]) bridges.emplace_back(min(id, e.to), max(id, e.to));	 // 条件を満たすので橋
			} else if(e.to != par) {														 // eが後退辺の時
				low[id] = min(low[id], ord[e.to]);
			}
		}
		if(par == -1 && count >= 2) is_aps = true;
		if(is_aps) aps.push_back(id);
		return k;
	}
};

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << A * B / 2 << "\n";
	return 0;
}

Measured memory_bytes: 256
x, k, d = map(int, input().split())

if abs(x) >= k * d:
    print(min(abs(x - k * d), abs(x + k * d)))
else:
    x = abs(x)
    s = x // d
    k -= s
    x %= d
    print(x if k % 2 == 0 else d - x)

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

int main(){

    char s[3];
    //for(int i=0; i<3; i++){
            scanf("%s",s);
    //printf("%s\n",s);

    if(s[1]=='B'){
        printf("ARC\n");
    }
    else{
    	printf("ABC\n");
    }


    return 0;

}

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


using namespace std;

#define MAXN 60
#define INF 99999999

int n;
int x[MAXN], y[MAXN];
map<int, map<int, int> > vis;

int main() {
    scanf("%d", &n);
    int i, j, k;
    for (i=1; i<=n; i++) {
        scanf("%d %d", &x[i], &y[i]);
        vis[x[i]][y[i]]=1;
    }
    if (n==1) {
        printf("1\n");
        return 0;
    }
    int ans = INF;
    int p, q;
    for (i=1; i<=n; i++) {
        for (j=1; j<=n; j++) {
            if (i==j) continue;
            p = x[i]-x[j];
            q = y[i]-y[j];
            int tot = 0;
            for (k=1; k<=n; k++) {
                if (vis[x[k]-p][y[k]-q]==0) {
                    tot++;
                }
            }
            ans = min(ans, tot);
        }
    }
    printf("%d\n", ans);
    return 0;
}








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

int main(void) {
  int n;
  int d[100];

  cin >> n;
  for (int i = 0; i < n; i++) cin >> d[i];

  set<int> val;
  for (int i = 0; i < n; i++){
    val.insert(d[i]);
  }

  cout << val.size() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const int N = 600000;
const int MOD = 1e9 + 7;

int n, m;
string s[500];
int dp[500][500];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) dp[i][j] = 1e9;
    dp[0][0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (i == 0 && j == 0) continue;
            if (i >= 1)
            {
                int x = dp[i - 1][j];
                if (s[i - 1][j] == '.' && s[i][j] == '#')
                {
                    x++;
                }
                dp[i][j] = min(dp[i][j], x);
            }
            if (j >= 1)
            {
                int x = dp[i][j - 1];
                if (s[i][j - 1] == '.' && s[i][j] == '#')
                {
                    x++;
                }
                dp[i][j] = min(dp[i][j], x);
            }
        }
    }
    cout << (s[0][0] == '#') + dp[n - 1][m - 1];
}


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

int main() {
    int A, P; cin >> A >> P;
    P += 3*A; 
    int ans = P/2;
    
    cout << ans << endl;
}


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

using namespace std;

int main(void) {
	string ans;
	int i, surplus, surplus_tmp;
	int A, B, C;
	cin >> A >> B >> C;
	surplus = A % B;
	ans = "NO";
	for (i = 1; i <= B; i++) {
		surplus_tmp = surplus * i % B;
		if (surplus_tmp == C) {
			ans = "YES";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}






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

using namespace std;

using int64 = long long;

int main() {
  int N;
  cin >> N;
  int64 latte = 1, malta = 1;
  for(int i = 0; i < N; i++) {
    int t, a;
    cin >> t >> a;
    __int128_t ok = 1LL << 60, ng = -1;
    while(ok - ng > 1) {
      __int128_t mid = (ok + ng) / 2;
      if(t * mid >= latte && a * mid >= malta) ok = mid;
      else ng = mid;
    }
    latte = t * ok;
    malta = a * ok;
  }
  cout << latte + malta << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{int H,W,i,j,k;
for(i=0;;i++){
scanf("%d%d",&H,&W);
if(H!=0&&W!=0){
for(j=0;j<H;j++){
for(k=0;k<W;k++){
if(j%2==1^k%2==0)       
putchar('#');
else{
putchar('.');}}
putchar('\n');}
putchar('\n');}
else return 0;}}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100001];
int n;
ll dp[100001];
ll cal(int i)
{
    if(i>=n)
    return 0;
    if(dp[i]!=-1)
    return dp[i];
    ll ans;
    if(i+1<=n)
    ans=(cal(i+1)+abs(a[i]-a[i+1]));
    if(i+2<=n)
    ans=min(ans,cal(i+2)+abs(a[i]-a[i+2]));
    dp[i]=ans;
    return ans;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    memset(dp,-1,sizeof(dp));
    ll ans=cal(1);
    cout<<ans;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T>
map<T, ll> get_zaatu(vector<T> vals) {
  sort(all(vals));
  vals.erase(unique(all(vals)), vals.end());
  map<T, ll> res;
  rep(i, vals.size()) res[vals[i]] = i;
  return res;
}
template<typename T>
void zaatu(vector<T>& vals) {
  map<T, ll> z = get_zaatu(vals);
  each(x, vals) x = z[x];
}
// template<typename T1, T2>
// void zaatu(vector<T1>& vals, const function<T2(T1)>& f) {
//   vector<T&> v;
//   each(x, vals) v.pb(f(x));
//   zaatu(v);
// }


int main() {
  ll a, b;
  while (cin >> a >> b) {
    cout << gcd(a, b) << " " << lcm(a, b) << endl;
  }
}



Measured memory_bytes: 3088
#include <iostream>
#include <map>

using namespace std;

int main() {
    int n, x;
    map<int, int> cnt1, cnt2;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        if (i % 2 == 0) {
            cnt1[x] += 1;
        } else {
            cnt2[x] += 1;
        }
    }

    int fir_max1 = -1, sec_max1 = -1, fir_max_val1 = 0, sec_max_val1 = 0;

    for (auto p : cnt1) {
        if (fir_max_val1 < p.second) {
            sec_max1 = fir_max1;
            sec_max_val1 = fir_max_val1;
            fir_max1 = p.first;
            fir_max_val1 = p.second;
        } else if (sec_max_val1 < p.second) {
            sec_max1 = p.first;
            sec_max_val1 = p.second;
        }
    }

    int fir_max2 = -1, sec_max2 = -1, fir_max_val2 = 0, sec_max_val2 = 0;

    for (auto p : cnt2) {
        if (fir_max_val2 < p.second) {
            sec_max2 = fir_max2;
            sec_max_val2 = fir_max_val2;
            fir_max2 = p.first;
            fir_max_val2 = p.second;
        } else if (sec_max_val2 < p.second) {
            sec_max2 = p.first;
            sec_max_val2 = p.second;
        }
    }

    if (fir_max1 == fir_max2) {
        cout << min(n - fir_max_val1 - sec_max_val2, n - fir_max_val2 - sec_max_val1) << endl;
    } else {
        cout << n - fir_max_val1 - fir_max_val2 << endl;
    }

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long a,b,k;
  cin>>a>>b>>k;
  if(a>=k){
    a-=k;
  }
 else if(a<k && b>=k-a){
   b-=k-a;
   a=0;
 }
else if(a<k && b<k-a){
  a=0;
  b=0;
}
cout<< a<<" "<<b <<endl;
 
}

Measured memory_bytes: 256
package main

import "fmt"

const INF = 1000000000

func main() {
  var h,w,xs,ys,xt,yt int
  var p string
  fmt.Scan(&h,&w)
  g := NewGraph(h+w+2)
  for i:=1;i<h+1;i++ {
    fmt.Scan(&p)
    for j:=1;j<w+1;j++ {
      if p[j-1:j] == "." { continue }
      g.Add(i,h+j,1)
      g.Add(h+j,i,1)
      if p[j-1:j] == "S" {
        xs,ys = i,j
        g.Add(0,i,INF)
        g.Add(0,h+j,INF)
      }
      if p[j-1:j] == "T" {
        xt,yt = i,j
        g.Add(i,h+w+1,INF)
        g.Add(h+j,h+w+1,INF)
      }
    }
  }
  if xs == xt || ys == yt { fmt.Println(-1);return }
  fmt.Println(g.FordFulkerson(0,h+w+1))
}

func min(n,m int) int {
  if n < m { return n }
  return m
}

type Edge struct { to,capa,rev int }
type Graph [][]Edge
func NewGraph(n int) Graph { return make([][]Edge,n) }
func(g Graph) AddEdge(fm int,e Edge) { g[fm] = append(g[fm],e) }
func(g Graph) Add(fm,to,capa int) {
  g.AddEdge(fm,Edge{to,capa,len(g[to])})
  g.AddEdge(to,Edge{fm,0,len(g[fm])-1})
}
func(g Graph) FordFulkerson(s,t int) int {
  used := make([]bool,len(g))
  var dfs func(int,int,int) int
  dfs = func(v,t,f int) int {
    if v == t { return f }
    used[v] = true
    for i,e := range g[v] {
      if used[e.to] || e.capa <= 0 { continue }
      d := dfs(e.to,t,min(f,e.capa))
      if d > 0 {
        g[v][i].capa -= d
        g[e.to][e.rev].capa += d
        return d
      }
    }
    return 0
  }
  for flow:=0;; {
    for i:=0;i<len(used);i++ { used[i] = false }
    f := dfs(s,t,INF)
    if f == 0 { return flow }
    flow += f
  }
}

Measured memory_bytes: 3200
#include <iostream>
using namespace std;
const int INF = 1<<29;
const int MAX_V = 110;
const int MAX_E = 1100;

int N, M;
int a[MAX_E], b[MAX_E], c[MAX_E]; // 各辺
int dist[MAX_V][MAX_V]; // Floyd-Warshall 用

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

    // Floyd-Warshall でよくやる初期化
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            dist[i][j] = INF;
        }
        dist[i][i] = 0; // ここがポイント
    }

    // 入力
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        --a[i], --b[i];
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }

    // Floyd-Warshall
    for (int k = 0; k < N; ++k)
        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    // 集計
    int res = 0;
    for (int i = 0; i < M; ++i) {
        if (c[i] > dist[a[i]][b[i]]) ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n, m;
int ans, res;

struct PP {
	int p;
	char s[5];
} a[maxx];

map <int, bool> flg;
map <int, int> cnt;

int main() {
	flg.clear();
	cnt.clear();
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++) scanf("%d %s", &a[i].p, a[i].s + 1);
	for(int i = 1; i <= m; i++) {
		if(!flg[a[i].p]) {
			if(a[i].s[1] == 'A') {
				flg[a[i].p] = 1;
				ans++;
				res += cnt[a[i].p];
			}
			else cnt[a[i].p]++;
		}
	}
	printf("%d %d\n", ans, res);
	return 0;
}

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

d_max = B // A + 1

cost = 0
x_1 = X_list.pop()
while(X_list):
    x_2 = X_list.pop()
    d = x_1 - x_2
    if d < d_max:
        cost += A * d
    else:
        cost += B
    x_1 = x_2

print(cost)


Measured memory_bytes: 15020
var a:array[0..51,0..51] of longint;n,m,i,j,s:longint;ch:char;
begin
 readln(n,m);
 for i:=1 to n do
  begin
   for j:=1 to m do
    begin
     read(ch);
     if ch='#' then a[i,j]:=1;
    end;readln;
  end;
 for i:=1 to n do
  begin
   for j:=1 to m do
    if a[i,j]<>0 then write('#')
                 else
                  begin
                   s:=a[i-1,j-1]+a[i,j-1]+a[i+1,j-1]+a[i-1,j]+a[i+1,j]+a[i-1,j+1]+a[i,j+1]+a[i+1,j+1];
                   write(s);
                  end;
   writeln;
  end;
end.

Measured memory_bytes: 128
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    String result = "";
    for(int i = 0; i < str.length(); i++){
      result = result + "x";
    }
    System.out.println(result);
  }
  
}


Measured memory_bytes: 23764
#include <iostream>

using namespace std;

const long long int MOD=1e9+7;

int main() {
    int N;
    cin >> N;
    string s1, s2;
    cin >> s1 >> s2;
    
    int pre=0;
    long long int ans;
    for(int i=0; i<s1.size(); i++) {
        if(i+1<s1.size() && s1[i]==s1[i+1]) {
            if(pre==0) {
                ans = 6;
            } else if(pre==1) {
                ans *= 2;
            } else {
                ans *= 3;
            }
            pre=2;
            i++;
        } else {
            if(pre==0) {
                ans = 3;
            } else if(pre==1) {
                ans *= 2;
            } else {
                ans *= 1;
            }
            pre=1;
        }
        ans %= MOD;
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256