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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n;
    cin >> n;

    vector<int> time(n);
    int sum = 0;

    rep(i, n){
        cin >> time[i];
        sum += time[i];
    }

    int m;
    cin >> m;

    rep(i, m){
        int p,x;
        cin >> p >> x;

        p--;

        cout << sum - time[p] + x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
const int MX = 1e5 + 10, MD = 1e9 + 7;
long long n, m, a[MX], ans, tmp, b;
int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ;
    cin >> n >> m >> b;
    if(n > b){
        cout << "NO";
        return 0;
    }
    if(n + m < b){
        cout << "NO";
        return 0;
    }
    cout << "YES";
}




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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 3e5 );
const int MOD  = int( 1e9 )+7;
const int oo   = INT_MAX;

int n, l;
int a[ MAXN ];

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( ".in", "r", stdin );
    //freopen( ".out", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif

  while( cin >> n >> l ) {
    for( int i = 0; i < n; ++i ) {
      cin >> a[ i ];
    }
    int ans = -1;
    for( int i = 0; i+1 < n; ++i ) {
      if( a[ i ]+a[ i+1 ] >= l ) {
        ans = i;
      }
    }
    if( ans == -1 ) {
      cout << "Impossible\n";
    } else {
      cout << "Possible\n";
      for( int i = 0; i < ans; ++i ) {
        cout << i+1 << '\n';
      }
      for( int i = n-2; i > ans; --i ) {
        cout << i+1 << '\n';
      }
      cout << ans+1 << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 1280
//============================================================================
// Name        : BeginnerContest072-C-Together.cpp
// Author      : tt
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
#include <vector>

vector<int> a;
vector<int> counta(200000, 0);
int N;

void solve(){
	cin >> N;
	int buf;
	for(int i=0; i<N; i++){
		cin >> buf;
		a.push_back(buf);

		//+1、-1、+0したとき全部の場合をカウントしていく
		counta[buf]+=1;
		if(buf-1>=0)counta[buf-1]++;
		counta[buf+1]++;
	}

	int max=-1;
	int maxInd;
	for(int i=0; i<counta.size(); i++){
		if(max < counta[i]){
			max = counta[i];
			maxInd = i;
		}
	}

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

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



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

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

    if (A * B * C % 7 == 0 && A * B * C == 25 * 7){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;

signed main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i,1,sqrt(n)+1){
        if(n % i == 0){
            if(n/i-1 > 0 && n / (n/i-1) == n % (n/i-1) )ans += n/i-1;

            if(i*i != n && i > 1 && n / (i-1) == n % (i-1)) ans += i-1;
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <cstdio>
using namespace std;
int a,b,c,k;
int main()
{
	cin>>a>>b>>c>>k;
	long long x=max(a,max(b,c));
	int y=a+b+c-x;
	for (int i=1;i<=k;i++)
		x*=2;
	cout<<x+y;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string.h>
using namespace std;

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

int main() {
  int w,h,t;
  while(cin>>w>>h, w||h) {
    memset(landscape, 0, sizeof(landscape));
    for(int i=1; i<=h; ++i)
      for(int j=1; j<=w; ++j)
	cin>>landscape[i][j];

    int count = 0;
    for(int i=1; i<=h; ++i) {
      for(int j=1; j<=w; ++j) {
	if(landscape[i][j] == 1) {
	  count++;
	  stack< pair<int, int> > st;
	  st.push(pair<int,int>(i,j));
	  while(!st.empty()) {
	    pair<int,int> p = st.top();
	    st.pop();
	    landscape[p.first][p.second] = 0;
	    for(int k=0; k<8; ++k)
	      if(landscape[p.first+dx[k]][p.second+dy[k]])
		st.push(pair<int,int>(p.first+dx[k], p.second+dy[k]));
	  }
	}
      }
    }

    cout<<count<<endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in);) {
      int n = sc.nextInt();
      int m = sc.nextInt();

      sc.nextLine();

      String[] results = new String[n];
      for (int i = 0; i < n; i++) {
        results[i] = sc.nextLine().substring(2);
      }

      int sum = 0;
      for (int i = 1; i <= m; i++) {
        if (hasElem(results, i)) {
          sum++;
        }
      }

      System.out.println(sum);
    }
  }

  private static boolean hasElem(String[] results, int num) {
    for (String result : results) {
      String[] elems = result.split(" ");
      if (hasWord(elems, num) == false) {
        return false;
      }
    }
    return true;
  }

  private static boolean hasWord(String[] words, int num) {
    for (String word : words) {
      if (word.equals(String.valueOf(num))) {
        return true;
      }
    }
    return false;
  }
}

Measured memory_bytes: 25812
I = input().split()
N = int(I[0])
M = int(I[1])
## input A and B ##
A = [["" for i in range(N)] for i in range(N)]
B = [["" for i in range(M)] for i in range(M)]
for i in range(N):
    A[i] = list(input())
for i in range(M):
    B[i] = list(input())

# print(A,B)

# print([ A_i[0:2] for A_i in A[0:2] ])

# print( B == [ A_i[0:2] for A_i in A[0:2] ]  )

EQ_flag = 0
for i in range(N+M+1):
    for j in range(N+M+1):
        if ( B == [ A_i[i:i+M] for A_i in A[j:j+M] ] ):
            EQ_flag = 1
            break

if(EQ_flag):
    print('Yes')
else:
    print('No')

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

int main(){
	char a[4],b[4];
	scanf("%s%s",a,b);
	for(int i=0,j=strlen(b)-1; i<strlen(a)&&j>=0; i++,j--) {
		if(a[i] != b[j]) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N =get_int
A = get_ints
B = get_ints

count = 0
0.step(N-1) do |i|
  if A[i] >= B[i]
    count += B[i]
    A[i] = 0
  elsif B[i] >= A[i] + A[i+1]
    count += A[i] + A[i+1]
    A[i] = 0
    A[i+1] = 0
  else
    count += B[i]
    A[i+1] = A[i+1] - B[i] + A[i]
    A[i] = 0
  end
end

puts count


Measured memory_bytes: 25796
def resolve():
    a = int(input()[-1])
    hon = [2, 4, 5, 7, 9]
    pon = [0, 1, 6, 8]
    bon = [3]

    for _hon in hon:
        if a == _hon:
            print('hon')
    for _pon in pon:
        if a == _pon:
            print('pon')

    for _bon in bon:
        if a == _bon:
            print('bon')
resolve()

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

using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))

int main()
{
    long long N,L;

    cin >> N >> L;

    vector<long long> a;

    a.push_back(0);
    for(int i=1; i<=N; ++i) {
        long long temp;
        cin >> temp;
        a.push_back(temp);
    }
    a.push_back(0);

    long long z=0,g=0,ans=0;

    for(int i=1; i<=N; ++i) {
        if(a[i-1]>a[i] && a[i]<a[i+1]) {
            g+=L-a[i];
            ans=MAX(ans,g);
            g=0;
            z=L-a[i];
        } else if(a[i-1]<a[i] && a[i]>a[i+1]) {
            z+=L-a[i];
            ans=MAX(ans,z);
            z=0;
            g=L-a[i];
        } else if(a[i-1]<a[i] && a[i]<a[i+1]) {
            z+=L-a[i];
        } else if(a[i-1]>a[i] && a[i]>a[i+1]) {
            g+=L-a[i];
        }
    }

    ans=MAX(ans,g);
    ans=MAX(ans,z);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3864
#include <algorithm>
#include <array>
#include <cstdio>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <queue>

using namespace std;

int main() {
    int N, M, X, c1, c2;
    c1 = c2 = 0;

    cin >> N >> M >> X;
    for (int i = 0; i < M; i++) {
        int t;
        cin >> t;

        if (0 < t && t <= X) c1++;
        else if(X <= t && t < N) c2++;
    }

    cout << (c1 < c2 ? c1 : c2) << endl;
}

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

if 1<=N<10:
    print(N)

elif 10<=N<100:
    print(9)

elif 100<=N<1000:
    x = 9 + N -100 + 1
    print(x)

elif 1000<=N<10000:
    print(909)

elif 10000<=N<100000:
    x = 909 + N -10000 + 1
    print(x)

else:
    print(90909)

Measured memory_bytes: 3060
import numpy as np
ans=10**9
N,C=map(int,input().split())
s=[list(map(int,input().split())) for i in range(C)]
t=[list(map(int,input().split())) for i in range(N)]
u=[np.zeros((C)) for i in range(3)]
for i in range(N):
    for j in range(N):
        u[(i+j)%3]+=np.array(s[t[i][j]-1])
from itertools import permutations
for i,j,k in list(permutations(range(C),3)):
    p=u[0][i]+u[1][j]+u[2][k]
    ans=min(ans,p)
print(int(ans))    


Measured memory_bytes: 16484
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

template<typename T>
struct SCC{
    T &G;
    vector<vector<int>> Ngraph,Rgraph;
    vector<int> comp,order;
    vector<bool> used;
    SCC(T &g):G(g),Ngraph((int)g.size()),Rgraph((int)g.size()),comp((int)g.size(),-1),used((int)g.size()){
        for(int i=0;i<(int)g.size();i++){
            for(int to:g[i]){
                Ngraph[i].push_back(to);
                Rgraph[to].push_back(i);
            }
        }
    }
    int operator[](int idx){
        //assert(0<=idx&&idx<comp.size());
        return comp[idx];
    }
    void dfs(int idx){
        if(used[idx]) return;
        used[idx]=true;
        for(auto &to:Ngraph[idx]) dfs(to);
        order.push_back(idx);
    }
    void rdfs(int idx,int cnt){
        if(comp[idx]!=-1) return;
        comp[idx]=cnt;
        for(auto &to:Rgraph[idx]) rdfs(to,cnt);
    }
    void build(vector<vector<int>> &ret){
        for(int i=0;i<(int)Ngraph.size();i++) dfs(i);
        reverse(order.begin(),order.end());
        int group=0;
        for(auto i:order){
            if(comp[i]==-1){
                rdfs(i,group);
                group++;
            }
        }
        ret.resize(group);
        for(int i=0;i<(int)G.size();i++){
            for(auto &to:G[i]){
                int s=comp[i],t=comp[to];
                if(s!=t) ret[s].push_back(t);
            }
        }
    }
};

signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int V,E; cin >> V >> E;
    vector<vector<int>> vec(V),ans;
    rep(i,E){
        int a,b; cin >> a >> b;
        vec[a].pb(b);
    }
    SCC<vector<vector<int>>> scc(vec);
    scc.build(ans);
    vector<vector<int>> res(V);
    vector<int> num(V,0);
    int K=0;
    rep(i,V){
        if(num[scc[i]]==0) K++;
        num[scc[i]]++;
        res[scc[i]].pb(i);

    }
    cout << K << endl;
    rep(i,V){
        if(num[i]==0) break;
        cout << num[i] << " ";
        for(auto u:res[i]) cout << u << " ";
        cout << "\n";
    }
}


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

const int N = 1e5 + 70;
const int base = 1e9 + 7;
vector< int> factors;
int fact[N], ifact[N];

int bpow(int a, int b, int base) {
    int rv = 1;
    while(b) {
        if(b & 1) rv = rv * 1LL * a % base;
        a = a * 1LL * a % base;
        b /= 2;
    }
    return rv;
}

void pre() {
    fact[0] = 1;
    for (int i = 1; i < N; i++) fact[i] = fact[i - 1] * 1LL * i % base;
    ifact[N - 1] = bpow(fact[N - 1], base - 2, base);
    for(int i = N - 2; i >= 0; i--) ifact[i] = ifact[i + 1] * 1LL * (i + 1) % base;
}

int ncr(int n, int r) {
    int rv = fact[n];
    rv = rv * 1LL * ifact[r] % base;
    rv = rv * 1LL * ifact[n - r] % base;
    return rv;
}


int main() {
    pre();
    int k, m;
    cin >> k >> m;
    for (long long i = 2; i * i <= m; i ++) {
        if (m % i == 0) {
            int cnt = 0;
            while (m % i == 0) {
                m /= i;
                cnt++;
            }
            factors.emplace_back(cnt);
        }
    }
    if (m > 1) factors.emplace_back(1);

    int res = 1;
    for (int a : factors) {
        res = res * 1LL * ncr(a + k - 1, a) % base;
    }
    cout << res << endl;
}


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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  // ABピザを買わない場合
  int sum1 = A*X+B*Y;
  // できるだけABピザを買う場合(minに合わせる)
  int sum2 = C*2*min(X, Y);
  if (X < Y) {
    sum2 += B*(Y-X);
  }
  else if (X > Y) {
    sum2 += A*(X-Y);
  }
  // できるだけABピザを買う場合(maxに合わせる)
  int sum3 = C*2*max(X, Y);
  int ans = min(sum1, min(sum2, sum3));
  cout << ans << endl;
}

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

using Float = double;
using Point = complex<Float>;
struct Line{ Point a,b; };
struct Circle{ Point center; Float r; };

const Float EPS = 1e-8;

inline bool eq(Float a,Float b) { return abs(a - b) < EPS; }
inline Float dot(const Point &p1,const Point &p2){ return real(conj(p1) * p2); }
inline Float cross(const Point &p1,const Point &p2){ return imag(conj(p1) * p2); }

namespace std{
	bool operator<(const Point &p1,const Point &p2){
		return eq(real(p1),real(p2)) ? imag(p1) < imag(p2) : real(p1) < real(p2);
	}
}

Point projection(const Line &l,const Point &p){
	Float t = dot(l.b - l.a,p - l.a) / norm(l.b - l.a);
	return l.a + (l.b - l.a) * t;
}

vector<Point> crosspoint(const Circle &c1,const Circle &c2){
	vector<Point> ret;
	Point d = c2.center - c1.center;
	Float rcosa = (c1.r * c1.r + norm(d) - c2.r * c2.r) / (abs(d) * 2);
	if(eq(0,abs(d)) || abs(rcosa) > c1.r) return ret;
	Float rsina = sqrt(c1.r * c1.r - rcosa * rcosa);
	ret.push_back(c1.center + d / abs(d) * Point(rcosa,rsina));
	if(!eq(rcosa,c1.r)) ret.push_back(c1.center + d / abs(d) * Point(rcosa,-rsina));
	return ret;
}

signed main(){
	Circle c[2];
	for(int i = 0;i < 2;i++){
		Float x,y,r;
		cin >> x >> y >> r;
		c[i] = {Point(x,y),r};
	}
	vector<Point> ps = crosspoint(c[0],c[1]);
	if(ps.size() == 1) ps.push_back(ps[0]);
	if(ps[1] < ps[0]) swap(ps[0],ps[1]);
	printf("%.15lf %.15lf %.15lf %.15lf\n",real(ps[0]),imag(ps[0]),real(ps[1]),imag(ps[1]));
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s1, s2;
    int a, b;
    cin >> s1 >> s2 >> a >> b;
    string ss;
    cin >> ss;
    if(ss==s1)a--;
    if(ss==s2)b--;
    cout << a <<' '<<b<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int A[100100];
    int sum = 0;
    A[0] = 0; A[N + 1] = 0;
    rep1(i, N) {
        cin >> A[i];
    }
    rep1(i, N + 1) {
        sum += abs(A[i] - A[i - 1]);
    }
    rep1(i, N) {
         cout << sum - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]) << endl;
    }
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int A,P;
    cin >> A >> P;
    
    cout << (A*3+P)/2 << endl;
    
    return 0;
}



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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
int a[MAXN], cnt[MAXN];
bool b[MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    forn (i, n)
        ++cnt[a[i]];

    int d = *max_element(a, a + n);

    for (int i = d; 2 * i > d; --i)
        if (cnt[i] < 2) {
            cout << "Impossible\n";
            return ;
        } else {
            ----cnt[i];
            b[i] = true;
        }

    if (d % 2 == 0) {
        --cnt[d / 2];
        b[d / 2] = true;

        if (cnt[d / 2] < 0) {
            cout << "Impossible\n";
            return ;
        }
    }

    for (int i = 1; i < n; ++i)
        if (cnt[i] > 0 && !b[i - 1]) {
            cout << "Impossible\n";
            return ;
        }

    cout << "Possible\n";
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll gcd(ll a, ll b){
    if(a < b)  swap(a,b);
    if(a%b==0) return b;
    else return gcd(b,a%b);
}
ll ngcd(vector<ll> a){
    ll res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
ll nlcm(vector<ll> numbers) {
    ll res;
    res = numbers[0];
    for (ll i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n ;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    cout << nlcm(v) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int a[299999]={};
    int ans=-1;
    
    cin >> n;
    
    for(int i=1; i<=n; i++){
        
        cin >> a[i];
        
        if(a[i]==1){
            
            ans = 1;
            
        }
        
    }
    
    if(ans==-1){
        
        cout << "-1" << endl;
        
        return 0;
        
    }
    
    for(int j=1; j<=n; j++){
        
        if(a[j]==ans){
            
            ans += 1;
            
        }
        
    }
    
    cout << n-ans+1 << endl;
    
    return 0;
    
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<cstdio>
using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = static_cast<int>(s.size()) - 1; i >= 0; i--)
	{
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <math.h>

double stdev(int s[], int n)
{
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum = sum + s[i];
    }
    double m = (double)sum / n;
    double sum2 = 0;
    for (int i = 0; i < n; i++)
    {
        sum2 = sum2 + pow(s[i] - m, 2);
    }
    double v = sum2 / n;
    return sqrt(v);
}

int main()
{
    int n, s[1000];
    do
    {
        scanf("%d", &n);
        if (n > 0)
        {
            for (int i = 0; i < n; i++)
            {
                scanf("%d", &s[i]);
            }
            double sd = stdev(s, n);
            printf("%.6lf\n", sd);
        }
    } while (n > 0);
    return 0;
}


Measured memory_bytes: 2036
N = input()
if N[0] == "9":
    if N[1:] == "9"*len(N[1:]):
        print(9*len(N))
    else:
        print(9*len(N)-1)
else:
    if N[1:] == "9"*len(N[1:]):
        print(int(N[0]) + 9*len(N[1:]))
    else:
        print(int(N[0]) + 9*len(N[1:]) - 1)


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

alph = [chr(ord('a') + i)  for i in range(N)]
S = ""
ans = []


# i文字目に何を入れるか　j種類使っている状態
def add_s(S, j):

    if len(S) == N:
        ans.append(S)
        print(S)
        return

    for s in range(j+2):
        S += alph[s]
        if s == j+1:
            add_s(S, j+1)
        else:
            add_s(S, j)
        S = S[:-1]

add_s("a", 0)

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      
      int X, A;
      cin >> X >> A;
      if(X < A)cout << 0 << endl;
      else cout << 10 << endl;
}


Measured memory_bytes: 256
import itertools
import copy
h,w,k = map(int,input().split())
c = []
for i in range(h):
    c.append(list(input()))

lish = [-1]
lisw = [-1]
num = [i for i in range(1,h+1)]
numw = [i for i in range(1,w+1)]
numm = [[i] for i in range(1,h+1)]
numww = [[i] for i in range(1,w+1)]
lish.extend(numm)
lisw.extend(numww)
for i in range(2,h+1):
    lish.extend(list(itertools.combinations(num,i)))
for i in range(2,w+1):
    lisw.extend(list(itertools.combinations(numw,i)))

ans = 0
for i in lish:
    for j in lisw:
        tmp = copy.deepcopy(c)
        tmpan = 0
        if i!=-1:
            for ii in i:
                for jj in range(w):
                    tmp[ii-1][jj] = -1
        if j!=-1:
            for jj in j:
                for ii in range(h):
                    tmp[ii][jj-1] = -1
        for ii in range(h):
            for jj in range(w):
                if tmp[ii][jj] == "#":
                    tmpan +=1
        if tmpan ==k:
            ans+=1

print(ans)


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

using namespace std;

int main(void)
{
    int N;
    int K;
    cin >> N >> K;
    string S;
    cin >> S;
    bool flag = false;
    for(int i = 1; i < N; i++){
        if(S[i-1] != S[i]){
            S[i] = S[i-1];
            if(!flag){
                flag = true;
                K--;
            }
        }
        else if(S[i-1] == S[i]){
            if(flag){
                flag = false;
            }
        }
        if(!flag && K == 0){
            break;
        }
    }
    if(K != 0 && S.size() > 1){
        S[0] = S[1];
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == 'L'){
            if(i > 0 && S[i-1] == 'L'){
                ans++;
            }
        }
        else if(S[i] == 'R'){
            if(i < N-1 && S[i+1] == 'R'){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
n=int(input())
ws=list(map(int,input().split()))
s1=ws[0]
s2=sum(ws[1:])
a=abs(s1-s2)
for t in ws[1:]:
    s1+=t
    s2-=t
    a=min(a,abs(s1-s2))
print(a)


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

int main(){
    int N;
    int64_t res;
    vector<int64_t> vA(100010);
    vector<int64_t> vB(100010);
    // int64_t vp[100010];
    // string res;

    res = 0;

    cin >> N;
    for (int i=1; i<=N+1; i++){
        cin >> vA.at(i);
    }
    for (int i=1; i<=N; i++){
        cin >> vB.at(i);
    }
    vB.at(N+1) = 0;

    // 勇者 Bi のループ
    for (int i=1; i<=N; i++){
        if (vA.at(i) <= vB.at(i)){
            // Ai 全部倒せる
            res += vA.at(i);
            vB.at(i) -= vA.at(i);

            // 余力で A_i+1 を倒す
            if (vA.at(i+1) <= vB.at(i)){
                res += vA.at(i+1);
                vA.at(i+1) = 0;
            }
            else {
                res += vB.at(i);
                vA.at(i+1) -= vB.at(i);
            }
        }
        else {
            // Ai 残してしまう
            res += vB.at(i);
            vB.at(i) = 0;
        }
    }

    cout << res << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++){
        cin >> vec.at(i);
    }
    vector<int> vec2 = vec;
    sort(vec.begin(),vec.end());
    int ex = vec.at(N-1);
    
    for(int i = 0;i < N;i++){
        if(vec2.at(i) == ex){
            cout << vec.at(N-2) << endl;
        }else{
        cout << vec.at(N-1) << endl;
        }
    }

}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 2e5+7;
/*
int head[M],cnt;
void init(){cnt=0,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,val;}ee[M*2];
void add(int x,int y){ee[++cnt].nxt=head[x],ee[cnt].to=y,head[x]=cnt;}
*/
const int mod = 998244353;
ll qpow (ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ans;
}
ll fac[M],inv[M],p[M];
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	ll n,m,k;
	cin>>n>>m>>k;
	fac[0]=p[0]=inv[0]=1;
	for(int i=1;i<=200000;i++)fac[i]=fac[i-1]*i%mod,p[i]=p[i-1]*(m-1)%mod;;
	inv[200000]=qpow(fac[200000],mod-2);
	for(int i=200000-1;i;i--)inv[i]=inv[i+1]*(i+1)%mod;
	ll ans=0;
	for(int i=1;i<=k;i++)
	{
		ll C=fac[n-1]*inv[i]%mod*inv[n-1-i]%mod;
		ans=(ans+m*p[n-i-1]%mod*C%mod)%mod;
	}
	ans=(ans+m*p[n-1]%mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8352
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n; cin>>n;
    for (int i = 1; i <= n; ++i) {
        ll t = (double)i*1.08;
        if (n==t) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
typedef long long ll;
using namespace std; 
using P = pair<int,int>;
const ll mod = 1e9+7;
const int INF = 1001001001;

const int MAX_W = 500;
const int MAX_H = 500;

int main(){
  string s;
  cin >> s;
  int n = s.size()-1;
  if(s[n]=='3'){
    cout << "bon" << endl;
  }else if(s[n]=='0' || s[n]=='1' || s[n]=='6' ||s[n]=='8'){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
//template
import java.util.*;
import java.util.stream.*;
import java.io.*;
public class Main{
	static BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out= new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	
	private static final int HUNDRED = 100;
	public static void main(String[] args) throws IOException{
		
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		out.println(IntStream.range(0, N).map(i ->{
			int a=scan.nextInt(),count=0;
			while(0==(a&1)) {
				count++;
				a>>=1;
			}
			return count;
		}).sum());
		
		out.flush();
		in.close();
		out.close();
	}
	
	public static boolean palindrome(String s) {
		boolean palindrome=true;
		int i=0,j=s.length()-1;
		while(i<j&&palindrome) {
			if(s.charAt(i++)!=s.charAt(j--))
				palindrome=false;
		}
		return palindrome;
	}
	public static long reverse(String s) {
		String aux="";
		for(int i=s.length()-1;i>=0;i--) {
			aux+=s.charAt(i);
		}
		return Long.parseLong(aux);
	}
	private static int modulo(int S, int N) { return ((S) & (N - 1)); } // returns S % N, where N is a power of 2
	private static int isPowerOfTwo(int S) { return (S & (S - 1)) == 0 ? 1 : 0; }
	private static int[] readInts() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	}
	private static int readInt() throws IOException {
		return Integer.parseInt(in.readLine());
	}
	private static long[] readLongs() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
	}
	private static long readLong() throws IOException {
		return Long.parseLong(in.readLine());
	}
	 
}
class Pair{
	int first;
	int second;
	public Pair(int first,int second) {
		this.first=first;
		this.second=second;
	}
	public Pair() {
		
	}
}

Measured memory_bytes: 49140
/*author : Yashvardhan
Sunday, August 18, 2019
5:27 PM
*/

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

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod(pow(takemod(a), mod-2,mod));}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int a;
	string s;
	cin>>a>>s;

	if(a >= 3200) cout<<s<<endl;
	else cout<<"red"<<endl;
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{  
     //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,k,sum=0;
	cin>>n>>k;
	int  a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<k;i++)
	{
		sum=sum+a[i];
	}
	cout<<sum<<"\n";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if (a+b==15) cout<<"+"<<endl;
	else if (a*b==15) cout<<"*"<<endl;
	else if (a+b!=15&&a*b!=15) cout<<"x"<<endl;
 	return 0;
}

Measured memory_bytes: 256
n,m,*t=map(int,open(0).read().split());a,c=[0]*-~n,0
for l,r in zip(t[::2],t[1::2]):a[l-1]+=1;a[r]-=1
for i in range(n):a[i+1]+=a[i];c+=a[i]==m
print(c)

Measured memory_bytes: 25076
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main(){
  int n;
  cin >> n;
  cout << 48 - n << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(input())

answer = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        answer += i

print(answer)

Measured memory_bytes: 9184
n = int(input())
s = input()
count_left = 0
count_right = 0
need_left = 0 
need_right = 0
for i in range(n):
  if s[i]==")":
    count_right += 1
  else:
    count_right -= 1
  need_left = max(need_left,count_right)

for i in range(n)[::-1]:
  if s[i]=="(":
    count_left += 1
  else:
    count_left -= 1
  need_right = max(need_right,count_left)
  
print("("*need_left+s+")"*need_right)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N, K;
int a[20];

int main(void){
	cin >> N >> K;
	rep(i, N) cin >> a[i];

	ll ret = INFF;
	for (int mask = 0; mask < (1 << N); ++mask){
		int cnt = 0;
		for (int pos = 0; pos < N; ++pos){
			if((mask & (1 << pos)) != 0) cnt++;
		}
		if(cnt != K) continue;
		int ma = 0;
		ll ans = 0;
		bool ff = true;
		for (int pos = 0; pos < N; ++pos){
			if((mask & (1 << pos)) != 0){
				if(ff){
					ma = a[pos];
					ff = false;
				}else{
					// ans += max(0, (ma + 1) - a[pos]);
					if(ma < a[pos]){
						ma = a[pos];
					}else{
						ans += (ma + 1) - a[pos];
						ma++;
					}
					// printf("ma %d\n", ma);
				}
			}else{
				ff = false;
				chmax(ma, a[pos]);
			}
		}
		chmin(ret, ans);
	}
	printf("%lld\n", ret);
	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,c; cin>>a>>b>>c;
  cout<<max(c-(a-b),0LL)<<endl;
}

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

using namespace std;

int main() {
    int A,B,K;
    cin >> A >> B >> K;
    
    int i = 0;
    int X = 10000;
    
    while(i < K){
    X = X - 1;
        if(A % X == 0 && B % X == 0){
            i++;
            
        }
    }
    cout << X << endl;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;

  vector<int64_t> Hs(N);
  for (int n = 0; n < N; ++n) {
    cin >> Hs[n];
  }
  sort(Hs.begin(), Hs.end());
  
  int64_t mn = 1e9+1;
  for (int n = 0; n < N - K + 1; ++n) {
    mn = min(mn, Hs[n+K-1] - Hs[n]);
  }
  cout << mn << endl;
  
  return 0;
}


Measured memory_bytes: 4020
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

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

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

	ll ans = 0;
	if (n > 1)
	{
		for (int i = 1; i < n; i++)
		{
			ans += i;
		}
	}
	if (m > 1)
	{
		for (int i = 0; i < m; i++)
		{
			ans += i;
		}
	}
	cout << ans << endl;

	return 0;
}

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

#define ll long long int
#define ull unsigned long long int
#define po2(z) 1<<(ll)z
#define fr(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define rf(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define TC ll test;cin>>test;while(test--)
#define tej ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
#define MAX 100005

ll static t[102][MAX];

ll knapsack(ll wt[],ll val[],ll W,ll n)
{
	if(n==0||W==0){
		return 0;
	}
	if(t[n][W]!=-1){
		return t[n][W];
	}
	
	if(wt[n-1]<=W){
		return t[n][W]=max(val[n-1]+knapsack(wt,val,W-wt[n-1],n-1),knapsack(wt,val,W,n-1));
	}
	else{
		return t[n][W]= knapsack(wt,val,W,n-1);
	}
	
}

int main(){
memset(t,-1,sizeof(t));
ll n,W;
cin>>n>>W;

ll wt[n],val[n];

fr(i,0,n)cin>>wt[i]>>val[i];

cout<<knapsack(wt,val,W,n);

}


Measured memory_bytes: 80000
N,D = map(int,input().split())
X=[]
for i in range(N):
  X +=[[int(x) for x in input().split()]]

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

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
  
#include <vector>
#include <deque>
#include <algorithm>
#include <cstdio>
using namespace std;
   
int main(){
    int N;
    long long W,tV=0,tW=0,x=0;
    scanf("%d%lld",&N,&W);
    vector<pair<long long,long long> >v(N);
    for(int i=0;i<N;i++)scanf("%lld%lld",&v[i].first,&v[i].second),tV+=v[i].first,tW+=v[i].second;
  
        int n=N/2;
        deque<pair<long long,long long> >se1,se2;
        for(int i=0;i<1<<n;i++){
            long long V=0,w=0;
            for(int j=0;j<n;j++)if(i&(1<<j))V+=v[j].first,w+=v[j].second;
            se1.emplace_back(w,V);
        }
        for(int i=0;i<1<<(N-n);i++){
            long long V=0,w=0;
            for(int j=0;j<(N-n);j++)if(i&(1<<j))V+=v[j+n].first,w+=v[j+n].second;
            se2.emplace_back(w,V);
        }
sort(se1.begin(),se1.end());
sort(se2.begin(),se2.end());
        for(auto it=se1.begin();it!=se1.end();){
            auto it2=it;
            for(++it2;it2!=se1.end()&&it->second>=it2->second;)it2=se1.erase(it2);
            ++it;
        }
        for(auto it=se2.begin();it!=se2.end();){
            auto it2=it;
            for(++it2;it2!=se2.end()&&it->second>=it2->second;)it2=se2.erase(it2);
            ++it;
        }
        long long r=0;
        for(auto &e1:se1){
            auto it=lower_bound(se2.begin(),se2.end(),make_pair(W-e1.first+1,0LL));
            if(it!=se2.begin()){
                --it;
                r=max(r,e1.second+it->second);
            }
        }
        printf("%lld\n",r);
}

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

typedef long long ll;

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

    ll a[n+1];
    a[0] = 0;
    for(int i = 1; i <= n; i++)  cin >> a[i], a[i] += a[i-1];

    vector<ll> v;
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j++){
            v.push_back(a[j]-a[i-1]);
        }
    }

    sort(v.begin(), v.end());

    int i;
    for(i = 62; i >= 0; i--){
        ll tmp = 1ll<<i;
        int cnt = 0;
        for(ll val : v) if((val&tmp) > 0) cnt++;
        if(cnt >= k)    break;
    }

    if(i == -1){
        cout << 0 << endl;
        return 0;
    }

    //ll ans = 1ll<<i;

    vector<ll> c;
    for(ll val : v) if((val&(1ll<<i)) > 0)    c.push_back(val);

    i--;
    while(i >= 0 && c.size() > k){
        vector<ll> next;
        ll tmp = 1ll<<i;
        for(ll val : c) if((val&tmp) > 0) next.push_back(val);
        if(next.size() >= k){
            c = next;
            //ans |= (1ll<<i);
        }
        i--;
    }

    ll ans = c[0];
    for(int i = 1; i < c.size(); i++)   ans &= c[i];
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6512
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var a = arr[1].split(" ").map(Number);
var ans = -1;
for (var i = 0; i < a.length; i++) {
   for (var j = i + 1; j < a.length; j++) {
      var v = a[i] * a[j];
      if (v < ans) continue; 
      var flag = true;
      (v+"").split("").map(Number).reduce(function(a, b) {
         if (a + 1 != b) flag = false;
         return b;
      });
      if (flag) ans = v;
   }
}
console.log(ans);

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

using namespace std;

int inRange(int a){
	return (-1000000<=a && a<=1000000);
}

int main(void){
	int k,x;
	cin >> k >> x;
	int diff = (k-1);
	for(int i=x-diff;i<=x+diff;i++){
		if(inRange(i)) cout<<i<<" ";
	}
	cout<<endl;
}


Measured memory_bytes: 256