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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long k;
  scanf("%lld", &k);
  long long x;
  scanf("%lld", &x);

  string ans;
  for (ll i = max(x - k + 1, -1000000LL); i <= min(x + k - 1, 1000000LL); i++) {
    ans += to_string(i) + " ";
  }
  ans.pop_back();
  cout << ans << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

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

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

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

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

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 A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A,B,C,D;
  
  scanf("%d %d %d %d",&A,&B,&C,&D);
  
  while(1){
    C-=B;
    if(C <= 0) {
      puts("Yes\n");
      break;
    }
    A-=D;
    if(A <= 0){
      puts("No\n");
      break;
    }
  }
  
  return 0;
}

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

int H,W;
int K;
char c[6][6+1];

int main(void){
    cin >> H >> W >> K;
    REP(i,H){
        REP(j,W){
            cin >> c[i][j];
        }
    }

    int ans=0;

    for(int bith=0;bith<(1<<H);bith++){
        for(int bitw=0;bitw<(1<<W);bitw++){
            int black=0;
                REP(i,H){
                    REP(j,W){
                        if(((bith>>i)&1)==0 && ((bitw>>j)&1)==0 && c[i][j]=='#')
                            black++;  
                    }
                }
            if(black==K)
                ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int, int> iP;

int main(){
  
  int N, M;
  vector < iP > bus;

  cin >> N;
  for(int i = 0; i < N; i++) {
    int h, m; cin >> h >> m;
    bus.push_back(make_pair(h, m));
  }
  cin >> M;
  for(int i = 0; i < M; i++) {
    int h, m; cin >> h >> m;
    bus.push_back(make_pair(h, m));
  }
  
  sort(bus.begin(), bus.end());
  bus.erase(unique(bus.begin(), bus.end()), bus.end());
  for(int i = 0; i < bus.size(); i++)
    printf("%d:%02d%c", bus[i].fr, bus[i].sc, (i + 1 != bus.size() ? ' ' : '\n'));
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    int n;
    vector < int > cur[42];
    int solve(vector < int >& cur) {
        multiset < int > all;
        for (int v : cur) all.insert(v);
        int ans = 0;
        while (!all.empty()) {
            auto it = --(all.end());
            int v = *it;
            all.erase(it);
            int pw = 1;
            while (v >= pw) pw *= 2;
            if (all.find(pw - v) != all.end()) {
                ans++;
                all.erase(all.find(pw - v));
            }
        }
        return ans;
    }
    int main() {
        //freopen("input.txt", "r", stdin);
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        srand(239);
        cin >> n;
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            int pw = 0;
            while (a % 2 == 0) {
                pw++;
                a /= 2;
            }
            cur[pw].push_back(a);
        }
        int ans = 0;
        for (int i = 0; i < 42; i++) {
            if (!cur[i].empty()) ans += solve(cur[i]);
        }
        cout << ans;
        return 0;
    }

Measured memory_bytes: 10484
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin>> n,n){
    char huda[100];
    for(int i=0;i<100;i++){
      cin>> huda[i];
    }

    int player=0;
    int score[10]={0};
    int stage=0;
    for(int i=0;i<100;i++){
      if(huda[i]=='M'){
	score[player]++;
      }
      else if(huda[i]=='S'){
	stage+=score[player]+1;
	score[player]=0;
      }
      else{
	score[player]+=stage+1;
	stage=0;
      }

      if(player==n-1) player=0;
      else player++;
    }

    sort(score,score+n);
    for(int i=0;i<n;i++){
      cout<< score[i]<< " ";
    }

    cout<< stage<< endl;
  }
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    string s;
    cin >> s;
    if (s == "Sunny") {
        s = "Cloudy";
    } else if (s == "Cloudy") {
        s = "Rainy";
    } else {
        s = "Sunny";
    }
    cout << s << endl;
}

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



Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int n,m;
int deg[100005];

int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> m;
	for (int u,v,i = 1;i <= m;i++)
	{
		cin >> u >> v;
		deg[u]++;
		deg[v]++;
	}
	for (int i = 1;i <= n;i++)
		if (deg[i] & 1)
		{
			puts("NO");
			return 0;
		}
	puts("YES");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;

}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
ll lcm(ll x,ll y)
{
	return (x*y)/__gcd(x,y);
}
ll cc(ll a,ll b,ll c)
{
	return (b/c)-((a-1)/c);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll j,l,m,h,w,f,n,k,b,ans,a,c,d;
    	cin>>a>>b>>c>>d;
    	
    	cout<<(b-a+1)-cc(a,b,c)-cc(a,b,d)+cc(a,b,c*d/__gcd(c,d));
    }
	return 0;
}

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

