akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>

using namespace std;

using lint = long long;
using ldouble = long double;

const int INF = 1 << 30;

struct Point {
    int x, y, z;
};

int N, K, S;

int collision(Point a, Point b) {
    if (max(a.x, b.x) - min(a.x, b.x) >= S ||
        max(a.y, b.y) - min(a.y, b.y) >= S ||
        max(a.z, b.z) - min(a.z, b.z) >= S) return 0;

    int dx = min(a.x, b.x) + S - max(a.x, b.x),
        dy = min(a.y, b.y) + S - max(a.y, b.y),
        dz = min(a.z, b.z) + S - max(a.z, b.z);

    return (dx * dy + dy * dz + dz * dx) * 2;
}

vector<vector<pair<int, int>>> graph;
vector<bool> visited;

int dfs(int v, int r, int K) {
    if (K == 0) {
        for (auto p : graph[v]) {
            int sv, c;
            tie(sv, c) = p;
            if (sv == r) continue;
            if (visited[sv]) return c;
        }
        return 0;
    }

    if (visited[v]) return -INF;

    visited[v] = true;
    int ret = -INF;
    for (auto p : graph[v]) {
        int sv, c;
        tie(sv, c) = p;
        if (sv == r) continue;
        ret = max(ret, dfs(sv, v, K - 1) + c);
    }
    visited[v] = false;
    return ret;
}

bool solve() {
    cin >> N >> K >> S;
    if (N == 0) return false;

    vector<Point> cubes(N);
    for (auto& c : cubes) cin >> c.x >> c.y >> c.z;

    graph.clear();
    graph.resize(N);
    for (int u = 0; u < N; ++u) {
        for (int v = 0; v < N; ++v) {
            if (u == v) continue;
            int elim = collision(cubes[u], cubes[v]);
            if (elim > 0) graph[u].emplace_back(v, elim);
        }
    }

    visited.assign(N, false);
    int ans = -1;
    for (int v = 0; v < N; ++v) {
        ans = max(ans, dfs(v, -1, K - 1));
    }
    cout << (ans < 0 ? -1 : S * S * 6 * K - ans) << endl;
    return true;
}

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



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	string	s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if (s < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
// END

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


Measured memory_bytes: 256
N, D = map(int, input().split())
X = [[int(_) for _ in input().split()] for _ in range(N)]
cnt = 0

for i in range(N-1):
    for j in range(i+1, N):
        dist = 0
        for k in range(D):
            dist += (X[i][k]-X[j][k]) ** 2
        
        if int(dist**0.5)**2 == dist:
            cnt += 1

print(cnt)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int cnt[4]{};
    REP(i,3){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        cnt[a]++;
        cnt[b]++;
    }
    bool ok = true;
    REP(i,4) if(cnt[i]>2) ok = false;
    cout << (ok?"YES":"NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,ans;

    scanf("%d",&n);

    if(n>=100){
        ans=n%100;
        ans=ans%10;
    }

    if(n<100){
        ans=n%10;
    }

    if(ans==2 || ans==4 || ans==5 || ans==7 || ans==9){
        printf("hon\n");
    }

    if(ans==0 || ans==1 || ans==6|| ans==8){
        printf("pon\n");
    }

    if(ans==3){
        printf("bon\n");
    }

    return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cctype>
#include<cstring>
#include<list>
#include<map>
#include<sstream>
#include<set>
#include<string>
#include<vector>
typedef long long ll;
using namespace std;
#define MN 300005
#define MM 600005
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define RF(i,a,b) for(int i=a;i>=(b);--i)
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define int long long
signed main()
{   
    int t;
    string s;
    while(cin>>t>>s){
        int n=s.size();
        int cnt=0;
        int cnt1=0,cnt2=0,cnt3=0;
        F2(i,0,n){
            if(s[i]=='R')cnt1++;
            if(s[i]=='B')cnt2++;
            if(s[i]=='G')cnt3++;
        }cnt=cnt1*cnt2*cnt3;
        for(int i=0;i<n;i++){
            for(int j=1;i+j*2<n;j+=1){
                if(s[i]!=s[i+j]&&s[i+j]!=s[i+j*2]&&s[i]!=s[i+j*2])cnt--;
            }
        }
        cout<<cnt<<endl;
    }
   return 0;
}


Measured memory_bytes: 3644
n, W = map(int, input().split())
w, v = [], []
for _ in range(n):
    _w, _v = map(int, input().split())
    w.append(_w)
    v.append(_v)

dp = [[0]*(W+1) for _ in range(n+1)]

for i in range(n):
    for j in range(W+1):
        dp[i+1][j] = dp[i][j]
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j])

print(dp[n][W])


Measured memory_bytes: 120044
n = int(input())
# したから計算
if n == 0:
    print(0)
    exit()
