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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

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

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e3+1;

int N, M;
vector<int> graph[MAXN];
vector<int> ans;

void bfs(int a)
{
    int v[N];
    for(int i=0; i<N; i++)
    {
        v[i] = -1;
    }

    queue<int> q;
    for(int i=0; i<graph[a].size(); i++)
    {
        v[graph[a][i]] = a;
        q.push(graph[a][i]);
    }

    while(!q.empty())
    {
        int x = q.front();
        q.pop();
        if(x != a)
        {
            for(int i=0; i<graph[x].size(); i++)
            {
                if(v[graph[x][i]] == -1)
                {
                    v[graph[x][i]] = x;
                    q.push(graph[x][i]);
                }
            }
        }
        else
        {
            vector<int> temp;
            temp.PB(x);
            x = v[x];
            while(x != a)
            {
                temp.PB(x);
                x = v[x];
            }

            if(!ans.size() || temp.size() < ans.size())
            {
                ans = temp;
            }
        }
    }
}

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M;
    for(int i=0; i<M; i++)
    {
        int x, y;
        cin >> x >> y;
        x--; y--;
        graph[x].PB(y);
    }

    //find shortest cycle
    for(int i=0; i<N; i++)
    {
        bfs(i);
    }

    if(ans.size())
    {
        cout << ans.size() << "\n";
        for(int i=0; i<ans.size(); i++)
        {
            cout << ans[i]+1 << "\n";
        }
    }
    else
    {
        cout << -1;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, M, a, b, ans = 0;
    cin >> N >> M;
    auto graph = make_v<int>(N, N);
    fill_v(graph, false);
    rep(i, M)
    {
        cin >> a >> b;
        a--;
        b--;
        graph[a][b] = true;
        graph[b][a] = true;
    }
    vint per(N);
    rep(i, N)
    {
        per[i] = i;
    }
    do
    {
        bool ok = true;
        rep(i, N - 1)
        {
            if (!graph[per[i]][per[i + 1]])
            {
                ok = false;
                break;
            }
        }
        if (ok)
            ans++;
    } while (next_permutation(++per.begin(), per.end()));
    cout << ans;
    return 0;
}

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

int x, y, s;

void solve() {
  int ans = -1;
  for (int a = 1; a < s; a++) {
    for (int b = 1; b < s; b++) {
      if (s == (a * (x + 100) / 100) + (b * (x + 100) / 100)) {
        ans = max(ans, (a * (y + 100) / 100) + (b * (y + 100) / 100));
      }
    }
  }
  cout << ans << endl;
}

int main() {
  while (1)  {
    cin >> x >> y >> s;
    if (x == 0) { break; }
    solve();
  }
}



Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int Work5Core2(string S);

