akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

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

using namespace std;

int main(){
	int N;
	int c[500],s[500],f[500];
	scanf("%d",&N);
	for(int i=0;i<N-1;i++){
		scanf("%d %d %d",&c[i],&s[i],&f[i]);
	}
	for(int i=0;i<N;i++){
		long long ans = 0;
		for(int j=i;j<N-1;j++){
			if(ans <= s[j]) ans = s[j];
			else if(ans%f[j]!=0) ans += (f[j] - ans%f[j]);
			ans += c[j];
		}
		printf("%lld\n",ans);
	}

	return 0;
}


Measured memory_bytes: 128
from itertools import chain

N = int(input())
zenhan = []
kouhan = []
for _ in range(N):
    si = input()
    last = 0
    low = last
    high = last
    for s in si:
        if s == "(":
            last += 1
        else:
            last -= 1
        low = min(low, last)
        high = max(high, last)
    if last >= 0:
        zenhan.append((-low, last, low))
    else:
        kouhan.append((low - last, last, low))
zenhan.sort()
kouhan.sort()

open_close = 0
for key, last, low in chain(zenhan, kouhan):
    if open_close + low < 0:
        ans = "No"
        break
    else:
        open_close += last
else:
    if open_close:
        ans = "No"
    else:
        ans = "Yes"
print(ans)


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