ans = ""
digit = 1
while n != 0:
    num = 0
    if n % pow(2, digit):
        num = 1
    ans = str(num) + ans
    n -= num * pow(-2, digit - 1)
    digit += 1
print(ans)


Measured memory_bytes: 61692
#include<stdio.h>
#include<string.h>
const int mod=1000000007;
void inc(int&a,int b){(a+=b)%=mod;}
char s[100010];
int sum[100010],f[300010],las[3]={0,-1,-1};
int main(){
	int n,i;
	scanf("%s",s+1);
	n=strlen(s+1);
	for(i=1;i<n;i++){
		if(s[i]==s[i+1]){
			i=-1;
			break;
		}
	}
	if(~i){
		putchar('1');
		return 0;
	}
	f[0]=1;
	for(i=1;i<=n;i++){
		sum[i]=(sum[i-1]+2-(s[i]=='a'))%3;
		if(sum[i]==0&&i<n)f[i]=1;
		#define gao(x) if(~x)inc(f[i],f[x]);
		gao(las[(sum[i]+1)%3])
		gao(las[(sum[i]+2)%3])
		las[sum[i]]=i;
	}
	printf("%d",f[n]);
}

Measured memory_bytes: 1024
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 998244353;

int f[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
 ll n;
 int x, m;
 cin>>n>>x>>m;
 unordered_map<int,int>mp;
 mp[x] = 1;
 ll cur = x;
 ll sum = x;
 f[1] = x;
 for(ll i=2;i<=n;i++){
   int tt = cur*cur%m;
   f[i] = tt;
   if(mp.find(tt)!=mp.end()){
     int len = i-mp[tt];
     ll cc = 0;
     for(int j=mp[tt];j<i;j++){
       cc = (cc+f[j]);
     }
     ll lft = n-i+1;
     ll tmp = lft/len;
     sum+=tmp*cc;
     lft%=len;
     for(int j=mp[tt];j<mp[tt]+lft;j++){
       sum+=f[j];
     }
     break;
   }
   cur = tt;
   sum = (sum+tt);
   mp[tt] = i;
 }
 cout<<sum<<endl;
 return 0;
}


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