int main(){
  double n, k;
  double ans = 0;
  cin >> n >> k;
  
  rep(i, n){
    rep(j, 20){
      double sum;
      sum = (i+1) * pow(2, j);
      if(sum >= k){
        ans += ((1/n) / pow(2, j));
        break;
      }
    }
  }
  cout << fixed << setprecision(12) << ans << endl;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

int solve(vector<int> A){

  int N = A.size();

  int ret = 0;
  rep(i, N){

    if(((N-1) & i) == i) ret += A[i];

    ret = ret % 2;

  }

  return ret;

}

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

  int N;
  cin >> N;
  string s;
  vector<int> a(N);
  cin >> s;
  rep(i, N){
    a[i] = int(s[i] - '0') - 1;
  }

  int ans1 = solve(a);

  if(ans1 == 1){
    cout << 1 << endl;
    return 0;
  }else{

    rep(i, N){
      if(a[i] == 1){
        cout << 0 << endl;
        return 0;
      }
    }

    rep(i, N){
      a[i] /= 2;
    }

    int ans2 = solve(a);

    if(ans2 == 1){
      cout << 2 << endl;
    }else{
      cout << 0 << endl;
    }



  }
  





  return 0;
}


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

using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; ++i){ cin >> A[i]; }
	vector<int> B;
	sort(A.begin(), A.end());
	int zero = 0, one = 0;
	for(int i = 0; i < N; ++i){
		if(A[i] == 0){
			++zero;
		}else if(A[i] == 1){
			++one;
		}else{
			B.push_back(A[i]);
		}
	}
	int offset = 0, tail = B.size();
	if(zero % 2 == 0){
		for(int i = 0; i < zero; ++i){ B.push_back(0); }
		for(int i = 0; i < one; ++i){ B.push_back(1); }
	}else if(one > 0){
		for(int i = 1; i < zero; ++i){ B.push_back(0); }
		B.push_back(1);
		B.push_back(0);
		for(int i = 1; i < one; ++i){ B.push_back(1); }
	}else if(tail == 0){
		for(int i = 0; i < zero; ++i){ B.push_back(0); }
	}else{
		int x = B[0];
		for(int i = 1; i < zero; ++i){ B.push_back(0); }
		B.push_back(x);
		B.push_back(0);
		++offset;
	}
	if(tail - 2 >= offset){
		if(B[tail - 2] == 2 && B[tail - 1] == 3){
			swap(B[tail - 2], B[tail - 1]);
		}
	}
	for(int i = 0; i < N; ++i){
		cout << B[i + offset] << endl;
	}
	return 0;
}

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

int main()
{
  string s;
  cin >> s;
  bool ans = false;
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ans = true;
  if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) ans = true;
  if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) ans = true;
  if (ans) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
from sys import exit
a,b,c = map(int,input().split())
cnt = 0
while ~a&1 and ~b&1 and ~c&1:
    newa = b//2+c//2
    newb = a//2+c//2
    newc = a//2+b//2
    a,b,c = newa,newb,newc
    cnt += 1
    if cnt >= 10**5:
        exit(print(-1))
print(cnt)

Measured memory_bytes: 9192
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int n, m;

int need[1001];