int main(){
  int N , A ;
  cin >> N ;
  vector<int> B(210000);
  for(int i=0;i<N-1;i++){
    cin >> A;
    B[A-1]++;
  }
  
  for(int i=0;i<N;i++){
    cout << B[i] << endl;
  }
}



Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int mi = INF;
    int ans = 0;
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    for (int i = 0; i < h; i++) {
        cin >> c[i];
        for (int j = 0; j < w; j++) {
            if (c[i][j] == 'B') {
                chmax(ans, i + j - mi);
                chmin(mi, i + j);
            }
        }
    }
    mi = INF;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (c[i][j] == 'B') {
                chmax(ans, i - j - mi);
                chmin(mi, i - j);
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3692
#include <iostream>

using ull = unsigned long long;

ull pow2( ull n )
{
	ull base = 1;
	for ( int i = 0; i < n; i++ )
	{
		base *= 2;
	}

	return ( base );
}

int main()
{
	int N;
	ull X;
	std::cin >> N >> X;

	// レベルNバーガーの下からN層はバンである
	// P
	// BPPPB
	// BBPPPBPBPPPBB
	// BBBPPPBPBPPPBBPBBPPPBPBPPPBBB
	// レベルNバーガーの下から中央のパティまでの層に含まれるパティの数は、
	// 2^N枚である（中央の1枚を含む）
	// レベルNバーガーの層の総数はLn = (2^N+1 - 1)+(2^N+1 - 2) = 2^N+2 - 3枚である

	ull p = pow2( N + 2 ); // Nは最大50なので、ull型で収まる
	ull counter = 0;

	while ( ( X > 0 ) && ( N >= 0 ) )
	{
#ifdef DEBUG_PRINT
		std::cout << "Lv : " << N << std::endl;
		std::cout << "all: " << p - 3 << std::endl;
		std::cout << "X  : " << X << std::endl;
		std::cout << "mid: " << ( p - 3 ) / 2 << std::endl;
#endif

		if ( X < ( p - 3 ) / 2 + 1 )
		{
			// 中央よりも下層までの時
			// 何もしない
		}
		else
		{
			// 中央よりも上層の時
			counter += pow2( N );	//	中央よりも下層に含まれるパティは全部食べる

			// 上層の時は、食べる側にバンが含まれているので取り除かないが、
			// 下層半分を食べ終えているので、Xはその分減らす
			X -= ( p - 3 ) / 2 + 1;
			++X;	//	調整しておく
		}
#ifdef DEBUG_PRINT
		std::cout << "eat: " << counter << std::endl;
#endif

		--N; // レベルを1段下げる
		--X; // レベルアップ時に両端にバンが追加されているので、それを取り除く
		p = pow2( N + 2 ); // 再計算
	}

	std::cout << counter << std::endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int mo=1e9+7,N=2e5+5;
int n,m,i,j,ans,lm=N,f[N],s[N];
char c[N];
int main(){
	scanf("%d%d%s",&n,&m,c+1);
	for(i=1;c[i]==c[1];++i);
	if(i>m){
		static int f[N][2];
		f[0][0]=1;
		for(i=1;i<=n;++i)f[i][0]=(f[i-1][0]+f[i-1][1])%mo,f[i][1]=f[i-1][0];
		ans=f[n][0];
		memset(f,0,sizeof f);
		f[0][1]=1;
		for(i=1;i<=n;++i)f[i][0]=(f[i-1][0]+f[i-1][1])%mo,f[i][1]=f[i-1][0];
		ans=(ans+f[n][1])%mo;
	}else{
		lm=i&1?i:i-1;
		for(;i<=m;i=j){
			for(j=i+1;c[j]==c[1];++j);
			if(j<=m && (j-i-1)%2==1)lm=std::min(lm,j-i-1);
		}
		if(n&1){puts("0");return 0;}
		lm-=lm%2==0;lm=lm+1>>1;
		s[0]=f[0]=1;
		for(i=1;i<=n;++i)f[i]=(s[i-1]+mo-(i>lm?s[i-lm-1]:0))%mo,s[i]=(s[i-1]+f[i])%mo;
		for(i=1;i<=lm*2-1 && i+1<=n;i+=2)ans=(ans+1ll*(i+1)*f[n-i-1>>1])%mo;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };

using ll = std::int64_t;
using vint = std::vector<std::int32_t>;
using vll = std::vector<ll>;
using vstr = std::vector<std::string>;
using pint = std::pair<std::int32_t, std::int32_t>;
using usetint = std::unordered_set<std::int32_t>;
using usetstr = std::unordered_set<std::string>;

constexpr std::int32_t INF = 1001001001;

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

// dp[i+1][j+1]: s[0, i], t[0,j]の lcs
int dp[3005][3005];

void Main() {
    rep(i, 3005)rep(j, 3005)dp[i][j] = 0;

    string s, t;
    cin >> s >> t;

    dp[0][0] = 0;

    rep(i, s.size()) {
        rep(j, t.size()) {
            if (s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            chmax(dp[i + 1][j + 1], dp[i + 1][j]);
            chmax(dp[i + 1][j + 1], dp[i][j + 1]);
        }
    }

    // 復元
    string res = "";
    int i = s.size(), j = t.size();
    while (i > 0 && j > 0) {
        // (i+1, j)->(i+1, j+1)
        if (dp[i][j] == dp[i][j - 1])--j;
        // (i, j+1)->(i+1, j+1)
        else if (dp[i][j] == dp[i - 1][j])--i;
        // (i, j)->(i+1, j+1)
        else {
            res = s[i - 1] + res;
            --i, --j;
        }
    }
    cout << res << endl;
}

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


Measured memory_bytes: 35584
N = int(input())
def shichigosan(n):
    if n < 10:
        s = {3, 5, 7}
    else:
        s = shichigosan(n//10)
        ss = shichigosan(n//10)
        for i in ss:
            s.add(i*10+3)
            s.add(i*10+5)
            s.add(i*10+7)
    return s

ans = 0
for s in shichigosan(N):
    if s <= N:
        for c in '753':
            if str(s).count(c) == 0:
                break
        else:
            ans += 1
#print(shichigosan(N))
print(ans)


Measured memory_bytes: 7188
#include <iostream>
using namespace std;
int n, m, h[100001], rs = 0;
bool bt[100001] = {};
int main()
{
	ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {cin >> h[i]; bt[i] = 1;}
	for (int i = 0; i < m; i++)
	{
		int u, v; cin >> u >> v;
		if (h[u - 1] >= h[v - 1]) {bt[v - 1] = 0;}
		if (h[v - 1] >= h[u - 1]) {bt[u - 1] = 0;}
	}
	for (int i = 0; i < n; i++) {rs += bt[i];}
	cout << rs << "\n";
	return 0;
}

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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  for (int i=0; i<N; i++) cin >> x.at(i);
  for (int i=0; i<M; i++) cin >> y.at(i);
  if (X >= Y) cout << "War" << endl;
  else {
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if (max(x.at(x.size()-1), X) >= min(y.at(0), Y)) cout << "War" << endl;
    else cout << "No War" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	double n, m, d;
	cin >> n >> m >> d;
	if(d==0){
		cout << (m-1)/n << endl;
	} else {
		cout << setprecision(10);
		cout << 2*(n-d)*(m-1)/n/n << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  ll d,ans;
  	ci(d>>ans);  
  FOR(i,0,n){
    ll a;
    	ci(a);
    FOR(j,0,100){
      if((j*a+1)<=d){
        ans++;
      }
      else{
        break;
      }}}  
  co(ans)
}

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


using namespace std;

int main() {
    int a1,a2,a3;
    cin>>a1>>a2>>a3;
    int ans=2e9;
    ans=min(abs(a2-a1)+abs(a3-a2),ans);
    ans=min(abs(a2-a1)+abs(a3-a1),ans);
    ans=min(abs(a3-a1)+abs(a3-a2),ans);
    ans=min(abs(a3-a1)+abs(a1-a2),ans);
    ans=min(abs(a2-a3)+abs(a1-a2),ans);
    ans=min(abs(a2-a3)+abs(a3-a1),ans);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int Q = scanner.nextInt();
        int[][] abcd = new int[Q][4];
        for (int i = 0; i < Q; i++) {
            abcd[i][0] = scanner.nextInt()-1;
            abcd[i][1] = scanner.nextInt()-1;
            abcd[i][2] = scanner.nextInt();
            abcd[i][3] = scanner.nextInt();
        }

        ArrayList<ArrayList<Integer>> As = new ArrayList<>();
        for(int i=1; i<=M; i++){
            ArrayList<Integer> A = new ArrayList<>();
            A.add(i);
            step(As, A, M, N); 
        }
        int ans = 0;
        for(int i=0; i<As.size(); i++){
            int score = 0;
            ArrayList<Integer> A = As.get(i);
            // System.out.println(A);
            for(int j=0; j<Q; j++){
                if( (A.get(abcd[j][1]) - A.get(abcd[j][0])) == abcd[j][2]){
                    score += abcd[j][3];
                }
            }
            // System.out.println(score);
            ans = Math.max(ans,score);
        }
        System.out.println(ans);
    }
    public static void step(ArrayList<ArrayList<Integer>> As, ArrayList<Integer> A, int M, int N){
        if(A.size() >= N){
            ArrayList<Integer> ac = new ArrayList<Integer>(A);
            As.add(ac);
            return;
        }else{
            int last = A.get(A.size()-1);
            for(int i=last; i<=M; i++){
                ArrayList<Integer> ac = new ArrayList<Integer>(A);
                ac.add(i);
                step(As,ac,M,N);
            }
        }
    }
}

Measured memory_bytes: 64568
import sys, math

def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    a = list(map(int,input().split()))
    ans = 10**9
    for k in range(-100,101):
        temp = 0
        for e in a:
            temp += (k-e)**2
        ans = min(ans,temp)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

class Printable a where
  format :: a -> String

instance Printable Int where
  format = show

instance Printable Integer where
  format = show

instance Printable Double where
  format = show

instance Printable Float where
  format = show

instance Printable Char where
  format = show

instance Printable String where
  format x = x

instance Printable Bool where
  format = show

put :: Printable a => a -> IO ()
put = putStr . format

putLn :: Printable a => a -> IO ()
putLn = putStrLn . format

putList :: Printable a => [a] -> IO ()
putList [a] = put a
putList (a:as) = do
  put a
  putStr " "
  putList as

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  n <- readInt
  if even (product n)
    then put "No"
    else put "Yes"


Measured memory_bytes: 380
s = input()
alf = 'abcdefghijklmnopqrstuvwxyz'
pos = {}
pos_alf = {c:i for i,c in enumerate(alf)}

for i,c in enumerate(s):
    if c not in pos:
        pos[c] = []
    pos[c] = i

# if s == 'zyxwvutsrqponmlkjihgfedcba':
#     print(-1)
#     exit()
# el
if len(s) != 26:
    for c in alf:
        if c not in pos:
            print(s+c)
            exit()

tmp = [pos_alf[s[-1]]]
for i in range(len(s)-1)[::-1]:
    if pos_alf[s[i]] < max(tmp):
        d = [j for j in tmp if j > pos_alf[s[i]]]
        print(s[:i]+alf[min(d)])
        break
    else:
        tmp.append(pos_alf[s[i]])
    # print(tmp)
else:
    print(-1)


Measured memory_bytes: 3064
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const ll &a, const ll &b){
    return abs(a)>abs(b);
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};


int main(){
    IOS;
    make(ll,n);
    vector <ll>dp(n+1);
    dp[0]=1;
    for(ll i=1;i<=n;i++){
        for(ll j=3;j<=i;j++){
            if(i-j==0 || i-j>=3){
                dp[i]+=dp[i-j]; dp[i]%=M;
            }
        }
    }
    cout<<dp[n]<<endl;




    return 0;
}


Measured memory_bytes: 3656
let rec print_rect x =
  let (h,w) = Scanf.scanf "%d %d\n" (fun x y -> (x,y) )in
  match (h,w) with
    (0,0) -> ()
  | (h,w) ->
     for i=1 to h do
       for j=1 to w do
         if i=1 || i= h then print_string "#"
         else
           if j = 1 || j = w then print_string "#"
           else print_string "."
       done;
       print_newline ();
     done;
     print_newline ();
     print_rect x;;
 let () = print_rect ();;

Measured memory_bytes: 2184
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue>
#include <vector>

using namespace std;

#define REP(I,A,B) for(int I = (A); I < (B); ++I)
#define REPN(I,A,B) for(int I = (A); I > (B); --I)
#define MAX(A,B) ((A) > (B) ? (A) : (B));

int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

int rb[200000];
int lb[200000];

int main() {
	int n;
	cin >> n;
	int p[100];
	int b[100] = {0};
	int max = 0;
	REP(i, 0, n) {
		cin >> p[i];
		max = MAX(max, p[i]);
		b[p[i]]++;
	}

	int r;
	int odd = max % 2 ==0;
	if (odd) {
		r = max / 2;
	} else {
		r = max / 2 + 1;
	}

	bool pass = true;
	REP(i, 0, max) {
		if (i<r && b[i] > 0) {
			pass = false;
			continue;
		}
		if (i == r) {
			if (odd && b[i] != 1)
				pass = false;
			if (!odd && b[i] != 2)
				pass = false;
			continue;
		}
		if (i > r && b[i] < 2)
			pass = false;

	}
	string s = pass ? "Possible" : "Impossible";
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
//カタラン数を語らん!w

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
int main() {
	int a, b;
	cin >> a >> b;
	cout << max(0, a - 2 * b) << endl;
}

Measured memory_bytes: 888
# N
# A1 A2 ... An

n = gets.chomp.to_i
as = gets.chomp.split(" ").map(&:to_i)

h = {}

as.each_with_index do |a, i|
  h[a] = i + 1
end

r = (1..n).map do |i|
  h[i]
end

puts r.join(" ")


Measured memory_bytes: 19712
import std.algorithm, std.array, std.conv, std.range, std.stdio, std.string;

void main()
{
immutable n = readln.chomp.to!size_t;
ubyte[][] b;
foreach (i; 0..n)
    b ~= cast(ubyte[])readln.chomp;
size_t ret;
foreach (i; 0..n)
{
    ret += b.sym * n;
    b = b[1..$] ~ b[0];
}
ret.writeln;
}

bool sym(T)(T[][] b)
{
    foreach (i; 0..b.length)
        foreach (j; 0..i)
            if (b[i][j]!=b[j][i]) return false;
    return true;
}

Measured memory_bytes: 4476
// Crt. 2019-12-03  21:31:25
#include <algorithm>
#include <iostream>
#include <cstdio>
#define N 503
using namespace std;

int n, m, x, y, ans[N * 2][N * 2];

int main() {
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n >> m >> x >> y;

    for (int i = x; i <= n; i += x)
        for (int j = y; j <= m; j += y)
            ans[i][j] = - (1000 * (x * y - 1) + 1);

    long long sum = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            sum += ans[i][j] ? ans[i][j] : ans[i][j] = 1000;

    if (sum <= 0) return puts("No"), 0;

    puts("Yes");

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j)
            printf("%d ", ans[i][j]);
        puts("");
    }

    return 0;
}


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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)

pair<int, pair<int, int>> d[334];

int dp[334][334];
int dpw[334][334];

signed main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    d[i] = make_pair(a - 1, make_pair(b - 1, c));
  }
  sort(d, d + m);
  trep(i, m) {
    trep(j, m) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  int p = 0;
  rep(_, n) {
    trep(i, m) {
      trep(j, m) {
        dpw[i][j] = dp[i][j];
      }
    }
    trep(i, m) {
      trep(j, m) {
        dpw[j][p] += dp[i][j];
      }
    }
    trep(i, m) {
      trep(j, m) {
        dpw[i][p] += dp[i][j];
      }
    }
    while(p < m && d[p].first == _) {
      p++;
    }
    trep(i, m) {
      trep(j, m) {
        dp[i][j] = dpw[i][j] % inf;
      }
    }
    rep(q, m) {
      if(d[q].second.first == _) {
        if(d[q].second.second == 1) {
          trep(i, m) {
            trep(j, m) {
              if(!(j <= q)) {
                dp[i][j] = 0;
              }
            }
          }
        }
        else if(d[q].second.second == 2) {
          trep(i, m) {
            trep(j, m) {
              if(!(i <= q && q < j)) {
                dp[i][j] = 0;
              }
            }
          }
        }
        else {
          trep(i, m) {
            trep(j, m) {
              if(!(q < i)) {
                dp[i][j] = 0;
              }
            }
          }
        }
      }
    }
  }
  int ans = 0;
  trep(i, m) {
    trep(j, m) {
      ans = (ans + dp[i][j]) % inf;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 6001
#define INF 1e9
 
struct State{
    int dist,v,cap;
    State(int dist,int v,int cap) 
	: dist(dist),v(v),cap(cap) {}
 
    bool operator > (const State &s)const{
	return dist > s.dist;
    }
};
 
struct Edge{
    int to,dist;
    Edge(int to,int dist) : to(to),dist(dist) {}
};
 
int N,M,cap,src,dst,idx;
set<int> LPG;
vector<Edge> G[MAX];
 
void init(){
    idx = 1;
    LPG.clear();
    for(int i = 0 ; i < MAX ; i++){
	G[i].clear();
    }
}
 
int dijkstra(){
    vector<vector<int> > dist(idx);
    cap *= 10;
  
    for(int i = 0 ; i < idx ; i++){
	dist[i].resize(cap+1);
	for(int j = 0 ; j <= cap ; j++){
	    dist[i][j] = INF;
	}
    }
 
    dist[src][cap] = 0;
 
    priority_queue<State,vector<State>,greater<State> > Q;
    Q.push(State(0,src,cap));
 
    while(!Q.empty()){
	State s = Q.top(); Q.pop();
	int v = s.v,c = s.cap;
     
	if(dist[v][c] < s.dist) continue;
     
	if(v == dst){
	    return dist[v][c];
	}
 
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    Edge e = G[v][i];
	    int nc = (LPG.find(v) != LPG.end()) ? cap : c;
	    if(e.dist <= nc){
		nc -= e.dist;
		if(dist[v][c] + e.dist < dist[e.to][nc]){
		    dist[e.to][nc] = dist[v][c] + e.dist;
		    Q.push(State(dist[e.to][nc],e.to,nc));
		}                           
	    }
	}
    }
    return -1;
}
 
int main(){
    int d;
    string a,b;
   
    while(cin >> N >> M >> cap, N){
	init();
	map<string,int> mp; 
	cin >> a; mp[a] = src = idx++; 
	cin >> a; mp[a] = dst = idx++; 
	for(int i = 0 ; i < N ; i++){
	    cin >> a >> b >> d;
	    if(mp.find(a) == mp.end()){
		mp[a] = idx++;
	    }
	    if(mp.find(b) == mp.end()){
		mp[b] = idx++;
	    }
	    G[mp[a]].push_back(Edge(mp[b],d));
	    G[mp[b]].push_back(Edge(mp[a],d));
	}
	for(int i = 0 ; i < M ; i++){
	    cin >> a;
	    LPG.insert(mp[a]);
	}
	cout << dijkstra() << endl;
    }
    return 0;
}

Measured memory_bytes: 52176
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<pair<string,P>> sp(n);
    REP(i,n){
        cin >> sp[i].first >> sp[i].second.first;
        sp[i].second.first*=-1;
        sp[i].second.second = i;
    }
    sort(all(sp));
    vector<int> res(n);
    REP(i,n){
        put(sp[i].second.second+1);
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

typedef pair <int, int> ii;

const int Maxn = 200005;
const int Maxm = 1048576;

int mn[Maxm][2];
bool ch[Maxm];
int lim[Maxm];
int n;
int a[Maxn];

int Better(int i, int j)
{
	if (i == -1) return j;
	if (j == -1) return i;
	return a[i] < a[j]? i: j;
}

void downOn(int v)
{
	swap(mn[v][0], mn[v][1]);
	ch[v] = !ch[v];
}

void Down(int v)
{
	if (ch[v]) {
		downOn(2 * v); downOn(2 * v + 1);
		ch[v] = false;
	}
}

void Union(int v)
{
	mn[v][0] = Better(mn[2 * v][0], mn[2 * v + 1][0]);
	mn[v][1] = Better(mn[2 * v][1], mn[2 * v + 1][1]);
}

void Create(int v, int l, int r)
{
	lim[v] = n - 1;
	if (l == r) { mn[v][l % 2] = l; mn[v][1 - l % 2] = -1; }
	else {
		int m = l + r >> 1;
		Create(2 * v, l, m); Create(2 * v + 1, m + 1, r);
		Union(v);
	}
}

void Erase(int v, int l, int r, int ind)
{
	if (l == r) a[l] = Maxn;
	else {
		Down(v);
		int m = l + r >> 1;
		if (ind <= m) Erase(2 * v, l, m, ind);
		else Erase(2 * v + 1, m + 1, r, ind);
		Union(v);
	}
}

int getMin(int v, int l, int r, int a, int b, int wh)
{
	if (l == a && r == b) return mn[v][wh];
	else {
		Down(v);
		int m = l + r >> 1;
		int res = -1;
		if (a <= m) res = Better(res, getMin(2 * v, l, m, a, min(m, b), wh));
		if (m + 1 <= b) res = Better(res, getMin(2 * v + 1, m + 1, r, max(m + 1, a), b, wh));
		return res;
	}
}

void Change(int v, int l, int r, int a, int b)
{
	if (l == a && r == b) downOn(v);
	else {
		Down(v);
		int m = l + r >> 1;
		if (a <= m) Change(2 * v, l, m, a, min(m, b));
		if (m + 1 <= b) Change(2 * v + 1, m + 1, r, max(m + 1, a), b);
		Union(v);
	}
}

void UpdateLim(int v, int l, int r, int a, int b, int val)
{
	if (l == a && r == b) lim[v] = min(lim[v], val);
	else {
		int m = l + r >> 1;
		if (a <= m) UpdateLim(2 * v, l, m, a, min(m, b), val);
		if (m + 1 <= b) UpdateLim(2 * v + 1, m + 1, r, max(m + 1, a), b, val);
	}
}

int GetLim(int v, int l, int r, int x)
{
	int res = lim[v];
	if (l < r) {
		int m = l + r >> 1;
		if (x <= m) res = min(res, GetLim(2 * v, l, m, x));
		else res = min(res, GetLim(2 * v + 1, m + 1, r, x));
	}
	return res;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	Create(1, 0, n - 1);
	for (int i = 0; i < n / 2; i++) {
		int A = getMin(1, 0, n - 1, 0, n - 1, 0);
		int lim = GetLim(1, 0, n - 1, A);
		int B = getMin(1, 0, n - 1, A + 1, lim, 1);
		printf("%d %d%c", a[A], a[B], i + 1 < n / 2? ' ': '\n');
		Erase(1, 0, n - 1, A); Erase(1, 0, n - 1, B);
		if (A > 0) UpdateLim(1, 0, n - 1, 0, A - 1, A - 1);
		if (A + 1 < B) {
			UpdateLim(1, 0, n - 1, A + 1, B - 1, B - 1);
			Change(1, 0, n - 1, A + 1, B - 1);
		}
	}
	return 0;
}

Measured memory_bytes: 11776
//#pragma GCC optimize("03,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb           push_back
#define ff           first
#define ss           second
#define gcd(a, b)    __gcd(a, b)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define lllim        2147483648
#define Pi           2*acos(0.0)
#define pii          pair<int,int>
#define pll 	     pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
#define mod          1000000007
#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define filein       freopen("input.txt","r", stdin)
#define D(x)         cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define case		 int t,cas=1;cin>>t;while(t--)
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define rev(i,n,a)   for(int i=n;i>=a;i--)
#define sim 		 template<class T

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

sim > void ckmin(T& a, const T& b) {
    a= b < a? b:a;
}
sim > void ckmax(T& a, const T& b) {
    a= b > a? b:a;
}

///.............................input.................................///
sim > void readvec( std::vector<T>& v, const int n) {
    rep(i,0,n) {
        T p;
        std::cin>>p;
        v.pb(p);
    }
}
///...........................input end...............................///


using namespace std;
using namespace __gnu_pbds;

const int maxn=800005;


void solve()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	
	ll ans=max(a*c, max(b*d, max(a*d, b*c)));
	
	cout<<ans<<endl;
	
}


int main()
{
	
    fast_cin;


   // case
    {
      //  cout<<"Case "<<cas++<<": ";
        solve();
    }

    return 0;
}


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

using namespace std;

int main(){
    int n,count=0;
    string str;
    cin >> n;
    for (int i=1;i<=n;i++){
        str = to_string(i);
        if(str.length()%2!=0){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a,n,sum=0,i=0;
	int counter[26] = {0};
	char number = 0;
	char c = 97;
	while(scanf("%c",&number) != EOF)
	{
		if(number - 'a' < 0)
		{
			sum = number - 'A';
		}
		else
		{
			sum = number - 'a';
		}
		if(sum <= 26 && sum >= 0)
		{
			counter[sum]++;
			i++;
		}
		else
		{
			i++;
		}
	}
	for(a = 0;a < 26;a++)
	{
		printf("%c : %d\n",c,counter[a]);
		c++;
	}
		
	return 0;
}

Measured memory_bytes: 540
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         string s = ReadLine();
         if(s[1] == 'B'){
             WriteLine("ARC");
         }else{
             WriteLine("ABC");
         }
      }
   }
}

Measured memory_bytes: 25640
def examB():
    from collections import deque
    Sa = S(); Sb = S(); Sc = S();
    Sa = deque(Sa); Sb = deque(Sb); Sc = deque(Sc);
    cur = "a"
    while (True):
        if cur=="a":
            if Sa:
                cur = Sa.popleft()
            else:
                ans = "A"
                break
        if cur=="b":
            if Sb:
                cur = Sb.popleft()
            else:
                ans = "B"
                break
        if cur=="c":
            if Sc:
                cur = Sc.popleft()
            else:
                ans = "C"
                break
    print(ans)

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 38768
#include<iostream>
#include<string>
#include<stdio.h>
#include<cstdio>
#include<math.h>
using namespace std;
int main(){
    int S,t,h,s,a,b,c,remain,remain2;
    while(1){
        cin>>t>>h>>s;
        if(t==-1 && h==-1 && s==-1){
            break;
        }
        S=7200;
        remain=S-(t*3600+h*60+s);
        a=remain/3600;
        b=remain/60-a*60;
        c=remain%60;
        printf("%02d:%02d:%02d",a,b,c);
        cout<<endl;
        remain2=remain*3;
        a=remain2/3600;
        b=remain2/60-a*60;
        c=remain2%60;
        printf("%02d:%02d:%02d",a,b,c);
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3160
# coding: utf-8

n, m = map(int, raw_input().split())

def npr(n, r):
    a = 1
    while r != 0:
        a *= n
        n -= 1
        r -= 1
    return a

def ncr(n, r):
    return npr(n, r) // npr(r, r)

print ncr(n, 2) + ncr(m, 2)


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e9)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
int dp[10005][5005];
int c[10]={0,2,5,5,4,5,6,3,7,6};
bool can[10];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		can[x] = 1;
		}
	for(int i=0;i<=n;i++)
	    for(int j=0;j<=5000;j++)
	       dp[i][j] = -1;
	
	int bestj = 0;
	dp[0][0] = 0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=5001;j++)
		{
			for(int k=9;k>0;k--)
			{
				if(!can[k] || i - c[k] < 0)continue;
				{
				   if(dp[i - c[k]][j-1] == -1)continue;
				   dp[i][j] = k;	
				   if(i == n)bestj = max(bestj,j);
				   break;
				}				
			}		
		}	
	}
	while(bestj)
	{
		cout<<dp[n][bestj];
		n-=c[dp[n][bestj]];
		bestj--;
	}
	
}