int main() {
  // ここにプログラムを追記
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int L,R;
  L = A+B;
  R = C+D;
  if(L>R){
    cout << "Left" << endl;
  }else if (L==R){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 220000;

int n;
int was[MAXN];
vector<int> eds[MAXN];
int h[MAXN];
int sz[MAXN];
ll ans = 0;
char s[MAXN];
int sm;

void dfs1(int v) {
	was[v] = 1;
	if (s[v] == '1')
		sz[v] = 1;
	h[v] = 0;
	for (int u: eds[v]) {
		if (!was[u])
			dfs1(u), sz[v] += sz[u], h[v] = max(h[v], h[u] + 1);
	}
}

void dfs2(int v, int hh) { 
	vector<pair<int, int> > vv;
	vv.push_back(make_pair(0, s[v] - '0'));
	was[v] = 1;
	int mx1 = hh;
	int mx2 = 0;
	int cur = sm;
	if (s[v] == '1')
		--cur;
	for (int u: eds[v]) {
		if (was[u])
			continue;
		if (h[u] + 1 > mx2)
			mx2 = h[u] + 1;
		if (mx2 > mx1)
			swap(mx2, mx1);
		vv.push_back(make_pair(h[u] + 1, (sz[u] ? 1 : 0)));
		cur -= sz[u];
	}
	vv.push_back(make_pair(hh, (cur ? 1 : 0)));
	for (int u: eds[v]) {
		if (was[u])
			continue;
		if (h[u] + 1 == mx1)
			dfs2(u, mx2 + 1);
		else
			dfs2(u, mx1 + 1);
	}
	int fl = 0;
	sort(vv.begin(), vv.end());
	for (int i = 0; i < vv.size() - 1; ++i) {
		fl |= vv[i].second;
		if (fl) {
			if (i + 2 == vv.size()) {
				if (vv[i + 1].first > vv[i].first)
					++ans;
				if (vv[i + 1].first > vv[i].first + 1)
					++ans;
			}
			else {
				ans += vv[i + 1].first - vv[i].first;
			}
		}
	}
}

int main() {
	ans = 1;
	scanf("%d", &n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a, --b;
		eds[a].push_back(b);
		eds[b].push_back(a);
	}
	scanf(" %s", s);
	for (int i = 0; i < n; ++i)
		if (s[i] == '1')
			++sm;
	dfs1(0);
	memset(was, 0, sizeof(was));
	dfs2(0, 0);
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 42880
import math
a,b,x = map(int,input().split())
A = 2*(a*a*b-x)
B = a*a*a
theta = math.atan(A/B)
if((b-a*math.tan(theta)) < 0): 
  theta = math.atan((a*b*b)/(2*x))
ans = math.degrees(theta)  
print(ans)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,lw,lr,rw,rr,ans=1e9;
string s;

int main()
{
	cin>>n>>s;
	rep(i,n)
	{
		if(s[i]=='W') rw++;
		else rr++;
	}
	rep(i,n+1)
	{
		ans=min(ans,max(lw,rr));
		if(i==n) break;
		if(s[i]=='W') lw++,rw--;
		else lr++,rr--;
	}
	cout<<ans<<endl;
	return 0;
}

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

int n, q;
std::string s;
std::vector<char> t, d;

int abs(int x) {
    return x >= 0 ? x : x * -1;
}

bool goal(int cur) {
    for (int i = 0; i < q; i++) {
        if (s[cur] == t[i]) {
            cur = (d[i] == 'L') ? cur - 1 : cur + 1;
        }
        if (cur < 0 || n <= cur) {
            return false;
        }
    }
    return true;
}

int bsearch(int ok, int ng) {
    while (std::abs(ok - ng) > 1) {
        int mi = (ok + ng) / 2;
        if (goal(mi)) {
            ok = mi;
        } else {
            ng = mi;
        }
    } 
    return ok;
}


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

    t.resize(q);
    d.resize(q);
    for (int i = 0; i < q; i++) {
        std::cin >> t[i] >> d[i];
    }

    int x = bsearch(-1, n);
    int y = bsearch(n, -1);
    int z = x - y + 1;
    std::cout << std::max(0, z) << std::endl;
}

Measured memory_bytes: 900
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
  int N, T;
  cin >> N >> T;
  
  long long ans = 0;
  vector<int> t(N);
  cin >> t[0];
  for(int i = 1; i < N; i++) {
    cin >> t[i];
    if(t[i] - t[i - 1] > T) ans += T;
    else ans += t[i] - t[i - 1];
  }
  ans += T;
  cout << ans << endl;
  
  return 0;
}
    
    

Measured memory_bytes: 1024
#include <stdio.h>

int selectionSort(int A[], int N){
  int i, j, t, sw = 0, minj;
  for(i = 0; i < N - 1; i++ ){
    minj = i;
    for(j = i; j < N; j++){
      if(A[j] < A[minj]) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
    if(i != minj) sw++;
  }
  return sw;
}

int main(){
  int A[100],N,i,sw;

  scanf("%d",&N);
  for(i = 0; i < N; i++) scanf("%d",&A[i]);

  sw = selectionSort(A, N);

  for( i = 0; i < N; i++ ){
    if( i > 0) printf(" ");
    printf("%d",A[i]);

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

  return 0;

}



Measured memory_bytes: 2104
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);       
		int n = sc.nextInt();
        int q = sc.nextInt();
		int [] L = new int [n];
        int [] R = new int [n];
        String s = sc.next();
        int count = 0;
        L[0]=0;
        R[n-1]=0;
        for(int i=0;i<n-1;i++){if(s.substring(i,i+2).equals("AC")){count++;}
                            }	
        for(int i=1;i<n;i++){if(s.substring(i-1,i+1).equals("AC")){L[i]=L[i-1]+1;}
                                else{L[i]=L[i-1];}
                            }
        for(int i=n-2;i>=0;i--){if(s.substring(i,i+2).equals("AC")){R[i]=R[i+1]+1;}
                                else{R[i]=R[i+1];}
                            }                       
	    for(int i=0;i<q;i++){int l = sc.nextInt();
                             int r = sc.nextInt();
                             System.out.println(L[r-1]+R[l-1]-count);}
  }
}


Measured memory_bytes: 89560
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] A = new long[N];
        long plus_max=0;
        int plus_max_index=-1;
        long minus_min=0;
        int minus_min_index=-1;
        for (int i=0;i<N;i++) {
            A[i] = Long.parseLong(sc.next());
            if (A[i]>0) {
                if (A[i]>plus_max) {
                    plus_max = A[i];
                    plus_max_index = i;
                }
            } else if (A[i]<0) {
                if (A[i]<minus_min) {
                    minus_min = A[i];
                    minus_min_index = i;
                }
            }
        }
        if (plus_max_index==-1 && minus_min_index==-1) {
            System.out.println(0);
        } else if (plus_max+minus_min>0) {
            System.out.println((2*N-1));
            for (int i=0;i<N;i++) {
                System.out.println((plus_max_index+1) + " " + (i+1));
            }
            for (int i=0;i<N-1;i++) {
                System.out.println((i+1) + " " + (i+2));
            }
        } else {
            System.out.println((2*N-1));
            for (int i=0;i<N;i++) {
                System.out.println((minus_min_index+1) + " " + (i+1));
            }
            for (int i=N-1;i>0;i--) {
                System.out.println((i+1) + " " + (i));
            }
        }
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    int n; cin >> n;
    int max_el = -1000001;
    int min_el = 1000001;
    int x;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> x;
        max_el = max(x, max_el);
        min_el = min(x, min_el);
        ans += x;
    }

    cout << min_el << ' ' << max_el << ' ' << ans << '\n';

}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
	int h, a;
	cin >> h >> a;
	if (h % a == 0) cout << h / a << endl;
	else cout << h / a + 1 << endl;
	return 0;
	/*
	int n, k;
	cin >> n >> k;
	vl h(n);
	rep (i, n) cin >> h[i];
	sort(all(h));
	reverse(all(h));
	int i = 0;
	while (k) {
		i++;
	}
	ll ans = 0;
	while (i < n) {
		ans += h[i];
		i++;
	}
	cout << ans << endl;
	//*/
}

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