main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	vector<pair<int, pii>> e;
	REP(i, m){
		int u, v, c;
		cin >> u >> v >> c;
		e.emplace_back(c, pii(u-1, v-1));
	}
	sort(ALL(e));
	vi tar;
	UnionFind uf(n);
	int mincost = 0;
	REP(i, m){
		if(uf.unionSet(e[i].second.first, e[i].second.second)){
			tar.push_back(i);
			mincost += e[i].first;
		}
	}
	int ans = 0, sum = 0;
	REP(j, tar.size()){
		int t = tar[j];
		UnionFind uf(n);
		int cost = 0;
		REP(i, m){
			if(i != t && uf.unionSet(e[i].second.first, e[i].second.second)){
				cost += e[i].first;
			}
		}
		if(cost != mincost){
			ans ++;
			sum += e[t].first;
		}
	}
	cout << ans <<	 " " << sum << endl;
	return 0;
}

Measured memory_bytes: 1996
#include <iostream>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S == "SUN") {
		cout << 7 << endl;
	}
	else if (S == "MON") {
		cout << 6 << endl;
	}
	else if (S == "TUE") {
		cout << 5 << endl;
	}
	else if (S == "WED") {
		cout << 4 << endl;
	}
	else if (S == "THU") {
		cout << 3 << endl;
	}
	else if (S == "FRI") {
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}
	return 0;

}




Measured memory_bytes: 3580
let frame h w =
  let rec top_bottom w =
    match w with
    |0 -> print_string "\n"
    |_ -> print_string "#";
          top_bottom (w-1)
  in
  top_bottom w;
  let rec inner w h =
    match h with
    |0 -> ()
    |_ -> print_string "#";
          let rec inner_w w =
            match w with
            |0 -> ()
            |_ -> print_string ".";
                  inner_w (w-1);
          in
          inner_w (w-2);
          print_string "#\n";
          inner w (h-1)
  in
  inner w (h-2);
  top_bottom w;
  print_string "\n"
;;

let rec loop () =
  Scanf.sscanf (read_line()) "%d %d" (fun h w -> if h = 0 || w = 0 then ()
                                                 else
                                                   begin
                                                     frame h w;
                                                     loop()
                                                   end
    )
;;
loop();;


Measured memory_bytes: 2120
import sys
input = sys.stdin.readline

def solve():
    INF = float('inf')

    def max2(x, y): return x if x >= y else y

    R, C, K = map(int, input().split())
    Vss = [[0]*(C+1) for _ in range(R+1)]
    for _ in range(K):
        r, c, v = map(int, input().split())
        Vss[r][c] = v

    dpMax = [0]*(C+1)
    for i in range(1, R+1):
        dp0 = [0]*(C+1)
        dp1 = [-INF]*(C+1)
        dp2 = [-INF]*(C+1)
        dp3 = [-INF]*(C+1)
        for j in range(1, C+1):
            V = Vss[i][j]
            dp0[j] = max2(dp0[j-1], dpMax[j])
            dp1[j] = max2(dp0[j] + V, dp1[j-1])
            dp2[j] = max2(dp1[j-1] + V, dp2[j-1])
            dp3[j] = max2(dp2[j-1] + V, dp3[j-1])
            dpMax[j] = max(dp0[j], dp1[j], dp2[j], dp3[j])

    ans = dpMax[C]
    print(ans)


solve()


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

using namespace std;

int main () {
    int n; cin >> n;
    
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) {

        } else {
            sum += i;
        }
    }
    cout << sum << endl;;

}

Measured memory_bytes: 3640
#include <stdio.h>
void main(){
    int K, A, B;
    scanf("%d", &K);
    scanf("%d", &A); 
    scanf("%d", &B); 
    int i = K;
    while(1){
        if(A<=i){
            if(i<=B){
                printf("OK");
                return;
            }
        }
        if(B<i){
            printf("NG");
            return;
        }
        i+=K;
    }
}

Measured memory_bytes: 1732
# -*- coding: utf-8 -*-
from fractions import gcd

