akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main() {
    int A, B, K;
    std::cin >> A >> B >> K;

    const int max = std::min(A, B);
    int cnt = 0;
    for (int i = max; i > 0; --i) {
        if (A % i == 0 && B % i == 0) {
            ++cnt;
        }
        if (cnt == K) {
            std::cout << i << std::endl;
            return 0;
        }
    }

    return 0;
}


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

int main(){
    long long a,b,k;
    cin >> a >> b >> k;
    if(k<=a){cout << a-k << " " << b << endl;}
    else {cout << 0 << " " << max(b-(k-a),(long long int)0) << endl;}
    return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

r = inp()
print(2 * r * math.pi)

Measured memory_bytes: 31164
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX_N 40
#define INF 1000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string dfs(string s, string t){
    if(s == "()" || t == "()") return "()";
    s.erase(0,1); s.erase(s.size()-1,1);
    t.erase(0,1); t.erase(t.size()-1,1);
    int cnt = 0;
    int i = 1;
    for(; i < s.size(); i++){
        if(s[i] == '(') cnt++;
        if(s[i] == ')') cnt--;
        if(cnt == -1) break;
    }
    string sl = s.substr(0,i+1);
    i += 2;
    int ns = 0;
    for(; i < s.size(); i++){
        if('0' > s[i] || s[i] > '9') break;
        ns = ns*10+s[i]-'0';
    }
    string sr = s.substr(i+1);
    cnt = 0;
    i = 1;
    for(; i < t.size(); i++){
        if(t[i] == '(') cnt++;
        if(t[i] == ')') cnt--;
        if(cnt == -1) break;
    }
    string tl = t.substr(0,i+1);
    i += 2;
    int nt = 0;
    for(; i < t.size(); i++){
        if('0' > t[i] || t[i] > '9') break;
        nt = nt*10+t[i]-'0';
    }
    string tr = t.substr(i+1);
    sr = dfs(sr,tr);
    sl = dfs(sl,tl);
    ns += nt;
    sl.push_back('[');
    sl += to_string(ns);
    sl.push_back(']');
    sl += sr;
    sl.insert(0,"("); sl.insert(sl.size()-1,")");
    return sl;
}

int main(){
    string s,t;
    cin >> s >> t;
    s.insert(0,"("); s.insert(s.size()-1,")");
    t.insert(0,"("); t.insert(t.size()-1,")");
    s = dfs(s,t);
    s.erase(0,1); s.erase(s.size()-1,1);
    cout << s << endl;
}

Measured memory_bytes: 3356
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DZabuton {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<P> vec(n);
      rep(i, n) {
        cin >> vec[i].first >> vec[i].second;
      }
      sort(all(vec), [](P a, P b){ return a.first+a.second < b.first+b.second; });
      vector<ll> dp(n+1, LLONG_MAX/2);
      dp[0] = 0;
      rep(i, n) {
        for(int j=n-1; j>=0; j--) {
          if (vec[i].first >= dp[j]) {
            chmin(dp[j+1], dp[j] + vec[i].second);
          }
        }
      }

      int ret = 0;
      for(int i=1; i<=n; i++) {
        if (dp[i] != LLONG_MAX/2) {
          ret = i;
        }
      }
      cout << ret << endl;

    }
};