const int MAX_N = 201010;

int bit[MAX_N + 1], n = 201000;

int sum(int i) {
  int res = 0;
  while (i > 0) {
    res += bit[i];
    i -= i & -i;
  }
  return res;
}

void add(int i, int x) {
  while (i <= n) {
    bit[i] += x;
    i += i & -i;
  }
}

int calc(string from, string to) {
  int N = from.size();

  queue<int> cidx[26];
  for (int i = 0; i < N; i++) {
    cidx[from[i] - 'a'].push(i);
  }

  vector<int> idx(N);
  for (int i = 0; i < N; i++) {
    idx[i] = cidx[to[i] - 'a'].front();
    cidx[to[i] - 'a'].pop();
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += sum(N - idx[i]);
    add(N - idx[i], 1);
  }

  return ans;
}

signed main() {
  string s;
  cin >> s;

  int cnt[26] = {};
  for (int i = 0; i < s.size(); i++) {
    cnt[s[i] - 'a']++;
  }

  int odd = 0;
  for (int i = 0; i < 26; i++) {
    if (cnt[i] % 2) {
      odd++;
    }
  }

  if (odd > 1) {
    cout << -1 << endl;
    return 0;
  }

  int app[30] = {};
  string A;
  for (auto c : s) {
    if (app[c - 'a'] < cnt[c - 'a'] / 2) {
      A.push_back(c);
      app[c - 'a']++;
    }
  }

  string B = A;

  for (int i = 0; i < 26; i++) {
    if (cnt[i] % 2) {
      B.push_back((char)('a' + i));
    }
  }

  reverse(B.begin(), B.end());
  A += B;

  cout << calc(s, A) << endl;
  return 0;
}


Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "Impossible"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 2e5 + 7;

int a[N];

void solve() {
    int n, xall = 0; 
    cin >> n;
    loop(i, n) {
        cin >> a[i];
        xall = (xall ^ a[i]);
    }
    loop(i, n)
        cout << (a[i] ^ xall) << " ";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 5104
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

typedef long long ll;
ll dp[210][210];
int U[210], D[210];
const ll M = 1e9+7;

int main() {
	int n;
	vector<int> v;
	cin >> n;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if(s[0] == 'U')
			v.push_back(1);
		else if(s[0] == 'D')
			v.push_back(-1);
	}
	if(!v.size()) {
		cout << 1 << endl;
		return 0;
	}

	U[0] = v[0] == 1;
	D[0] = v[0] == -1;
	for(int i = 1; i < v.size(); i++) {
		U[i] = U[i-1] + (v[i] == 1);
		D[i] = D[i-1] + (v[i] == -1);
	}

	dp[0][0] = 1;
	for(int i = 0; i < v.size(); i++) {
		for(int j = 0; j < v.size(); j++) {
			// i+1??????????????????????????¨???
			if(j-1 >= 0) {
				ll tmp;
				tmp = dp[i][j-1];
				if(v[i] == -1) {
					tmp *= max(0,(j-1)-D[i-1]);
					tmp %= M;
				}
				dp[i+1][j] += tmp;
				dp[i+1][j] %= M;
			}
			// i+1??????????????????????????????
			if(i > 0 && U[i]-(i-j) >= 0) {
				ll tmp;
				tmp = dp[i][j] * (U[i-1] - (i-j)) % M;
				if(v[i] == -1) {
					tmp *= max(0,j-D[i-1]);
					tmp %= M;
				}
				dp[i+1][j] += tmp;
				dp[i+1][j] %= M;
			}
		}
	}
	/*
	for(int i = 0; i < 10; i++) {
		for(int j = 0; j < 10; j++)
			cout << dp[i][j] << " ";
		cout << endl;
	}
	cout << v.size() << " " << D[v.size()-1] << endl;
	// */
	cout << dp[v.size()][D[v.size()-1]] << endl;
}

Measured memory_bytes: 1548
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n-2):
    for j in range(i,n-1):
        for k in range(j,n):
            a = l[i]
            b = l[j]
            c = l[k]
            if a != b and b != c and c != a and a + b > c:
                ans += 1

print(ans)

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

