akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;


void Main() {
	int N, M; cin >> N >> M;
	vector<vector<int>> g(N, vector<int>());
	REP(i,M) {
		int start, to;
		cin >> start >> to;
		--start; --to;
		g[start].push_back(to);
        g[to].push_back(start);
	}
	vector<bool> seen(N, false);
	auto dfs = [&](auto dfs, int v, int& cnt) -> void {
        seen[v] = true;
		++cnt;

        for (auto e : g[v]) {
            int next_v = e;
            if (seen[next_v]) continue;
            dfs(dfs, next_v, cnt);
        }
    };
	int ans = 1;
	REP(i,N) {
		if (seen[i]) continue;
		int tmp = 0;
		dfs(dfs, i, tmp);
		chmax(ans, tmp);
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 26692
#include <stdio.h>

int main()
{
    int n, checker = 0;
    char string[101] = {0};
    scanf("%d %s", &n, string);

    for (int i = 0; i < n/2; i++)
    {
        if (string[i] != string[i+(n/2)])
        {
            checker = 1;
            break;
        }
    }
    
    if (checker == 0 && n % 2 == 0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1636
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
int g[10][10];
int perm[10];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p][q]=g[q][p]=1;
	}
	for(int i=0;i<a;i++)perm[i]=i;
	int ret=0;
	do{
		if(perm[0]==0){
			bool ok=true;
			for(int i=0;i<a-1;i++)if(!g[perm[i]][perm[i+1]])ok=false;
			if(ok)ret++;
		}
	}while(next_permutation(perm,perm+a));
	printf("%d\n",ret);
}

Measured memory_bytes: 128
face = list(map(int, input().split()))
order = int(input())
for i in range(order) :
  a, b = map(int, input().split())
  if((a == face[0] and b == face[1]) or (a == face[1] and b == face[5]) or (a == face[5] and b == face[4]) or (a == face[4] and b == face[0])) :
    print(face[2])
  elif((a == face[0] and b == face[4]) or (a == face[4] and b == face[5]) or (a == face[5] and b == face[1]) or (a == face[1] and b == face[0])) :
    print(face[3])
  elif((a == face[0] and b == face[2]) or (a == face[2] and b == face[5]) or (a == face[5] and b == face[3]) or (a == face[3] and b == face[0])) :
    print(face[4])
  elif((a == face[1] and b == face[3]) or (a == face[3] and b == face[4]) or (a == face[4] and b == face[2]) or (a == face[2] and b == face[1])) :
    print(face[5])
  elif((a == face[1] and b == face[2]) or (a == face[2] and b == face[4]) or (a == face[4] and b == face[3]) or (a == face[3] and b == face[1])) :
    print(face[0])
  elif((a == face[0] and b == face[3]) or (a == face[3] and b == face[5]) or (a == face[5] and b == face[2]) or (a == face[2] and b == face[0])) :
    print(face[1])


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

int main() {
  int N; cin >> N;
  vector<int> c(N+1);
  vector<int> money = {1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
  c[0] = 0;
  for (int i = 1; i <= N; i++) {
    int num = 100000;
    for (int j = 0; j < 12; j++) {
      if (money[j] <= i) {
        num = min(num,c[i-money[j]]+1);
      }
    }
    c[i] = num;
  }
  
  cout << c[N] << endl;  
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  char x;
  cin>>x;
  if('A'==x)cout<<'T'<<endl;
  if('C'==x)cout<<'G'<<endl;
  if('G'==x)cout<<'C'<<endl;
  if('T'==x)cout<<'A'<<endl; 
}


Measured memory_bytes: 256
#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 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;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> 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; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }



int main() {
	IOS;
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u) {
		a--;
	} else {
		b--;
	}
	put(a, b);
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for(ll i=0;i<(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    V<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll q;cin>>q;
    while(q--){
        ll l,r,k;cin>>l>>r>>k;
        ll cnt=0;
        for(ll i=l;i<r;i++){
            if(a[i]==k)cnt++;
        }
        cout<<cnt<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------













































Measured memory_bytes: 3244
n, m = gets.chomp.split.map(&:to_i)
dir = Array.new(n) { [] }
prev = Array.new(n, -1)
visited = Array.new(n, false)
m.times do |_|
  a, b = gets.chomp.split.map(&:to_i)
  dir[a - 1] << b - 1
  dir[b - 1] << a - 1
end

q = [0]
while !q.empty?
  cur = q.shift
  next if visited[cur]

  visited[cur] = true
  dir[cur].each do |v|
    if v != 0 && prev[v] == -1
      prev[v] = cur
      q << v
    end
  end
end

if prev.count(-1) <= 1
  puts "Yes"
  puts prev[1...n].map {|i| i + 1 }
else
  puts "No"
end


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll x, y;
    cin >> x >> y;

    ll ans = 0;
    if (x <= y)
    {
        if (x * y >= 0)
        {
            ans = y - x;
        }
        else
        {
            ans = abs(abs(x) - abs(y)) + 1;   
        }
    }
    else
    {
        if (x * y > 0)
        {
            ans = abs(abs(x) - abs(y)) + 2;   
        }
        else
        {
            ans = abs(abs(x) - abs(y)) + 1;   
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

static uint64_t gcd(uint64_t a, uint64_t b)
{
	uint64_t temp;

	if (a < b) {
		temp = a;
		a = b;
		b = temp;
	}

	uint64_t r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main()
{
	int32_t N;
	cin >> N;

	vector<int32_t> A(N);
	for (int32_t i = 0; i < N; i++) {
		cin >> A[i];
	}

	vector<int32_t> gcd_forward(N);
	gcd_forward[0] = A[0];
	for (int32_t i = 1; i < N; i++) {
		gcd_forward[i] = gcd(gcd_forward[i - 1], A[i]);
	}

	vector<int32_t> gcd_backward(N);
	gcd_backward[N - 1] = A[N - 1];
	for (int32_t i = N - 2 ; i >= 0; i--) {
		gcd_backward[i] = gcd(A[i], gcd_backward[i + 1]);
	}

	int32_t res = 1;
	for (int32_t i = 0; i < N; i++) {
		int32_t _gcd;
		if (i == 0) {
			_gcd = gcd_backward[1];
		} else if (i == N - 1) {
			_gcd = gcd_forward[N - 2];
		} else {
			_gcd = gcd(gcd_forward[i - 1], gcd_backward[i + 1]);
		}
		res = max(res, _gcd);
	}

	cout << res << endl;

	return 0;
}


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

int main() {
	int N, M, a[1001], b[1001], now, i;
	while (cin >> N >> M, N, M) {
		now = 1;
		for (i = 1; i<=N; i++) {
			cin >> a[i];
		}
		for (i = 1; i<=M; i++) {
			cin >> b[i];
		}
		for (i = 1; i<=M; i++) {
			now += b[i];
			if(now < N)now += a[now];
			if (now >= N) break;
		}
		cout << i << endl;
	}
}

Measured memory_bytes: 1168
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>

using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

typedef pair <string,int> si;

int main()
{
	int n;
	cin >> n;
	map<string, int> S;
	string s;
	rep(i, n) {
		cin >> s;
		S[s] += 1;
	}

	int maxv = 0;

	for (map<string, int>::iterator it = S.begin(); it != S.end(); it++) {
		maxv = max(maxv, it->second);
	}
	for (map<string, int>::iterator it = S.begin(); it != S.end(); it++) {
		if (it->second == maxv)  cout << it->first << endl;
	}
}


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

int main() {
  int N;
  cin>>N;
  vector<tuple<string,int,int>> a(N);
  for(int i=0;i<N;i++){
    cin>>get<0>(a.at(i))>>get<1>(a.at(i));
    get<2>(a.at(i))=i+1;
    get<1>(a.at(i))=100-get<1>(a.at(i));
    
  }
  sort(a.begin(),a.end());
  for(int i=0;i<N;i++){
    cout<<get<2>(a.at(i))<<endl;
  }
  
  
  
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
	int a[10][10]={{'*'},{'.',',','!','?',' '},{'a','b','c'},{'d','e','f'},{'g','h','i'},{'j','k','l'},{'m','n','o'},{'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};
	int n, i,ch,t,cnt=-1;
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++){
		while((ch=getchar())!='\n'){
			if(ch=='0'){
				if(cnt==-1)continue;
				printf("%c",a[t-'0'][cnt%(t>='2' ? t=='9'||t=='7' ? 4 : 3 : 5)]);
				cnt=-1;
			}else{
				t=ch;
				cnt++;
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 568
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let w: f64 = read();
    let h: f64 = read();
    let x: f64 = read();
    let y: f64 = read();
    let multi = if w / 2.0 == x && h / 2.0 == y {
        1
    } else {
        0
    };
    println!("{} {}", w * h / 2.0, multi);
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b + c - max({a, b, c}));
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3604
N=int(input())
S = input()

subS = [0]
for s in (S):
    subS.append(subS[-1]+int(s=="W"))
subS.append(subS[-1])

ans = N
for i in range(N):
    ans = min(ans,subS[i] + (N-(i+1)) - (subS[-1]-subS[i+1]))
print(ans)

Measured memory_bytes: 15516
import math
def plot(x,y):
    print(f'{x:.8f} {y:.8f}')
def koch(n,x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*math.cos(math.radians(60))-(ty-sy)*math.sin(math.radians(60))+sx
    uy=(tx-sx)*math.sin(math.radians(60))+(ty-sy)*math.cos(math.radians(60))+sy
    koch(n-1,x1,y1,sx,sy)
    koch(n-1,sx,sy,ux,uy)
    koch(n-1,ux,uy,tx,ty)
    koch(n-1,tx,ty,x2,y2)
n=int(input())
koch(n,0,0,100,0)
plot(100,0)


Measured memory_bytes: 5776
#include <bits/stdc++.h>
#define cinf(n,x,y,z) for(int i=0;i<(n);i++) cin >> x[i]>>y[i]>>z[i];
typedef long long int ll;
using namespace std;

int main(){
	int n;cin >>n;
	int card[4][13]={{}};
	char a; int b;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		switch(a){
			case 'S':
			card[0][b-1]=1;
			break;
			case 'H':
			card[1][b-1]=1;
			break;
			case 'C':
			card[2][b-1]=1;
			break;
			case 'D':
			card[3][b-1]=1;
			break;
		}
	}
	for(int i=0;i<52;i++){
		switch(i/13){
			case 0:
			if(card[0][i%13]==0) cout << "S" << " " << i+1 << endl;
			break;
			case 1:
			if(card[1][i%13]==0) cout << "H " << i%13+1 << endl;
			break;
			case 2:
			if(card[2][i%13]==0) cout << "C " << i%13+1 << endl;
			break;
			case 3:
			if(card[3][i%13]==0) cout << "D " << i%13+1 << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int N;
    cin>>N;

    vector<int> ps {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};

    vector<int> div(15);
    rep(i, N) {
        int temp = i + 1;
        rep(j, 15) {
            while (temp % ps[j] == 0) {
                temp /= ps[j];
                div[j]++;
            }
        }
    }

    ll ans = 0;
    rep(i, 15) {
        if (div[i] < 2) continue;
        rep(j, 15) {
            if (div[j] < 4 || i == j) continue;
            for (int k = j + 1; k < 15; ++k) {
                if (div[k] < 4 || i == k) continue;
                ans++;
            }
        }
    }
    rep(i, 15) {
        if (div[i] < 14) continue;
        rep(j, 15) {
            if (div[j] < 4 || i == j) continue;
            ans++;
        }
    }
    rep(i, 15) {
        if (div[i] < 24) continue;
        rep(j, 15) {
            if (div[j] < 2 || i == j) continue;
            ans++;
        }
    }
    rep(i, 15) {
        if (div[i] > 73) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_set>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n+1);
    for(int i = 1;i<h.size();i++){
        ll x;
        cin >> x;
        h[i] = x;
    }
    vector<vector<ll>> vec(n+1);
    for(int i = 0;i<m;i++){
        ll x,y;
        cin >> x >> y;
        vec[x].push_back(y);
        vec[y].push_back(x);
    }
    
    ll cnt = 0;
    for(int i =1;i<vec.size();i++){
        if(vec[i].size() == 0){
            cnt++;
            continue;
        }
        bool b = true;
        for(int j = 0;j<vec[i].size();j++){
            if(h[i] <= h[vec[i][j]]){
            b = false;
            break;
            }
        }
        if(b)
        cnt++;
    }
    cout << cnt;
}








Measured memory_bytes: 9812
# coding: utf-8

s=input()
ans=0
p = 2019
n = len(s)
s=s[::-1]
accum=[0]*n
d=dict()
for i in range(n):
    accum[i]=int(s[i])*pow(10,i,p)%p
for i in range(n-1):
    accum[i+1]+=accum[i]
    accum[i+1]%=p
accum[-1]%=p
    #print(accum)
for i in range(n):
    if accum[i] not in d:
        if accum[i]==0:
            ans+=1
        d[accum[i]]=1
    else:
        if accum[i]==0:
            ans+=1
        ans+=d[accum[i]]
        d[accum[i]]+=1
    #print(d)
print(ans)


Measured memory_bytes: 16388
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<stdlib.h>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;


int main(void) {
	int a, b, c, d, e, f;
	int flag = 0;
	int wama = 0, soma = 0;
	int dpwa[31] = {}, dpso[3001] = {};
	double maxi = 0;
	double de;
	cin >> a >> b >> c >> d >> e >> f;

	FOR(i, 0, 30) {
		FOR(t, 0, 30) {
			//cout << i << " " << t << endl;
			if (i*a + t*b > 30) {
				break;
			}
			if ((i*a + t*b) * 100 <= f) {
				dpwa[i*a + t*b] = 1;
				//cout << i*a + t*b << endl;
			}
		}
	}
	//cout << endl;
	FOR(i, 0, 3000) {
		FOR(t, 0, 3000) {
			if (c*i + d*t > f) {
				break;
			}
			/*
			if (dpso[i*c + t*d] == 1) {
			break;
			}
			*/
			if ((i*c + t*d) <= 30 * e) {

				dpso[i*c + t*d] = 1;
				//cout << i*c + t*d << endl;
			}
		}
	}
	//cout << endl;
	FOR(i, 0, 30) {
		FOR(t, 0, 3000) {
			if (dpwa[i] == 1 && dpso[t] == 1 && (t <= i*e) && i * 100 + t <= f) {
				de = ((double)100 * (double)t) / ((double)i*(double)100 + (double)t);
				//cout << de << endl;
				if (maxi < de) {
					wama = i * 100 + t;
					soma = t;
					maxi = de;
					flag++;
					//cout << wama << " " << soma << " " << de << endl;
				}
			}
		}
	}
	if (flag == 0) {
		cout << a * 100 << " " << 0 << endl;
	}
	else {
		cout << wama << " " << soma << endl;
	}

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math
import itertools


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArray = LI()
    ans = 0
    max_sintyou = 0

    for A in AArray:
        if max_sintyou > A:
            sa = max_sintyou-A
            ans += sa
            A += sa

        max_sintyou = max(A, max_sintyou)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 33964
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

vector<int> Prime(int num) {
	vector<int>ret;
	ret.push_back(2);
	ret.push_back(3);
	for (int i = 5; i <= num; i += 6) {
		bool flag = true;
		for (int j = 2; j < ret.size(); j++) {
			if (ret[j] * ret[j] > i)break;
			if (i%ret[j] == 0) {
				flag = false;
				break;
			}
		}
		if (flag)ret.push_back(i);
		flag = true;
		for (int j = 2; j < ret.size(); j++) {
			if (ret[j] * ret[j] > i + 2)break;
			if ((i + 2) % ret[j] == 0) {
				flag = false;
				break;
			}
		}
		if (flag)ret.push_back(i + 2);
	}
	return ret;
}

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

	cin >> N;
	vector<int>v(301);
	for (int i = 1; i <= N; i++) {
		cin >> L >> R;
		v[L] += R;
	}
	auto p = Prime(300);
	vector<int>div(301);
	for (int i = 1; i <= 300; i++) {
		div[i] = i;
		for (auto j : p) {
			if (j < 19)continue;
			if (i%j == 0)div[i] /= j;
		}
	}
	long long int ans = 0;
	for (long long int i = 1; i <= 300; i *= 2) {
		for (long long int j = 1; j <= 300; j *= 3) {
			for (long long int k = 1; k <= 300; k *= 5) {
				for (long long int l = 1; l <= 300; l *= 7) {
					for (long long int m = 1; m <= 300; m *= 11) {
						for (long long int n = 1; n <= 300; n *= 13) {
							for (long long int o = 1; o <= 300; o *= 17) {
								long long int box = i * j*k*l*m*n*o;
								long long int c = 0;
								for (int num = 2; num <= 300; num++) {
									if (box%num==0)c += v[num];
								}
								for (auto num : p) {
									if (num < 19)continue;
									int add = 0;
									for (int a = num; a <= 300; a += num) {
										if(box%(a/num)==0)add += v[a];
									}
									c += max(add, 0);
								}
								ans = max(ans, c);
							}
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}

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

const int C[6] {1, 5, 10, 50, 100, 500,};

int N;
void solve(){
    int ret = 0;
    for(int i = 5; i > -1; --i){
        int t = N/C[i];
        N -= t*C[i];
        ret += t;
    }
    cout << ret << '\n';
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1) {
        cin >> N;
        if(N == 0) break;
        N = 1000 - N;
        solve();
    }
    return 0;
}


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

using namespace std;

int main() {
    double w, h, x, y;
    int isNotOnly;
    double ans;
    cin >> w >> h >> x >> y;
    ans = w * h / 2;
    if (x == w / 2 && y == h / 2)
        isNotOnly = 1;
    else
        isNotOnly = 0;

    printf("%12lf %d\n", ans, isNotOnly);
}


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

typedef pair<int,int> P;

int main() {
  int n;
  cin >> n;
  for(int t=1; t<=n; t++) {
    int a[8][8];
    for(int i=0; i<8; i++) {
      string s;
      cin >> s;
      for(int j=0; j<8; j++) a[i][j]=(int)s[j]-48;
    }
    int x,y;
    cin >> y >> x;
    queue<P> que;
    que.push(P(x-1,y-1));
    while(!que.empty()) {
      P now=que.front();
      que.pop();
      int x=now.first,y=now.second;
      a[x][y]=0;
      for(int i=1; i<=3; i++) {
	if(y-i>=0) {
	  if(a[x][y-i]) que.push(P(x,y-i));
	}
      }
      for(int i=1; i<=3; i++) {
	if(y+i<8) {
	  if(a[x][y+i]) que.push(P(x,y+i));
	}
      }
      for(int i=1; i<=3; i++) {
	if(x-i>=0) {
	  if(a[x-i][y]) que.push(P(x-i,y));
	}
      }
      for(int i=1; i<=3; i++) {
	if(x+i<8) {
	  if(a[x+i][y]) que.push(P(x+i,y));
	}
      }
    }
    cout << "Data " << t << ":" << endl;
    for(int i=0; i<8; i++) {
      for(int j=0; j<8; j++) cout << a[i][j];
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
        double X = scan.nextDouble();
        if(X<=6){
        	System.out.println(1);
        }else if(X<=11){
        	System.out.println(2);
        }else{
        	if(X%11==0){
        		System.out.println((long)(X/11*2));
        	}else if(X%11>6){
        	System.out.println((long)(Math.floor(X/11)*2+2));
        	}else{
        		System.out.println((long)(Math.floor(X/11)*2+1));
        	}
        }
	}
}

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


int main() {

	double N, M;
	cin >> N >> M;
	vector<double> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A.at(i);
	}

	int sum = 0;
	for (int i = 0;i < N;i++) {
		sum += A.at(i);
	}

	int count = 0;
	for (int i = 0;i < N;i++) {
		if (A.at(i) >= ceil(sum / (4 * M)))
			count++;
	}

	if (count >= M)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 256
// Card Game for Two

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());

    int alice = 0;
    int bob = 0;
    // choice
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }

    cout << alice - bob << endl;

    return 0;
}


Measured memory_bytes: 256
z=chomp(readline())
n=length(z)
x=zeros(Int,n)
s,t=copy(x),copy(x)
x=[parse(Int,y) for y in z]
for i=1:n
d=i%2
s[i]=d
t[i]=1-d
end
min(sum(abs(s-x)),sum(abs(t-x)))|>print

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

using namespace std;
#define lint long long


int main() {
    int N;
    cin >> N;
    int cnt = 0;
    for(int i = 0; i < 4; ++i){
        if(N % 10 == 2){
            ++cnt;
        }
            N /= 10;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
/// 10:13 pm 22/08/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)

#include<bits/stdc++.h>

using namespace std;
#define endl '\n'
typedef long long ll;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll h, w, m;
    cin >> h >> w >> m;
    map<pll, bool> check;
    map<ll, ll> x;
    map<ll, ll> y;
    ll mr=0;
    ll mc=0;
    ll r = -1;
    ll c = -1;
    for (ll i = 0; i < m; ++i) {
        ll a, b;
        cin >> a >> b;
        check[mp(a,b)] = true;
        x[a]++;
        y[b]++;
        if (x[a] > mr) {
            r = a;
            mr = x[a];
        }
        if (y[b] > mc) {
            c = b;
            mc = y[b];
        }
        mr = max(mr, x[a]);
        mc = max(mc, y[b]);
    }
    ll ans = 0;
    for (ll i = 1; i <= h; i++) {
        ll temp = x[i] + mc;
        if (check[mp(i, c)]) {
            temp--;
        }
        ans = max(ans, temp);
    }
    for (ll i=1;i<=w;++i) {
        ll temp = y[i] + mr;
        if (check[mp(r, i)]) {
            temp--;
        }
        ans = max(ans, temp);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 97412
#include<set>  
#include<map> 
#include<stack>
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<climits>  
#include<cstring>  
#include<iostream>  
#include<algorithm>  
using namespace std;
#define eps 1
#define MAXN 1000
#define INF 0x3f3f3f3f  
int read(){  
    int f=1,x=0;  
    char c=getchar();  
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}  
    while('0'<=c&&c<='9') x=x*10+c-'0',c=getchar();  
    return f*x;  
}
int main()  
{
	char str[10];
	int a=read(),b=read(),ans=0;
	
	for(int i=a;i<=b;i++)
	{
		bool flag=0;
		sprintf(str,"%d",i);
		for(int j=0;j<int(strlen(str))/2;j++)
			if(str[j]!=str[strlen(str)-j-1]){flag=1;break;}
		if(!flag) ans++;
	}
	printf("%d\n",ans);
    return 0;  
}


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

struct Unionfind {
	vector<int> par;

	Unionfind(int n) {
		par.resize(n);
		for (int i = 0;i < n;i++) {
			par[i] = i;
		}
	}

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

	bool same(int a, int b) {
		return root(a) == root(b);
	}

	void unite(int a, int b) {
		int A = root(a);
		int B = root(b);
		if (A == B)return;

		par[A] = B;
	}
};

int main(void) {
	int i, n, q;
	int c, x, y;
	cin >> n >> q;

	Unionfind u(n);

	for (i = 0;i < q;i++) {
		cin >> c >> x >> y;
		if (c == 0) {
			u.unite(x, y);
		}
		else {
			printf("%d\n",u.same(x, y));
		}
	}

	return 0;
}



Measured memory_bytes: 3332
def insertionSort(A, n, gap):
    cnt = 0
    for i in range(gap, n):
        v = A[i]
        j = i - gap
        while j >= 0 and A[j] > v:
            cnt += 1
            A[j + gap] = A[j]
            j = j - gap
        A[j + gap] = v
    return cnt


def shellSort(A, n):
    if len(A) == 1:
        print(1,1,0,A[0],sep='\n')
        return
    cnt = 0
    G = []
    m = 1
    while (3**m - 1) // 2 < n:
        G.append((3**m - 1) // 2)
        m += 1
    m -= 1
    print(m)
    for i in range(m):
        cnt += insertionSort(A, n, G[m - i - 1])
    print(*G[::-1])
    print(cnt)
    print(*A, sep='\n')

N = int(input())
A = list([int(input()) for i in range(N)])
shellSort(A, N)

Measured memory_bytes: 63156
#include <climits>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int min_cost(vector<int>& costs, int k) {
    const int INF = INT_MAX;
    int size = costs.size();
    vector<int> calc(size, INF);

    calc[0] = 0;
    for (int i = 1; i < size; ++i) {
        for (int j = 1; j <= k; ++j) {
            if (i - j < 0)
                break;
            int c = calc[i - j] + abs(costs[i] - costs[i - j]);
            if (calc[i] > c)
                calc[i] = c;
        }
    }
    return calc[size - 1];
}

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

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

    cout << min_cost(costs, k) << '\n';
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

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

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

struct P {
  ll a,b;
};

int main() {
  int N;
  cin >> N;
  vector<P> X(N);
  rep(i, N) cin >> X[i].a >> X[i].b;
  std::sort(X.begin(), X.end(), [](P l, P r){return l.b<r.b;});

  ll sum_now{};
  bool is_error {false};
  rep(i, N) {
    sum_now += X[i].a;
    if (X[i].b < sum_now) {
      is_error = true;
      break;
    }
  }
  if (is_error == true) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
}


Measured memory_bytes: 3328
using System;
class Program{
	static void Main(){
		const int mod=1000000007;
		int n=int.Parse(Console.ReadLine()),i=0;
		string[] arr=new string[]{Console.ReadLine(),Console.ReadLine()};
		long ans=1;
		bool? b=null;
		while(i<n){
			if(arr[0][i]==arr[1][i]){
				if(b==false){ans=(ans*2)%mod;}
				else if(b==null){ans=(ans*3)%mod;}
				i++;
				b=false;
			}
			else{
				if(b==false){ans=(ans*2)%mod;}
				else if(b==true){ans=(ans*3)%mod;}
				else{ans=(ans*6)%mod;}
				i+=2;
				b=true;
			}
		}
		Console.WriteLine("{0}",ans);
	}
}

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

namespace TemplateAlgorithm
{
    class Program
    {
        public const long Inf = (long)1e18;
        public const double eps = 1e-6;
        public const string alfa = "abcdefghijklmnopqrstuvwxyz";
        public const string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const int MOD = 1000000007;
        
        // c ot i
        static int ToInt(char c) => c - '0';

        static void Main(string[] args)
        {
            int N = IO.ReadInt();
            int[] values = IO.ReadIntArr();
            int[] costs = IO.ReadIntArr();

            long sum = 0;
            for (var i = 0; i< N; i++)
            {
                if (values[i] > costs[i]) sum += values[i] - costs[i];
            }
            WriteLine(sum);
        }

        #region  範囲

        public static bool InRange<T>(T begin, T end, T value) where T : IComparable<T> 
            => value.CompareTo(begin) >= 0 && value.CompareTo(end) <= 0;

        #endregion

        #region MIN,MAX

        /// <summary>
        /// 最大値を返す
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vals"></param>
        /// <returns></returns>
        public static T MaxValue<T>(params T[] vals) => vals.Max();

        /// <summary>
        /// 最小値を返す
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vals"></param>
        /// <returns></returns>
        public static T MinValue<T>(params T[] vals) => vals.Min();
        #endregion
    }

    #region IO

    /// <summary>
    /// IO
    /// </summary>
    public class IO
    {
        public static string ReadStr(bool isTrim = false) => (isTrim) ? ReadLine().Trim() : ReadLine();
        public static int ReadInt() => int.Parse(ReadStr());

        public static long ReadLong() => long.Parse(ReadStr());

        public static decimal ReadDecimal() => decimal.Parse(ReadStr());
        public static double ReadDouble() => double.Parse(ReadStr());
        public static string[] ReadStrArr(char separator = ' ') => ReadLine().Split(separator);
        public static int[] ReadIntArr() => Array.ConvertAll(ReadStrArr(), int.Parse);
        public static long[] ReadLongArr() => Array.ConvertAll(ReadStrArr(), long.Parse);

        public static decimal[] ReadDecimalArr() => Array.ConvertAll(ReadStrArr(), decimal.Parse);
        public static double[] ReadDoubleArr() => Array.ConvertAll(ReadStrArr(), double.Parse);        
    }

    #endregion    
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W,N; cin >> H >> W >> N;
    set<Pii> s;
    vector<vector<int>> block(W);
    vector<Pii> P(N);
    rep(i,N){
        int x,y; cin >> x >> y;
        P[i]={--x,--y};
        s.insert({x,y});
    }
    sort(P.begin(),P.end());
    rep(i,N) block[P[i].second].push_back(P[i].first);
    rep(i,W) block[i].push_back(H);
    int now=0,ans=H;
    rep(i,H){
        chmin(ans,*upper_bound(block[now].begin(),block[now].end(),i));
        if (s.count({i+1,now})) break;
        if (!s.count({i+1,now+1})&&now<W-1) ++now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 22272
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

int main()
{
    double pi = 2.0*asin(1.0); int a,b;double h, m;
    cin >> a >> b >> h >> m;
    int time=h*60+m;
    double kaku=(double(time)/360.0-double(time%60)/30.0);
    kaku=fabs(kaku);
    kaku=min(kaku,2.0-kaku);
    kaku*=pi;
    cout << fixed << setprecision(12);
    cout << sqrt(a*a+b*b-2*a*b*cos(kaku)) << endl;
}


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

#define FOR(i, a, b) for(int i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define INF 1e9+2137
#define all(x) (x).begin(), (x).end()

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 1e5+1;
const int M = 1e9+7;

int n, k, tab[MAX];
bool dp[MAX];
int main()
{
    _upgrade;
    cin>>n>>k;

    dp[0] = 0;
    FOR(i, 0, n)
        cin>>tab[i];
    for(int j = 1; j<=k; ++j)
        FOR(i, 0, n)
        {
            if(j - tab[i] < 0)continue;
            if(!dp[j-tab[i]])
            {
                dp[j] = 1;
                break;
            }
        }

    if(dp[k])
        cout<<"First";
    else
        cout<<"Second";
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  ll L;
  cin >> N >> L;
  ll a[N];
  for(int i = 0; i < N; i++) cin >> a[i];

  int pos = -1; //両端のロープの長さがL以上の箇所
  for(int i = 1; i < N; i++){
    if(a[i-1] + a[i] >= L) pos = i;
  }

  if(pos == -1){
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << endl;
  for(int i = 1; i < pos; i++){
    cout << i << endl;
  }
  for(int i = N - 1; i > pos; i--){
    cout << i << endl;
  }
  cout << pos << endl;

  return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n);
    for(i = 0;i < n;++i){
        cin >> p.at(i);
    }
    sort(all(p));
    ll ans = 0;
    for(i = 0;i < k;++i){
        ans += p.at(i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
x, n = input().split()
pn = map(int,input().split())
ints = [i for i in range(102)]
for p in pn:
  ints[p] = -200

x = int(x)
_min = 200
argmin = -100
for _int in ints:
  if abs(_int - x) < _min:
    _min = abs(_int - x)
    argmin = _int

print(argmin)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
const static int MAX = 20;
const static int DT = 11;
const static int INFTY = 4001;

class Edge{
public:
    int target, cost;
    Edge(int target = 0, int cost = 0) : target(target), cost(cost) {}
};

int G[DT][DT];
const static int dx[4] = {0, -1, 0, 1};
const static int dy[4] = {-1, 0, 1, 0};
char map[MAX][MAX];
int dmap[MAX][MAX];
int dp[DT][(1 << (DT-1))];
std::deque<std::pair<int, int> > dpos;
std::vector<int> ridx;
bool isnoRes, visited[DT];
int W, H, V, ps, len;

void bfs(const std::pair<int, int> &p1, const std::pair<int, int> &p2, const int &idx1,
         const int &idx2) {
    for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) dmap[i][j] = INFTY; }
    dmap[p1.first][p1.second] = 0;
    std::queue<std::pair<int, int> > q;
    q.push(p1);
    int nx, ny;
    while( !q.empty() ) {
        std::pair<int, int> p = q.front(); q.pop();
        if (p == p2) {
            //add elem to graph
            G[idx1][idx2] = G[idx2][idx1] = dmap[p.first][p.second];
            return;

        }
        for (int i = 0; i < 4; i++) {
            nx = p.first + dx[i], ny = p.second + dy[i];
            if (nx >= 0 && nx < H && ny >= 0 && ny < W && map[nx][ny] != 'x' && dmap[nx][ny] == INFTY) {
                dmap[nx][ny] = dmap[p.first][p.second] + 1;
                q.push({nx, ny});
            }
        }
    }
    isnoRes = true;
}

int solve(std::vector<int> &seq) {
    int ans = G[0][seq[0]];
    for (int i = 1; i < ps-1; i++) {
        ans+= G[seq[i-1]][seq[i]];
    }
    return ans;
}


int main() {
    while(1) {
        char tmp[MAX+1];
        std::scanf("%d %d", &W, &H);
        if (W == 0 && H == 0) break;
        ps = 0;
        for (int i = 0; i < H; i++) {
            std::scanf("%s", tmp);
            for (int j = 0; j < W; j++) {
                if (tmp[j] == 'o') { dpos.push_front({i, j}); ps++; }
                else if (tmp[j] == '*') { dpos.push_back({i, j}); ps++; }
                map[i][j] = tmp[j];
            }
        }
        isnoRes = false;
        for (int i = 1; i < ps; i++) {
            bfs(dpos[0], dpos[i], 0, i);
        }
        if (isnoRes) {
            std::printf("%d\n", -1);
        } else {
            for (int i = 1; i < ps-1; i++) {
                for (int j = i+1;  j < ps; j++)
                bfs(dpos[i], dpos[j], i, j);
            }
            len = (1 << ps) - 1;
            std::memset(dp, 0, sizeof (dp));
            for (int i = 1; i < ps; i++) {
                ridx.push_back(i);
            }

            int ans = INFTY;
            do {
                ans = std::min(ans, solve(ridx));
            } while (std::next_permutation(ridx.begin(), ridx.end()));
            std::printf("%d\n", ans);
        }
        ridx.clear();
        dpos.clear();
    }
    return 0;
}



Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  int n;
  ll h,w; cin >> n >> h >> w;
  int ans=0;
  rep(i,n){
    ll a,b; cin >> a >> b;
    if(a>=h&&b>=w) ans++;
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
ll n,xx[10],yy[10];
db ans;
ll dis(int i,int j){
	return (xx[i]-xx[j])*(xx[i]-xx[j])+(yy[i]-yy[j])*(yy[i]-yy[j]); 
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>xx[i]>>yy[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			ans+=sqrt(dis(i,j));
		}
	}
	printf("%.10f\n",(db)2/n*ans);
	return 0;
}


Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,S = MI()
A = [0] + LI()
mod = 998244353

dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1,N+1):
    for j in range(S+1):
        if j >= A[i]:
            dp[i][j] = 2*dp[i-1][j] + dp[i-1][j-A[i]]
            dp[i][j] %= mod
        else:
            dp[i][j] = 2*dp[i-1][j]
            dp[i][j] %= mod

print(dp[-1][-1])


Measured memory_bytes: 135112
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n = int(input())
    As = list(map(int, input().split()))

    for i in range(n):
        if As[i] % 2 == 0:
            if As[i] % 3 != 0 and As[i] %5 != 0:
                print('DENIED')
                return
    print('APPROVED')
                
    return

if __name__ == '__main__':
    main()

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

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

  string stone;
  cin >> stone;
  
  int redcount=0, whitecount=0;
  rep(i,n){
    if(stone.at(i)=='R')redcount++;
    else whitecount++;  
  }

  int stayred=0, staywhite=0;
  rep(i,redcount){
    if(stone.at(i)=='R') stayred++;
  }
  rep(i,whitecount){
    if(stone.at(n-1-i)=='W') staywhite++;
  }

  cout << redcount-stayred;
  
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<long long>a(n+1), sum(n+1);
	vector< vector<long long> > dp(n+1, vector<long long>(n+1, 1e18));
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		dp[i][i] = 0;
		sum[i] = sum[i - 1] + a[i];
	}
	for (int i = 1; i < n; i++)
		for (int j = 1; j + i <= n; j++)
			for (int k = j; k < j + i; k++)
				dp[j][j + i] = min(dp[j][j + i], dp[j][k] + dp[k + 1][j + i] + sum[j + i] - sum[j - 1]);
	cout << dp[1][n] << '\n';
	return 0;
}

Measured memory_bytes: 4848