def solve():
    A, B, C, D = map(int, input().split())
    E = C*D//gcd(C,D)

    return B-A+1 - ((B//C + B//D - B//E)-((A-1)//C + (A-1)//D - (A-1)//E))

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 5048
#include<stdio.h>

int main(void)
{
	int a, b, d, r;
	double f;
	
	scanf("%d %d", &a, &b);

	d = a / b;
	r = a % b;
	f = (double)a / (double)b;

	printf("%d %d %f\n", d, r, f);

	return 0;
}

Measured memory_bytes: 636
pre=list(map(int,input().split()))
B=list(map(int,input().split()))

count = 0
judge = 0

for i in range(pre[0]):
  A=list(map(int,input().split()))
  for j in range(pre[1]):
    judge+=B[j]*A[j]    
  judge+=pre[2]
  
  if judge>0:
    count+=1
  judge=0
  
print(count)
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

// M * (M-1)^(N-1-K) * N-1 C K
int main(int argc, const char * argv[]) {
    string S; cin >> S;
    
    for(ll i=0;i<S.size();i++){
        cout << "x";
    }
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x - a) < abs(x - b))
    cout << "A" << endl;
  else
    cout << "B" << endl;

  return 0;
}


Measured memory_bytes: 888
#include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    #include <vector>
    #include <string>
    #include <algorithm>
    #include <stack>
    #include <queue>
    #include <set>
    #include <map>
    using namespace std;
    #define MOD @
    #define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
    typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;
     
    int N, K;
     
    i64 sublevel(int a, int b)
    {
    	i64 ret = 0, p = 1;
    	for (int i = 0; i < b; ++i) {
    		ret += p;
    		if (ret > 1000000) break;
    		p *= a;
    	}
    	return ret;
    }
     
    void show(const vector<int> &v)
    {
    	for (int i = 0; i < v.size(); ++i) printf("%d%c", v[i], i == v.size() - 1 ? '\n' : ' ');
    }
     
    vector<int> sol;
     
    void absolute(int k, int n, int ai, int top)
    {
    	if (ai == 0) {
    		sol.push_back(top);
    		return;
    	}
    	ai -= 1;
    	i64 sl = sublevel(k, n - 1);
    	sol.push_back(top);
    	absolute(k, n - 1, ai % sl, ai / sl + 1);
    }
     
    void solve(int k, int n, int ofs, int top)
    {
    	if (n == 0) {
    		return;
    	}
    	i64 sl = sublevel(k, n - 1);
    	if (sl > ofs + 2) {
    		sol.push_back(top);
    		solve(k, n - 1, ofs + 1, (k + 1) / 2);
    		return;
    	}
    	i64 mp = (ofs + sl * k) / 2 - (ofs + 1);
    	if (mp < 0) {
    		sol.push_back(top);
    		return;
    	}
    	i64 ntop = mp / sl, nidx = mp % sl;
    	sol.push_back(top);
    	absolute(k, n - 1, nidx, ntop + 1);
    }
     
    int main()
    {
    	scanf("%d%d", &K, &N);
    	if (K % 2 == 0) {
    		vector<int> ans;
    		ans.push_back(K / 2);
    		for (int i = 0; i < N - 1; ++i) ans.push_back(K);
    		show(ans);
    		return 0;
    	}
    	if (K == 1) {
    		show(vector<int>((N + 1) / 2, 1));
    		return 0;
    	}
    	solve(K, N, 0, K / 2 + 1);
    	show(sol);
     
    	return 0;
    }

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

