akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    ll q;
    cin >> q;
    priority_queue<int> small;
    priority_queue<int, vector<int>, greater<int>> large;

    ll sb = 0, t1 = 0, md;
    ll sq = 0, sr = 0;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int a, b;
            cin >> a >> b;
            sb += b;
            if (t1 % 2) {
                if (small.top() > a) {
                    sq += a - small.top();
                    sr += small.top();
                    small.push(a);
                    large.push(small.top());
                    small.pop();
                    md = small.top();
                }
                else {
                    large.push(a);
                    sr += a;
                }
            }
            else {
                if (t1 == 0 || large.top() > a) {
                    sq += a;
                    small.push(a);
                    md = small.top();
                }
                else {
                    sq += large.top();
                    sr += a - large.top();
                    small.push(large.top());
                    large.pop();
                    large.push(a);
                    md = small.top();
                }
            }
            t1++;
            if (t1 > 1) cerr << small.top() _ large.top() _ md << endl;
        }
        else {
            cout << md _ md * (t1 % 2) + sr - sq + sb << endl;
        }
    }
}


Measured memory_bytes: 3452
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;

class in {
  int n;
public:
  in() {}
  in(int n_) : n(n_){};
  template <class T> operator T() { T ret; cin >> ret; return ret; }
  template <class T> operator vector<T>() { vector<T> ret(n); for (int i = 0; i < n; i++) cin >> ret[i]; return ret; }
};

template <std::uint_fast64_t Mod> class modint {
  using u64 = std::uint_fast64_t;
  u64 a;
  friend ostream& operator<<(ostream& os, const modint& m);
public:
  constexpr modint(const u64 x = 0) noexcept : a(x % Mod) {}
  constexpr u64 val() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
  constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
  constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
  constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
  constexpr bool operator==(const modint rhs) const noexcept { return modint(*this).val() == rhs.val(); }
  modint &operator+=(const modint rhs) noexcept { a += rhs.a; if (a >= Mod) a -= Mod; return *this; }
  modint &operator-=(const modint rhs) noexcept { if (a < rhs.a) a += Mod; a -= rhs.a; return *this; }
  modint &operator*=(const modint rhs) noexcept { a = a * rhs.a % Mod; return *this; }
  modint &operator/=(modint rhs) noexcept { u64 exp = Mod - 2; while (exp) { if (exp % 2) *this *= rhs; rhs *= rhs; exp /= 2; } return *this; }
};
const ll mod=(ll)1e9+7;
using mint = modint<mod>;
ostream& operator<<(ostream& os, const mint& m){ return os << m.a; }
//}}}

const int kMaxBit = 64;
int bit0[kMaxBit];
int bit1[kMaxBit];