signed main() {
  DZabuton solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

using namespace std;

int cnt[26];

int main()
{
  string s; cin >> s;
  for (int i=0; i<s.size(); i++)
  {
    cnt[s[i] - 'a']++;
  }
  for (int i=0; i<26; i++)
  {
    if (cnt[i]%2!=0)
    {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	char tairu[100001];
	int n,i;
	char asdf[100001];
	char jkl[100001];
	int min=0;
	int count=0;
	

	int zerokara=0;
	int itikara=0;
	
	scanf("%s", tairu);
	
	for(i=0; tairu[i]!='\0'; ++i);//i文字


	for(n=0;n<=i;n++){
	    asdf[n]='0';
	    jkl[n]='1';
	    n++;
	}
	
	for(n=1;n<=i;n++){
	    asdf[n]='1';
	    jkl[n]='0';
	    n++;
	}
	

	for(n=0;n<i;n++){
	    if(tairu[n]!=asdf[n])zerokara++;
	    if(tairu[n]!=jkl[n])itikara++;
	    if(tairu[n]=='\0')break;
	}
	/*	printf("tairu %s\n",tairu);
	printf("asdf %s\n",asdf);
		printf("jkl %s\n",jkl);
    printf("zerokara %d\n",zerokara);
	printf("itikara %d\n",itikara);
	*/
	
	if(zerokara<itikara)min=zerokara; else min=itikara;
	
	
	/*
	for(n=0;n<=100000;n++){
	    if(asdf[n]==0)
	}*/

 printf("%d",min);
	
	//printf("%d", min);
	
	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
double pi = acos(-1.0);
const double EPS=1e-9;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define t() ll tt;cin>>tt;while(tt--) 


ll n,m;
vector<vector<ll>>g;
vector<bool>visited;
vector<ll>dist,indegree;
void dfs(ll s)
{
    visited[s]=true;
    for(auto to:g[s]){
        dist[to]=max(dist[to],dist[s]+1);
        indegree[to]--;
        if(indegree[to]==0){
            dfs(to);
        }
    }
}

int main()
{
    fastio;
    ll i,u,v;
    cin>>n>>m;
    g.resize(n+1);
    visited.resize(n+1,0);
    dist.resize(n+1,0);
    indegree.resize(n+1,0);
    for(i=0;i<m;i++)
    {
        cin>>u>>v;
        g[u].push_back(v);
        indegree[v]++;
    }
    for(i=1;i<=n;i++)
        if(!visited[i] && indegree[i]==0)
            dfs(i);

    ll ans=0;
    for(i=0;i<=n;i++) ans=max(ans,dist[i]);
    cout<<ans;
    

    



}

Measured memory_bytes: 14976
S = input()
front = int(S[:2])
back = int(S[2:])


def is_month(num):
    if num >= 1 and num <= 12:
        return True


if is_month(front) and is_month(back):
    print('AMBIGUOUS')
elif is_month(front) and not is_month(back):
    print('MMYY')
elif not is_month(front) and is_month(back):
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 3060
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/** Author: Nicklaus **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define ld long double
#define PI 3.14159265358979324
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<int>
#define frs first
#define snd second
#define pb push_back
#define sz size
#define X real()
#define Y imag()
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(){
	#ifdef LOCAL_JUDGE
        //freopen("in.txt", "rt", stdin);
        //freopen("out.txt", "wt", stdout);
    #endif
	int n;
	cin>>n;
	vector<pair<string,pii> > a(n+1);
	for(int i=1; i<=n; i++){
		string c;
		int s;
		cin>>c>>s;
		a[i] = {c,{s,i}};
	}
	sort(a.begin(),a.end());
	vi f;
	for(int i=1; i<n; i++){
		if(a[i].frs != a[i+1].frs){
			f.pb(i);
		}
	}
	f.pb(n);
	int en = 1;
	for(auto j : f){
		for(int i=j; i>=en; i--){
			cout<<a[i].snd.snd<<endl;
		}
		en = j+1;
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    
    sort(a, a + N, greater<int>());
    int alice = 0;
    int bob =0;
    for(int i=0;i<N;i++){
        if(i%2==0)alice += a[i];
        else bob += a[i];
    }
    cout << alice - bob <<endl;
}

Measured memory_bytes: 256
def e_almost_everywhere_zero():
    def digit_dp(n):  # n は文字列で与える
        """n 以下の非負整数で、0でない数字がちょうど K 個あるような数の個数"""
        digit = len(n)

        # dp[i][j][k]: i 桁目まで見たとき、N 未満が確定しているなら j = 1、
        # していないなら j = 0 とし、0 でない桁が k 個ある
        dp = [[[0] * (K + 2) for j in range(2)] for i in range(digit + 1)]
        dp[0][0][0] = 1
        for i in range(digit):
            for j in range(2):
                for k in range(K + 1):
                    lim = 9 if j == 1 else ord(n[i]) - ord('0')
                    for d in range(lim + 1):
                        # 0 でない桁が K + 1 個以上ある場合を同一視する
                        t = k + int(d != 0)
                        if t >= K + 1:
                            t = K + 1
                        dp[i + 1][j or (d < lim)][t] += dp[i][j][k]
        return sum(dp[digit][j][K] for j in range(2))

    N = input()
    K = int(input())
    return digit_dp(N)

print(e_almost_everywhere_zero())

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

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

        static void Main(string[] args)
        {
            int N = ReadInt();
            int H = ReadInt();
            int W = ReadInt();
            Console.WriteLine((N - H + 1) * (N - W + 1));
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define mod 998244353
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
//#include<bits/stdc++.h>
bool sortbydesc(int a,int b){
	return a>b;
}
bool sortbydesc1(pair<int,int> a,pair<int,int> b){
	return a.first>b.first;
}
struct triple{
	int n1;

	int n2;
	int n3; 
};
struct edge{
	int s;
	int e;
	int w;

};

class Graph 
{ 
	int V; 
	list<int> *adj; 
public: 
	Graph(int V); 
	void addEdge(int v, int w);
	void DFSUtil(int v, bool *visited,std::vector<int> &v1); 
}; 

Graph::Graph(int V) 
{ 
	this->V = V; 
	adj = new list<int>[V]; 
} 

void Graph::addEdge(int v, int w) 
{ 
	adj[v].push_back(w);}

void Graph::DFSUtil(int v, bool *visited,vector<int>&v1) 
{ 
	
	visited[v] = true;
	v1.push_back(v); 
	// cout << v << " "; 

	
	list<int>::iterator i; 
	for(i = adj[v].begin(); i != adj[v].end(); ++i) 
		if(!visited[*i]) 
			DFSUtil(*i, visited,v1); 
} 
// ll dp(ll n,ll k,ll *h,ll *a){
// 	if(n>=k){
// 		return 0;
// 	}
// 	else if(n==k-1){
// 		return a[k-1];
// 	}
// 	else if(n==k-2||n==k-3){
// 		return a[k-2];
// 	}
// 	else if(h[n]==-1){
// 		//return max(a[n]+)

// 	}
// }







int32_t main(){
	int n;
	int wmax;
	cin>>n>>wmax;
	int w[n+1];
	int v[n+1];
	for(int i=1;i<n+1;i++){
		cin>>w[i]>>v[i];
	}
	int dp[n+1][wmax+1];
	for(int i=0;i<n+1;i++){
		dp[i][0]=0;
		//dp[0][i]=0;
	}
	for(int i=0;i<wmax+1;i++){
		dp[0][i]=0;
	}
	for(int i=1;i<n+1;i++){
		for(int j=1;j<wmax+1;j++){
			if(j>=w[i])dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
			else{
				dp[i][j]=dp[i-1][j];

			}

		}
	}
	cout<<dp[n][wmax]<<endl;



	
	return 0;
}

Measured memory_bytes: 79104
s = input().split()
N, M = [int(i) for i in s]
H = [int(h) for h in input().split()]
goods = [True] * N
for m in range(M):
  a, b = [int(i)-1 for i in input().split()]
  if H[a] <= H[b]:
    goods[a] = False
  if H[a] >= H[b]:
    goods[b] = False
print(sum(goods))

Measured memory_bytes: 20044
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, M; cin >> N >> M;
    cout << (N + M) * (N + M - 1) / 2 - N * M << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static String[] str;
	
	public static void main(String[] args) {
		setInput();
		System.out.println(str[getIndexMaxNumSameWords()] + " " + str[getIndexLongestWord()]);
	}
	
	public static void setInput(){
		String input = getLine();
		str = input.split(" ");
	}
	
	private static String getLine(){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		return str;
	}
	
	public static int getIndexLongestWord(){
		int index = 0;
		int maxLength = str[index].length();
		for(int i = 1; i < str.length; i++){
			if(maxLength < str[i].length()){
				maxLength = str[i].length();
				index = i;
			}
		}
		return index;
	}
	
	private static int getNumSameWords(int index){
		int numSameWord = 0;
		for(int i = 0; i < str.length; i++){
			if(str[index].compareToIgnoreCase(str[i]) == 0){
				numSameWord++;
			}
		}
		return numSameWord;
	}
	
	public static int getIndexMaxNumSameWords(){
		int index = 0;
		int maxSameWords = 0;
		for(int i = 0; i < str.length; i++){
			if(maxSameWords < getNumSameWords(i)){
				maxSameWords = getNumSameWords(i);
				index = i;
			}
		}
		return index;
	}
	
	public static String getStr(int index) {
		return str[index];
	}
	
	public static void setStr(String[] str) {
		Main.str = str;
	}
}

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

#define n 100
#define INFTY 200000000
#define BLACK 2
#define WHITE 0
#define GRAY 1

int color[n],M[n][n],d[n],p[n],m;


int prim(void){
  int i,v,mincost,u;


  for(int i= 0;i<m;i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;
 
  while(1){
    mincost = INFTY;
    for(i = 0;i<m;i++){
      if(color[i]!=BLACK && d[i]< mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == INFTY) break;

    color[u] = BLACK;

    for(v = 0;v<m;v++){
      if(color[v]!= BLACK && M[u][v] !=INFTY){
	if(M[u][v] < d[v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  
  int sum = 0;
  for(int i = 0;i<m;i++){
    if(p[i] != -1) sum += M[i][p[i]];
  }
  return sum;
}
  
    

int main(){
  int e;
  

  scanf("%d",&m);

  for(int i = 0;i<m;i++){
    for(int j = 0;j < m;j++){
      scanf("%d",&e);
      M[i][j] = (e == -1)?INFTY:e;
    }
  }

  printf("%d\n",prim());
		       

  return 0;
}



Measured memory_bytes: 1996
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,i,c=0,l,a[200001],s[200001];
map<ll,ll>f;
int main()
{
    cin>>n;
    f[0]=1;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        s[i]=s[i-1]+a[i];
        c+=f[s[i]];
        f[s[i]]++;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// chctxdy
int main(){
	ll n, a, b; cin >> n >> a >> b;
	cout << (n / (a + b) * a) + min(n % (a + b), a) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 1e9
using namespace std;

int main(){
  string S;
  string T;
  
  int count = 0;
  
  cin >> S;
  cin >> T;
  
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) != T.at(i))
      count++;
  }
  
  cout << count << endl;
  
}

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

int main(){
    int N,M;
    cin>>N>>M;
    int A[M][10];
    rep(i,M)rep(j,N)A[i][j]=-1;
    rep(i,M){
        int k;
        cin>>k;
        rep(j,k){
            int s;
            cin>>s;
            A[i][j]=s;
        }
    }
    int p[M];
    rep(i,M){
        int q;
        cin>>q;
        p[i]=q;
    }
    int ans=0;
    for(int bit=0; bit<(1<<N); ++bit){
        int allon=0;
        rep(i, M){
            int on=0;
            rep(j,10){
                if(A[i][j]==-1)break;
                else if(bit&(1<<(A[i][j]-1)))on++;
            }    
            if(on%2==p[i])allon++;
        }
        if(allon==M)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,ans = 0;
    cin >> n;
    map<ll,int> mp;
    for(int i = 0;i < n;i ++){
        ll a;
        cin >> a;
        mp[a] ++;
    }
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(itr->second%2) ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll unsigned long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int mod = 1e9 + 7;
int main()
{
	SPEED
	int arr[3][3];
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin >> arr[i][j];
		}
	}
	int n;
	cin >> n;
	int brr[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> brr[i];
	}

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			bool break_off = false;
			for (int k = 0; k < 3; ++k)
			{
				if (brr[i] == arr[j][k])
				{
					arr[j][k] = 0;
					break_off = true;
					break;
				}
			}
			if (break_off)
			{
				break;
			}
		}
	}

	bool solution_found = false;

	for (int i = 0; i < 3; ++i)
	{
		bool ans_found = true;
		for (int j = 0; j < 3; ++j)
		{
			if (arr[i][j] != 0)
			{
				ans_found = false;
				break;
			}
		}
		if (ans_found)
		{
			cout << "Yes\n";
			return 0;
		}
	}

	for (int i = 0; i < 3; ++i)
	{
		bool ans_found = true;
		for (int j = 0; j < 3; ++j)
		{
			if (arr[j][i] != 0)
			{
				ans_found = false;
				break;
			}
		}
		if (ans_found)
		{
			cout << "Yes\n";
			return 0;
		}
	}

	if (arr[0][0]==0 && arr[1][1]==0 && arr[2][2]==0)
	{
		cout << "Yes\n";
		return 0;
	}

	if (arr[0][2]==0 && arr[1][1]==0 && arr[2][0]==0)
	{
		cout << "Yes\n";
		return 0;
	}


	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<cmath>

using namespace std;

int main() {
   int N, W;
   cin >> N >> W;
   int v[ N ];
   int w[ N ];
   for( int i = 0; i < N; i++ ) {
      cin >> w[ i ] >> v[ i ];
   }
   long **dp = ( long ** ) malloc( N * sizeof( long * ) );
   for( int i = 0; i < N; i++ ) {
      dp[ i ] = ( long * ) malloc( (W + 1 ) * sizeof( long ) );
   }
   for( int i = 0; i < N; i++ ) {
      for( int j = 0; j <= W; j++ ) {
         dp[ i ][ j ] = -1;
      }
   }

   function< long ( int, int ) > getDp;
   getDp = [ & ] ( int cn, int cw ) -> long {
      if( cn < 0 || cw <= 0 ) {
         return 0;
      }
      if( dp[ cn ][ cw ] != -1 ) {
         return dp[ cn ][ cw ];
      }
      dp[ cn ][ cw ] = max(
                        w[ cn ] <= cw ? v[ cn ] + getDp( cn - 1, cw - w[ cn ] ) : 0,
                        getDp( cn - 1, cw ) );
      return dp[ cn ][ cw ];
   };

   cout << getDp( N - 1, W );
   return 0;
}


Measured memory_bytes: 78592
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define NIL -1
#define MAX 251

int main(){
  int *node;
  int a, b, c, h;
  int i;

  scanf("%d", &h);

  node = malloc(sizeof(int)*h + 1);

  for(i = 0; i <= h; i++) node[i] = NIL;

  for(i = 1; i <= h; i++) scanf("%d", &node[i]);

  for(i = 1; i <= h; i++){
    printf("node %d: ", i);
    printf("key = %d, ", node[i]);
    if(i != 1) printf("parent key = %d, ", node[i/2]);
    if(i*2 <= h) printf("left key = %d, ", node[i*2]);
    if(i*2+1 <= h) printf("right key = %d, ", node[i*2+1]);
    
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }


template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}


// 最大公約数を求める(ユークリッドの互除法).
ll gcd (ll x, ll y) {
  if (y > x) swap(x,y);
  if (y == 0) return x;
  return gcd(x%y,y);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  vector<ll> l(n), r(n);
  l[0] = a[0], r[n - 1] = a[n - 1];
  
  for (int i = 1; i < n; ++i) {
    l[i] = gcd(a[i], l[i - 1]);
  }

  for (int i = n - 2; i >= 0; --i) {
    r[i] = gcd(a[i], r[i + 1]);
  }
  // roll(l);
  // roll(r);
  ll mmax = 1, tmp;
  for (int i = 0; i < n; ++i) {
    tmp = 0;
    if (i == 0) tmp = r[i + 1];
    else if (i == n - 1) tmp = l[i - 1];
    else {
      tmp = gcd(l[i - 1], r[i + 1]);
    }
    // debug(tmp);
    chmax(mmax, tmp);
  }

  cout << mmax << endl;
}


Measured memory_bytes: 2688
N,M=map(int,input().split())
dp=[1]*(N+1)
for _ in range(M):
    a=int(input())
    dp[a]=0
for i in range(2,N+1):
    if dp[i]!=0:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[N]%(10**9+7))

Measured memory_bytes: 460020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

void recursive_debug(string) { cerr << endl; }

template<class H,class... T>
void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}

template<class T,class U>
ostream& operator<<(ostream& ost, const pair<T,U> &p) {
    ost << "(" << p.first << ", " << p.second << ")";
    return ost;
}

template<class T>
ostream& operator<<(ostream &ost, const vector<T> &v) {
    ost << "[";
    for(T t : v) ost << t << ",";
    ost << "]";
    return ost;
}

struct State {
    ll score;
    vector<int> last;
    vector<int> types;
    bool operator<(const State& rhs) const {
        return (score < rhs.score);
    }
    bool operator>(const State& rhs) const {
        return (score > rhs.score);
    }
};


int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int D, M = 26;
    cin >> D;
    vector<ll> c(M);
    rep(m,M) cin >> c[m];
    vector<vector<ll>> s(D, vector<ll>(M));
    rep(d,D) rep(m,M) cin >> s[d][m];

    set<State> cur_states = {{0, vector<int>(M, -1), {}}};
    size_t SIZE = 950;

    rep(d,D) {
        set<State> nxt_states;
        for (auto &cur_itr : cur_states) {
            State state = cur_itr;
            ll minus_score = 0;
            rep(i,M) {
                minus_score -= c[i] * (d - state.last[i]);
            }
            rep(m,M) {
                State nxt_state;
                nxt_state.score = state.score + s[d][m] + minus_score + c[m] * (d - state.last[m]);
                nxt_state.last = state.last;
                nxt_state.last[m] = d;
                nxt_state.types = state.types;
                nxt_state.types.push_back(m);
                
                nxt_states.insert(nxt_state);
                if (nxt_states.size() > SIZE) {
                    nxt_states.erase(nxt_states.begin());
                }
            }
        }

        cur_states = std::move(nxt_states);
    }

    for (int t : cur_states.begin()->types) {
        cout << t+1 << endl;
    }
    // debug(cur_states[0].score);

    return 0;
}


Measured memory_bytes: 7348
import java.util.*;class Main{public static void main(String[]z){Scanner s = new Scanner(System.in);z=new String[10];for(int n;(n=s.nextInt())>0;){for(Arrays.fill(z,"");n-->0;)z[s.nextInt()]+="*";for(String y:z)System.out.println(y.length()<1?"-":y);}}}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

/*---------------------------------------------------*/

bool check(string s){
  for(int i=1;i<int(s.size());i++){
    if(s[i]!=s[i-1])return false;
  }
  return true;
}

int solve(char c,string s){
  int cnt=0;
  bool use=true;
  string tmp;
  for(;!check(s);cnt++){
    tmp=s;
    use=true;
    rep(i,s.size()){
      //cout<<"check "<<s[i]<<" "<<tmp[i]<<" "<<tmp[i+1]<<endl;
      if((tmp[i]==c)||(tmp[i+1]==c)){
	s[i]=c;
      }else if(use){
	s.erase(s.begin()+i);
	i--;
	use=false;
      }
    }
    //cout<<s<<endl;
  }
  return cnt;
}

int main(){
  int a[26]={0};
  string s;
  int maxi=-INF;
  char c;
  cin>>s;
  rep(i,26)a[i]=0;
  /*
  rep(i,s.size()){
    a[int(s[i]-'a')]++;
    if(maxi<=a[s[i]-'a']){
      maxi=max(maxi,a[s[i]-'a']);
      c=s[i];
    }
  }
  */
  //cout<<maxi<<endl;
  //rep(i,26)cout<<char('a'+i)<<" "<<a[s[i]-'a']<<endl;
  int ans=INF;
  rep(i,26){
    //cout<<"use: "<<char('a'+i)<<endl;
    ans=min(ans,solve(char('a'+i),s));
    }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main()
{
	int n, x;
	int ans;

	while(1){
		ans = 0;
		cin >> n >> x;
		if ((n == x) && (x == 0))
			break;

		for (int i = 1; i <= n - 2; i++){
			for (int j = i + 1; j <= n - 1; j++){
				int k = x - i - j;
				if ((k > j) && (k <= n))
					ans++;
			}
		}
		cout << ans << endl;
	}

	return 0;
}



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

int main(){
  vector<int> num = {5, 7, 5, 7, 7};
  int n;
  while(std::cin >> n, n){
    vector<string> vs(n);
    for (int i = 0; i < n; i++) std::cin >> vs[i];
    for (int i = 0; i < n; i++) {
    int sum = 0, pos = 0;
      for (int j = i; j < n; j++) {
        sum += vs[j].size();
        if(sum == num[pos])sum = 0, pos++;
        if(pos == 5){
          std::cout << i + 1 << std::endl;
          i = j = 1e9;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3120
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    gen = (float(s) for s in line.split())
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = gen

    if xa1 > xb2 or xa2 < xb1:
        print('NO')
    elif ya1 > yb2 or ya2 < yb1:
        print('NO')
    else:
        print('YES')

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

int main(int argc, char **argv)
{
    int N;
    cin >> N;

    int dpA[N + 1], dpB[N + 1], dpC[N + 1];
    dpA[0] = 0, dpB[0] = 0, dpC[0] = 0;

    for (int i = 1; i < N + 1; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        dpA[i] = a + max(dpB[i - 1], dpC[i - 1]);
        dpB[i] = b + max(dpA[i - 1], dpC[i - 1]);
        dpC[i] = c + max(dpB[i - 1], dpA[i - 1]);
    }

    cout << max({dpA[N], dpB[N], dpC[N]});

    return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC120A
{
    class MainClass
    {

        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            Console.WriteLine(Math.Min(s[1] / s[0], s[2]));

        }
    }
}


Measured memory_bytes: 11220
list_money = [1]
list_money.extend([6**i for i in range(1, 7)])
list_money.extend([9**i for i in range(1, 6)])
list_money = list(set(list_money))
list_money = list(sorted(list_money))

l = len(list_money)
n = int(input())

dp = [[0 for j in range(n+1)] for i in range(l)]
for j in range(n+1):
    dp[0][j] = j

for i in range(1, l):
    num = list_money[i]
    for j in range(1, n+1):
        ij_list = [dp[i-1][j]]
        if j >= num:
            ij_list.append(dp[i][j-num]+1)
        dp[i][j] = min(ij_list)

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

Measured memory_bytes: 28696
n=int(input())
s=list(str(input().split()))
if n%2==1:
  print("No")
else:
  for i in range(int(n/2)):
    if s[2+i]!=s[2+int(n/2)+i]:
      break
  if i==n/2-1:
    if s[2+i]==s[2+int(n/2)+i]:
      print("Yes")
    else:
      print("No")
  else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

template<int M>
class Cyclic {
	using ll = long long;
	int n;
	static ll inv(ll a, ll p) { return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p); }
public:
	Cyclic() : n(0) { ; }
	Cyclic(int m) : n(m) {
		if (n >= M) n %= M;
		else if (n < 0) n = (n % M + M) % M;
	}
	operator int() const { return n; }
	bool operator==(const Cyclic &a) const { return n == a.n; }
	Cyclic operator+=(const Cyclic &a) { n += a.n; if (n >= M) n -= M; return *this; }
	Cyclic operator-=(const Cyclic &a) { n -= a.n; if (n < 0) n += M; return *this; }
	Cyclic operator*=(const Cyclic &a) { n = (ll(n) * a.n) % M; return *this; }
	Cyclic operator+(const Cyclic &a) const { Cyclic res = *this; return res += a; }
	Cyclic operator-(const Cyclic &a) const { Cyclic res = *this; return res -= a; }
	Cyclic operator*(const Cyclic &a) const { Cyclic res = *this; return res *= a; }
	Cyclic operator/(const Cyclic &a) const { return *this * Cyclic<M>(inv(a, M)); }
	Cyclic operator^(int n) const {
		if (n == 0) return Cyclic(1);
		const Cyclic a = *this;
		Cyclic res = (a * a) ^ (n / 2);
		return n % 2 ? res * a : res;
	}
};

template<int M> Cyclic<M> fact(int n, bool sw = true) {
	static vector<Cyclic<M>> v1 = { 1 }, v2 = { 1 };
	if (n >= (int)v1.size()) {
		const int from = v1.size(), to = n + 1024;
		v1.reserve(to);
		v2.reserve(to);
		for (int i = from; i < to; ++i) {
			v1.push_back(v1.back() * Cyclic<M>(i));
			v2.push_back(v2.back() / Cyclic<M>(i));
		}
	}
	return sw ? v1[n] : v2[n];
}

template<int M> Cyclic<M> comb(int a, int b) {
	return fact<M>(a, true) * fact<M>(b, false) * fact<M>(a - b, false);
}

const int mod = 1000000007;
using Mod = Cyclic<mod>;


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	Mod a = 1;
	REP(i, n) a *= i + 1;
	cout << int(a) << endl;
	return 0;
}

Measured memory_bytes: 256
import math
a, b, h, m = list(map(int, input().split()))
ans = 0
h = (h + m / 60) * 30
m = m * 6

if h > m:
    if h - m < 180:
        ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(h - m)))
    elif h - m == 180:
        ans = a + b
    else:
        ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(360 - (h - m))))
elif h == m:
    ans = abs(a-b)
elif h < m:
    if m - h < 180:
        ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(m - h)))
    elif m - h == 180:
        ans = a + b
    else:
        ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(360 - (m - h))))