int Work5Core(string X)
{
	int numSt = 0;

	stack<char> stackS;

	for (const auto c : X) {
		stackS.push(c);
		while (stackS.size() >= 2) {
			if (stackS.top() == 'T') {
				stackS.pop();
				if (stackS.top() == 'S') {
					++numSt;
					stackS.pop();
				}
				else {
					stackS.push('T');
					// stackS.push('T');
					break;
				}
			}
			else {
				break;
			}
		}
	}

	return stackS.size();
}
int main()
{
	string X;

	cin >> X;

	int result = Work5Core(X);

	cout << result << endl;

	return 0;
}

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

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

    while (S.size() > 0) {
        S = std::string(S.begin(), S.end() - 2);
    
        if (S.substr(0, S.size() / 2) == S.substr(S.size() / 2, S.size())) {
            std::cout << S.size() << std::endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <array>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>

using namespace std;
int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	long long cost = 0;
	//ABピザを使う場合
	if (A + B > 2 * C)
	{
		if (X > Y)
		{
			cost += C * 2 * Y;
			if (A > 2 * C)
				cost += 2 * C * (X - Y);
			else
				cost += A * (X - Y);
		}
		else
		{
			cost += C * 2 * X;
			if (B > 2 * C)
				cost += 2 * C * (Y - X);
			else
				cost += B * (Y - X);
		}
	}
	else
		cost = A * X + B * Y;
	cout << cost;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mxn=200005;
#define init int nd, int cl, int cr
#define md (cl+cr)/2
#define lnd nd*2
#define rnd nd*2+1
#define lc lnd, cl, md
#define rc rnd, md+1, cr
int n, m, st[mxn*4], lz[mxn*4];
vector<int>ins[mxn];
void build(init){
	st[nd]=cl;
	if(cl==cr) return;
	build(lc); build(rc);
	st[nd]=min(st[lnd], st[rnd]);
}
void pro(int nd){
	if(!lz[nd]) return;
	st[lnd]+=lz[nd], lz[lnd]+=lz[nd];
	st[rnd]+=lz[nd], lz[rnd]+=lz[nd];
	lz[nd]=0;
}
void upd(init, int l, int r){
	if(r<cl || cr<l) return;
	if(l<=cl && cr<=r){
		st[nd]--; lz[nd]--;
		return;
	}
	pro(nd);
	upd(lc, l, r); upd(rc, l, r);
	st[nd]=min(st[lnd], st[rnd]);
}
int que(init, int l, int r){
	if(r<cl || cr<l) return INT_MAX;
	if(l<=cl && cr<=r) return st[nd];
	pro(nd);
	return min(que(lc, l, r), que(rc, l, r));
}
int main(){
	scanf("%d%d", &n, &m); m++;
	for(int i=1, u, v; i<=n; i++){
		scanf("%d%d", &u, &v);
		v=m-v;
		ins[u].push_back(v);
	}
	build(1, 0, m);
	int ans=m-1-n;
	for(int i=0; i<=m; i++){
		for(int j=0; j<ins[i].size(); j++){
			int pos=ins[i][j];
			upd(1, 0, m, pos, m);
		}
		ans=min(ans, i+que(1, 0, m, 0, m-i));
	}
	printf("%d\n", max(0, -ans));
	return 0;
}

Measured memory_bytes: 14080
k = list(map(int, list(input())))
n = len(k)
d = int(input())
dp = [[[0]*d for _ in range(2)] for _ in range(n+1)]
dp[0][0][0] = 1
mod = 10**9 + 7
for s in (0,1):
  for i in range(n):
    for j in range(10 if s else k[i]+1):
      for m in range(d):
        dp[i+1][s|(j<k[i])][(m+j)%d] = (dp[i+1][s|(j<k[i])][(m+j)%d] + dp[i][s][m]) % mod
print((dp[n][0][0] + dp[n][1][0] - 1) % mod)

Measured memory_bytes: 63196
n, q = gets.split.map(&:to_i)
s = gets.chomp
a = [0] * n
n.pred.times do |i|
  if s[i] == 'A' && s[i + 1] == 'C'
    a[i + 1] = a[i] + 1
  else
    a[i + 1] = a[i]
  end
end
q.times do
  l, r = gets.split.map(&:to_i)
  puts a[r - 1] - a[l - 1]
end

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


void solve(long long N, std::string S){
    ll ans = 0, x = 0;
    for(ll i=0; i< N; i++){
        if(S.at(i) == 'I') x++;
        if(S.at(i) == 'D') x--;
        ans = max(ans, x);
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b;
int gcd;
int lcm;
int tmp;
while(scanf("%d%d",&a,&b)!=EOF){
    int k=1;
	for(;k<=b;k++)
	    if(k*a%b==0){
		    lcm=k*a;
			break;
			}
	while(a!=b){
	  if(a<b){
	    tmp=a;
		a=b;
		b=tmp;
		}
	  a=a-b;
	  }
	  gcd=a;
    printf("%d %d\n",gcd,lcm);
}
return 0;
}	

Measured memory_bytes: 596
object Main {
  val judge = (ret: Boolean, ok: String, ng: String) => if (ret) println(ok) else println(ng)
  val mult4 = (a: Int, b: Int) => if ((a * 10 + b) % 4 == 0) true else false

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val _, g, b = sc.nextInt
    val ret = mult4(g,b)
    judge(ret, "YES", "NO")
  }
}


Measured memory_bytes: 27456
N = gets.to_i
AS = gets.split.map(&:to_i)

sorted = AS.sort.reverse
score = 0
semimax_i = 0

(sorted.length - 1).times.each do |i|
  score += sorted[semimax_i]
  semimax_i += 1 if i % 2 == 0
  i += 1
end

puts score


Measured memory_bytes: 31336
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<s64, s64>;

void dijkstra(const vector< vector< P > >& g, vs64& d, int s)
{
    rep (i, d.size()) d[i] = 1e18;
    d[s] = 0;

    priority_queue<P, vector<P>, greater<P> > pq;
    pq.push(P{d[s], s});

    while (!pq.empty())
    {
        auto p = pq.top(); pq.pop();
        s64 from = p.second;
        s64 d1 = p.first;

        for (auto& x : g[from])
        {
            s64 to = x.first;
            s64 d2 = x.second;
            if (d[to] > d1 + d2)
            {
                d[to] = d1 + d2;
                pq.push(P{d[to], to});
            }
        }
    }
}

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

    int n, m, s, t;
    cin >> n >> m >> s >> t;
    --s, --t;

    vector< vector< P > > g1(n), g2(n);
    rep (i, m)
    {
        int u, v;
        s64 a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        g1[u].emplace_back(v, a);
        g1[v].emplace_back(u, a);
        g2[u].emplace_back(v, b);
        g2[v].emplace_back(u, b);
    }

    vs64 d1(n), d2(n);
    dijkstra(g1, d1, s);
    dijkstra(g2, d2, t);

    vs64 d(n, 1e15);
    rep (i, n)
    {
        d[i] -= d1[i] + d2[i];
    }

    for (int i = n - 2; i >= 0; --i)
    {
        d[i] = MAX(d[i], d[i + 1]);
    }

    rep (i, n)
    {
        cout << d[i] << "\n";
    }
    return 0;
}



Measured memory_bytes: 19016
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
int arr[100005];
int fun(int n,int k)
{
    if(n==1) return 0;
    if(dp[n]!=INT_MAX) return dp[n];
    int ans=INT_MAX;
    for(int i=1;i<=k;i++)
    {
        if(n-i>=1)
            ans=fun(n-i,k)+abs(arr[n]-arr[n-i]);
        dp[n]=min(dp[n],ans);
    }
    return dp[n];

}
int main()
{
    int n,k;cin>>n>>k;
    //int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        dp[i]=INT_MAX;
    }
    int res=fun(n,k);
    cout<<res<<"\n";

}



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