int main(){
  int N = in();
  vector<ll> A = in(N);

  mint ans = 0;
  rep(i, N){
    rep(b, kMaxBit){
      bit1[b] += ((A[i] >> b) & 1);
    }
  }
  rep(b, kMaxBit){
    bit0[b] = N - bit1[b];
  }

  rep(b, kMaxBit){
    ans += (1LL << b) % mod * bit0[b] % mod * bit1[b];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
unittest
{
	assert( [ "2 16" ].parse.expand.solve == "9" );
	assert( [ "0 3" ].parse.expand.solve == "IMPOSSIBLE" );
	assert( [ "998244353 99824435" ].parse.expand.solve == "549034394" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	auto kk = a + b;
	if( kk % 2 == 1 ) return "IMPOSSIBLE";
	else              return ( kk / 2 ).to!string;
}


Measured memory_bytes: 256
K, M = map(int, input().split())

KS = []
for _ in range(M):
    ks = list(map(int, input().split()))
    KS.append(ks)
    
P = list(map(int, input().split()))
def checker(on_off):
    for i, ks, in enumerate(KS):
        sum_s = sum([ on_off[s-1] for s in  ks[1:]])
        if sum_s % 2 != P[i]:
            return 0
    return 1
        

def dfs(i, on_off):
    if i == 0:
        #print(on_off)
        return checker(on_off)
    
    a = dfs(i-1, on_off[:] + [0])
    b = dfs(i-1, on_off[:] + [1])
    return a + b
        
    
ans = dfs(K, [])
print(ans)

Measured memory_bytes: 43884
S = input()
R = 0
S = list(S)
temp = []
for i in range(2**(len(S)-1)):
    for m in range(len(S)-1):
        if i+1 & 2**(m) > 0:
            temp.append(S[m] + "+")
        else:
            temp.append(S[m])
    temp.append(S[len(S)-1])
    temp = "".join(temp)
    R += eval(temp)
    temp = []    
print(R)

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

H,W = LI()
h,w = LI()
print(H*W - h*W - H*w + h*w)

Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
int parent(int u) {
	return u / 2;
}
int left(int u) {
	return u * 2;
}
int right(int u) {
	return u * 2 + 1;
}
void maxHeap(int u,vi& A) {
	int l = left(u);
	int r = right(u);
	int max_ = u;
	if (l < A.size() && A[l]>A[max_]) max_ = l;
	if (r < A.size() && A[r]>A[max_]) max_ = r;
	if (max_!=u) {
		swap(A[u],A[max_]);
		maxHeap(max_,A);
	}
}
void buildMaxHeap(vi& A) {
	for (int i = A.size()/2; i>=1; i--)
	{
		maxHeap(i,A);
	}
}
int main() {
	int N;
	cin >> N;
	vi A(N+1);
	for (int i = 1; i <=N; i++)cin >> A[i];
	buildMaxHeap(A);
	for (int i = 1; i <= N; i++)
	{
		cout << " " << A[i];
	}
	cout << endl;
};




Measured memory_bytes: 4648
/**
*    created: 15.05.2020 05:28:39
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    string s, t;
    cin >> s >> t;
    string ans=s;
    int n = s.size();
    int m = t.size();
    int x = 0,y=-1;

    for (int i = n - 1; i > m - 2;i--)
    {
        int k = 0;
        for (int j = i; j > i - m ; j--)
        {
            if(s[j]==t[m-k-1]||s[j]=='?'){
                s[j] = t[m-k-1];
            }else{
                break;
            }
            k++;
        }
        if(k==m){
            rep(d,n){
                if(s[d]=='?'){
                    s[d] = 'a';
                }
            }
            cout << s << endl;
            return 0;
        }
        s = ans;
    }
    cout << "UNRESTORABLE" << endl;
    /*rep(i,n){
        if(s[i]=='?'){
            x = 0;
            continue;
        }else{
            x++;
        }
        if(x>=m)
            y = i;
    }
    if(y==-1){
        cout << "UNRESTORABLE" << endl;
    }else{
        rep(i,n){
            if(i<=y&&i>y-m){
                ans[i]=
            }
        }
    }*/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k, s, t; cin >> n >> k >> s >> t, --s, --t;
  struct Edge { int to, w; };
  VV<Edge> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v, w; cin >> u >> v >> w, --u, --v;
    g[u].emplace_back(Edge{v, w});
    g[v].emplace_back(Edge{u, w});
  }

  V<bool> vis(n);
  {
    auto dfs = [&](const auto& dfs, int v, int p) -> bool {
      if (v == t) return true;
      for (const auto& e : g[v]) if (e.to != p) {
        if (dfs(dfs, e.to, v)) {
          return vis[v] = true;
        }
      }
      return false;
    };
    vis[t] = true;
    dfs(dfs, s, -1);
  }

  VV<Edge> ch(n);
  {
    auto dfs = [&](const auto& dfs, int v, int p) -> void {
      for (const auto& e : g[v]) if (e.to != p) {
        ch[v].push_back(e);
        dfs(dfs, e.to, v);
      }
    };
    dfs(dfs, s, -1);
  }

  for (int v = 0; v < n; ++v) {
    V<lint> c(ch[v].size());
    for (int i = 0; i < (int)ch[v].size(); ++i) {
      c[i] = ch[ch[v][i].to].size() + 2;
      if (vis[ch[v][i].to]) {
        c[i] = 1;
      }
      c[i] -= v == s;
    }
    V<> idx(ch[v].size());
    iota(begin(idx), end(idx), 0);
    sort(begin(idx), end(idx), [&](int i, int j) { return ch[v][i].w - c[i] * k < ch[v][j].w - c[j] * k; });
    int j = 0;
    for (int i : idx) {
      if (ch[v][i].w <= (c[i] + j++) * k) {
        return cout << "No" << '\n', 0;
      }
    }
  }
  cout << "Yes" << '\n';
}


Measured memory_bytes: 15560
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
int main(){
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vi p(a), q(b), r(c + x + y);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  Sort(p); rev(p);
  Sort(q); rev(q);
  rep(i, x) r[c + i] = p[i];
  rep(i, y) r[c + x + i] = q[i];
  Sort(r); rev(r);
  ll ans = 0;
  rep(i, x + y) ans += r[i];
  cout << ans << endl;
}

Measured memory_bytes: 2176
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

ll M=60;
ll cal1(ll a,ll b){
    ll s;
    for(ll i=M;i>=0;i--){
        if(b&(1ll<<i)){
            s=1ll<<i;break;
        }
    }
    return s-a;
}
l_l cal2(ll b){
    for(ll i=M;i>=0;i--){
        if(b&(1ll<<i)){
            b-=(1ll<<i);
            for(ll j=i-1;j>=-1;j--){
                if(j==-1){
                    return {0,0};
                }
                if(b&(1ll<<j)){
                    return {0,((1ll<<(j+1))-1)};
                }
            }
        }
    }
    return {-inf,inf};
}
l_l cal3(ll a,ll b){
    for(ll i=M;i>=0;i--){
        if(b&(1ll<<i)){
            return {a,(1ll<<i)-1};
        }
    }
    return {-inf/2,inf/2};
}
ll cal(l_l a,l_l b){
    if(a>b)swap(a,b);
    if(a.se<b.fi){
        return a.se-a.fi+1+b.se-b.fi+1;
    }
    return max(a.se,b.se)-a.fi+1;
}

int main(){fastio
    ll a,b;cin>>a>>b;
    if(a==b){cout<<1;return 0;}
    for(ll i=M;i>=0;i--){
        ll ca=(1ll<<i)&a;
        ll cb=(1ll<<i)&b;
        if(ca!=0&&cb!=0){
            a-=(1ll<<i);
            b-=(1ll<<i);
        }else if(ca==0&&cb!=0){
            break;
        }
    }
    
    ll sa=cal1(a,b);
    l_l sb=cal2(b);
    l_l sc=cal3(a,b);
    ll s=cal(sb,sc);
    //cout<<sa<<" "<<s<<endl;
    cout<<sa+s<<endl;
    
    return 0;
}


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

using namespace std;  

typedef long long ll;
typedef long double ld;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rs resize
#define all(x) x.begin(), x.end()   

void pre(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void pudge(){
    string s;
    cin >> s;
    if (s == "MON")
        cout << 6;
    else if (s == "TUE")
        cout << 5;
    else if (s == "WED")
        cout << 4;
    else if (s == "THU")
        cout << 3;
    else if (s == "FRI")
        cout << 2;
    else if (s == "SAT")
        cout << 1;
    else if (s == "SUN")
        cout << 7;
}

int main(){ 
    pre();  
    pudge();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

ll N, A[100000], B[100000], res;
vector<lP>v;

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i) {
		cin >> A[i] >> B[i];
		v.push_back(mkp(A[i] + B[i], i));
	}
	sort(v.begin(), v.end());
	for (int i = N - 1; i != -1; --i) {
		if (i % 2 == (N - 1) % 2)
			res += A[v[i].second];
		else
			res -= B[v[i].second];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3444
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


ll a[MAXN];
ll b[MAXN];



int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    ll n = readInt(), x = readInt();
    for (int i = 0; i < n; i++) {
    	a[i] = readInt();
    	b[i] = a[i];
    }
	ll ans = 1e18;
    for (int k = 0; k < n; k++) {
		ll tmp = k * x;		
		for (int j = 0; j < n; j++) {
			tmp += (b[j]);			
		}    
		for (int j = 0; j < n; j++) {
			b[j] = min(b[j], a[(n + j - k - 1) % n]);
		}
		ans = min(ans, tmp);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2432
p = [int(input())for i in range(5)]
perm  =[0]*5
used = [0]*5
nums = []
def dfs(now):
    if now == 5:
        nums.append([perm[i]for i in range(5)])
        
        
        return
    for i in range(5):
        if used[i]:continue
        used[i] = 1
        perm[now] = i
        dfs(now+1)
        used[i] = 0
dfs(0)

ans = 10**19
for l in nums:
    time = 0
    
    for i in range(5):
        
        time +=p[l[i]]
        if i == 4:break
        
        for i in range(10):
            
            if time%10 == 0:
                break
            time +=1
    ans = min(ans,time)
print(ans)
                

        

Measured memory_bytes: 3064
function Main(arg) {
 
    var A = arg.split(" ")[0];
    var B = arg.split(" ")[1] -0;
 
    var ans = 0;
    if (1 <= A && A <= 9 && 1 <= B && B <= 9) {
        ans = A * B;
    }
    else {
        ans = -1;
    }
    
    console.log(ans)

    return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_C
{
    class _005
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            Array.Sort(array);
            int max = array[n - 1];
            if (max == 1 && n == 2)
            {
                WriteLine("Possible");
                return;
            }
            int min = (max + 1) / 2;
            int minCnt = 0;
            for(int i = 0; i < n; i++)
            {
                if (array[i] != min) break;
                minCnt++;
            }
            if ((max % 2 == 0 && minCnt != 1)
                || (max % 2 != 0 && minCnt != 2))
            {
                WriteLine("Impossible");
                return;
            }
            int now = min + 1;
            int nowCnt = 0;
            for(int i = minCnt; i < n; i++)
            {
                if (array[i] == now)
                {
                    nowCnt++;
                }
                else
                {
                    if (nowCnt < 2)
                    {
                        WriteLine("Impossible");
                        return;
                    }
                    now++;
                    nowCnt = 1;
                }
            }
            if (nowCnt < 2)
            {
                WriteLine("Impossible");
                return;
            }
            WriteLine("Possible");
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  for(int i=1;i<4;i++){
    if(s[i-1]==s[i]){
      cout<<"Bad";
      return 0;
    } 
  }
  cout<<"Good";
  return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

constexpr ll MOD = 1000000000 + 7;

int N;
std::vector<int> G[100100];
ll dp[100100][2];

ll rec(int v, int p, int c){
    if(dp[v][c] != -1){
        return dp[v][c];
    }

    ll c1 = 0, c2 = 1;
    
    // 黒を取る
    if(v == 1 || c == 0){
        c1 = 1;

        for(int w : G[v]){
            if(w == p){
                continue;
            }

            c1 = c1 * rec(w, v, 1) % MOD;
        }
    }

    // 白を取る
    for(int w : G[v]){
        if(w == p){
            continue;
        }

        c2 = c2 * rec(w, v, 0) % MOD;
    }

    return dp[v][c] = (c1 + c2) % MOD;
}

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

    std::cin >> N;

    for(int i=0;i<N-1;++i){
        int x, y;
        std::cin >> x >> y;

        G[x].emplace_back(y);
        G[y].emplace_back(x);
    }

    memset(dp, -1, sizeof(dp));

    ll res = rec(1, -1, 0);
    std::cout << res << std::endl;
}


Measured memory_bytes: 15616
a,b,c,x,y=map(int,input().split())
ans=0
if a+b<c*2:
  ans=a*x+b*y
else:
  ans+=min(x,y)*c*2
  if x > y:
    ans+=(x-y)*a
  else:
    ans+=(y-x)*b
  if ans > max(x,y)*c*2:
    ans=max(x,y)*c*2
print(ans)

Measured memory_bytes: 3064
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// Criba de Eratostenes ------------------------------------
const int pr=10000;
map<int,int>isp;
void criba(){
    for(int i=0;i<=pr;i++)isp[i]=i;
    isp[0]=isp[1]=-1;
    for(int i=2;i*i<=pr;i++){
        if(isp[i]==i){
        for(int j=i+i;j<=pr;j+=i)
            isp[j]=i;
        }
    }
}
/// My Code -------------------------------------------------
/*
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
bool vis[55][55];
void dfs(int x,int y){
    int nx,ny;
    vis[x][y]=true;
    rep(i,4){
        nx=x+dx[i];
        ny=y+dy[i];
        if(!vis[nx][ny]&&v[nx][ny]=='#')dfs(nx,ny);
    }
}
*/
int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);
    ///criba();

    int n,m;
    char v[55][55];
    cin>>n>>m;
    rep(i,n)rep(j,m)cin>>v[i][j];

    bool fl=1;
    rep(i,n-1)rep(j,m-1){
        if(v[i][j]=='#'){
            if(v[i+1][j]=='.'&&v[i-1][j]=='.'&&v[i][j+1]=='.'&&v[i][j-1]=='.')fl=0;
        }
    }

    cout<<((fl)?"Yes":"No")<<enl;

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 200005
  #define INF 1000000000000
  #define eps 1e-6

  bool custom(pair<int,int> &a,pair<int,int> &b)
  {
    if(a.s == b.s)return a.f > b.f;
    return a.s > b.s;
  }
int32_t main()
{

    IOS


    int n,m;
    cin >> n >> m;

    priority_queue<int,vector<int> ,greater<int>> pq;



    for(int i = 1; i <= n; i++)
    {
      int x;
      cin >> x;
      pq.push(x);
    }

    vector<pair<int,int>> v;

    for(int i = 1; i <= m; i++)
    {
      int x, y;
      cin >> x >> y;
      v.PB(MP(x,y));
    }

    sort(all(v),custom);


    for(auto i:v)
    {
      int k = pq.top();
      while(i.f > 0 && k < i.s)
      {
        if(k >= i.s)break;
        pq.pop();
        pq.push(i.s);   
        i.f--;    
      }
       if(k >= i.s)break;
    }

      int ans = 0;

    while(!pq.empty())
    {
      ans += pq.top();
      pq.pop();
    }
    cout << ans << endl;


	return 0;  
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> vect(n);
    vector<int> dp(n);
    dp[0] = 0;

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

    for(int i = 1; i < n; i++)
    {
        int cost = INT_MAX;

        for(int j = 1; j <= k; j++)
        {
            int tmp_cost = INT_MAX;

            if(i >= j)
            {
                int tmp = dp[i-j] + abs(vect[i] - vect[i-j]);
                //cout << "\n> " << i << " " << j << " " << tmp << " "  << cost;
                cost = min(cost, tmp);
                //cout << "\nNew Cost: " << cost;
            }
            else
                break;
        }

        dp[i] = cost;
    }

    cout << dp[n-1];
}

int main()
{
    fastio;
    solve();
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
int main(void){
    int a,b;
    string s;
    cin>>a>>b>>s;
    for(int i=0;i<s.size();i++){
        if(i!=a&&s[i]=='-'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(s[a]!='-')cout<<"No"<<endl;
    else if(s.size()!=a+b+1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string[] i = Console.ReadLine().Split(' ');
        int a = int.Parse(i[0]);
        int b = int.Parse(i[1]);
        int c = int.Parse(i[2]);
        var count = 0;
        
        for (int x = a; x <= b; x ++)
        {
            if (c % x == 0)
            {
                count = count + 1;
            }
            else
            {
                continue;
            }
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 17948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
/*
 * C言語のサンプルプログラム - Webkaru
 * - 入力した2つの自然数の最小公倍数を求める -
 */
 
int main(void){
  long a, b, r, x, tmp;
 cin>>a>>b;
 
  x = a * b;
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  /* 最小公倍数を出力 */
  printf("%lu\n", x/b);
//   printf("%lu", 5000000000);
// // cout<<(x/b);
  return 0;
}


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

int main()
{
  int k, s;
  cin >> k >> s;
  int count = 0;
  for (int i = 0; i <= k; i++)
  {
    for (int j = 0; j <= k; j++)
    {
      int z = s - i - j;
      if(z>=0 && z<=k )
        count++;

    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main (){
  int x1,y1,x2,y2,x3,y3,x4,y4;
  cin >> x1 >> y1 >> x2 >> y2;
  int a,b;
  a=x1-x2;
  b=y1-y2;
  x4=x1+b;
  y4=y1-a;
  x3=x2+b;
  y3=y2-a;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
n=int(n)
k=int(k)
n = n % k
minimam = n
record=[]
for i in range(k):
  n=abs(n-k)
  if n < minimam:
    minimam = n
  record.append(n)
  if n in record:
    break
print(minimam)

Measured memory_bytes: 3060
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
        int ans;
        if(a>=b&&a>=c)ans = a*10+b+c;
        else if(b>=a&&b>=c)ans = b*10+a+c;
        else ans = c*10+a+b;
        System.out.println(ans);
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
 using namespace  std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const double pi=3.1415926535897932384626433832;
const long long mod=1e9+7;
//long long primeset[5000000]={};
typedef complex<double> cd;
typedef long long ll;
typedef double ld;
//#define For(i,0,n) for(long long i = 0 ; i<n ;i++) 
cd fast_exp(cd a, long long b)
{
	if (b == 0)
		return 1;
	
	cd res = fast_exp(a, b / 2);
		
	res = res * res;
	
	if (b % 2 == 1)
		res = res * a;
	
	return res;
}

long long fastexpon(long long a,long long b,long long mod)
{
	if(b==0)
		return 1;
	
	long long res=fastexpon(a,b/2,mod);
	
	res=(res*res)%mod;
	if(b%2==1)
		res= (res * a)%mod;

	return res;
}


//template ends here





int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll a[n];
	//priority_queue <ll,vector<ll>,greater<ll>> pq;
	
	for(ll i=0 ;i<n ;i++)
	cin>>a[i];
	  
	 ll sum[n+1]={};
	 for(ll i=0 ;i<n ;i++)
	 sum[i+1]=sum[i]+a[i];
	const ll INF=1e18+5;
	 ll dp[n+1][n+1];
	 for(ll i=0 ;i<=n ;i++)
	 	for(ll j=0; j<=n ;j++)
	 		dp[i][j]=INF;
	 for(ll r=0; r<n ;r++)
	 for(ll l=r; l>=0 ;l--)
	 {
	 	if(l==r)
	 		dp[l][r]=0;
	 	else
	 		for(ll i=l ; i<r ; i++)
	 			dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+sum[r+1]-sum[l]);
	 } 

	 cout<<dp[0][n-1]<<'\n';
	//cout<<'\n'<<"time elapsed: "<<clock()*1000.0 / CLOCKS_PER_SEC<<" ms"<<'\n';
	return 0;
}

Measured memory_bytes: 1536
x = list(map(int,input().split()))
f = 0
y = [1,9,7,4]
r = 0
for i in range(len(x)):
    for j in range(4):
        if x[i] == y[j]:
            y[j] = 0
if sum(y)==0:
    print("YES")
else:print("NO")

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main() {
	char str[200] = "", code[100000] = "";
	char *pstr, *pcode;
	int x, b, base;

	while (fgets(str,sizeof(str),stdin)!=NULL) {
		pstr = &str[0];
		pcode = &code[0];
		while (*pstr) {
			switch (*pstr) {
			case 'O': strcat(pcode, "0"); case 'C': strcat(pcode, "0"); case ' ': strcat(pcode, "101"); break;
			case '\'': strcat(pcode, "000000"); break;
			case ',': strcat(pcode, "000011"); break;
			case '-': strcat(pcode, "1001"); case 'D': strcat(pcode, "0001"); break;
			case '.': strcat(pcode, "010001"); break;
			case 'T': strcat(pcode, "0"); case 'I': strcat(pcode, "0"); case 'P': strcat(pcode, "111"); break;
			case 'S': strcat(pcode, "0"); case 'K': strcat(pcode, "0"); case 'E': strcat(pcode, "110"); break;
			case 'A': strcat(pcode, "100101"); break;
			case 'B': strcat(pcode, "10011010"); break;
			case 'F': strcat(pcode, "01001"); break;
			case 'G': strcat(pcode, "10011011"); break;
			case 'H': strcat(pcode, "010000"); break;
			case 'J': strcat(pcode, "1001"); case 'R': strcat(pcode, "1000"); break;
			case 'L': strcat(pcode, "00100"); break;
			case 'M': strcat(pcode, "10011001"); break;
			case 'N': strcat(pcode, "10011110"); break;
			case 'Q': strcat(pcode, "10011111"); break;
			case 'U': strcat(pcode, "10011100"); break;
			case 'V': strcat(pcode, "10011101"); break;
			case 'W': strcat(pcode, "000010"); break;
			case 'X': strcat(pcode, "10010010"); break;
			case 'Y': strcat(pcode, "10010011"); break;
			case 'Z': strcat(pcode, "10010000"); break;
			case '?': strcat(pcode, "000001"); break;
			default:break;
			}
			pstr++;
		}
		while (strlen(pcode) % 5) strcat(pcode, "0");
		while (*pcode) {
			sprintf(str, "%.5s", pcode);
			pcode += 5;
			b = atoi(str);
			base = 1, x = 0;
			while (b > 0) {
				x += (b % 10)*base;
				b /= 10;
				base *= 2;
			}
			if (x == 26) x = ' ' - 'A';
			else if (x == 27) x = '.' - 'A';
			else if (x == 28) x = ',' - 'A';
			else if (x == 29) x = '-' - 'A';
			else if (x == 30) x = '\'' - 'A';
			else if (x == 31) x = '?' - 'A';
			printf("%c", 'A' + x);
		}
		printf("\n");
		memset(code, '\0', sizeof(code));
		memset(str, '\0', sizeof(str));
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    bool is_same = true;
    for (ll i = 0; i < s.length();)
    {
        bool is_find = false;
        if (s.substr(i, 5) == "maerd" || s.substr(i, 5) == "esare")
        {
            i += 5;
            is_find = true;
        }
        else if (s.substr(i, 6) == "resare")
        {
            i += 6;
            is_find = true;
        }
        else if (s.substr(i, 7) == "remaerd")
        {
            i += 7;
            is_find = true;
        }
        if (!is_find)
        {
            is_same = false;
            break;
        }
    }
    cout << (is_same ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var m = sc.nextInt();
		var set = new HashSet[n];
		for (int i = 0; i < n; i++) {
			set[i] = new HashSet<Integer>();
		}
		for (int i = 0; i < m; i++) {
			var a = sc.nextInt();
			var b = sc.nextInt();
			set[a - 1].add(b);
			set[b - 1].add(a);
		}
		sc.close();

		var count = 0;
		var r = new int[n];
		var list = new ArrayList<Integer>();
		list.add(1);
		while (count < n -1) {
			var list2 = new ArrayList<Integer>();
			for(var n2 : list) {
				for (var x : set[n2 - 1]) {
					if ((int)x != 1 && r[(int) x - 1] == 0) {
						r[(int) x - 1] = n2;
						list2.add((int)x);
					}
				}
			}
			list.clear();
			list.addAll(list2);
			count += list2.size();
		}

		System.out.println("Yes");
		for (int i = 1; i < n; i++) {
			System.out.println(r[i]);
		}
	}
}

Measured memory_bytes: 98244
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define pb emplace_back
#define em emplace
#define fi first
#define se second
#define USE1(...) template <typename __VA_ARGS__> inline
#define USE2(T, ...) USE1(T, typename __VA_ARGS__)
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
using ll = long long;
template<typename T> using vec = std::vector<T>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE2(T=int,V=vec<T>)V reserved(int n){V v;v.reserve(n);return v;}
USE1(T=int)vec<T>in(int n){auto v=reserved<T>(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=std::pair<T,int>)vec<U>enume(const vec<T>&x,int s=0){int N=x.size();auto v=reserved<U>(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE2(T,U)void prif(bool b,T t,U f){if(b)pr(t);else pr(f);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(20);
    std::cout.setf(std::ios::fixed);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

int a[100], b[100];
int c[100], d[100];

signed main() {
  int N = in(), M = in();
  rep(i, N) { a[i] = in(), b[i] = in(); }
  rep(i, M) { c[i] = in(), d[i] = in(); }
  rep(i, N) {
    ll mini = infl;
    int ans;
    rep(j, M) {
      if (chmin(mini, abs(a[i] - c[j]) + abs(b[i] - d[j]))) { ans = j; }
    }
    pr(ans + 1);
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long int a,b,maxv=-1900000000;
	cin>>a>>b;
	if(a+b>maxv)maxv=a+b;
	if(a-b>maxv)maxv=a-b;
	if(a*b>maxv)maxv=a*b;
	cout<<maxv;
}

Measured memory_bytes: 256
use warnings;
    use Data::Dumper;
    use List::Util qw(max min);
    # use Statistics::Lite qw(max min sum);
    
    sub GetInputData{
    
        my @array_data;
    
        my $line = <STDIN>;
    
        chomp($line);
    
        while($line ne ""){
    
           push(@array_data,$line);
    
           $line = <STDIN>;
    
           chomp($line);
    
    }
    
        return @array_data;
    
    }
    
    sub GetSpaceInputData{
    
        my @array_temp=GetInputData();
    
        my @array_buf;
    
        foreach(@array_temp){
    
            #戻りは配列スペース区切りを分解
            # myを先頭につける必要あり
            my @array_work=split(" ",$_);

            # print "@array_work";
    
            # リファレンスを配列に代入
            push(@array_buf,\@array_work);
        }
    
        return @array_buf;
    
    }
    
    my @arr_result = GetSpaceInputData();

    my $n = $arr_result[0][0];
    my $arr = $arr_result[1];

    my $mysum= eval join '+',@$arr;

    my $myave=$mysum/$n;
    my @arr_data= map{abs($_ - $myave)} @$arr;

    my $mindata= min @arr_data;

    my @result = grep { $arr_data[$_] == $mindata } 0 .. $#arr_data;
    
    print $result[0];

Measured memory_bytes: 1920
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(i) sort(i.begin(),i.end())
#define rSORT(i) sort(i.rbegin(),i.rend())
#define fSORT(i,a) sort(i.begin(),i.end(),a)
#define all(i) i.begin(),i.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    ld a, b, h, m; cin >> a >> b >> h >> m;
    ld hrad = 360*pi / 180 * ((60 * h + m) / ld(720));
    ld mrad = 360*pi / 180 * (m / ld(60));
    ld d = abs(hrad - mrad);
    chmin(d, 2 * pi - d);
    ld ax = a, ay = 0;
    ld bx = cos(d) * b, by = sin(d) * b;
    cout << sqrtl(pow(bx - ax, 2) + pow(by - ay, 2)) << "\n";

    return 0;
}

Measured memory_bytes: 4184
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a := [3][3]int{}
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			a[i][j] = scanInt()
		}
	}
	f := [3][3]bool{}

	n := scanInt()
	b := scanInts(n)

	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if b[i] == a[j][k] {
					f[j][k] = true
				}
			}
		}
	}

	for i := 0; i < 3; i++ {
		cnt := 0
		for j := 0; j < 3; j++ {
			if f[i][j] {
				cnt++
			}
		}

		if cnt == 3 {
			fmt.Fprintln(wr, "Yes")
			return
		}
	}


	for i := 0; i < 3; i++ {
		cnt := 0
		for j := 0; j < 3; j++ {
			if f[j][i] {
				cnt++
			}
		}

		if cnt == 3 {
			fmt.Fprintln(wr, "Yes")
			return
		}
	}

	
	cnt := 0
	for j := 0; j < 3; j++ {
		if f[j][j] {
			cnt++
		}
	}

	if cnt == 3 {
		fmt.Fprintln(wr, "Yes")
		return
	}

	cnt = 0
	for j := 0; j < 3; j++ {
		if f[2-j][j] {
			cnt++
		}
	}

	if cnt == 3 {
		fmt.Fprintln(wr, "Yes")
		return
	}

	fmt.Fprintln(wr, "No")
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

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

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

// factorization O(sqrt(n))
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll gc = gcd(a, b);
    map<ll, ll> primes = prime_factor(gc);
    // debug(gc);
    // debug(primes.size());
    out(primes.size() + 1);
    return 0;
}


Measured memory_bytes: 256