print(ans)



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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

int main(){
  string S;
  cin >> S;
  using mint = modint<(int)1e9+7>;
  vector<mint> dp(13);
  dp[0] = 1;
  for(auto c : S){
    vector<mint> dp_(13);
    if(c != '?'){
      int t = c - '0';
      for(int i = 0; i < 13; ++i){
        dp_[(i*10+t)%13] += dp[i];
      }
    }else{
      for(int t = 0; t < 10; ++t){
        for(int i = 0; i < 13; ++i){
          dp_[(i*10+t)%13] += dp[i];
        }
      }
    }
    dp = dp_;
  }
  cout << dp[5] << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ff first
#define ss second
#define maxn 1000000007
#define PI 3.14159265358979323846
#define MAX 1000007 
using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    //cout<<fixed<<setprecision(20);
    ll n,m;
    cin>>n>>m;
    std::vector<ll> a;
    vector<ll>::iterator it;
    multiset<ll> s;
    multiset<ll>::iterator it1,it2;
    ll sum=0;
    for (int i = 0; i < n; ++i)
    {
        ll x;
        cin>>x;
        a.pb(x);
        s.insert(x);
        sum+=x;
    }
    //cout<<sum<<endl;
    pair<ll,ll> b[m];
    for (int i = 0; i < m; ++i)
    {
        cin>>b[i].ss>>b[i].ff;
    }
    sort(b,b+m);
    for (int i = m-1; i >=0; i--)
    {
        ll x=0;
        while(*s.begin()<b[i].ff)
        {
            s.erase(s.begin());
            s.insert(b[i].ff);
            x++;
            if(x==b[i].ss)
            {
                break;
            }
        }
    }
    sum=0;
    for (it1=s.begin();it1!=s.end(); it1++)
    {
        sum+=*it1;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 7284
def main():
    N, X, M = map(int, input().split())
    a = X
    r = a
    i = 1
    S = {X: (0, 0)}
    ns = True
    while i < N:
        an = (a * a) % M
        if an == 0:
            break
        if ns and an in S:
            l = S[a][1] - S[an][1] + 1
            skip = (N - i - 1) // l
            r += (r - S[an][0]) * skip
            i += l * skip
            ns = False
        if i >= N:
            break
        a = an
        S[a] = (r, i)
        r += a
        i += 1

    return r

# print("Yes" if main() else "No")
print(main())


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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    
    int n, l;
    cin >> n >> l;
    vi a(n);
    rep (i, n) cin >> a[i];
    pii ma(-inf, -inf);
    rep (i, n - 1) {
        chmax(ma, pii(a[i] + a[i + 1], i));
    }

    if (ma.first < l) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    rep (i, n - 1) {
        if (ma.second == i) break;
        cout << i + 1 << endl;
    }
    rrep (i, n - 1) {
        if (ma.second == i) break;
        cout << i + 1 << endl;
    }
    cout << ma.second + 1 << endl;
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
int n;
int a[51],b[51];
int G[50][50];
int A[50],B[50];
typedef pair<int,int> P;

bool solve(){
  int ca=0,cb=0;
  for(int i=0;i<=n;i++){
    while(a[i]>0){
      A[ca++]=i;
      a[i]--;
    }
    while(b[i]>0){
      B[cb++]=i;
      b[i]--;
    }
  }
  if(ca!=cb||ca!=n)return false;
  
  for(int i=0;i<n;i++){
    vector<P> v;
    for(int j=0;j<n;j++)v.push_back( P(-B[j],j) );
    sort(v.begin(),v.end());
    for(int j=0;j<n;j++){
      int id=v[j].second;
      if(A[i]>0&&B[id]>0&&G[i][id]==0){
        A[i]--;
        B[id]--;
        G[i][id]++;
      }
    }
  }

  for(int i=0;i<n;i++)
    if(A[i]!=0||B[i]!=0)return false;
  return true;
}
int main(){
  cin>>n;
  for(int i=0;i<=n;i++)cin>>b[i];
  for(int i=0;i<=n;i++)cin>>a[i];
  if(solve()){
    cout<<"YES"<<endl;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(j)cout<<' ';
        cout<<G[i][j];
      }
      cout<<endl;
    }
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3112
N, M = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
ans = 0

n = 0
for i in range(2**N):
    nums = [True if n&j != 0 else False for j in [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200]]
    n += 1

    for idx, s_ in enumerate(s):
        x = 0
        for _ in s_[1:]:
            x += nums[_-1]
        if x % 2 != p[idx]:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005

using namespace std;

int n;
ll a[100003];
ll dp[100003];

int rec(int i){
	if(i+2==n)return abs(a[i]-a[i+1]);
	else if(i+1>=n)return 0;
	if(dp[i]>=0)return dp[i];
	dp[i]=min(abs(a[i]-a[i+1])+rec(i+1),abs(a[i]-a[i+2])+rec(i+2));
	return dp[i];
}

int solve(){
    rep(i,0,100003)dp[i]=-1;
	cin>>n;
	rep(i,0,n)cin>>a[i];
	cout<<rec(0)<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 4224
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

struct UnionFind {
  vector<ll> par; // 親ノード
  vector<ll> size; // サイズ

  UnionFind(ll n = 1) {
    init(n);
  }

  void init(ll n = 1) {
    par.resize(n); size.resize(n);
    for (ll i = 0; i < n; ++i) {
      par[i] = i;
      size[i] = 1;
    }
  }

  ll root(ll x) {
    if (par[x] == x) {
      return x;
    }
    else {
      ll r = root(par[x]);
      return par[x] = r;
    }
  }

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (size[x] < size[y]) {
      par[x] = y;
      size[y] += size[x];
    } else {
      par[y] = x;
      size[x] += size[y];
    }
    return true;
  }

  ll getSize(ll x) {
    return size[root(x)];
  }
};

int main() {
  ll N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> vec(M);
  for (ll i = 0; i < M; i++) {
    cin >> vec[i].first >> vec[i].second;
    vec[i].first--;
    vec[i].second--;
  }

  UnionFind uf(N);
  vector<ll> his(M);
  ll cnt = N * (N - 1) / 2;
  for (ll i = M - 1; i >= 0; i--) {
    his[i] = cnt;
    if (uf.issame(vec[i].first, vec[i].second)) {
      continue;
    }
    cnt -= uf.getSize(vec[i].first) * uf.getSize(vec[i].second);
    uf.merge(vec[i].first , vec[i].second);
  }

  for (ll i = 0; i < M; i++) {
    cout << his[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 5248