Measured memory_bytes: 195840
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

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

    for (int i = n - 1; i > 0; i--)
    {
        if (niz[i] >= niz[i - 1])
            continue;
        else if (niz[i] + 1 == niz[i - 1])
            --niz[i - 1];
        else
        {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
}

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

int main() {
  //
  int x = 0;
  string str;
  cin >> str;
  for (int i = 0; i < str.size(); i++) x = (x + str[i] - '0') % 9;
  if (!x)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

using namespace std;

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

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

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

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

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

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

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

  ll N, L;
  cin >> N >> L;
  ll before=0;
  ll index=-1;
  rep(i, 0, N){
    ll tmp;
    cin >> tmp;
    if(before + tmp >= L){
      index=i;
    }
    before = tmp;
  }

  if(index == -1){
    cout << "Impossible\n";
    return 0;
  }

  cout << "Possible\n";

  rep(i, 1, N-index){
    cout << ((N-1-i)+1) << "\n";
  }

  rep(i, 0, index){
    cout << (i+1) << "\n";
  }

  return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    ll a,b,k;
    slll(a,b,k);
    ll mn=min(a,k);
    a-=mn;
    k-=mn;
    mn=min(k,b);
    k-=mn,b-=mn;
    cout<<a<<" "<<b;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t,u;
  int n,i,j;
  cin>>s>>t;
  n=s.length();
  for(i=0;i<n;i++){
    u="";
    for(j=0;j<n;j++) u+=s.at((n-i+j)%n);
    if(t==u) break;
  }
  if(i<n) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(int argc, char **argv)
{
	ll n, q; string str;
	cin >> n >> q >> str;

	vector<ll> ac(n-1, 0);
	for (int i = 0; i < n-1; ++i)
	{
		if (str[i] == 'A' && str[i+1] == 'C')
			++ac[i];
	}

	vector<ll> sum_ac(n, 0);
	for (int i = 1; i < n; ++i) sum_ac[i] = sum_ac[i-1] + ac[i-1];

	for (int i = 0; i < q; ++i)
	{
		int l, r; cin >> l >> r; --l, --r;
		std::cout << sum_ac[r] - sum_ac[l] << std::endl;
	}
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   int q;
   cin >> q;
   string t;
   rep(i, 0, q) {
      int T;
      cin >> T;
      if (T == 1) {
         swap(s, t);
      } else {
         int f;
         char c;
         cin >> f >> c;
         if (f == 1)
            t += c;
         else
            s += c;
      }
   }
   reverse(t.begin(), t.end());
   cout << t + s << endl;
   return 0;
}

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

int main(){
	int m, n, temp2[110][110] = {}, count = 0, temp3[110][110] = {};
	string temp;
	
	cin>>m>>n;
	
	for(int i = 1; i <= m; i++){
		cin>>temp;
		for(int j = 1; j <= n; j++){
			temp3[i][j] = temp[j-1];
		}
	}
	
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++){
			if(i == 1) temp2[i][j] = 1;
			if(temp3[i][j] == 'o'){
				temp2[i][j+1] = 1;
				temp2[i][j-1] = 1;
			} else if(temp3[i][j] == 'x'){
				temp2[i][j+1] = 1;
				temp2[i][j-1] = 1;
				temp2[i+1][j+1] = 1;
				temp2[i+1][j-1] = 1;
				temp2[i-1][j+1] = 1;
				temp2[i-1][j-1] = 1;
				temp2[i+1][j] = 1;
				temp2[i-1][j] = 1;
			}
		}
	}
	
	
		for(int i = 1; i <= m; i++){
			for(int j = 1; j <= n; j++){
				if(temp3[i][j] == '-' && temp2[i][j] != 1) count++;
			//	cout<<temp2[i][j];
			}//cout<<endl;
		}
	
	cout<<count<<endl;
	

	
	return 0;
}



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