typedef long long ll;

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

    int a, b, c;
    cin>>a>>b>>c;

    if (a-b >= c) cout<<"0"<<endl;
    else cout<<c-(a-b)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    for (int i = 1; i <= 5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


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

using namespace std;

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.14159265358979323846;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int L, A, B, M;
int C[110];
int pow_ten[110];

template<class T>
struct Matrix {
    vector<vector<T> > A;

    Matrix() {}

    Matrix(size_t n, size_t m) : A(n, vector<T>(m, 0)) {}

    Matrix(size_t n) : A(n, vector<T>(n, 0)) {};

    size_t height() const {
        return (A.size());
    }

    size_t width() const {
        return (A[0].size());
    }

    inline const vector<T> &operator[](int k) const {
        return (A.at(k));
    }

    inline vector<T> &operator[](int k) {
        return (A.at(k));
    }

    static Matrix I(size_t n) {
        Matrix mat(n);
        for (int i = 0; i < n; i++) mat[i][i] = 1;
        return (mat);
    }

    Matrix &operator*=(const Matrix &B) {
        size_t n = height(), m = B.width(), p = width();
        assert(p == B.height());
        vector<vector<T> > C(n, vector<T>(m, 0));
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                for (int k = 0; k < p; k++)
                    C[i][j] = (C[i][j] + (*this)[i][k] * B[k][j] % M) % M;
        A.swap(C);
        return (*this);
    }

    Matrix &operator^=(long long k) {
        Matrix B = Matrix::I(height());
        while (k > 0) {
            if (k & 1) B *= *this;
            *this *= *this;
            k >>= 1LL;
        }
        A.swap(B.A);
        return (*this);
    }

    Matrix operator*(const Matrix &B) const {
        return (Matrix(*this) *= B);
    }

    friend ostream &operator<<(ostream &os, Matrix &p) {
        size_t n = p.height(), m = p.width();
        for (int i = 0; i < n; i++) {
            os << "[";
            for (int j = 0; j < m; j++) {
                os << p[i][j] << (j + 1 == m ? "]\n" : ",");
            }
        }
        return (os);
    }
};

signed main() {
    cin >> L >> A >> B >> M;
    __int128 a = 1;
    for (int i = 1; i < 38; i++) {
        a *= 10;
        if (a > A)C[i] = min((__int128) L, (a - A - 1) / B + 1);
    }
    for (int i = 37; i > 0; i--)C[i] -= C[i - 1];
    pow_ten[0] = 1;
    for (int i = 1; i < 38; i++)pow_ten[i] = pow_ten[i - 1] * 10 % M;
    Matrix<int> ans(3, 1);
    ans[0][0] = 0, ans[1][0] = A, ans[2][0] = 1;
    for (int i = 1; i < 38; i++) {
        Matrix<int> co(3, 3);
        co[0][0] = pow_ten[i], co[0][1] = 1, co[0][2] = 0;
        co[1][0] = 0, co[1][1] = 1, co[1][2] = B;
        co[2][0] = 0, co[2][1] = 0, co[2][2] = 1;
        co ^= C[i];
        ans = co * ans;
    }
    cout << ans[0][0] << endl;
}

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

#define U 1
#define D 2
#define R 3 
#define L 4


const int ans = 123456780;
set<int> leaf;


void print(int s){
  int board[9];
  for(int i=0; i<9; i++){
    board[8-i] = s%10;
    s /= 10;
  }
  for(int i=0; i<9; i++){
    cout << board[i] << ' ';
    if(i%3 == 2)cout << endl;
  }
}

int  moveSpace(int state, int dir){
  int board[9];

  //int --> matrix
  for(int i=0; i<9; i++){
    board[8-i] = state%10;
    state /= 10;
  }

  //find space
  int pos = 0;
  while(board[pos]!=0)pos++;
  

  //move space up
  if(dir==U && pos > 2){
    int tmp = board[pos];
    board[pos] = board[pos-3];
    board[pos-3] = tmp;
  }
  else if(dir==D && pos < 6){
    int tmp = board[pos];
    board[pos] = board[pos+3];
    board[pos+3] = tmp;
  }
  else if(dir==R && pos != 2 && pos != 5 && pos != 8){
    int tmp = board[pos];
    board[pos] = board[pos+1];
    board[pos+1] = tmp;
  }
  else if(dir==L && pos != 0 && pos != 3 && pos != 6){
    int tmp = board[pos];
    board[pos] = board[pos-1];
    board[pos-1] = tmp;
  }
  else{
    return -1;
  }

  //matrix --> int
  state = board[0];
  for(int i=1; i<9; i++){
    state *= 10;
    state += board[i];
  }

  return state;
}
//@end moveSpace



int solve(int state, int step, int depth){
  if(state == ans)return step;
  if(step == depth){
    leaf.insert(state);

    //cout << "Step:" << step << endl;
    //print(state); cout << endl;
    
    return -1;
  }
  //if(searched.find(state)!=searched.end())return -1;
  
  int next;
  next = moveSpace(state, U);
  if(next!=-1){
    int res=solve(next, step+1, depth);
    if(res != -1)return res;
  }
  next = moveSpace(state, D);
  if(next!=-1){
    int res=solve(next, step+1, depth);
    if(res != -1)return res;
  }
  next = moveSpace(state, R);
  if(next!=-1){
    int res=solve(next, step+1, depth);
    if(res != -1)return res;
  }
  next = moveSpace(state, L);
  if(next!=-1){
    int res=solve(next, step+1, depth);
    if(res != -1)return res;
  }

  return -1;
}


int main(){

  /*
    Index of array
    0 1 2
    3 4 5 
    6 7 8
   */
  int init_state;

  //input
  cin >> init_state;
  for(int i=1; i<9; i++){
    int tmp;
    cin >> tmp;
    init_state*=10; init_state+=tmp;
  }
  

  int step = 0;
 
  //solve
  int depth = 1;
  leaf.insert(init_state);
  while(1){

    //test
    //cout << "===================================" << endl;
    //cout << "Depth: " << depth << endl;

    
    set<int> next = leaf;
    leaf.clear();
    step = 0;
    
    for(int state : next){
      step = solve(state ,depth-1, depth);
      if(step != -1)break;
    }
    if(step != -1)break;

    
    depth++;
  }
  
  cout << step << endl;
  
  return 0;
}



Measured memory_bytes: 12520
import numpy as np
n = int(input())
p = np.array(list(map(int, input().split())))
ans = 1
min_n = p[0]
for i in range(1, n):
    min_n = min(min_n, p[i-1])
    if p[i] <= min_n:
        ans += 1
print(ans)


Measured memory_bytes: 34104
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<cstdio>
using namespace std;

int main()
{
	double  x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double X = max(x1, x2) - min(x1, x2);
	double Y = max(y1, y2) - min(y1, y2);

	printf("%.8lf\n", sqrt(X*X + Y*Y));


	return 0;

}

Measured memory_bytes: 1236
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;

int main(){
    INIT;
    cin >> s;
    int n = (int)s.size();
    if(s[0] == '0' || s[n - 1] == '1'){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 1;i <= n - 1;i++){
        if(s[i - 1] != s[n - i - 1]){
            cout << -1 << endl;
            return 0;
        }
    }
    s[n - 1] = '1';
    int pre = n;
    for(int i = n - 1;i >= 1;i--){
        cout << i << " " << pre << endl;
        if(s[i - 1] == '1'){
            pre = i;
        }
    }
}

Measured memory_bytes: 1616
#include <stdio.h>

int main(void){
  int A[100][100]={0};
  int b[100][1]={0};
  int C[100][1]={0};
  int n,m,i,j,num;

  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&num);
      A[i][j]=num;
    }
  }
  for(i=0;i<m;i++){
    scanf("%d",&num);
    b[i][0]=num;
  }

  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      C[i][0]+=A[i][j]*b[j][0];
    }
  }

  for(i=0;i<n;i++){
    printf("%d\n",C[i][0]);
  }

  return 0;

}