int main() {
  int N;
  cin >> N;
  vector<int> pow;
  for (int i = 1; i <= 64; i *= 2) {
    pow.push_back(i);
  }
  int ans;
  for (int i = 0; i < pow.size(); ++i) {
    if (N >= pow.at(pow.size() - 1 - i)) {
      ans = pow.at(pow.size() - 1 - i);
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, M, R = getNM()

d = [[float("inf")] * N for i in range(N)]
list_R = [int(i) - 1 for i in input().split()]
for i in range(M):
   x, y, z = getNM()
   d[x - 1][y - 1] = min(d[x - 1][y - 1], z)
   d[y - 1][x - 1] = min(d[x - 1][y - 1], z)

def warshall_floyd(dist):
    for k in range(N):
        # i:start j:goal k:中間地点でループ回す
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
    #return dist

warshall_floyd(d)

ans = float('inf')
for case in permutations(list_R):
    x1 = case[0]
    opt = 0
    for j in range(1, R):
        x2 = case[j]
        opt += d[x1][x2]
        x1 = x2
    ans = min(ans, opt)
print(ans)

Measured memory_bytes: 84556
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	cout << max({ N + M,N - M,N*M }) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORALL(i, m) for( auto i = m.begin(); i != m.end() ; ++i )
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

ll N;
vector<ll> li;
vector<vector<vector<double>>> dp;

int input(){
  cin >> N;
  REP(i,N) li.push_back( inp<ll>() );
}



double rep(ll s1,ll s2,ll s3){
  if ( dp[s1][s2][s3] >= 0 ) return dp[s1][s2][s3];
  if ( s1 == 0 & s2 == 0 & s3 == 0 ) {
    dp[0][0][0] = 0.;
    return dp[s1][s2][s3];
  }
  double ret = 0;
  if ( s1>0 ) ret += (double)s1*rep(s1-1,s2,s3);
  if ( s2>0 ) ret += (double)s2*rep(s1+1,s2-1,s3);
  if ( s3>0 ) ret += (double)s3*rep(s1,s2+1,s3-1);
  ret += (double)N;
  ret/= (double)(s1+s2+s3);
  
  dp[s1][s2][s3] = ret;
  return dp[s1][s2][s3];

}

int main()
{
  input();
  
  map<ll,int> mp;
  REP(i,N) mp[li[i]] = mp[li[i]] + 1;
  ll ss[3] = {0,0,0};
  FORALL(i,mp) ss[i->first -1]= i->second;
  
  REP(i,N+1){
    dp.push_back( vector<vector<double>>() );
    REP(j,N+1){
      dp[i].push_back( vector<double>() );
      REP(k,N+1){
        dp[i][j].push_back( -1 );
      }
    }
  }
  
  double ret = rep(ss[0],ss[1],ss[2]);
  cout << setprecision(11) << ret << endl;
  
}

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

using namespace std;

const long long MOD = 1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(12);
    cout << fixed;
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    long long money = 1000;
    for (int i = 1; i < n; i++) {
        if (v[i] > v[i-1]) {
            long long stonks = money / v[i-1];
            money += stonks * (v[i] - v[i-1]);
        }
    }
    cout << money << endl;

    return 0;
}


Measured memory_bytes: 3616
def isPalindrome(st):
    l = len(st)
    c = l//2
    if l%2 == 1:
        return st[:c] == st[c+1:][::-1]
    else:
        return st[:c] == st[c:][::-1]

S = input()
N = len(S)

if isPalindrome(S) and isPalindrome(S[:(N-1)//2]) and isPalindrome(S[(N+3)//2 - 1:]):
    print('Yes')
else:
    print('No')




Measured memory_bytes: 9104
n,m,r=map(int,input().split())
root=list(map(int,input().split()))
abc=[list(map(int,input().split())) for _ in [0]*m]
inf=10**10
dist=[[inf for _ in [0]*n] for _ in [0]*n]
for i in range(n):dist[i][i]=0
for a,b,c in abc:
    dist[a-1][b-1]=c
    dist[b-1][a-1]=c
for k in range(n):
    for i in range(n):
        for j in range(n):dist[i][j]=min(dist[i][j],(dist[i][k]+dist[k][j]))

from itertools import permutations

p=list(permutations(root))

D=10**10
for i in p:
    d=0
    for j in range(len(i)-1):
        d+=dist[i[j]-1][i[j+1]-1]
    D=min(D,d)
print(D)

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

using namespace std;

using int64 = long long;

int64 dp[20][4][2][2][10];
string S;

int64 rec(int idx, int match, bool matched, bool lim, int pv) {
  if(idx == S.size()) return matched;
  if(~dp[idx][match][matched][lim][pv]) return dp[idx][match][matched][lim][pv];
  int64 ret = 0;
  for(int i = lim ? S[idx] - '0' : 9; i >= 0; i--) {
    bool next_lim = lim & (S[idx] - '0' == i);
    if(matched) {
      ret += rec(idx + 1, match, matched, next_lim, 0);
    } else if(match == 0 && i == 5) {
      ret += rec(idx + 1, 1, matched, next_lim, i);
    } else if(match == 1 && i == 1) {
      ret += rec(idx + 1, 2, matched, next_lim, i);
    } else if(match == 2) {
      ret += rec(idx + 1, 3, matched, next_lim, i);
    } else if(match == 3) {
      if(i == 3) ret += rec(idx + 1, 0, true, next_lim, i);
      else if(pv == 5 && i == 1) ret += rec(idx + 1, 2, matched, next_lim, i);
      else ret += rec(idx + 1, i == 5, matched, next_lim, i);
    } else {
      ret += rec(idx + 1, i == 5, matched, next_lim, i);
    }
  }
  return dp[idx][match][matched][lim][pv] = ret;
}

int main() {
  cin >> S;
  memset(dp, -1, sizeof(dp));
  cout << rec(0, 0, 0, true, 0) << endl;
}


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

int main(){
  int a,b,count = 0;
  cin >> a >> b;
  vector< vector<int> > table(a,vector<int>(b) );
  rep(i,a){
    rep(j,b){
      cin >> table[i][j];
    }
  }

  rep(i,a){
    for(int j = i+1; j < a; j++){
      double sum = 0;
      rep(k,b){
        sum += pow(table[i][k]-table[j][k],2);
      }
      sum = sqrt(sum);
      if(sum == (int)sum){
        count++;
      }
    }
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<int> p(N);
    REP(i, N) cin >> p[i],p[i]--;
    vector<int> a(N),b(N);
    REP(i,N){
        a[i]=20000*(N-i);
        b[i]=20000*(i+1);
    }
    REP(i,N){
        a[p[i]]+=i;
    }
    REP(i,N) cout<<b[i]<<" \n"[i+1==N];
    REP(i,N) cout<<a[i]<<" \n"[i+1==N];
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000;
const ll mod = 1000000007;
ll res[12345678], aa[1234][1234], bb[1234][1234];
ll dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
char maze[1234][1234];
signed main() {
	ll n, m, a = 0, b = 0, ans = 0; cin >> n;
	vector<ll> test(n), aaa;
	for (int h = 0; h < n; h++) { 
		cin >> test[h]; ans += abs(test[h]);
		if (test[h] > 0) { a++; }
		if (test[h] < 0) { b++; }
	}
	sort(test.begin(), test.end());
	if (n == 2) { cout << test[1] - test[0] << endl; cout << test[1] << ' ' << test[0] << endl; return 0; }
	if (a != 0 && b != 0) {
		cout << ans << endl;
		if (test[n - 2] < 0) {
			reverse(test.begin(), test.end());
			for (int h = 0; h < n - 1; h++) {
				cout << test[h] << ' ' << test[h + 1] << endl;
				test[h + 1] = test[h] - test[h + 1];
			}
			return 0;
		}
		for (int h = 0; h < n - 2; h++) {
			if (test[h] < 0 && test[h + 1] < 0) { aaa.push_back(test[h]); }
			else {
				cout << test[h] << ' ' << test[h + 1] << endl;
				if (h == n - 3) { aaa.push_back(test[h] - test[h + 1]); }
				test[h + 1] = test[h] - test[h + 1];
			}
		}
		aaa.push_back(test[n - 1]); reverse(aaa.begin(), aaa.end());
		for (int h = 0; h < aaa.size() - 1; h++) {
			cout << aaa[h] << ' ' << aaa[h + 1] << endl;
			aaa[h + 1] = aaa[h] - aaa[h + 1];
		}
	}
	if (b == 0) {
		ans -= test[0] + test[0];
		cout << ans << endl;
		for (int h = 2; h < n; h++) {
			cout << test[0] << ' ' << test[h] << endl;
			test[0] = test[0] - test[h];
		}
		cout << test[1] << ' ' << test[0] << endl;
	}
	else if (a == 0) {
		reverse(test.begin(), test.end());
		ans += test[0] + test[0];
		cout << ans << endl;
		for (int h = 2; h < n; h++) {
			cout << test[0] << ' ' << test[h] << endl;
			test[0] = test[0] - test[h];
		}
		cout << test[0] << ' ' << test[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3444
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	998244353//1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

int func(int a, int b)
{
	if (a < b)
		return func(b, a);
	int r;
	while (r = a % b)
	{
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	int k;
	cin >> k;
	ll r = 0;
	for (int a = 1; a <= k; a++)
		for (int b = 1; b <= k; b++)
		{
			int gcd = func(a, b);
			for (int c = 1; c <= k; c++)
				r += func(gcd, c);
		}
	printf("%lld", r);

	return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
     
    #define mp make_pair
    #define pb push_back
    #define f first
    #define s second
     
    using namespace std;
     
    typedef long long ll;
    const int INF = 1e9;
    const ll INFl = 1e18;
     
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef set<int> si;
    typedef map<int,int> mii;
    typedef unordered_map<int,int> umii;
    typedef queue<int> qi;
     
    vi V;
     
    int main() {
    	ios::sync_with_stdio(false); cin.tie(0);
    	int k; cin >> k;
    	ll sum = 0;
    	for (int i = 1; i <= k; i ++) {
    		for (int j = 1; j <= k; j ++) {
    			for (int h = 1; h <= k; h ++) {
    				int x = __gcd(i, j);
    				int y = __gcd(h, x);
    				sum += y;
    			}
    		}
    	}
    	cout << sum << '\n';
    }

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

///Author:Refat(BSMRSTU)///

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const int M = 1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}
int main() {
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);
    int test=1;ll n,ans=1e18,r,c,s1;
    ///scanf("%d",&test);
    for(int cs=1; cs<=test; cs++) {
        scanf("%lld",&n);
        ll limit=sqrt(n);
        for(int i=1;i<=limit;i++){
            if(n%i==0){
                r=i;
                c=n/i;
                s1=(c-1)+(r-1);
                ans=min(ans,s1);
                r=n/i;
                c=i;
                s1=(c-1)+(r-1);
                ans=min(ans,s1);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int a,b;
    cin >> a >> b;
    if( abs(a-b) %2 == 0){
        cout << (a+b) / 2 << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
}

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

string s;
int n;

int dp[100005];

int go(int at)
{
    if (at == n) {
        return 1;
    }
    string ss;
    if (dp[at] != -1) {
        return dp[at];
    }
    int i, j, res = 0;
    for (i = at, j = 0; res == 0 && j < 7 && i < n; i++, j++) {
        ss.push_back(s[i]);
        if (ss == "dream" || ss == "dreamer" || ss == "erase" || ss == "eraser") {
            res = res | go(i + 1);
        }
    }
    dp[at] = res;
    return res;
}

int main( )
{
    cin >> s;
    n = (int) s.size();
    memset(dp, -1, sizeof dp);
    if (go(0) == 1) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 3456
a,b,c=map(int,input().split())
d=0
while(all([a%2==0,b%2==0,c%2==0])):
  x=b//2+c//2
  y=c//2+a//2
  z=a//2+b//2
  d+=1
  a=x
  b=y
  c=z
  if a==b==c:
    d=-1
    break
print(d)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

LL dp[100][101][2] = {};

void solve() {
    string s;
    int K;
    cin >> s >> K;
    int len = s.size();
    VI a(len);
    REP(i,0,len) a[i] = s[i] - '0';
    dp[0][1][0] = 1;
    dp[0][1][1] = a[0] - 1;
    dp[0][0][1] = 1;
    REP(i,1,len) {
        REP(j,0,100) {
            dp[i][j][1] += dp[i-1][j][1];

            dp[i][j+1][1] += dp[i-1][j][1] * 9;

            dp[i][j+(a[i]>0)][0] += dp[i-1][j][0];

            REP(k,1,a[i]) {
                dp[i][j+1][1] += dp[i-1][j][0];
            }
            if (a[i] > 0) dp[i][j][1] += dp[i-1][j][0];

        }
    }
    cout << dp[len-1][K][0] + dp[len-1][K][1] << endl;

    /*
    REP(k,0,2) {
        REP(i,0,len) {
            LL sum = 0;
            REP(j,0,len+1) {
                cout << dp[i][j][k] << " ";
                sum += dp[i][j][k];
            }
            cout << sum;
            cout << endl;
        }
        cout << endl;
    }
    */
}

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

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        Set<String> set = new HashSet<String>();
        for (int i = 0; i < w.length(); i++) {
            String c = String.valueOf(w.charAt(i));
            if (set.contains(c)) {
                set.remove(c);
            } else {
                set.add(c);
            }
        }
        
        if (set.size() == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define pb(x) push_back(x)
#define fi first
#define se second
#define mp(x,y) make_pair(x,y);
/*struct comp
{
    bool operator()()
    {
        
    }
};*/
struct node
{
    int a,b,c,d;
    node(int A,int B,int C,int D)
    {
        a=A;b=B;c=C;d=D;
    }
};
int N,M,Q;
int sum=0;
vector<node>q;
void calculate(vector<int>&A)
{
    int S=0;
    for(int i=0;i<Q;i++)
    {
        if(A[q[i].b]-A[q[i].a]==q[i].c)
        {
            S+=q[i].d;
        }
    }
    sum=max(sum,S);
    return;
}
void call(int idx,vector<int>&A,int last)
{
    if(idx==N+1)
    {
        calculate(A);
        return ;
    }
    
    for(int i=last;i<=M;i++)
    {
        A[idx]=i;
        call(idx+1,A,i);
    }
    return;
}
int32_t main() {
    
    cin>>N>>M>>Q;
    vector<int>A(N+1);
    for(int i=0;i<Q;i++)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        node temp(a,b,c,d);
        q.pb(temp);
    }
    
    call(0,A,1);
    cout<<sum;
    return 0;
}

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

int main() {

	string S;

	cin >> S;

	rep(i, 0, S.size()) if (S[i] == ',') S[i] = ' ';

	cout << S << endl;

	return 0;
}

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

int main()
{
	int W, H;
	int x, y, r;

	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	W -= r, H -= r;
	if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 2108
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var x = aaa[2] - aaa[0];
            var y = aaa[3] - aaa[1];

            var x3 = aaa[2] - y;
            var y3 = aaa[3] + x;

            var x4 = x3 - x;
            var y4 = y3 - y;

            Console.WriteLine("{0} {1} {2} {3}", x3, y3, x4, y4);
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    long long int a, b, n;
    long long int max1 = 0;
    long long int max2 = 0;

    cin >> a >> b >> n;

    if (b > n) {
        max1 = (a * n / b) - a * (n / b);
    }
    else {
        max1 = (a * (b-1) / b) - a * ((b-1) / b);
    }

    cout << max1 << endl;
}


Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  string s;
  int a;
  while(cin>>s){
    for(int i=0;i<s.size();i++){
      if(s[i]=='@'){
	a = s[i+1]-'0';
	for(int j=0;j<a;j++){
	  cout<<s[i+2];
	}
	i += 2;
      }
      else cout<<s[i];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 0
n=int(input())
a=list(map(int,input().strip().split()))[:n]
b=[]
b.append(a[0])
sum = 0
for i in range(1,n):
  b.append(a[i]+b[i-1])
for i in range(0,n-1):
    sum=sum+a[i]*(b[n-1]-b[i])
    sum=sum%1000000007
print(sum)

Measured memory_bytes: 31452
#include<stdio.h>

int main(){
   int array[] = {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;
   scanf("%d",&k);
   printf("%d",array[k-1]);
   return 0;
}


Measured memory_bytes: 128