using namespace std;

int n, x;

int main()
{
    cin >> n >> x;
    int l = 2 * n - 1;
    if(x == 1 || x == l)
    {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    if(n == 2)
    {
        cout << "1 2 3\n";
        return 0;
    }
    if(x == 2)
    {
        int val;
        val = 1;
        for(int i = 1; i <= n - 3;)
        {
            if(val != l && val != 1 && val != x && val != l - 1)
            {
                cout << val << "\n";
                i++;
            }
            val++;
        }
        cout << l << "\n" << 1 << "\n" << x << "\n" << l - 1 << "\n";
        val = 2 * n - 1;
        for(int i = 1; i <= n - 2;)
        {
            if(val != l && val != 1 && val != x && val != l - 1)
            {
                cout << val << "\n";
                i++;
            }
            val--;
        }
    }
    else
    {
        int val;
        val = 1;
        for(int i = 1; i <= n - 3;)
        {
            if(val != 1 && val != l && val != x && val != 2)
            {
                cout << val << "\n";
                i++;
            }
            val++;
        }
        cout << 1 << "\n" << l << "\n" << x << "\n" << 2 << "\n";
        val = 2 * n - 1;
        for(int i = 1; i <= n - 2;)
        {
            if(val != 1 && val != l && val != x && val != 2)
            {
                cout << val << "\n";
                i++;
            }
            val--;
        }
    }
    return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>

int main() {

  int n,a[100] = {0};
  int i,j,k,l;
  int sum;
  int suma[30];
  j = 0;
  while(1) {
 int max = -1;
  int min = 10001;
   sum = 0;

  scanf("%d",&n);
  if(n == 0){
    break ;}

  for(i=0;i<n;i++) {

    scanf("%d",&a[i]);
    sum = sum + a[i];
    if(min > a[i] ) {
      min = a[i];
    } if( max < a[i]) {
      max  = a[i];
    }
  } 
 sum = (sum-max-min) / (n-2);
 suma[j] = sum;
 j++;

  }

  //  printf("sum = %d\n",sum);
  // printf("max = %d min = %d",max,min);

  for(i = 0; i < j; i++) {

  printf("%d\n",suma[i]);
  
  }

  return 0;

}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int c1=0,c2=0;
    while(n--){
        int x;
        cin>>x;
        if(x%2==0){
            c1++;
            if(x%3==0 || x%5==0)
            c2++;
        }
    }
    if(c1==c2)
    cout<<"APPROVED";
    else
    cout<<"DENIED";
  
    return 0;
}


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

using namespace std;

int main(){
    int k;cin>>k;
    long long val=7;
    val=val%k;
    for(int i=1;i<1e7;i++){
        if(val==0){
            cout << i <<endl;
            return 0;
        }
        val=(val*10+7)%k;
    }
    cout <<-1<<endl;
}


Measured memory_bytes: 3600