Measured memory_bytes: 648
#include <stdio.h>

int main(){
    int i, j, H, W;
    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        for(i=0; i<H; i++){
            for(j=0; j<W; j++){
                if((i+j)%2==0){
                    printf("#");
                }else{
                    printf(".");
            }
        }
    printf("\n");
    }
    printf("\n");
}
return 0;
}


Measured memory_bytes: 2528
#include <iostream>

using namespace std;

int main() {
	int n;
	char s[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	int flag = false;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'Y') flag = true;
	}
	if (flag) cout << "Four" << endl;
	else cout << "Three" << endl;
}

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

void swap(char*);

#define MAX 50000

int main()
{
	int i = 0;
	unsigned long long int n;
	char s[MAX];

	scanf("%llu", &n);

	while (n != 0) {
		n--;
		s[i] = ('a' + n % 26);
		n /= 26;
		i++;
		s[i] = '\0';
	}
	swap(s);

	printf("%s\n", s);

	return 0;
}

void swap(char* s)
{
	int i = 0;
	int j =strlen(s)-1;
	char temp;


	for (; i < j; i++, j--) {
		temp = s[i];
		s[i] = s[j];
		s[j] = temp;
	}
}

// 1000000000000001

Measured memory_bytes: 1668
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, M;
  cin >> N >> M;
  vector<bool> flag(N, false);
  vector<ll> num_ball(N, 1);
  flag[0] = true;
  rep(i, 0, M){
    ll x, y;
    cin >> x >> y;
    num_ball[x-1]--;
    num_ball[y-1]++;
    if(flag[x-1]){
      flag[y-1]=true;
    }
    if(num_ball[x-1]==0){
      flag[x-1]=false;
    }
  }

  ll count=0;
  rep(i, 0, N){
    if(flag[i]){
      ++count;
    }
  }

  cout << count << "\n";

  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    string s;
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
Ball=[]
for i in range(2*N):
  c,a=input().split()
  Ball.append((c,int(a)))
