akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n,m,c; cin>>n>>m>>c;
    vector<int> b(m);
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,m)cin>>b.at(i);
    rep(i,n){
        rep(j,m){
            cin>>a.at(i).at(j);
        }
    }
    int ans=0;
    rep(i,n){
        int sum=c;
        rep(j,m){
            sum+=a.at(i).at(j)*b.at(j);
        }
        if(sum>0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 998244353;
const int MX = 2001;
int g[MX][MX];
int C[2*MX][2*MX];
ll pw[MX];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	rep(i, 2*MX) rep(j, i+1) C[i][j] = j==0||j==i ? 1 : (C[i-1][j] + C[i-1][j-1]) % mod;
	rep(i, MX){
		pw[i] = i ? pw[i - 1] * 2 % mod : 1;
		g[i][0] = i ? 0 : 1;
		for(int j = 1; j < MX && i + j - 1 < 2*MX; j++) g[i][j] = C[i + j - 1][j - 1];
	}
	
	int k, n; cin >> k >> n;
	vector<ll> ans(2 * k + 1);
	
	for(int x = 2; x <= k + 1; x += 2){
		//真ん中使う
		for(int j = 0; j < x / 2; j++) if(n - j - 1 >= 0){
			ans[x] += pw[j] * g[n - j - 1][k - x + 1 + j] % mod * C[x / 2 - 1][j] % mod;
		}
		//つかわない
		for(int j = 0; j < x / 2; j++) if(n - j >= 0){
			ans[x] += pw[j] * g[n - j][k - x + 1 + j] % mod * C[x / 2 - 1][j] % mod;
		}
	}
	
	for(int x = 3; x <= k + 1; x += 2){
		for(int j = 0; j <= x / 2; j++) if(n - j >= 0){
			ans[x] += pw[j] * g[n - j][k - x + 1 + j] % mod * C[x / 2][j] % mod;
		}
	}
	for(int i = 2; i <= 2 * k; i++){
		ans[i] %= mod;
		if(i > k + 1) cout << ans[2 * k + 2 - i] << endl;
		else cout << ans[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 77056
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    int n,d,ans=0;
    scanf("%d%d",&n,&d);
    long double x[n][d],sum[(n*n-n)/2][n];
    for(int i=0;n>i;++i){
        for(int j=0;d>j;++j)
        scanf("%Lf",&x[i][j]);
    }
    for(int i=0;(n*n-n)/2>i;++i){
        for(int j=0;n>j;++j)
        sum[i][j]=0;
    }
    for(int i=0;(n*n-n)/2>i;++i){
        for(int j=i+1;n>j;++j){
            for(int k=0;d>k;++k){
                sum[i][j]+=(fabs(x[i][k]-x[j][k])*fabs(x[i][k]-x[j][k]));
            }
        }
    }
    for(int i=0;(n*n-n)/2>i;++i){
        for(int j=i+1;n>j;++j){
            sum[i][j]=sqrt(sum[i][j]);
            if(sum[i][j]==(int)sum[i][j])
            ++ans;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std

void solve() {
    i64 h, w, n;
    std::cin >> h >> w >> n;
    std::cout << std::min((n + h - 1) / h, (n + w - 1) / w) << std::endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int  a, b ,c;
    char X,Y;
    string S1,S2;
    cin >>a >> b;
    
    if(a % 3 == 0 || b % 3 == 0 || (a + b)%3 == 0){
        cout << "Possible" << endl;
    }
    else cout << "Impossible" << endl;
    


}


Measured memory_bytes: 256
a=int(input())
b=input().rstrip().split()
l=[]
for i in range(a):
  l.append(int(b[i]))
l.sort()
max = l[a-1]
SUM=sum(l[:a-1])

if (SUM > max):
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	int ans = 0;

	for (int i = 1; i <= N; i++)
	{
		ans += i;
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main()
{
	ll a;
	double b;
	scanf("%lld %lf",&a,&b);
	b=b+1e-7;
	ll c=b*100;
	ll d=c*a/100;
	printf("%lld",d);
	return 0;
}

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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD   = 1e9 + 7;
const double PI = acos(-1.0);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
const int INF   = 1e18;

#define fastio            ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define rsz resize
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define f first
#define s second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define spc " "
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){

    int n;
    cin >> n;
    vi dp(n + 1, 1);
    vb visited(n + 1);

    repA(curr, 2, n){
        if(!visited[curr]){
            for(int i = curr; i <= n; i += curr){
                visited[i] = true;
                int ss = 0;
                int tp = i;
                while(tp % curr == 0){
                    tp /= curr;
                    ss++;
                }
                dp[i] *= (ss + 1);
            }
        }
    }

    int ans = 0;
    repA(k, 1, n){
        ans += k * dp[k];
    }
    cout << ans << endl;





}

signed main(){
    fastio;

    solve();

    return 0;
}


Measured memory_bytes: 82632
import sys
a=int(input())
b=list(map(int,input().split()))
c=b.count(0)
if c>0:
    print('0')
    sys.exit()
ans=1
for i in range(a):
  ans=ans*b[i-1]
  if ans>10**18:
      print('-1')
      sys.exit()
      
print(ans)  
  


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


int main(){
    long N,M;
    cin >> N >> M;
    vector<long> L(M);
    vector<long> R(M);
    long low,high;
    for(int i=0;i<M;++i) cin >> L[i] >> R[i];
    low = L[0];
    high = R[0];
    for(int i=0;i<M;++i){
        if(L[i]>low) low = L[i];
        if(R[i]<high) high = R[i];
    }

    if(low>high) cout <<  "0" << endl;
    else cout <<  high - low + 1 << endl;

    }



Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct union_find{
    VI par;

    void init(int n){
        par.resize(n);
        REP(i,n) par[i] = i;
    }

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

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

    void merge(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y) return;
        par[x] = y;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    if (m % 2){
        cout << -1 << endl;
        return 0;
    }
    VI a(n);
    vector<set<int>> e(n);
    vector<P> ans;
    union_find uf;
    uf.init(n);
    REP(i,m){
        int u = in() - 1, v = in() - 1;
        if (uf.same(u, v)){
            a[u] ^= 1;
            ans.emplace_back(u, v);
        }else{
            uf.merge(u, v);
            e[u].insert(v);
            e[v].insert(u);
        }
    }
    queue<int> que;
    REP(i,n){
        if (e[i].size() == 1){
            que.push(i);
        }
    }
    while (!que.empty()){
        int x = que.front();
        que.pop();
        for (int y : e[x]){
            if (a[x]){
                ans.emplace_back(x, y);
                a[x] ^= 1;
            }else{
                ans.emplace_back(y, x);
                a[y] ^= 1;
            }
            e[y].erase(x);
            if (e[y].size() == 1) que.push(y);
        }
        e[x].clear();
    }

    for (P p : ans){
        cout << p.first + 1 << " " << p.second + 1 << endl;
    }

    return 0;
}


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

#define fastio {\
    ios::sync_with_stdio(0);\
    cin.tie(0);\
}

#define file {\
    freopen("io\\in.txt", "r", stdin);\
    freopen("io\\out.txt", "w", stdout);\
    freopen("io\\err.txt", "w", stderr);\
}

#ifdef LOCAL
#define debug(args...) {\
    string _s(#args);\
    replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s);\
    istream_iterator<string> _it(_ss);\
    debug1(_it, args);\
}

#pragma GCC diagnostic ignored "-Wunused-parameter"
void debug1(istream_iterator<string> it) {
    cerr << endl;
}
#pragma GCC diagnostic pop

template<class T, class... Args>
void debug1(istream_iterator<string> it, T a, Args... args) {
    cerr << '>' << *it << " = " << a << "; ";
    debug1(++it, args...);
}
#else
#define debug(args...)
#define cerr if (false) cerr
#endif

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < n; i++)
#define dotc()      int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const int inf(0x3fffffff);
const int mod(1000000007);
const double pi(acos(-1.0));

signed main() {
    fastio;
#ifdef LOCAL
    file;
#endif

    int n, m;
    cin >> n >> m;
    while (m--) {
        int x;
        cin >> x;
        n -= x;
    }

    cout << (n < 0 ? -1 : n);

    return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

template <class T> int mergecount(vector<T> &a){
	int cnt = 0;
	int n = a.size();
	if(n<=1) return 0;
	vector<T> b(a.begin(), a.begin()+n/2);
	vector<T> c(a.begin()+n/2, a.end());
	cnt += mergecount(b);
	cnt += mergecount(c);
	for(int i = 0, j = 0, k = 0; i < n; i++){
		if(k==c.size()) a[i] = b[j++];
		else if(j==b.size()) a[i] = c[k++];
		else if(b[j] <= c[k]) a[i] = b[j++];
		else { a[i] = c[k++]; cnt+=b.size()-j; }
	}
	return cnt;
}

double calc(vector<P> &v){
	ll n = v.size();
	ll m = (n*(n-1)/2+1)/2;
	double lb = -1e12, ub = 1e12;
	vector<double> x(n);
	rep(_, 200){
		double md = (lb+ub)/2;
		rep(i, n) x[i] = v[i].fst*md+v[i].snd;
		vector<double> x2(x);
		ll cnt = mergecount(x);
		/*if(_%10==0){
			cerr<<"current pos: "<<md<<", mergecount: "<<cnt<<endl;
			cerr<<x2<<endl;
		}*/
		if(cnt>=m) ub = md;
		else lb = md;
	}
	return lb;
}

int main(){
	ll n;
	cin>>n;
	vector<P> v(n);
	rep(i, n){
		double a, b, c;
		cin>>a>>b>>c;
		v[i] = P(-a/b, c/b);
	}
	sort(all(v)); reverse(all(v));
	double x = calc(v);
	rep(i, n) v[i] = P(1/v[i].fst, -v[i].snd/v[i].fst);
	sort(all(v)); reverse(all(v));
	double y = calc(v);
	cout.precision(22);
	cout<<x<<" "<<y<<endl;
	return 0;
}


Measured memory_bytes: 2184
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int n,m;
vector<string> area;
bool ok(int x,int y,int nx,int ny){
  bool res = 0<=nx&&nx<n&&0<=ny&&ny<m;
  if(res){
    res = (area[y][x]=='.'||area[y][x]=='@')&&(area[ny][nx]=='.'||area[ny][nx]=='@');
  }
  return res;
}
struct union_find{//rank,経路圧縮で高速化
  vector<long long> data;//そのノードがrootであれば-（集合のサイズ）を表し、そうでなければ親ノードidを示す。
  union_find(long long size):data(size,-1){}//コンストラクタ,size個のノードを作成し、-1で初期化
  inline long long root(long long a){//根を探す,経路圧縮
    return data[a] < 0 ? a : data[a]=root(data[a]);
  }
  inline bool find(long long a,long long b){//a,bが同じ集合に属するか調べる
    return root(a) == root(b);
  }
  inline bool unite(long long a,long long b){//小さい方の木の根に大きい方の根を上書きする
    a = root(a),b = root(b);
    if(a==b) return false;//根が同じなら終了,uniteが失敗したことを出力
    if(data[a]<data[b]) swap(a,b); //集合サイズの大きい方の根に低い方の根をつける
    data[b] += data[a];//集合サイズを統合
    data[a] = b;//yの親にxをつける
    return true;//unite成功を出力
  }
  inline long long size(long long a){//aが属する集合のサイズを出力
    return -data[root(a)];
  }
};
int main(){
  while(cin>>n>>m,n){
    union_find uf(n*m);
    area.resize(m);
    REP(i,m) cin >> area[i];
    int person = -1;
    REP(i,m)REP(j,n){
      if(area[i][j]=='@') person = i*n+j;
      REP(k,4){
        if(ok(j,i,j+dx[k],i+dy[k])){
          uf.unite(i*n+j,(i+dy[k])*n+j+dx[k]);
        }
      }
    }
    cout << uf.size(person) << endl;
  }
}



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

int main() {
  int n,m,x;
  cin>>n>>m>>x;
  vector<vector<int>>a(n,vector<int>(m+1));
  for(int i=0;i<n;i++){
    for(int j=0;j<m+1;j++) cin>>a[i][j];
  }
  int ans=10000000;
  for(int tmp=0;tmp<(1<<12);tmp++){
    bitset<12>s(tmp);
    int answer=0;
    vector<int>abi(m);
    for(int i=0;i<m;i++) abi[i]=0;
    for(int i=0;i<n;i++){
      if(s.test(i)){
        answer+=a[i][0];
        for(int j=0;j<m;j++){
          abi[j]+=a[i][j+1];
        }
      }
    }
      bool check=true;
      for(int j=0;j<m;j++){
        if(abi[j]<x) check=false;
      }
      if(check) ans=min(answer,ans);
    }
  if(ans==10000000) ans=-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
class TreasureHunter
  def initialize
    @x = 0
    @y = 0
    @deg = 0
  end

  def to_rad(deg)
    return Math::PI * deg / 180.0
  end
  
  def walk(distance)
    @x += Math.sin(to_rad(@deg)) * distance
    @y += Math.cos(to_rad(@deg)) * distance
  end

  def turn(direction)
    @deg += direction
  end

  def dumpXY
    return [@x.to_s.gsub(/\..*/, ""), @y.to_s.gsub(/\..*/, "")]
  end
end

t = TreasureHunter.new
$<.each_line do |line|
  distance, direction = line.split(/,/).map(&:to_i)
  t.walk(distance)
  t.turn(direction)
end
puts t.dumpXY

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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(){

    int n;
    ll T;
    cin >> n >> T;
    ll ans = 0;
    vector<ll> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 1; i < n; i++){
        ans += min(T, v[i] - v[i-1]);
    }
    ans += T;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define all(c) begin(c),end(c)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//最大公約数
ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}
//最小公倍数
ll lcm(ll x, ll y) {
  return x/gcd(x, y)*y;
}
//素因数分解
vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}
 
 
 ll mod=998244353;
 
int main() {


  int x[5];
  for(int i=0;i<5;i++){
    cin>>x[i];
    if(x[i]==0){
      cout<<i+1;
    }

  }








}



Measured memory_bytes: 3628
//#pragma GCC optimize("O3")
//#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define M2 998244353
#define ll long long
#define pll pair<long, long>
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define ff first
#define ss second
#define pb push_back
#define db pop_back
#define mp make_pair
#define mt make_tuple
#define g(a, b) get<a>(b)
#define INF (ll)1e18 + 100
#define vl vector<ll>
#define vi vector<int>
#define vll vector<pair<ll, ll>>
#define vii vector<pair<int, int>>
#define all(v) v.begin(),v.end()
#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);
 
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
 
ll modI(ll a, ll m)
{
   return powM(a, m-2, m);
}
 
void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
const int N = 2e5+5;
bool sieve[N];
int main()
{
    REP(i, 2, (ll)sqrt(N)+1){
        if(!sieve[i]){
            for(ll j = i+i; j < N; j+=i){
                sieve[j] = true;
            }
        }
    }
    ll x;
    cin>>x;
    REP(i, x, N){
        if(!sieve[i]){cout<<i; return 0;}
    }
}


Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int N;
  scanf("%d", &N);
  int array[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", array+i);
  }

  int num = 1;
  int break_count = 0;
  for (int i = 0; i < N; i++) {
    if (array[i]==num) num++;
    else break_count++;
  }
  if (num==1) break_count = -1;
  printf("%d\n", break_count);
  return 0;
}


Measured memory_bytes: 896
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1000000007 ))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define bigint __int128
#define sqrt sqrtl
#define cbrt cbrtl
#define endl '\n'
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef pair<float,float> ff;
typedef vector<ff> vff;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi;


