akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	allMn := genMarkNum()

	var N int
	fmt.Scan(&N)

	s := bufio.NewScanner(os.Stdin)
	for i := 0; i < N; i++ {
		s.Scan()
		allMn = filter(allMn, s.Text())
	}
	for _, v := range allMn {
		fmt.Println(v)
	}
}

func genMarkNum() []string {
	var s []string
	for _, m := range []string{"S", "H", "C", "D"} {
		for i := 1; i <= 13; i++ {
			s = append(s, fmt.Sprintf("%s %d", m, i))
		}
	}
	return s
}

func filter(mn []string, target string) []string {
	var filteredMn []string
	for _, v := range mn {
		if v == target {
			continue
		}
		filteredMn = append(filteredMn, v)
	}
	return filteredMn
}



Measured memory_bytes: 1244
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

 
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int a,b,c,d,e,f;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> a >> b >> c >> d >> e >> f;
}

map<pii, pair<double,pii>> memo;
pair<double,pii> sugar_water_concentration(int p, int q, int rc, int rd){
    // tuple<int,int,int,int> t = make_tuple(p,q,rc,rd);
    int sugar = c*rc+d*rd;
    int water = 100*a*p+100*b*q;
    int sugar_water = sugar + water;
    if(sugar_water>f) return {-1,{sugar_water,sugar}};
    if(100*sugar>e*water) return {-1,{sugar_water,sugar}};
    if(memo[{sugar_water,sugar}]!=pair<double,pii>()){
        // SAY("memo ")
        // cout << memo[{flu,m}] << endl;
        return memo[{sugar_water,sugar}];
        }
    // else{
    //     SAY("No memo ")
    //     cout << memo[{flu,m}] << endl;
    // }
    // DBG(make_pair(flu,m))
    pair<double,pii> ret;
    ret.second = {sugar_water,sugar};
    ret.first = (double)sugar/sugar_water;
    auto p1 = sugar_water_concentration(p,q,rc+1,rd);
    auto p2 = sugar_water_concentration(p,q,rc,rd+1);
    return memo[{sugar_water,sugar}] = max({ret,p1,p2});
}

int solve(){
    // DBG(sugar_water(0,0,0,0))
    pair<double,pii> res={0,{0,0}};
    for (int p = 0; p <= 30; p++)
    {
        for (int q = 0; q <= 30; q++)
        {
            if(p==0 && q==0) continue;
            int water = 100*a*p+100*b*q;
            if(water>f) continue;
            res = max(res,sugar_water_concentration(p,q,0,0));
        }
        
    }
    DBG(res)
    cout << res.second.first << " " << res.second.second << endl;
    

    return 0;
}   

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


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

int main()
{
  int n, m;
  cin >> n >> m;

  int cnt = 0, tmp;
  REP(i, m){
    cin >> tmp;
    cnt += tmp;
  }

  int answer = (cnt > n) ? -1 : (n - cnt);

  cout << answer << endl;
}

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

using namespace std;