B=[0]*N
W=[0]*N
B_table=[[0]*(N+1) for i in range(N)]
W_table=[[0]*(N+1) for i in range(N)]
for i in range(2*N):
  c=Ball[i][1]-1
  if Ball[i][0]=="B":
    B[c]=i+1
    for j in range(i+1,2*N):
      if Ball[j][0]=="B":
        if Ball[j][1]<Ball[i][1]:
          B_table[Ball[i][1]-1][0]+=1
      elif Ball[j][0]=="W":
        B_table[c][Ball[j][1]]+=1
    for k in range(N):
      B_table[c][k+1]+=B_table[c][k]
  elif Ball[i][0]=="W":
    W[c]=i+1
    for j in range(i+1,2*N):
      if Ball[j][0]=="W":
        if Ball[j][1]<Ball[i][1]:
          W_table[c][0]+=1
      elif Ball[j][0]=="B":
        W_table[c][Ball[j][1]]+=1
    for k in range(N):
      W_table[c][k+1]+=W_table[c][k]
dp=[[0]*(N+1) for i in range(N+1)]
for s in range(1,2*N+1):
  for b in range(max(0,s-N),min(s,N)+1):
    if b==0:
      dp[0][s]=dp[0][s-1]+(W[s-1]+W_table[s-1][0]-s)
    elif b==s:
      dp[s][0]=dp[s-1][0]+(B[s-1]+B_table[s-1][0]-s)
    else:
      dp[b][s-b]=min(dp[b-1][s-b]+(B[b-1]+B_table[b-1][s-b]-s),dp[b][s-b-1]+(W[s-b-1]+W_table[s-b-1][b]-s))
print(dp[N][N])

   #

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

int main(void) {
  int X;
  cin >> X;
  vector<int> prices = {5, 4, 3, 2, 1};
  int num = X % 100;
  int cnt = 0;
  for (int i = 0; i < 5; i++) {
    int tmp = num / prices[i];
    num -= tmp * prices[i];
    cnt += tmp;
  }
  cout << (cnt <= X / 100 ? 1 : 0) << endl;

  return 0;
}

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

using namespace std;

int main()
{
	long long n;
	cin >> n;
	for(long long i = sqrt(n); i > 0; i--)
		if(n % i == 0)
		{
			long long j = n / i;
			cout << i+j-2;
			return 0;
		}
	for(long long i = n/2; i > 0; i--)
		if(n % i == 0)
		{
			long long j = n / i;
			cout << i+j-2;
			return 0;
		}
	return 0;
}

Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = putStr "Christmas" >> readLn >>= putStrLn . solve 

solve :: Int -> String
solve n = concat $ replicate (25 - n) " Eve"

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    const ll MOD = ll(1e9 + 7);

    int N, L;
    vector<int> X, A;
    void input() {
        cin >> N >> L;
        X.clear(); X.resize(N); cin >> X;
        A.clear(); A.resize(N); cin >> A;
    }

    void solve() {
        auto dp = vector< vector<ll> >(2, vector<ll>(L, 0));
        auto sum = vector< vector<ll> >(2, vector<ll>(L + 1, 0));
        for (ll i = 0; i <= L - 1; i++) {
            const ll x = X[0];
            const ll a = A[0];
            if (a == 0) {
                if (i == x) {
                    dp[0][i] = 1;
                }
            } else if (i - x >= 0 && (i - x) % a == 0) {
                dp[0][i] = 1;
            }
            sum[0][i + 1] = (sum[0][i] + dp[0][i]) % MOD;
        }
        for (int i = 1; i <= N - 1; i++) {
            swap(dp[0], dp[1]); fill(dp[0].begin(), dp[0].end(), 0);
            swap(sum[0], sum[1]); fill(sum[0].begin(), sum[0].end(), 0);
            const ll x = X[i];
            const ll a = A[i];
            for (ll j = 0; j <= L - 1; j++) {
                if (a == 0) {
                    if (j == x) {
                        dp[0][j] = sum[1][j];
                    }
                } else if (j - x >= 0 && (j - x) % a == 0) {
                    assert(j - 1 >= 0);
                    dp[0][j] = sum[1][j];
                }
                sum[0][j + 1] = (sum[0][j] + dp[0][j]) % MOD;
            }
        }
        //cout << sum << endl;
        cout << sum[0][L] << endl;
    }
}

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

Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31); // 2147483647

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) { return (a % b + b) % b; }

int n;
int arr[100];

ll mem[100][2];

ll dp(int at, int odd) {
    if(at == n) return odd;
    if(mem[at][odd] != -1) return mem[at][odd];
    ll res = 0;
    if(arr[at] % 2){
        res = 2*dp(at+1, 1) + dp(at+1, odd);
    }
    else {
        res = 2*dp(at+1, odd) + dp(at+1, 1);
    }
    return mem[at][odd] = res;
}