vector<int> func(int n)
{
	vector<int>next(n);
	for(int i=0;i<n;i++)
	next[i]=(i+1)%n;
	
	vector<int>ans;
	
	int i=0;
	while( next[ next[i] ] != i )
	{
		int a=next[i];
		int b=next[ next[a] ];
		next[ next[a] ]=-1;
		next[a]=b;
		i=next[i];
	}
	for(int i=0;i<n;i++)
	{
		if(next[i]!=-1)
		{
			ans.push_back(i+1);
		}	
	}
	return ans;
}
int32_t main()
{
	IOS
	int a,b;cin>>a>>b;
	cout<<max(0LL,a-2*b)<<endl;
}
	
	
	
	
	
	
	
	

 


Measured memory_bytes: 256
H,W=map(int,input().split())

def g(j):
    if j==".":
        return 1 #白
    else:
        return 0 #黒
    
S=[]
for j in range(H):
    S.append(list(map(g,input())))


Z=[[0]*W for i in range(H)]

for y in range(H):
    if y==0:
        for x in range(W):
            if x==0:
                Z[0][0]=1-S[0][0]
            else:
                Z[y][x]=Z[y][x-1]+(S[y][x-1]==1 and S[y][x]==0)
    else:
        for x in range(W):
            if x==0:
                Z[y][x]=Z[y-1][x]+(S[y-1][x]==1 and S[y][x]==0)
            else:
                Z[y][x]=min(Z[y][x-1]+(S[y][x-1]==1 and S[y][x]==0),Z[y-1][x]+(S[y-1][x]==1 and S[y][x]==0))