int compare_char(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;

    return strcmp( left_char, right_char );
}

int main() {
  int n;
  scanf("%d", &n);
  char s[n][11];
  for(int i=0;i<n;i++) scanf("%s", &s[i]);

  qsort(s, n, sizeof(s[0]), compare_char);

  int c=1;

  for(int i=1;i<n;i++){
    if(strcmp(s[i-1], s[i])) c++;
  }
  printf("%d", c);
  return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    int a = (n + 1) / 2;
    cout << fixed << setprecision(7) << (float)(a / (n * 1.0));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
  long long h,w,ans;
  cin >> h >> w;

  if(h==1||w==1){
    ans=1;
  }else{
    ans=(h*w+1)/2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

constexpr double EPS = 1e-9;
bool EQ(double a, double b) {
    return (b - EPS) <= a && a <= (b + EPS);
}

int main() {
    ll W, H, x, y; cin >> W >> H >> x >> y;
    double half = (W * H) / 2.0;
    int center = 0;
    if(EQ(x, W / 2.0) && EQ(y, H / 2.0)) center = 1;
    printf("%.9f %d\n", half, center);
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli x;
    cin>>x;
    lli t=1;
    while((x*t)%360!=0){
        t++;
    }
    out(t);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using i64 = long long;

class UF {
    int *par;
    int *rank;

    public:
    UF(int size) : par(new int[size]), rank(new int[size]()) {
        for (int i = 0; i < size; i++) par[i] = i;
    }
    ~UF() { delete[] par; delete[] rank; }

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

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

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;

        if (rank[x] < rank[y]) par[x] = y;
        else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }
};

int main() {
    int n, h, w;
    std::cin >> n >> h >> w;
    std::vector<std::tuple<i64, int, int>> edges;
    for (int i = 0; i < n; i++) {
        int a, b; i64 c;
        std::cin >> a >> b >> c;
        edges.emplace_back(c, a - 1, h + b - 1);
    }

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

    UF uft(h + w);
    std::vector<int> nv(h + w, 1), ne(h + w);
    i64 ret = 0;

    for (auto &e : edges) {
        i64 c = std::get<0>(e);
        int a = std::get<1>(e), b = std::get<2>(e);
        int pa = uft.root(a), pb = uft.root(b);
        if (pa == pb) {
            if (nv[pa] > ne[pa]) {
                ret += c;
                ne[pa]++;
            }
        } else {
            if (nv[pa] + nv[pb] > ne[pa] + ne[pb]) {
                ret += c;
                uft.unite(pa, pb);
                nv[uft.root(pa)] = nv[pa] + nv[pb];
                ne[uft.root(pa)] = ne[pa] + ne[pb] + 1;
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 4976
n, m = map(int, input().split())
a = []
b = []

for i in range(n):
    a.append(list(map(int,input().split())))
    
for i in range(m):
    b.append(list())
    b[i]=int(input())

for i in range(n):
    t=0
    for j in range(m):
        t+=a[i][j]*b[j]
    print(t)


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
int h[100005];
long long dp[100005];
long long solve(int pt,int n)
{
	if(dp[pt]!=-1)	return dp[pt];
	if(pt==n)	return dp[pt]=0;
	long long ans=1000000005;
	if(pt<n-1)	ans=solve(pt+2,n)+abs(h[pt+1]-h[pt-1]);
	ans=min(ans,solve(pt+1,n)+abs(h[pt]-h[pt-1]));
	return dp[pt]=ans;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("ou.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	memset(dp,-1ll,sizeof(dp));
	for(int i=0;i<n;i++)
		cin>>h[i];
	cout<<solve(1,n);
	return 0;
}

Measured memory_bytes: 7904
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    long long  Q,H,S,D; cin >> Q >> H >> S >> D;
    long long  N; cin >> N;
    long long  ans = 0;
    long long  min1 = Q*4;
    if(min1 > H*2) min1 = H*2;
    if(min1 > S) min1 = S;

    if(D > min1*2) ans = (min1)*N;
    else ans = (N/2)*D + (N%2)*min1;
    cout << ans << endl;
}




Measured memory_bytes: 256
import math
# print(math.sin(math.radians(-30)))

a, b, h, m = map(int, input().split())
# h時 m分

digh = (h + m/60) * (1/12) * 360
digm = m * 6

# print(digh, digm)

cos = math.cos(math.radians(digm-digh))
c2 = a**2 + b**2 - 2 * a * b * cos

print(c2**0.5)

Measured memory_bytes: 9500
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

    int n ;
    cin >> n ;
    int arr[n+3]  ;

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

    }
    int flag = 0 ;
    int cnt = 0 ;
    while( true )
    {
        for(int i = 1 ; i <= n ; i++)
        {
            if(arr[i] % 2 != 0)
            {
                flag = 1 ;
                break ;
            }
            else if(arr[i] % 2 == 0)
            {
                arr[i] = arr[i]/2 ;
            }
        }
        if(flag == 0)
            cnt ++ ;
        if(flag == 1)
            break ;
    }
    cout << cnt << endl  ;

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,temp,rem;
    cin>>n;
    temp=n;
    rem=temp%10;

    if(rem==2 ||rem==4 ||rem==5 ||rem==7 ||rem==9)
    {
        cout<< "hon"<<endl;
    }
    else if(rem==0 ||rem==1 ||rem==6 ||rem==8 )
    {
        cout<< "pon"<<endl;
    }
    else
    {
        cout<< "bon"<<endl;
    }
}

Measured memory_bytes: 3128
s=input()
l=['0' for _ in s]
ind=0
for i in range(len(s)):
    if s[i]=='R':
        ind=i
    elif (i-ind)%2==0:
        l[ind]=str(int(l[ind])+1)
    else:
        l[ind+1]=str(int(l[ind+1])+1)

for i in range(1,len(s)+1):
    if s[-i]=='L':
        ind=-i
    elif (-i-ind)%2==0:
        l[ind]=str(int(l[ind])+1)
    else:
        l[ind-1]=str(int(l[ind-1])+1)
print(' '.join(l))


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

int main(){
    long long A, B, C, K;
    cin >> A >> B >> C >> K;

    if(K <= A){
        cout << K << endl;
    }else if(K <= A + B){
        cout << A << endl;
    }else if(K <= A + B + C){
        K = K - A - B;
        if(C <= K){
            cout << A - C << endl;
        }else{
            cout << A - K << endl;
        }
    }
}

Measured memory_bytes: 3584
class DisjointSet:
    def __init__(self,size):
        self.rank=[0]*size
        self.p=[0]*size
        for i in range(size):
            self.makeSet(i)
    
    def makeSet(self,i):
        self.p[i]=i
        self.rank[i]=0
    
    def same(self,x,y):
        return self.findSet(x) == self.findSet(y)
    
    def unite(self, x,y):
        self.link(self.findSet(x), self.findSet(y))
    
    def link(self, x, y):
        if(self.rank[x] > self.rank[y]):
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y]+=1
     
    def findSet(self, x):
        if(x!=self.p[x]):
            self.p[x]=self.findSet(self.p[x])
        return self.p[x]

    def print(self):
        print(self.p)
        
def readinput():
    n,m=list(map(int,input().split()))
    p=list(map(int,input().split()))
    p.insert(0,0)
    pairs=[]
    for _ in range(m):
        pair=list(map(int,input().split()))
        pairs.append(pair)
    return n,m,p,pairs

def main(n,m,p,pairs):
    uft=DisjointSet(n+1)
    for x,y in pairs:
        if uft.same(x, y):
            pass
        else:
            uft.unite(x, y)

    #uft.print()

    #print(p)
    count=0
    for i in range(1,n+1):
        if uft.same(i,p[i]):
            #p[i],p[j] = p[j], p[i]
            count+=1
    
    return count

if __name__=='__main__':
    n,m,p,pairs=readinput()
    ans=main(n,m,p,pairs)
    print(ans)


Measured memory_bytes: 36132
# atcoder
import math

def get_number_of_digits(n):
    return int(math.log10(n) + 1)

def get_larger_digits(a, b):
    return max(get_number_of_digits(a), get_number_of_digits(b))

n = int(input())
min_digit = float('inf')
for a in range(1, int(math.sqrt(float(n))+5.0)):
    if n % a != 0:
        continue
    b = int(n / a)
    if n == a * b:
        temp_digit = get_larger_digits(a, b)
        min_digit = min(min_digit, temp_digit)
print(min_digit)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    int key1 = 0;
    int key2 = 0;
    if(a/100 <= 99 && a%100 <= 99){
        if(1 <= a/100 && a/100 <= 12 && 1 <= a%100 && a%100 <= 12)
            cout << "AMBIGUOUS" <<endl;
        else if(1 <= a/100 && a/100 <= 12)
            cout << "MMYY" << endl;
        else if(1 <= a%100 && a%100 <= 12)
            cout << "YYMM" << endl;
        else
        {
            cout << "NA" << endl;
        }
        
    }
    
}

Measured memory_bytes: 256
using namespace std;

#include <bits/stdc++.h>

int main(){
    int r, D, x2000;
    cin >> r >> D >> x2000;
    int next = x2000;
    for ( int i = 0; i < 10; i ++ ){
        next = r * next - D;
        cout << next << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define deb(x) cout << #x << " -> " << x << "\n"

template<class T> bool uin(T a, T b) { return a > b ? (a == b, true) : false; }
template<class T> bool uax(T a, T b) { return a < b ? (a == b, true) : false; }

#ifdef LOCAL_DEFINE
	mt19937 rng(228);
#else 
	mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ll MOD = 1000000007;
const ll INF = 1e18;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int a, b, c, k, cnt = 0;
	cin >> a >> b >> c;
	cin >> k;
	while (a >= b) {
		cnt++;
		b *= 2;
	} 
	while (b >= c) {
		cnt++;
		c *= 2;
	}
	if (cnt <= k) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}


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

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

    int n;
    cin >> n;

    vector<int> a(n+2);
    a[0] = 0;
    a[n+1] = 0;
    int sum = 0;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    rep(i, n+1) {
        sum += abs(a[i] - a[i+1]);
    }
    for(int i = 1; i <= n; ++i) {
        int ans = 0;
        ans = sum + abs(a[i-1] - a[i+1]) - (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1]));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3724
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
    We are considering j > i so we need to find all i and j such that
    j - i = a[j] + a[i] which is a[j] - j = - a[i] - i
    so for each j we need find count all of those whose value - a[i] - i is equal to a[j] -j. 
    We can use a map to store values of - a[i] - i and add it to our answer in each step for value a[j] - j.

*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
   int n,i;cin>>n;
   ll A[n],ans=0;
   map<ll,int>M; 
   foe(i,1,n)
   {
       cin>>A[i-1];
       ans+=M[A[i-1]-i];//performed in this loop itself because we are checking j,i where j>i;
       M[-A[i-1]-i]++;
   }
   cout<<ans<<"\n";
   
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 27952
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



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

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



int main() {

	int i, j, k;
	//ll N, M, K;
	int N, M, K;
	cin >> N >> M;
	int A[101];
	int sum = 0;
	int ans = 0;
	rep(i, 0, N) {
		cin >> A[i];
		sum += A[i];
	}
	rep(i, 0, N) {
		if (A[i] * 4 * M >= sum)
			ans++;
	}
	if (ans >= M)
		cout << "Yes";
	else
		cout << "No";

	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <stdio.h>

int max(int a, int b){
	if (a>=b) return a;
	else return b;
}

int min(int a, int b){
	if (a>=b) return b;
	else return a;
}

int main(){
	int N, A, B;
	std::cin >> N >> A >> B;
	int D;
	D = A + B - N;
	std::cout << min(A, B) << " " <<  max(D, 0) << std::endl;
	return 0;
}


Measured memory_bytes: 256
using System;
class C_RectCut{
	static void Main(string[] args){
		string[] Str = Console.ReadLine().Split(' ');
		double W = double.Parse(Str[0]);
		double H = double.Parse(Str[1]);
		double x = double.Parse(Str[2]);
		double y = double.Parse(Str[3]);
		Console.WriteLine("{0} {1}",W * H / 2,((W / 2) == x) & ((H / 2) == y) ? 1 : 0);
		return;
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

#define N 26
#define MAX_T 1.9
#define TRIAL 5

int c[N];
int s[365][N];

std::chrono::time_point<std::chrono::steady_clock> start, endt;

random_device rd;
mt19937 generator(rd());
uniform_real_distribution<> dist_real(0.0, 1.0);
uniform_int_distribution<> dist_int(0, RAND_MAX);

struct ContestInfo {
	int D;
	long score;
	long best_score;
	vector<int> t;
	vector<int> best_t;
	set<int> held[N];
	ContestInfo(int dd) : D(dd), score(0) {
		t.resize(D, -1);
		for (int i = 0; i < N; i++) {
			held[i].insert(-1);
			held[i].insert(D);
			score -= c[i] * D * (D + 1) / 2;
		}
	}

	void add(int dd, int qq) {
		if (t[dd] != -1) {
			cout << "Add faild!" << endl;
			exit(1);
		}

		t[dd] = qq;
		score += s[dd][qq];
		auto itr = held[qq].insert(dd).first;
		auto ritr = next(itr);
		auto litr = prev(itr);
		auto range = [](int l, int r) {
			int k = r - l - 1;
			return -k * (k + 1) / 2;
		};
		score -= c[qq] * range(*litr, *ritr);
		score += c[qq] * (range(*litr, *itr) + range(*itr, *ritr));
	}

	void erase(int dd) {
		if (t[dd] == -1) {
			cout << "Erase faild!" << endl;
			exit(1);
		}
		int qq = t[dd];
		t[dd] = -1;
		score -= s[dd][qq];
		auto itr = held[qq].find(dd);
		auto ritr = next(itr);
		auto litr = prev(itr);
		auto range = [](int l, int r) {
			int k = r - l - 1;
			return -k * (k + 1) / 2;
		};
		score += c[qq] * range(*litr, *ritr);
		score -= c[qq] * (range(*litr, *itr) + range(*itr, *ritr));
		held[qq].erase(itr);
	}

	void change(int dd, int qq) {
		erase(dd);
		add(dd, qq);
	}

	void save() {
		best_t = t;
		best_score = score;
	}

	void output(bool show = false) {
		for (int i = 0; i < D; i++)
			cout << best_t[i] + 1 << endl;
		if (show) cout << best_score << endl;
	}
};

double dice() {
	return dist_real(generator);
}

double prob(double rem) {
	return 1.0 / exp(rem);
	// return 1.0 / pow(3, rem);
}

void tic() {
	start = std::chrono::steady_clock::now();
}

double toc() {
	endt = std::chrono::steady_clock::now();
	std::chrono::duration<double> elapsed_seconds = endt - start;
	return elapsed_seconds.count();
}

vector<int> sort_index(const vector<int> &v) {
	vector<int> idx(v.size());
	iota(idx.begin(), idx.end(), 0);
	sort(idx.begin(), idx.end(), [&v](int i1, int i2) { return v[i1] > v[i2]; });
	return idx;
}

int main() {
	int d;
	cin >> d;
	for (int i = 0; i < N; i++)
		cin >> c[i];
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < N; j++) {
			cin >> s[i][j];
		}
	}

	tic();
	int t = 0;
	ContestInfo ci(d);
	for (int i = 0; i < d; i++) {
		t = max_element(s[i], s[i] + N) - s[i];
		ci.add(i, t);
	}

	long current_score = ci.score;
	int best_score = current_score;
	ci.save();

	int dd, qq;
	while (toc() < MAX_T) {
		dd = dist_int(generator) % d;
		qq = dist_int(generator) % N;
		int old_q = ci.t[dd];
		ci.change(dd, qq);
		long new_score = ci.score;
		if (new_score < current_score && prob(MAX_T - toc()) < dice()) {
			// if (new_score < current_score) {
			ci.change(dd, old_q);
		} else {
			current_score = new_score;
			if (best_score < current_score) {
				best_score = current_score;
				ci.save();
			}
		}
	}
	ci.output();
}

Measured memory_bytes: 4324
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	int A, B, C;

	scanf("%d%d%d", &A, &B, &C);

	if (A == B)printf("%d", C);
	else if (B == C)printf("%d", A);
	else printf("%d", B);



}

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

fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get_line().parse::<u64>().unwrap();
    let mut set = HashSet::new();
    for _i in 0..n {
        let s = get_line();
        set.insert(s);
    }
    println!("{}", set.len());
}


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

int main() {
    int r,c;
    cin >> r >> c;
    vector<vector<char>> arr(r,vector<char>(c));
    char cc;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin >> cc;
            arr[i][j]=cc;
        }
    }
    
    vector<vector<int>> dp(r+1,vector<int>(c+1,0));
    dp[0][1]=1;
    
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            if(arr[i-1][j-1] == '.'){
                dp[i][j] = (dp[i-1][j]%1000000007 + dp[i][j-1]%1000000007)%1000000007;
            }
            else dp[i][j]=0;
        }
    }
    cout << dp[r][c] << endl;
	return 0;
}