int main(){
    memset(mem, -1, sizeof(mem));
    cin >> n;
    rep(i,0,n){
        cin >> arr[i];
    }
    cout << dp(0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(){
    
    int a, b;

    cin >> a >> b;

    if(a < b){
        cout << "a < b" << endl;
    }else if(a > b){
        cout << "a > b" << endl;
    }else if(a == b){
        cout << "a == b" << endl;
    }

    return 0;
}




Measured memory_bytes: 3084
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

div = make_divisors(N)


min_m = 0
if len(div)%2 == 1:
    min_m = int((len(div)+1)/2)
if len(div)%2 == 0:
    min_m = int(len(div)/2)
    if div[min_m] - div[min_m-1] < 2:
        min_m += 1

print(sum(div[min_m:])-(len(div)-min_m))

Measured memory_bytes: 3296
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define MAX 10000000000
#define rep(i,n) for(int i = 0; i < n;i++)
ll v, n, c, e, u, k, ans = 0;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
int main(void) {
	int h, w;cin >> h >> w;char s[100][100];
	ll dp[110][110];
	rep(i, h) {
		rep(j, w) {
			cin >> s[i][j];
		}
	}
	Fill(dp, MAX);
	dp[0][0] = (s[0][0] == '.') ? 0 : 1;
	rep(i, h) {
		rep(j, w) {
			e = (s[i][j] == '.' && s[i][j + 1] == '#') ? 1 : 0;
			u = (s[i][j] == '.' && s[i + 1][j] == '#') ? 1 : 0;
			dp[i][j + 1] = min(dp[i][j] + e, dp[i][j + 1]);
			dp[i + 1][j] = min(dp[i][j] + u, dp[i + 1][j]);
		}
	}
	cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#define ll long long

using namespace std;

int main()
{
	int a;
	string b;
	cin >> a >> b;
	int otpt = 0;
	for (int i=0;i<=a-3;i++)
	{
		if (b.substr(i,3)=="ABC") otpt++;
	}
	cout << otpt;
	
}


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

using namespace std;

int main(){
  string S; cin>>S;

  vector<bool> check(26,false);

  for(int i=0;i<S.size();i++) check[S[i]-'a']=true;
  for(int i=0;i<check.size();i++){
    if(!check[i]){
      cout<<char('a'+i)<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    int a,b,c;
    cin >> a >> b>>c;

    string ans = "No";
    if(min(a,b) <= c && c <= max(a,b)){
        ans = "Yes";
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, 0, n)
        cin >> v[i];
    sort(begin(v), end(v));
    cout << accumulate(begin(v), begin(v) + k, 0);
    return 0;
}

Measured memory_bytes: 3604
#include <math.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <ostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

typedef int _lcint;
#define REP(i, n) for (_lcint i = 0; i < n; i++)
#define FOR(i, a, b) for (_lcint i = (_lcint)(a); i < (_lcint)(b); i++)
#define FORREV(i, a, b) for (_lcint i = (_lcint)(b)-1; i >= (_lcint)(a); i--)
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)  \
  cout << #v << ": "; \
  REP(i, v.size()) cout << " " << v[i] << endl;

#define ALL(a) (a).begin(), (a).end()
#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// permutation
ll mPn(ll m, ll n) {
  ll a = 1;
  REP(i, n) { a *= m - i; }
  return a;
}

// excrametion
ll exc(ll m) {
  ll a = 1;
  FOR(i, 1, m) { a *= i + 1; }
  return a;
}

// combination
ll mCn(ll m, ll n) {
  ll a = 1, b = 1;
  REP(i, n) {
    a *= m - i;
    b *= n - i;
  }
  return a / b;
}

int main() {
  int a[5], k;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
  for (int i = 0; i < 4; i++) {
    for (int j = i + 1; j < 5; j++) {
      if (a[j] - a[i] > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;

  return 0;
}


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

ll mod = 1000000007;

ll fact[200010];


ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;
  
    x = x % p;
  
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}

void init(){

    fact[0] = 1;

	for(int i=1;i<=200005; i++){
		fact[i] = (fact[i-1]*i)%mod;
	}
}

ll sol(ll r, ll d){
    ll ans = fact[r+d];
    ans = (ans*modInverse(fact[r],mod))%mod;
    ans = (ans*modInverse(fact[d],mod))%mod;
    
    return ans;
}

int main() {
    init();
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    
    ll ans = 0;
    ll t;
    
    for(int i=0; i<h-a; i++){
        t = 1;
        t = (t*sol(i,b-1))%mod;
        t = (t*sol(w-b-1,h-i-1))%mod;
        // cout<<i<<":"<<b<<" "<<w-b-1<<":"<<h-i-1<<'\n';
        ans = (ans + t)%mod;
    }
    
    cout<<ans;
    
    return 0;
}







Measured memory_bytes: 1920