print(Z[H-1][W-1])

Measured memory_bytes: 3188
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// type alias
using ll = long long;
using ull = unsigned long long;

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getMaxEffectiveBit(ull a)
{
	ll index = -1;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

inline ll getSpecifiedBit(ull a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}

ll val(ll a, ll c, ll d)
{
	ll m = c / getGcd(c, d) * d;
	return a - a / c - a / d + a / m;
}

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

	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	ll res = val(B, C, D) - val(A - 1, C, D);
	cout << res << endl;

	return 0;
}


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

int main(){
 int N, M ;
string str;
cin >> N >> str >> M ;
for(int i = 0 ; i < N; i++){
 if(str.at(i) == str.at(M - 1) ){
cout << str.at(M - 1)  ;
} 
 else{
cout << "*"  ;
}
}
cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=5e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }



int n;
set<int> s;
   
void Cal(int x) {
	   int ct=0;	   
	   for(int i=1;i*i<=x;i++) {
		      if(x%i==0) {
				     if(i!=1) s.insert(i);				    
				     if((x/i)!=i) {
						 s.insert(x/i);						
					 } 
				  }
		   }		
   	}
   	
void Cal1(int x) {	    
	    for(int i=2;i*i<=x;i++) {
		      int p=x;
		      while(p%i==0) p/=i;
		      if(p%i==1) s.insert(i);
		   }		  
	}   	