int main(){
    int A,B,X;
    cin >> A >> B >> X;
    if(A+B >=X && A <= X){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, M;
    std::cin >> N >> M;

    vector<ll> a_sum(1, 0);
    a_sum.reserve(N + 1);
    REP(i, N) {
        ll a;
        std::cin >> a;
        a_sum.push_back(a + a_sum[i]);
    }

    map<ll, ll> map;
    for(const auto& v : a_sum) {
        auto itr = map.find(v % M);
        if(itr != map.end()) {
            itr->second++;
        }
        else {
            map.emplace(v % M, 1);
        }
    }

    ll ans = 0;
    for(const auto& v : map) {
        ans += (v.second * (v.second + 1)) / 2 - v.second;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();


int main () { _read(); 

      string s,t;
      cin >> s >> t;
      auto give = [&]( int i, int j ) {
            int c = 0;
            for( int x = i, y = 0; x <= j; x++,y++) {
                  c += ( s[x] != t[y]);
            }
            return c;
      };
      int ans = sz(s);
      for( int i = 0, j = i + sz(t) - 1; j < sz(s); i++,j++) {
            ans = min(ans,give(i,j));
      }
      cout << ans << '\n';
};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


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

typedef pair<long long, long long> data_t;

int main(){
  vector<int> a(5);
  for(int i=0;i<5;i++)
    cin>>a[i];
  int min=10;
  int minnum;
  int sum=0;
  for(int i=0;i<5;i++){
    if(min>a[i]%10&&a[i]%10!=0){
      minnum=i;
      min=a[i]%10;
    }
  }
  for(int i=0;i<5;i++){
    if(i!=minnum){
      sum+=a[i];
      if(a[i]%10!=0)
    	sum+=10-a[i]%10;
    }
  }
  sum+=a[minnum];
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;


int main(){
  long long int n, p, a, cnt=0, ans=1;
  cin >> p >> n;
  a=2;
  while(n>=a*a){
    if(n%a==0){
      cnt++;
      n/=a;
      if(cnt==p){
        ans*=a;
        cnt=0;
      }
    }
    else{
      a++;
      cnt=0;
    }
  }
  cnt++;
  if(cnt==p){
    ans*=n;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[110];
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];}
  sort(a,a+n);
  int mn=0;
  if(sum%10==0)
    for(int i=0;i<n;i++)
      if(a[i]%10!=0){
        mn=a[i];
        break;}
  if((sum-mn)%10==0)
    cout<<0;
  else
    cout<<sum-mn;
  return 0;
} 

Measured memory_bytes: 256
n, m = map(int, input().split())
switch = [format(i, '010b') for i in range(2**n)]
s = [[int(j) for j in input()[1:].split()] for i in range(m)]
p = [int(i) for i in input().split()]
ans = 0

for sw in switch:
    for pi, si in zip(p, s):
        total = 0
        for x in si:
            total += int(sw[-x])
        if total % 2 != pi:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int m,d;
  cin >> m >> d;
  int ans=0;
  rep1(i,m) rep1(j,d){
    int d1 = j%10;
    int d2 = (j/10)%10;
    if(d1>1 && d2 >1 && d1*d2==i) ans++;
  }
  cout << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const double PI = 3.14159265359;
typedef pair<int,int> P;

signed main() {
    int N;
    cin >> N;
    vector<P> vec(N);
    for(int i = 0;i < N;i++) {
        int A,B;
        cin >> A >> B;
        vec.at(i) = P(A,B);
    }
    vector<int> cnt(N);
    for(int i = 0;i < N;i++) {
        cnt.at(i) = i;
    }
    double ret = 0;
    do{
        double count = 0;
        for(int i = 0;i < N - 1;i++) {
            double c = 0;
            c += (vec[cnt.at(i)].first - vec[cnt.at(i + 1)].first) * (vec[cnt.at(i)].first - vec[cnt.at(i + 1)].first);
            c += (vec[cnt.at(i)].second - vec[cnt.at(i + 1)].second) * (vec[cnt.at(i)].second - vec[cnt.at(i + 1)].second);
            count += sqrt(c);
        }
        ret += count;
    } while(next_permutation(cnt.begin(),cnt.end()));
    int A = 1;
    for(int i = 1;i <= N;i++) {
        A *= i;
    }
    cout << fixed;
    cout << setprecision(10) << ret / A << endl;
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
 
a=[0]
b=[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
 
#print(a)
#print(b)
 
ans=0
j=M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    #print(i,j)
    ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 47600
#include <stdint.h>
#include <array>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

double dp[3010][3010];
void solve(long long N, std::vector<long double> p){
  dp[0][0] = 1 - p[0];
  dp[0][1] = p[0];
  FOR(i, 1, N) {
    REP(j, i + 2) {
      dp[i][j] = dp[i - 1][j] * (1 - p[i]);
      if (j - 1 >= 0) {
        dp[i][j] += dp[i - 1][j - 1] * p[i];
      }
    }
  }
  double ans = 0;
  FOR(j, (N + 1) / 2, N + 1) {
    ans += dp[N - 1][j];
  }
  printf("%0.10f\n", ans);
}

int main(){
  long long N;
    scanf("%lld",&N);
    std::vector<long double> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%Lf",&p[i]);
    }
  solve(N, std::move(p));
  return 0;
}


Measured memory_bytes: 69120
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))



A,B=nm()

print(A*B//fractions.gcd(A,B))

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

#define MAX_N 1000000
#define MAX_TEAM 1000000

priority_queue<pair<long long, long long>> Q;
long long d[MAX_TEAM], n, s, L, x[MAX_N], y[MAX_N], t[MAX_N], ti[MAX_TEAM], maxn, maxid;

int main() {
	cin >> n >> s >> L;
	Q.push(make_pair(0, -1));
	x[0] = 1; t[0] = 0; y[0] = 0; x[s + 1] = 1; t[s + 1] = L; y[s + 1] = 0;
	for (int i = 1; i <= s; i++) { cin >> x[i] >> t[i] >> y[i]; }
	for (int i = 0; i <= s; i++) {
		d[x[i]] += y[i];
		Q.push(make_pair(d[x[i]], -x[i]));
		while (true) {
			pair<int, int>p = Q.top();
			if (p.first == d[-p.second]) {
				ti[-p.second] += t[i + 1] - t[i]; break;
			}
			Q.pop();
		}
	}
	for (int i = 1; i <= n; i++) {
		if (maxn < ti[i]) {
			maxn = ti[i];
			maxid = i;
		}
	}
	cout << maxid << endl;
	return 0;
}

Measured memory_bytes: 34508
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 2e6 + 6;
const ll MOD = 1e9 + 7;

ll fact[MAX], invFact[MAX];

ll bigMod(ll a, ll b) {
    
    if(b == 0 ) return 1LL;
    ll ret = bigMod(a, b/2);
    ret = (ret *ret )%MOD;
    if(b&1) ret = (ret * a)%MOD;
    return ret;
}
ll invMod(ll x) {
    return bigMod(x, MOD-2);
}
void pre() {
    
    fact[0] =1;
    for(int i =1 ; i < MAX ; i++ ) {
        fact[i] = (fact[i-1] * i)%MOD;
    }
    
    invFact[MAX-1] = invMod(fact[MAX-1]);
    
    for(int i = MAX-2 ; i >=0 ; i--) {
        invFact[i] = (invFact[i+1] *(i+1))%MOD;
    }
//    for(int i =0 ; i < 5; i++ ) cout<<invFact[i]<<" ";
}

ll ncr(ll n, ll r) {
    
    
    ll lob = fact[n];
    
    
    ll hor = (invFact[r] * invFact[n-r])%MOD;
    
    return (lob * hor)%MOD;
}

int main()
{
    fastRead;
    pre();
    int k;
    string s;
    cin>>k>>s;
    int n = s.size();
    int tot = n + k;
    ll ans = bigMod(26, tot);
    
    
    for(int i =0 ; i < n ; i++ ) {
        
        ll tmp = (ncr(tot, i) * bigMod(25, tot-i))%MOD;
        ans = (ans - tmp)%MOD;
        ans = (ans + MOD)%MOD;
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 35508
#include <stdio.h>


int Prime(int p){
  int i,f;
  f = 0;
  if(p == 1) return 0;
  if(p == 2) return 1;
  if(p % 2 == 0) return 0;
  for(i=3;i*i <= p;i += 2){
    if(p % i == 0) f = 1;
  }

  if(f == 0) return 1;
  else return 0;
}

int main(){
  int a,d,n;
 
  while(1){
   int f;
    scanf("%d%d%d",&a,&d,&n);
    if(!(a|d|n)) break;
    f = 0;
  while(1){
    if(Prime(a)) {
      f++;if(f == n) break;
    }
    a += d;
  }

    printf("%d\n",a);
  }

  return 0;
}

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

typedef long long ll;
const int MAXN = 100010;

template<typename T> inline T read() {
	T x(0), f(1);
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10) + (ch^48);
	return x * f;
}

int n, m;
ll x[MAXN], S;

struct Permutation {
	int p[MAXN];
	Permutation(int x) {
		if(x) for(int i = 1; i < n; i++) p[i] = i;
	}
};

Permutation operator * (const Permutation A, const Permutation B) {
	Permutation res(0);
	for(int i = 1; i < n; i++) res.p[i] = B.p[A.p[i]];
	return res;
}

inline Permutation qpow(Permutation A, ll K) {
	Permutation res(1);
	while(K) {
		if(K & 1) res = res * A;
		K >>= 1, A = A * A;
	}
	return res;
}

int main() {
	n = read<int>();
	ll pre;
	pre = S = read<int>();
	for(int i = 2; i <= n; i++) {
		ll loc = read<ll>();
		x[i-1] = loc-pre;
		pre = loc;
	}
	m = read<int>();
	ll K = read<ll>();
	Permutation A(1);
	for(int i = 1; i <= m; i++) {
		int u = read<int>();
		swap(A.p[u-1], A.p[u]);
	}
	/*for(int i = 1; i < n; i++) printf("%d ", A.p[i]);
	printf("\n");*/
	A = qpow(A, K);
	/*for(int i = 1; i < n; i++) printf("%d ", A.p[i]);
	printf("\n");
	for(int i = 1; i < n; i++) printf("%lld ", x[i]);
	printf("\n");*/
	printf("%.1LF\n", (long double)S);
	for(int i = 1; i < n; i++) {
		S += x[A.p[i]];
		printf("%.1LF\n", (long double)S);
	}
	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
/* nichijou */
template<class T,class U>
bool cmax(T & a, const U & b) {return a < b ? a = b, 1 : 0;}
template<class T,class U>
bool cmin(T & a, const U & b) {return b < a ? a = b, 1 : 0;}
/* data type */
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second
/* STL container */
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define CLR(a) (a).clear()
#define BK(a) ((a).back())
#define FT(a) ((a).front())
#define DB(a) (a).pop_back()
#define DF(a) (a).pop_front()
#define PB push_back
#define EB emplace_back
/* I gave you my heart and then you turned around. */
void _BG(const char * s) {cerr<<s<<endl;}
template<class T, class ... TT>
void _BG(const char * s,T a, TT...b)
{
    for (size_t c = 0; *s && (c || *s != ','); cerr << *s++)
        c += count(ALL("([{"),*s) - count(ALL(")]}"),*s);
    cerr << " = " << a;
    if (*s) {
        cerr << ", ";
        ++s;
    }
    _BG(s,b...);
}
#ifdef PR3PONY
#define BG(...) do { \
    cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
    _BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)
#else
#define BG(...)
#endif
/* Good Luck && Have Fun ! */
bool ispa(string s)
{
    return equal(ALL(s), s.rbegin());
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    if (ispa(s) && ispa(s.substr(0, (n - 1) / 2)) && ispa(s.substr((n + 3) / 2 - 1)))
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    #ifdef FILIP_KADAK
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    string s;
    cin >> s;
    string sol;

    for(int i=0; i<s.size(); i++){
        if(i==s.size()-1 && s[i]!='B'){
            sol.push_back(s[i]);
            break;
        }
        if(s[i]=='B' && sol.size()>0)
            sol.pop_back();
        else if(s[i]!='B')
            sol.push_back(s[i]);
    }
    cout << sol;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]

h = {}
for i in range(N):
    h[i+1] = 0

for i in range(Q):
        h[A[i]] += 1

for k, v in h.items():
    tmp = Q - v
    h[k] = K - tmp

for k, v in h.items():
    if v > 0:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 20256
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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

signed main(){
	ll k,x;
	cin >> k >> x;
	if(500*k >= x) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]
def SR(n):
    return [S() for _ in range(n)]
def LSR(n):
    return [LS() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,x,m = LI()
    f = [0]*m
    a = x
    ans = 0
    for i in range(1,n+1):
        ans += a
        if f[a]:
            break
        f[a] = 1
        a = pow(a,2,m)
    s = []
    f = [0]*m
    for j in range(i+1,n+1):
        if f[a]:
            break
        f[a] = 1
        a = pow(a,2,m)
        s.append(a)
    r = n-i
    if s:
        ans += sum(s)*(r//len(s))+sum(s[:r%len(s)])
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


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

int main(){
  int N, K;
  cin >> N >> K;
  
  int num = 1;
  for (int i = 0; i < N; i++){
    if (num + K <= num * 2){
      num += K;
    } else {
      num *= 2;
    }
  }
  cout << num << endl;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

template <std::uint_fast64_t mod>
class ModInt {
    using u64 = std::uint_fast64_t;

   public:
    u64 x;
    ModInt(const ll x = 0) : x(x < 0 ? (mod - (-x % mod)) % mod : x % mod) {}

    ModInt operator+(const ModInt r) { return ModInt(*this) += r; }
    ModInt operator*(const ModInt r) { return ModInt(*this) *= r; }
    ModInt operator-(const ModInt r) { return ModInt(*this) -= r; }
    ModInt operator/(const ModInt r) { return ModInt(*this) /= r; }
    ModInt operator-() { return ModInt(mod - x); }

    ModInt &operator+=(const ModInt r) {
        x += r.x;
        if (x >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt r) {
        if (x < r.x) x += mod;
        x -= r.x;
        return *this;
    }
    ModInt &operator*=(const ModInt r) {
        x *= r.x;
        if (x >= mod) x %= mod;
        return *this;
    }
    ModInt &operator/=(ModInt r) {
        if (!(x % r.x)) {
            x /= r.x;
            return *this;
        }
        u64 p = mod - 2;
        while (p > 0) {
            if (p & 1) *this *= r;
            r *= r;
            p >>= 1;
        }
        return *this;
    }
    ModInt &operator++(int) { return (*this) += 1; }
    ModInt &operator++() { return (*this) += 1; }
    ModInt &operator--(int) { return (*this) -= 1; }
    ModInt &operator--() { return (*this) -= 1; }

    bool operator<(const ModInt r) { return x < r.x; }
    bool operator>(const ModInt r) { return x > r.x; }
    bool operator<=(const ModInt r) { return x <= r.x; }
    bool operator>=(const ModInt r) { return x >= r.x; }
    bool operator==(const ModInt r) { return x == r.x; }
    bool operator!=(const ModInt r) { return x != r.x; }

    ModInt inv() { return (ModInt)1 / (*this); }
    int get_mod() { return mod; }

    friend std::istream &operator>>(std::istream &in, ModInt &m) {
        ll a;
        in >> a;
        if (a < 0) a = mod - (-a % mod);
        if (a >= mod) a %= mod;
        m.x = a;
        return in;
    }
    friend std::ostream &operator<<(std::ostream &out, const ModInt &m) {
        out << m.x;
        return out;
    }
};
constexpr std::uint_fast64_t mod = 1e9 + 7;
using mint = ModInt<mod>;

template <typename T, typename U>
T pow(T x, U n, T e = 1) {
    T res = e;
    while (n > 0) {
        if (n & 1) res *= x;
        x *= x;
        n >>= 1;
    }
    return res;
}

int main() {
    int n, a, b, c;
    cin >> n >> a >> b;
    c = max(a, b);
    vector<mint> v0(c + 1, 1), v1(c + 1, n);
    for (int i = 1; i <= c; i++) {
        v0[i] = v0[i - 1] * i;
        v1[i] = v1[i - 1] * (n - i);
    }
    cout << pow<mint, int>(2, n) - v1[a - 1] / v0[a] - v1[b - 1] / v0[b] - 1 << endl;
    return 0;
}

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;

struct Point {
	double x, y;
	Point(){};
	Point(double _x, double _y) : x(_x), y(_y) {};
};

Point operator + (const Point &p, const Point &q){
	return Point(p.x + q.x, p.y + q.y);
}

Point operator - (const Point &p, const Point &q){
	return Point(p.x - q.x, p.y - q.y);
}

double operator * (const Point &p, const Point &q){
	return p.x * q.x + p.y * q.y;
}

double dist(const Point &p, const Point &q){
	return sqrt((q - p) * (q - p));
}

Point operator * (const Point &p, double k){
	return Point(p.x * k, p.y * k);
}

Point projection(const Point &A, const Point &p, const Point &q){
	Point pq = q - p;
	Point pA = A - p;
	
	double K = (pq * pA) / (pq * pq);

	return p + pq * K;
}

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

	cout << setprecision(10) << fixed;

	Point p1, p2;
	cin >> p1.x >> p1.y >> p2.x >> p2.y;

	int q;	cin >> q;
	while(q--){
		Point p;	cin >> p.x >> p.y;
		Point m = projection(p, p1, p2);

		cout << m.x << ' ' << m.y << '\n'; 
	}

	return 0;
}


Measured memory_bytes: 3312
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);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 LOCAL 0
//#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


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    char c;
    cin >> c;
    char a[] = {'a','i','u','e','o'};
    rep(i,0,5){
        if(c == a[i]){
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
    return 0;
}


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

int main(){
  int k,mn=0;
  cin>>k;
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      for(int c=1;c<=k;c++){
        mn+=gcd(gcd(a,b),c);
      }
    }
  }
  cout<<mn<<endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int n,m; cin >> n >> m; //桁数n,条件がm個
    vector<P> p(m);
    //p[i].firstが左から～桁目
    //p[i].secondがその桁の数値
    rep(i,m) cin >> p[i].first >> p[i].second;
    //候補0~999を試す
    rep(x,1000){
        string s=to_string(x);
        int keta=s.length();

        if (keta!=n) continue;
        bool ok=true;
        rep(i,m){
            if (s[p[i].first-1]!=p[i].second+'0') ok=false;
        }
        if(ok){
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

using namespace std;

int32_t main()
{
    int n;
    cin>>n;
    
    vector<int> a(n+1,0);
    for(int i=1;i<=n;++i){
        for(int j=0;j<=n;j+=i){
            a[j]++;
        }
    }
    
    int total=0;
    
    for(int i=1;i<=n;++i)
    {
        total+=(i*(long long)a[i]);
    }
    cout<<total<<'\n';
    return 0;
}


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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3,greater<int>());
  int s = 0;
  while(a[0] - a[1] > 1) {
    a[1] += 2;
    s ++;
  }
  while(a[0] - a[2] > 1) {
    a[2] += 2;
    s ++;
  }
  sort(a,a+3,greater<int>());
  
  if(a[0] == a[1] && a[1] == a[2]) {
    cout << s << endl;
  }
  if(a[1] > a[2]) {
    cout << s + 2 << endl;
  }
  if(a[0] > a[1]) {
    cout << s + 1 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
  while (1){
    int n,p,sum=0;
    cin >> n;
    if (n==0) return 0;
    vector<int> points;
    for(int i=0;i<n;i++){
      cin >> p;
      points.push_back(p);
    }
    sort(points.begin(),points.end());
    points.erase(points.begin());
    points.pop_back();
    for (int i=0;i<points.size();i++){
      sum+=points[i];
    }
    cout << floor(sum/points.size()) << endl;
  }
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef int ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 1e5+100;
const ll inf = 1e9;
const ll mod = 1e9+7;



int main(){
	fastio;
	ll a,b;
	cin >> a >> b;
	if(a >9 || b > 9) cout << "-1\n";
	else cout << a*b << endl;
 
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
bool check(vector<vvi> &v, int n, int m) {
	REP(x, n) {
		REP(y, n) {
			REP(z, n) {
				int p = v[x][y][z];
				if (p != -1) {

					FOR(i, -1, 2) {
						FOR(j, -1, 2) {
							FOR(k, -1, 2) {
								if (i == 0 && j == 0 && k == 0)continue;
								int flag = 1;
								if (x + i*(m - 1) < 0 || x + i*(m - 1) >= n || y + j*(m - 1) < 0 || y + j*(m - 1) >= n || z + k*(m - 1) < 0 || z + k*(m - 1) >= n)continue;
								REP(a, m) {
									int nx = x + i*a, ny = y + j*a, nz = z + k*a;
									if (v[nx][ny][nz] != p)flag = 0;
								}
								if (flag)return true;
							}
						}
					}
				}
			}
		}
	}

	return false;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, m, p;
		cin >> n >> m >> p;
		if (!n)break;
		vvi height(n, vi(n, 0));
		vector<vvi> v(n, vvi(n, vi(n, -1)));
		vi x(p), y(p);
		REP(i, p) {
			cin >> x[i] >> y[i];
		}
		REP(i, p) {
			v[x[i] - 1][y[i] - 1][height[x[i] - 1][y[i] - 1]] = i % 2;
			height[x[i] - 1][y[i] - 1]++;
			if (check(v, n, m)) {
				if (i % 2 == 1) {
					cout << "White " << i + 1 << endl;
					goto nemui;
				}
				else {
					cout << "Black " << i + 1 << endl;
					goto nemui;
				}
			}
		}
		cout << "Draw" << endl;
	nemui:;
	}
	return 0;
}

Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int x = int.Parse(str[0]);
        int y = int.Parse(str[1]);
        int z = int.Parse(str[2]);

        x -= z;
        int cnt = 0;
        while(x >= 0){
            if((x - (y + z)) >= 0){
                x -= (y + z);
                cnt++;
            }else{
                break;
            }
        }
        Console.WriteLine(cnt);
    }
}



Measured memory_bytes: 13140
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N, M = input_number_list()
    A = input_number_list()
    total = sum(A)
    cnt = 0
    for a in A:
        if a >= total / (4 * M):
            cnt += 1
    print('YNeos'[cnt < M::2])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
use std::collections::HashSet;

fn main() {
    let nmk = read_vec::<usize>();
    let n = nmk[0];
    let m = nmk[1];
    let k = nmk[2];

    let mut friends: Vec<HashSet<usize>> = vec![HashSet::new(); n+1];
    for _ in 0..m {
        let ab = read_vec::<usize>();
        let a = ab[0];
        let b = ab[1];

        friends[a].insert(b);
        friends[b].insert(a);
    }
    let mut blocks: Vec<(usize, usize)> = Vec::new();
    for _ in 0..k {
        let ab = read_vec::<usize>();
        let a = ab[0];
        let b = ab[1];

        blocks.push((a, b));
    }

    let mut ret = vec![0; n+1];
    let mut groups = vec![0; n+1];
    for i in 1..n+1 {
        let cnt = dfs(i, i, &ret, &mut groups, &friends);
        ret[i] = cnt;
    }

    for i in 1..n+1 {
        ret[i] = ret[i] - friends[i].len() - 1;
    }

    for block in blocks {
        if groups[block.0] == groups[block.1] {
            ret[block.0] -= 1;
            ret[block.1] -= 1;
        }
    }

    for i in 1..n+1 {
        print!("{}", ret[i]);
        print!(" ");
    }
    println!("");
}

fn dfs(i: usize, base: usize, ret: &Vec<usize>, groups: &mut Vec<usize>, friends: &Vec<HashSet<usize>>) -> usize {
    if groups[i] != 0 {
        return ret[groups[i]]
    }
    groups[i] = base;

    let mut cnt = 0;
    for friend in friends[i].iter() {
        cnt += dfs(*friend, base, ret, groups, friends);
    }

    return cnt + 1
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

using namespace std;

bool judge(int lineA[], int lineB[], int num)
{
	for(int i = 0; i < num; i++)
	{
		if(lineA[i] != lineB[i])
		{
			return false;
		}
	}
	return true;
}

int main()
{
	int num, lineA[16], lineB[16];
	
	while(cin >> num)
	{
		if(!num) break;
		int amo = 0;
		for(int i = 0; i < num; i++)
		{
			cin >> lineA[i];
		}
		while(1)
		{
			for(int i = 0; i < num; i++)
			{
				lineB[i] = 0;
				for(int j = 0; j < num; j++)
				{
					if(lineA[i] == lineA[j])
					{
						++lineB[i];
					}
				}
			}

			if( judge(lineA, lineB, num) ) break;
			else amo++;

			for(int i = 0; i < num; i++)
			{
				lineA[i] = 0;
				for(int j = 0; j < num; j++)
				{
					if(lineB[i] == lineB[j])
					{
						++lineA[i];
					}
				}
			}
			if( judge(lineA, lineB, num) ) break;
			else amo++;
		}
		
		cout << amo << endl;
		for(int i = 0; i < num; i++)
		{
			cout << lineA[i];
			if(i != num -1) cout << ' ';
		}
		cout << endl;
	}
}

Measured memory_bytes: 1160
import java.lang.reflect.Array;
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int max = a;
        int maxi = 1;
        if (max < b) {
            max = b;
            maxi = 2;
        }
        if (max < c) {
            max = c;
            maxi = 3;
        }
        if (maxi == 1) {
            System.out.println((int)(a * Math.pow(2, k) + b + c));
        } else if (maxi == 2) {
            System.out.println((int)(b * Math.pow(2, k) + a + c));
        } else {
            System.out.println((int)(c * Math.pow(2, k) + b + a));
        }
    }
}

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

void test1();
int GCD(int a, int b);
int LCM(int a, int b, int gcd);

int main(void)
{
	test1();

	return 0;
}

void test1()
{
	int a, b;
	unsigned int iGcd, iLcm;

	while (cin >> a >> b)
	{
		iGcd = GCD(a, b);
		iLcm = LCM(a, b, iGcd);

		cout << iGcd << " " << iLcm << endl;
	}
}

int GCD(int a, int b)
{
	if (a%b == 0)
		return b;
	else
		return GCD(b, a%b);
}

int LCM(int a, int b, int gcd)
{
	return ((a / gcd) * (b / gcd))*gcd;
}

Measured memory_bytes: 3104
def flipping(n,a):
    c = list(filter(lambda x:x<0,a))
    b = list(map(lambda x:abs(x),a))
    if len(c)%2==0:
        return sum(b)
    if len(c)%2!=0:
        return sum(b)-2*min(b)
    return b
n = int(input())
a=list(map(int, input().split()))
print(flipping(n,a))

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

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;

    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p.at(i);
    }

    vector<int> three_num(3);
    int ans = 0;
    int check_pi;
    for (int i = 1; i < n - 1; i++)
    {
        check_pi = p.at(i);
        three_num = {p.at(i - 1),
                     p.at(i),
                     p.at(i + 1)};

        sort(three_num.begin(), three_num.end());
        if (three_num.at(1) == check_pi)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define Tsetso ios_base::sync_with_stdio(0) ; cin.tie(0) ;
using namespace std;
const ll N = 2e5+50, inf = 1e3+5, mod = 1e9+7, NN = 1e5+10;
int main()
{
    Tsetso
    int n ; ;
    cin >> n ;
    vector < ll > a(n), b(n), c(n) ;
    for ( int i = 0 ; i < n ; i++)
        cin >> a[i] ;
    for ( int i = 0 ; i < n ; i++)
        cin >> b[i] ;
    for ( int i = 0 ; i < n ; i++)
        cin >> c[i] ;
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    ll ans = 0 ;
    for ( int i = 0 ; i < n ; i++)
        ans += 1ll*(upper_bound(c.begin(),c.end(),c.back())-upper_bound(c.begin(),c.end(),b[i]))*(lower_bound(a.begin(),a.end(),b[i])-lower_bound(a.begin(),a.end(),0));
    cout << ans;
}


Measured memory_bytes: 5552
#include <iostream>
#include <vector>
#include <queue>
#include <climits>

using namespace std;

int main(int argc, char **argv)
{
        int V, E, r;
        cin >> V >> E >> r;
        vector<vector< pair<int, int>>> A(V);
        for (int i = 0; i < E; i++) {
                int s, t, d;
                cin >> s >> t >> d;
                A[s].push_back({t, d});
        }
        vector<int> d(V, INT_MAX);
        d[r] = 0;
        bool done = false;
        for (int i = 0; !done && i < V; i++) {
                done = true;
                for (int i = 0; i < V; i++) {
                        if (d[i] == INT_MAX)
                                continue;
                        for (auto n: A[i]) {
                                int m = d[i] + n.second;
                                if (m < d[n.first]) {
                                        d[n.first] = m;
                                        done = false;
                                }
                        }
                }
        }
        if (!done) {
                cout << "NEGATIVE CYCLE" << endl;
        }
        else {
                for (int i = 0; i < V; i++) {
                        if (d[i] == INT_MAX)
                                cout << "INF";
                        else
                                cout << d[i];
                        cout << endl;
                }
        }
        return 0;
}

Measured memory_bytes: 3124
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int MAXN=100+10;
int n,m,sum[30];
char S[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	if(n==1&&m==1)
	{
		printf("Yes\n");
		return 0;
	}
	for(register int i=1;i<=n;++i)
	{
		scanf("%s",S);
		for(register int j=0;j<strlen(S);++j)sum[S[j]-'a'+1]++;
	}
	if(n==1||m==1)
	{
		int mark=0;
		for(register int i=1;i<=26;++i)
			if(sum[i]&1)
				if(mark)
				{
					printf("No\n");
					return 0;
				}
				else mark=1;
		printf("Yes\n");
		return 0;
	}
	else if(n%2==0&&m%2==0)
	{
		for(register int i=1;i<=26;++i)
			if(sum[i]&&sum[i]%4!=0)
			{
				printf("No\n");
				return 0;
			}
		printf("Yes\n");
		return 0;
	}
	else if(n%2==0)
	{
		int sum2=0;
		for(register int i=1;i<=26;++i)
			if(sum[i])
			{
				if(sum[i]&1)
				{
					printf("No\n");
					return 0;
				}
				if(sum[i]==2||sum[i]%4!=0)
				{
					sum2++;
					if(sum2>(n/2))
					{
						printf("No\n");
						return 0;
					}
				}
			}
		printf("Yes\n");
		return 0;
	}
	else if(m%2==0)
	{
		int sum2=0;
		for(register int i=1;i<=26;++i)
			if(sum[i])
			{
				if(sum[i]&1)
				{
					printf("No\n");
					return 0;
				}
				if(sum[i]==2||sum[i]%4!=0)
				{
					sum2++;
					if(sum2>(m/2))
					{
						printf("No\n");
						return 0;
					}
				}
			}
		printf("Yes\n");
		return 0;
	}
	else
	{
		int sum1=0,sum2=0;
		for(register int i=1;i<=26;++i)
			if(sum[i])
			{
				if(sum[i]==1||sum[i]%4==1)
				{
					sum1++;
					if(sum1>1)
					{
						printf("No\n");
						return 0;
					}
				}
				if(sum[i]==2||sum[i]%4==2)
				{
					sum2++;
					if(sum2>((m+n)/2-1))
					{
						printf("No\n");
						return 0;
					}
				}
			}
		if(!sum1)
		{
			printf("No\n");
			return 0;
		}
		printf("Yes\n");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N,*D = map(int, open(0).read().split())
MOD = 998244353
c = Counter(D)
cnt = 1
M = max(c.keys())
ans = 1
if D[0]!=0 or c[0]!=1:
  print(0)
  import sys
  sys.exit()
while cnt<=M:
  ans *= c[cnt-1]**c[cnt]
  ans %= MOD
  cnt += 1
print(ans)

Measured memory_bytes: 62008
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	int a,b;
	cin>>a>>b;
	
	if(a + b == 15) printf("+\n");
	else if(a * b == 15) printf("*\n");
	else printf("x\n");

	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int maxi = 0;
    int mini = 1000;
    for(int j=0;j<n;j++){
        maxi = max(maxi,a[j]);
        mini = min(mini,a[j]);
    }
    cout << maxi-mini << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	string s;
	cin >> s;
	for (int i = s.length() - 2; i >= 1; i -= 2) {
		bool f = true;
		REP(j, i / 2) f &= (s[j] == s[i / 2 + j]);
		if (f) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main()
{
  int a;cin >> a;
  cout << a+a*a+a*a*a << endl;
}

Measured memory_bytes: 3628
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#define m_p(x,y) (make_pair((x),(y)))
using namespace std;
const int maxn=2e5;
int n,k,cnt;
char S[maxn+8];
deque<pair<int,int> >que;


int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int main()
{
    n=read(),k=read();
    k=min(k,2*(n+1)-(k&1));
    scanf("%s",S+1);
    S[n+1]='B';
    for (int i=1;i<=n;i++) if (S[i]!=S[i+1])  que.push_back(m_p(i,S[i]=='B'?1:0));
    if (que.empty()) k--,que.push_back(m_p(n,0));
    while(k--)
	{
	    pair<int,int> p=que.front();
	    if (p.first<=cnt) que.pop_front(),p=que.front();
	    if ((p.second^(cnt&1))==0)
		{
		    if (p.first-cnt==1) que.pop_front();
		    else
			que.push_front(m_p(cnt+1,(cnt&1)^1));
		    continue;
		}
	    cnt++;
	    que.push_back(m_p(n+cnt,cnt&1));
	}
    pair<int,int> p=que.front();que.pop_front();
    for (int i=1;i<=n;i++)
	{
	    //printf("%d %d\n",p.first,p.second);
	    if (p.first-cnt<i) p=que.front(),que.pop_front();
	    putchar(p.second^(cnt&1)?'B':'A');
	}
    return 0;
}

	    


Measured memory_bytes: 2304
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let a:usize = read!();
    let mut sum:usize = 0;
    for i in 1..a+1 {
        if i % 3 != 0 && i % 5 != 0 {
            sum += i;
        }
    }
    println!("{}",sum);
}

Measured memory_bytes: 2136
#include <iostream>
using namespace std;
int w,h;
int tx[4] = {0,-1,0,1};
int ty[4] = {-1,0,1,0};
char map[21][21];

int slv(int x,int y){
    map[y][x]='#';
    int ans=0;
    for(int i=0;i<4;++i)
        if( x+tx[i]!=-1 && y+ty[i]!=-1 && x+tx[i]!=w && y+ty[i]!=h)
            if( map[y+ty[i]][x+tx[i]] == '.' )
                ans+=slv( x+tx[i], y+ty[i] ) + 1 ;
    return ans;
}

int main()
{
    int ix,iy;
    while(1){
        cin >> w >> h;
        if(w==0&&h==0)break;
        for(int i=0;i<h;++i)
            for(int j=0;j<w;++j){
                cin >> map[i][j];
                if(map[i][j]=='@'){ix=j;iy=i;}
            }
        cout << slv( ix , iy ) + 1 << endl;
    }
    return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
  int64_t n;
  cin >> n;

  vector<int64_t> b(n);
  for (auto i : irange(0L, n)) {
    int64_t a;
    cin >> a;
    ++b[a];
  }

  for (auto i : irange(0L, n)) {
    if ((i + n) % 2 == 0) {
      if (b[i] != 0) {
        cout << 0 << endl;
        return 0;
      }
    } else if (i == 0) {
      if (b[i] != 1) {
        cout << 0 << endl;
        return 0;
      }
    } else {
      if (b[i] != 2) {
        cout << 0 << endl;
        return 0;
      }
    }
  }

  int64_t p = 1;
  constexpr auto M = 1000000007;

  for (auto _ : irange(0L, n / 2)) {
    p *= 2;
    p %= M;
  }

  cout << p << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

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

  int N;
  cin >> N;

  int jp_sum = 0;
  double btc_sum = 0.0;
  double x;
  string s;
  for (int i = 0; i < N; ++i) {
    cin >> x >> s;
    if (s == "JPY")
      jp_sum += int(x);
    else
      btc_sum += x;
  }

  printf("%f\n", jp_sum + btc_sum * 380000);

  return 0;
}


Measured memory_bytes: 256