Measured memory_bytes: 5248
#include<iostream>
#include<stdio.h>
using namespace std ;
int gcd(int a ,int b ){
   if(a<b){
     swap(a,b);
   }
   if(a%b==0){
     return b ;
   }
   else
     return gcd(b,a%b) ;

}
int main(){
    int n ;
cin >> n ;
int ans = 2*n/gcd(n,2)  ;
printf("%d",ans);
return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
#include <algorithm>
using namespace std;
int main(void){
    int n; cin >> n;
    vector<string> words(n);
    vector<string> pwords(n);
    string ans = "Yes";
    int i = 0;
    while (i < n) {
        cin >> words[i];
        i++;
    }
    i = 1;
    pwords[0] = words[0];
    while (i < n) {
        if (words[i].at(0) != words[i-1].at(words[i-1].length() - 1) || find(pwords.begin(), pwords.end(), words[i]) != pwords.end()) ans = "No";
        pwords[i] = words[i];
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    string s;
    cin >> s;
    string ans = "";
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == '0' || s[i] == '1')
        {
            ans += s[i];
        }
        if (s[i] == 'B' && ans != "")
        {
            ans.erase(ans.length() - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  map<int, int> p;
  rep(i, 3) {
    int n; cin >> n;
    p[n] += 1;
  }
  cout << p.size() << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String ans = "No";
    for(int i = 0; i < 3; i++) {
      int d = n % 10;
      n /= 10;
      if(d == 7) ans = "Yes";
    }
    System.out.println(ans);
  }
}

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

int main() {
  string s;
  cin >> s;
  int ans = 700;
  
  for (int i = 0; i < 3; i++) {
    if(s[i] == 'o') ans += 100;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]

ans = 0
for i in range(N):
  t = C
  for j in range(M):
    t += B[j] * A[i][j]
  if t > 0:
    ans += 1
    
print(ans)
         

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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    string S, T;
    cin >> S >> T;
    
    for(int n=0; n<N; n++) {
        cout << S[n] << T[n];
    }
    cout << endl;


    return 0;
    
}

Measured memory_bytes: 256
Form = ["((ae1b)e2(ce3d))", "((ae1(be2c))e3d)", "(ae1((be2c)e3d))", "(((ae1b)e2c)e3d)", "(ae1(be2(ce3d)))"]
Exp = ["+", "-", "*"]
def solve(num)
  num.permutation(4).to_a.each do |p,q,r,s| 
    Exp.repeated_permutation(3).to_a.each do |ex1, ex2, ex3|
      Form.each do |form|
        f = form.dup
        f.gsub!("a", p); f.gsub!("b", q); f.gsub!("c", r); f.gsub!("d", s); f.gsub!("e1", ex1); f.gsub!("e2", ex2); f.gsub!("e3", ex3)
        if eval(f) == 10
          puts f
          return true
        end
      end
    end
  end
  false
end
loop do
  num = gets.split
  break if num[0] == "0"
  p 0 unless solve(num)
end

Measured memory_bytes: 9688
X, Y = map(int, input().split())
if (X + Y) % 3 != 0:
    print(0)
    quit()
n = (2 * Y - X) // 3
m = (2 * X - Y) // 3
if n < 0 or m < 0:
    print(0)
    quit()
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
print(cmb(n + m, n, p))

Measured memory_bytes: 123840
#include <stdio.h>
void convert(char stc[], int len);
void convertapp(char stc[], int from);
void convertpea(char str[], int from);
int appsearch(char str[], int from);
int peasearch(char str[], int from);

int main(int argc, const char * argv[])
{
    char stc[1050];
    int len = 0;
    int k;

    while (1) {
        stc[len] = getchar();
        if (stc[len] == '\n') break;
        len++;
    }
    convert(stc, len);
    for (k = 0; k < len; k++) {
        printf("%c", stc[k]);
    }
    puts("");
    return 0;
}

void convert(char stc[], int len){
    int i;
    for (i = 0; i < len; i++) {
        if (appsearch(stc, i)) {
            convertpea(stc, i);
            i += 5;
        }
        else if (peasearch(stc, i)) {
            convertapp(stc, i);
            i += 5;
        }
    }
}

int appsearch(char stc[], int i){
    if (stc[i] == 'a') {
        if (stc[i + 1] == 'p') {
            if (stc[i + 2] == 'p') {
                if (stc[i + 3] == 'l') {
                    if (stc[i + 4] == 'e') {
                        return 1;
                    }
                }
            }
        }
    }
    return 0;
}

int peasearch(char stc[], int i){
    if (stc[i] == 'p') {
        if (stc[i + 1] == 'e') {
            if (stc[i + 2] == 'a') {
                if (stc[i + 3] == 'c') {
                    if (stc[i + 4] == 'h') {
                        return 1;
                    }
                }
            }
        }
    }
    return 0;
}

void convertpea(char stc[], int i){
    stc[i] = 'p';
    stc[i + 1] = 'e';
    stc[i + 2] = 'a';
    stc[i + 3] = 'c';
    stc[i + 4] = 'h';
    return;
}
void convertapp(char stc[], int i){
    stc[i] = 'a';
    stc[i + 1] = 'p';
    stc[i + 2] = 'p';
    stc[i + 3] = 'l';
    stc[i + 4] = 'e';
    return;
}

Measured memory_bytes: 524
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int a[N];

bool cmp(int x, int y){
	return (x % 2) < (y % 2);
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	int cnt = 0;
	for (int i = 1; i <= m; i++){
		cin >> a[i];
		if (a[i] % 2 == 1) cnt++;
	}
	if (m == 1){
		cout << a[1] << '\n';
		if (n == 1){
			cout << 1 << '\n';
			cout << 1;
			return 0;
		}
		cout << 2 << '\n';
		cout << a[1] - 1 << ' ' << 1 ;
		return 0;
	}
	sort(a + 1, a + m + 1, cmp);
	swap(a[1], a[m - 1]);
	if (cnt > 2) return cout << "Impossible", 0;
	for (int i = 1; i <= m; i++) cout << a[i] << ' ';
	cout << '\n';
	vector<int> ans;
	for (int i = 1; i <= m; i++){
		if (i == 1){
			if (a[i] != 1) ans.pb(a[i] - 1);
		}
		else if (i == m) ans.pb(a[i] + 1);
		else ans.pb(a[i]);
	}
	cout << ans.size() << '\n';
	for (auto u:ans) cout << u << ' ';








	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[] in=new int[6];
        String[] input=new String[6];
        input=(br.readLine().split(" "));
        for(int i=0;i<6;i++)in[i]=Integer.parseInt(input[i]);
        Dice D1=new Dice(in);
        input=(br.readLine().split(" "));
        for(int i=0;i<6;i++)in[i]=Integer.parseInt(input[i]);
        Dice D2=new Dice(in);
        if(D1.isequal(D2))out.println("Yes");
        else out.println("No");
        out.flush();
    }
}
class Dice{
    private int[] memo=new int[6];
    private static final String equalmove="NNNNWNNNWNNNENNNENNNWNNN";
    public Dice(int[] in){
        Set(in[0],in[1],in[2],in[3],in[4],in[5]);
    }
    private void Set(int a,int b,int c,int d,int e,int f){
        memo[0]=a;memo[1]=b;memo[2]=c;memo[3]=d;memo[4]=e;memo[5]=f;
    }
    public void move(char c){
        switch(c){
            case 'W':
                Set(memo[2],memo[1],memo[5],memo[0],memo[4],memo[3]);
                break;
            case 'N':
                Set(memo[1],memo[5],memo[2],memo[3],memo[0],memo[4]);
                break;
            case 'S':
                Set(memo[4],memo[0],memo[2],memo[3],memo[5],memo[1]);
                break;
            case 'E':
                Set(memo[3],memo[1],memo[0],memo[5],memo[4],memo[2]);
                break;
            default:
                System.out.println("error");
        }
    }
    public int Get(int i){
        return memo[i];
    }
    public boolean isequal(Dice D2){
        if(D2==this)return true;
        for(int i=0;i<equalmove.length();i++){
            this.move(equalmove.charAt(i));
            boolean flag=true;
            for(int j=0;j<6;j++){
                if(this.Get(j)!=D2.Get(j)){
                    flag=false;
                    break;
                }
            }
            if(flag)return true;
        }
        return false;
    }
}


Measured memory_bytes: 24516
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

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

int main(){
   int n,x;
   cin >> n >> x;
   vector<ll> v(n+1);
   rep(i,n) cin >> v[i];
   v[n] = x;
   sort(v.begin(),v.end());
   
   ll ans = v[1]- v[0];
   for (int i = 1; i < n;i++){
     ll tmp = v[i+1]-v[i];
     ans = gcd(ans,tmp);
   }
   cout << ans << endl;
  
  return 0; 
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <map>
#include <set>
using namespace std;




int main()
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(),a.end());
	cout << abs(a[1] - a[0]) + abs(a[2] - a[1]) << endl;
	

	return 0;

}

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

int main() {
    int H, W;
    while (true) {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0) break;

        for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {
                printf("#");
            }
            printf("\n");
        }

        printf("\n");
    }
}

Measured memory_bytes: 1160
#!/usr/bin/env python3

def main():
    S = input()

    s = len([1 for _ in S if _ == 'S'])
    n = len([1 for _ in S if _ == 'N'])
    e = len([1 for _ in S if _ == 'E'])
    w = len([1 for _ in S if _ == 'W'])

    if (s > 0 and n > 0) or (s == n == 0):
        flag1 = True
    else:
        flag1 = False
    if (e > 0 and w > 0) or (e == w == 0):
        flag2 = True
    else:
        flag2 = False
    
    if flag1 and flag2:
        print('Yes')
    else:
        print('No')

main()

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

int main() {
    string str;
    cin >> str;
    set<char> alphabet;
    rep(i, str.length()) alphabet.insert(str.at(i));
    if(alphabet.size() == 26) {
        cout << "None" << endl;
    } else {
        char ans;
        rep(i, 26) if(alphabet.find(i + 'a') == alphabet.end()) {
            ans = i + 'a';
            break;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 512