void solve() {     
      cin>>n;
      Cal(n-1);
      //~ cout<<sz(s)<<endl;
      Cal1(n);
      
      s.insert(n);
      
	  cout<<sz(s)<<endl;              
}

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


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

using namespace std;

int func(int a, int b) {
    int tmp,r;
    if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;

}

int main()
{
    // スペース区切りの整数の入力
    int K,ab;
    cin >> K;

    long int sum;

    sum = 0;
    for (int i = 1; i < K+1; i++)
    {
        for (int j = 1; j < K+1; j++)
        {
            for (int k = 1; k < K+1; k++)
            {
                ab= func(i,j);
                sum += func(ab,k);
            }
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

const int MX = 2000 * 2000 + 1;

bitset <MX> dp[2];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, sum = 0;
    cin >> n;
    dp[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        sum += x;

        int t = (i & 1);
        dp[t] = (dp[t ^ 1] | (dp[t ^ 1] << x));
    }

    int t = (n & 1);
    for (int i = (sum + 1) / 2; i <= sum; i++)
        if (dp[t][i]) cout << i, exit(0);
    return 0;
}



Measured memory_bytes: 2688
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long A;
        A = sc.nextLong();
        long B;
        B = sc.nextLong();
        long K;
        K = sc.nextLong();
        solve(A, B, K);
    }

    static void solve(long A, long B, long K){
        long remain = A - K;
        if(remain < 0) System.out.println(0 + " " + Math.max(A + B - K, 0));
        else System.out.println(A - K + " " + B);
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
ll mod=1E9+7;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    ll A=ii();
    ll B=ii();
    ll N=ii();
    ll target = B-1;
    if(N<B-1){
        oie(A*N/B-A*(N/B));
    }else{
        oie(A*(B-1)/B-A*((B-1)/B));
    }

    return 0;
}


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

const int INF = 1001001001;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

int gcd(int a, int b) {
	if (a < b) {
		int c = a;
		a = b;
		b = c;
	}
	if (b == 0) return a;
	return gcd (b, a % b);
}

int main() {
	int r;
	cin >> r;
	cout << fixed << setprecision(3) << 2*M_PI*r << endl;
}


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

int main()
{
  int n;
  cin>>n;
  if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9 ){
    cout<<"hon"<<endl;
  }
  else if(n%10==0 || n%10==1 || n%10==6 || n%10==8 ){
    cout<<"pon"<<endl;
  }
  else{
    cout<<"bon"<<endl;
  }
}

Measured memory_bytes: 3632
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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 <class T>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N, A;
    cin >> N >> A;

    int b = N % 500;
    debug(b);
    if (A >= b) {
        cout << "Yes";
        return;
    }

    cout << "No";
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


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

int N;

int main() {
	scanf("%d", &N);
	multiset<int> A;
	for (int i = 0; i < N; i++) {
		int d; scanf("%d", &d);
		A.insert(d);
	}

	// on diameter path
	int diam = *A.rbegin();
	int low = diam;
	for (int i = 0; i <= diam; i++) {
		int d = max(i, diam-i);
		if (A.find(d) == A.end()) {
			puts("Impossible");
			return 0;
		}
		A.erase(A.find(d));
		low = min(low, d);
	}

	if (!A.empty() && *A.begin() <= low) {
		puts("Impossible");
	} else {
		puts("Possible");
	}

	return 0;
}


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

ll RepeatSquare(ll x,ll n,ll mod){
    if(n==0) return 1;
    if(n==1) return x%mod;
    if(n%2==0){
        ll half=RepeatSquare(x,n/2,mod);
        return (half*half)%mod;
    }
    if(n%2==1){
        return x*RepeatSquare(x,n-1,mod)%mod;
    }
}

int main(){
    ll n;
    cin >> n;
    vector<ll> c(n);
    rp(i,n) cin >> c.at(i);
    sort(c.begin(),c.end());
    reverse(c.begin(),c.end());
    ll ans=0;
    ll x=RepeatSquare(4,n-1,1000000007);
    rp(i,n){
        ans += c.at(i)*(i+2);
        ans %=1000000007;
    }
    ans *= x;
     ans %= 1000000007;
     cout << ans << endl;
     return 0;
}

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

int main(){
	int a;
	int b[9];
	while(scanf("%d", &a), a){
		for (int i = 0; i < 9; i++){
			scanf("%d", &b[i]);
			a -= b[i];
		}
		printf("%d\n", a);
	}
	return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



ll n;
int m;


void solve(int testCase){

    scanf("%lld %d" , &n , &m);

    ll sum = 0;
    while(m --){
            ll x; scanf("%lld" , &x);
            sum += x;
    }
    printf("%s\n" , sum >= n ? "Yes" : "No");
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;
const int N=0;
const int E=1;
const int S=2;
const int W=3;
const int Z=4;
int rs[5][4]={{0,1,5,4},{0,3,5,2},{0,4,5,1},{0,2,5,3},{3,1,2,4}};
struct xai{
int ds[6];
void round(int n){
	int t=ds[rs[n][0]];
	for(int i=0;i<3;i++){
		ds[rs[n][i]]=ds[rs[n][i+1]];
	}
	ds[rs[n][3]]=t;
}
xai rounds(int n){
	xai e;
	for(int i=0;i<6;i++)e.ds[i]=ds[i];
	
	if(0<n){
		e.round(S);
	}
	if(1<n){
		e.round(E);
	}
	if(2<n){
		e.round(E);
	}
	if(3<n){
		e.round(E);
	}
	if(4<n){
		e.round(S);
	}
	return e;
}
void roundZ(){
	int cs[4];
	std::vector<int> vec;
	for(int i=0;i<4;i++){
		vec.push_back(ds[rs[Z][i]]);
	}
	for(int i=0;i<4;i++){
		round(Z);
		std::vector<int> vec2;
		for(int i=0;i<4;i++){
			vec2.push_back(ds[rs[Z][i]]);
		}
		if(vec<vec2)vec=vec2;
	}
	for(int i=0;i<4;i++){
		ds[rs[Z][i]]=vec[i];
	}
}
};

int main() {
// your code goes here
xai e,e2;
for(int i=0;i<6;i++){
	scanf("%d",&e.ds[i]);
}
int n;
scanf("%d",&n);
while(n--){
	int a,b,ans;
	bool hit=false;
	scanf("%d %d",&a,&b);
	
	for(int i=0;i<6;i++){
		e2=e.rounds(i);
		if(e2.ds[0]!=a)continue;
		for(int j=0;j<4;j++){
			if(e2.ds[rs[Z][j]]==b){
				ans=e2.ds[rs[Z][(j+1)%4]];
				hit=true;
				break;
			}
		}
		if(hit==true)break;
	}
	printf("%d\n",ans);
}
return 0;
}


Measured memory_bytes: 3200
n = int(input())
fx = [[0 for i in range(4)] for j in range(n)]

for i in range(n):
  x, y = map(int, input().split())
  fx[i][0] = x + y
  fx[i][1] = x - y
  fx[i][2] = - x + y
  fx[i][3] = - x - y

ans = 0
for j in range(4):
  saidai = -(10 ** 10)
  saisho = 10 ** 10
  for i in range(n):
    if saidai < fx[i][j]:
      saidai = fx[i][j]
    if saisho > fx[i][j]:
      saisho = fx[i][j]
  ans = max(ans, saidai - saisho)

print(ans)

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n;
  cin >> n;
  int ans= 0;
  // c = n - a*b
  // 1 <= n - a*b
  // a*b <= n-1
  for(int a = 1; a < n; ++a)
  {
    ans += (n - 1) / a;
  }

  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

ll mod = 1e9+7;

ll power(ll n, ll x)
{
	if(x==0) return 1ll;
	ll p = 1;
	while(x--)
	{
		p = (p*n)%mod;
	}
	return p;
}

int main()
{
	ll i,j,n;
	cin>>n;
	if(n==1) {cout<<0;return 0;}
	ll ch = power(10,n);
    ch -= 2*power(9,n);
    ch += power(8,n);
    ch%=mod;
	ch = ch+mod;
	ch%=mod;
	cout<<ch<<"\n";
}


Measured memory_bytes: 3636
#include <iostream>

int main() {
  signed int bottle_a, bottle_b, bottle_c;
  std::cin >> bottle_a >> bottle_b >> bottle_c;
  
  signed int mm_left = bottle_a - bottle_b;
  if (bottle_c - mm_left >= 0) {
  	std::cout << bottle_c - mm_left;
  } else {
  	std::cout << "0";
  }
  
  return 0;
}

Measured memory_bytes: 256
def judge(a, i, m, n, v, p):
    if i <= p: return True
    if a[i-1] + m < a[p-1]: return False
    check = (p + n - i)*m
    for j in range(p, i):
        check += a[i-1] + m - a[j-1]
    return check >= m*v

n, m, v, p = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse=True)
ng = n + 1
ok = -1

while (ng - ok) > 1:
    mid = (ok + ng) // 2
    if judge(a, mid, m, n, v, p):
        ok = mid
    else:
        ng = mid
print(ok)

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

#define endl '\n'
#define rep(i,n)       for(int i=0; i<n; i++)
#define clr(arr)       memset(arr, 0, sizeof arr)
#define all(x)         x.begin(), x.end()
const int MOD = 1e9 + 7;
template<class F, class S> ostream& operator<<(ostream &out, const pair<F, S> &p)
{
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out)
{
	out << '{';
	for (auto i = x.begin(); i != x.end(); i++)
		out << *i << (i == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dmp() {}
template<class T, class... Args> void dmp(T &&x, Args... args)
{
	cerr << x << ";  "; dmp(args...);
}
#ifdef SMIT
struct Nl {~Nl() {cerr << '\n';}};
#define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dmp(x), Nl(), cerr << ""
#else
#define debug(...) {}
#endif
// Yes you CAN

const int N = 1e5 + 1;

int a[3][N], n, dp[3][N];

int happiness(int n, int curr)
{
	if (n == 0)
		return a[curr][n];
	if (dp[curr][n] != -1)
		return dp[curr][n];
	int maxi = INT_MIN;
	for (int i = 1; i <= 2; i++)
		maxi = max(maxi, a[curr][n] + happiness(n - 1, (curr + i) % 3));
	return dp[curr][n] = maxi;
}

void solve()
{
// #define TEST
	cin >> n;
	rep(i, n) cin >> a[0][i] >> a[1][i] >> a[2][i];
	int ans = INT_MIN;
	memset(dp, -1, sizeof dp);
	rep(i, 3)
	{
		ans = max(ans, happiness(n - 1, i));
	}
	cout << ans << endl;
}

int32_t main()
{
#ifdef SMIT
	freopen("/home/smit/Desktop/in.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);

	int t = 1;
#ifdef TEST
	cin >> t;
#endif
	while (t--)
		solve();
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

const i64 MAXN = 300005;

i64 a, b, c;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> a >> b >> c;

    if (a + b + c >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;

    return 0;
}

Measured memory_bytes: 256