akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    while(N != 0){
        vector<ll> C(M);
        for(int i=0; i<M; i++){
            cin >> C[i];
        }
        vector<ll> X(N);
        for(int i=0; i<N; i++){
            cin >> X[i];
        }
        vector<vector<ll>> dp(N+1, vector<ll> (256,INF));
        dp[0][128] = 0;
        for(int i=0; i<N; i++){
            for(int j=0; j<=255; j++){
                if(dp[i][j] == INF) continue;
                for(int k=0; k<M; k++){
                    if(C[k] < 0){
                        chmin(dp[i+1][max(0LL,C[k]+j)],dp[i][j]+(max(0LL,C[k]+j)-X[i])*(max(0LL,C[k]+j)-X[i]));
                    }else{
                        chmin(dp[i+1][min(255LL,C[k]+j)],dp[i][j]+(min(255LL,C[k]+j)-X[i])*(min(255LL,C[k]+j)-X[i]));
                    }
                }
            }
        }
        ll ans = INF;
        for(int i=0; i<=255; i++){
            if(dp[N][i] == INF) continue;
            chmin(ans,dp[N][i]);
        }
        cout << ans << enld;
        cin >> N >> M;
    }


    return 0;
}


Measured memory_bytes: 43956
//#i#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T> >;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T> > &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int solve(int n){
	int ret = 0, x,ma = 0,mi = 10000;
	rip(i,n,0){
		cin >> x;
		ret += x;
		chmax(ma,x);
		chmin(mi,x);
	}
	ret -= ma+mi;
	return ret/(n-2);
}

int main(){
	int n;
	cin >> n;
	vector<int> ans(0);
	while(n){
		ans.push_back(solve(n));
		cin >> n;
	}
	rip(i,ans.size(),0) cout << ans[i] << endl;
}


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

int main(){
    int N,K;
    cin>>N>>K;
    int K1=K;
    vector<int> data;
    while(K1>1) {
        int x=K1/2;
        data.push_back(x);
        K1-=x;
    }

    int p=data.size();
    reverse(data.begin(),data.end());

    //for(int i=0;i<p;i++)cout<<data.at(i)<<endl;

    long long sum=0;
    int count=0;
    int soe=1;
    int soemax=1;

    for(int i=0;i<p;i++) soemax*=2;

    for(int i=0;i<p;i++){
        sum+=data.at(i)*soe;
        count+=data.at(i);
        if(N<=count){
            sum-=(count-N)*soe;
            break;
        }
        soe*=2;
    }

    //cout<<soe<<endl;

    //cout<<sum<<endl;

    if(N>=K) sum+=soe*(N+1-K);
    double ans=(double)sum/(soemax*N);
    printf("%.16f", ans);
    cout<<endl;
}

Measured memory_bytes: 256
#8 C - Colorful Leaderboard
N = int(input())
a = list(map(int,input().split()))

seen = [False]*8
cnt = 0
cnt_3200 = 0
for i in a:
    i = i//400
    if i >= 8:
        cnt_3200 += 1
    elif (seen[i] == False):
        cnt += 1
        seen[i] = True
    
if cnt == 0:
    print(1,cnt_3200)
else:
    print(cnt,cnt+cnt_3200)

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

using namespace std;

int n,i,j,t,l,r,m;
bool sieve[100005];
int dp[100005];


int main(){
    //init shieve
	memset(sieve, true, sizeof sieve);
	sieve[0]=sieve[1]=false;
	for(i=2;i<=sqrt(100000);i++){
		if(sieve[i]){
			j=i*i;
			while(j<=100000){
				sieve[j] = false;
				j+=i;
			}
		}
	}
	//init dp
	dp[0]=dp[1]=0;
	for(i=2;i<=100000;i++){
		dp[i]=dp[i-1];
		if(sieve[i]){
			if(sieve[(i+1)/2])
				dp[i]++;
		}
	}
	scanf("%d", &n);
	while(n-- > 0){
		scanf("%d %d", &l, &r);
		printf("%d\n", dp[r]-dp[l-1]);
	}
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    set<string> s;
    rep(i, N){
        string S;
        cin >> S;
        s.insert(S);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 19176
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

//UnionFind木(サイズ有り)
struct UnionFind{
private:
	vector<int> par;
	vector<int> siz;
public:
	void init(int N){ //初期化する O(N)
		par.clear();
		siz.clear();
		for(int i=0; i<N; i++) par.push_back(i);
		for(int i=0; i<N; i++) siz.push_back(1);
	}
	int root(int a){ //親を返す O(α(N))
		if(par[a] == a) return a;
		return par[a] = root(par[a]);
	}
	void unite(int a, int b){ //木を併合する O(α(N))
		int rootA = root(a);
		int rootB = root(b);
		if(rootA == rootB) return;
		if(siz[rootA] < siz[rootB]) swap(rootA, rootB);
		par[rootB] = rootA;
		siz[rootA] += siz[rootB];
	}
	bool same(int a, int b){ //属する木が同じかを返す O(α(N))
		return root(a) == root(b);
	}
	int size(int a){ //その素集合の要素数を返す O(α(N))
		return siz[root(a)];
	}
};

int N, M, K;
int A[100000], B[100000];
int C[100000], D[100000];
UnionFind uf;
int ans[100000];
signed main(){
	cin >> N >> M >> K;
	uf.init(N);
	rep(i, M){
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
		uf.unite(A[i], B[i]);
	}
	rep(i, K){
		cin >> C[i] >> D[i];
		C[i]--; D[i]--;
	}

	rep(i, N){
		ans[i] = uf.size(i);
		ans[i]--;
	}
	rep(i, M){
		if(uf.same(A[i], B[i])){
			ans[A[i]]--;
			ans[B[i]]--;
		}
	}
	rep(i, K){
		if(uf.same(C[i], D[i])){
			ans[C[i]]--;
			ans[D[i]]--;
		}
	}
	rep(i, N){
		if(i != 0) cout << " ";
		cout << ans[i];
	}
	cout << endl;
}

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

int main()
{
    char c;
    cin >> c;

    if ((c == 'a') || (c == 'i') || (c == 'u') || (c == 'e') || (c == 'o'))
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;

    return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ for (T item: v) { cout << item << " "; } cout << endl; }

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

void Main() {
    //code here
    string s = gs;
    vec<char> chars = {'A', 'T', 'C', 'G'};
    int cont = 0;
    int maxcont = 0;
    for(char c: s) {
        if(find(ALL(chars), c) != chars.end()) {
            cont++;
        } else {
            maxcont = max(maxcont, cont);
            cont = 0;
        }
    }
    maxcont = max(maxcont, cont);
    print(maxcont);
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	x := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&x[i])
	}
	dist := 0
	for i := 0; i < N; i++ {
		if y := K - x[i]; y < x[i] {
			dist += 2 * y
		} else {
			dist += 2 * x[i]
		}
	}
	fmt.Println(dist)
}


Measured memory_bytes: 512
#include<stdio.h>

int main( ){

  int H,W,S,T;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0){break;}
    for (S=0;S<H;S++){
      for (T=0;T<W;T++){printf("#");}
      printf("\n");

    }printf("\n"); }
return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <utility>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

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

    cout << (48 - m) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
int main(void)
{
    int n,a[100000], ans=0;
    int cnt=0;
    //unsigned long long int max;
    scanf("%d", &n);
    for(int i =0;i<n;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),asc);
    
    //int now=a[0];

    for(int i=0;i<n;i++){
       
        if(a[i]==a[i+1]){
            cnt++;
        }else{
            cnt++;
            if(a[i]>cnt){
                ans+=cnt;
            }else if(a[i]<cnt){
                ans+=cnt-a[i];
            }
            cnt=0;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 892
import sys
n = int(input())
a =[ [int(c) for c in l.split()] for l in sys.stdin]
a =a[0]
m = 1

if (0 in a)==True:
 m=0
else:
 for i in range(n):
  m*=a[i]
  if m>10**18:
   m=-1
   break

print(m)

Measured memory_bytes: 23572
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sat Jul 20 21:17:55 2019
//
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	arr = append([]int{0}, arr...)

	bs := make([]int, len(arr))
	for i := n; i > 0; i-- {
		num := 0
		for j := i; j <= n; j += i {
			if j%i == 0 {
				num += bs[j]
			}
		}
		if arr[i] != num%2 {
			bs[i] = 1
		}
	}
	ans := make([]int, 0)
	for i := 1; i <= n; i++ {
		if bs[i] == 1 {
			ans = append(ans, i)
		}
	}

	fmt.Println(len(ans))
	for i := range ans {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(ans[i])
	}
	fmt.Println()
}


Measured memory_bytes: 9984
h,w = list(map(int,input().split()))
a = [0] * h
m = [0] * 27
if h == w == 1:
    print('Yes')
    exit()

for i in range(h):
    a[i] = list(input())
    for j in range(w):
        m[ord(a[i][j])-97] += 1
wki = w%2
hki = h%2
whan = int(w/2)
hhan = int(h/2)

m.sort()
m.reverse()

yon = int(whan * hhan)
ni =int(  (wki * hhan) + (hki * whan) )
iti = 0
if wki == 1 and hki == 1:
    iti = 1
flag = 0
for i in range(26):
    if (m[i]%2 == 1 and iti == 0) or (m[i]%2 == 1 and flag == 1):
        print('No')
        exit()
    if m[i]%2 == 1 and flag == 0 and iti == 1:
        flag +=1
        m[i] -= 1
        iti -= 1

for i in range(26):
    while m[i] >=4 and yon > 0:
        m[i] -= 4
        yon -= 1
if yon:
    print('No')
    exit()
m.sort()
m.reverse()
for i in range(26):
    while m[i] >= 2 and ni >0:
        m[i] -= 2
        ni -= 1
if ni :
    print('No')
    exit()

print('Yes')


Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
  int l, a, b, c, d, spent_a, spent_b;

  scanf("%d%d%d%d%d", &l, &a, &b, &c, &d);

  spent_a = a / c;
  if(a%c != 0)
    spent_a += 1;

  spent_b = b / d;
  if(b%d != 0)
    spent_b += 1;

  if(spent_a > spent_b)
    printf("%d\n", l - spent_a);
  else
    printf("%d\n", l - spent_b);

  return 0;
}

Measured memory_bytes: 596
import java.io.*;
import java.util.*;
/**
 * Main
 */
public class Main {
        static Stack<Integer> subset = new Stack<>();
        static String input = "";
        static int stop = 0;
        static int mod  = 1000000007;
        static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
        static HashMap<Integer,Integer> map = new HashMap<>();
        static ArrayList<String> list = new ArrayList<>();
    public static void main(String[] args) {
       MyScanner ms  = new MyScanner();
        int N = ms.nextInt();
        double [] coins = new double[N];
        for(int i=0;i<coins.length;i++)
        coins[i] = ms.nextDouble();
        double [][] dp = new double[N+1][N+1];
        dp[0][0] =1;
        double sum =0;
        for(int i=1;i<=N;i++)
        dp[0][i] = 0;
        int mid = N/2;
        for(int i=1;i<=N;i++){
            for(int col=0;col<=N;col++){
                if(col==0){
                    dp[i][col] = dp[i-1][col]*(1-coins[i-1]);
                }else {
                    //to go hte top left get the value of desciding not and acino doin 
                    //adnd up to fligign the i-1 coin to get head and it own not to do 
                    dp[i][col] = (dp[i-1][col-1]*(coins[i-1]))
                    +(dp[i-1][col]*(1-coins[i-1]));
                    if(i==N&&col>mid)
                    sum+=dp[i][col];
                    
                }
            }
        }
       pw.println(sum);
        pw.flush();
        

    }



    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
    
}

Measured memory_bytes: 107272
#include <bits/stdc++.h>
using namespace std;
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;
}

int main() {
  string s,t;
  cin >> s >> t;
  vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
  for(int i=0;i<s.size();i++){
    for(int j=0;j< t.size();j++){
      if(s.at(i) ==t.at(j)) chmax(dp.at(i+1).at(j+1),dp.at(i).at(j)+1);
      chmax(dp.at(i+1).at(j+1),dp.at(i).at(j+1));
      chmax(dp.at(i+1).at(j+1),dp.at(i+1).at(j));
    }
  }
  
  string ans = "";
  int i = (int)s.size() ,j = (int)t.size();
  while(i > 0 &&j > 0){
    if(dp.at(i).at(j) == dp.at(i).at(j-1)) j--;
    else if(dp.at(i).at(j) == dp.at(i-1).at(j)) i--;
    else{
      ans = s.at(i-1) + ans;
      i--; j--;
    }
  }
  cout << ans << endl;
}
  
      
      




Measured memory_bytes: 35584
N, G = map(int, input().split())
bonus = []
problems = []
for _ in range(N):
    PI, CI = map(int, input().split())
    problems.append(PI)
    bonus.append(CI)


def calc_rest_score():
    total = 0
    for i, pi in enumerate(problems):
        if pi:
            score = (i+1) * 100
            total += score * pi + bonus[i]
    return total


def make_plan(total_problem, total_score, flag):
    """
    :param total_score: ここまでの合計スコア
    :param total_problem: ここまでの合計問題数
    :param flag: 最後のスコア調整実施済みフラグ
    :return: 合計問題数
    """
    if total_score >= G:
        return total_problem

    # print("call ", total_problem, total_score, problems)

    rest_score = calc_rest_score()  # 残り全部解いたら何点になるのか
    if total_score + rest_score < G:
        # もう無理
        return 10000

    for i in range(N - 1, -1, -1):
        pi = problems[i]
        si = (i + 1) * 100
        if pi == 0:
            continue
        else:
            # 1. 全部解く
            problems[i] = 0
            pn1 = make_plan(total_problem + pi,
                            total_score + si * pi + bonus[i],
                            flag)
            problems[i] = pi
            # print("pn1:", pn1)

            # 2. 部分的に解く(ただし最後の調整として)
            if not flag:
                # 1問ずつ減らして結果を比較
                min_pn = 10000  # 多分問題数はmaxでも5500問くらい
                for j in range(pi, -1, -1):  # 1～(pi-1)
                    plus_score = si * j
                    if j == pi:
                        plus_score += bonus[i]
                    problems[i] = 0
                    pn = make_plan(total_problem+j,
                                   total_score+plus_score,
                                   True if j != 0 else flag)
                    # print("test", j, pn)
                    problems[i] = pi
                    if pn < min_pn:
                        min_pn = pn
                pn2 = min_pn
            else:
                pn2 = 10000

            return min(pn1, pn2)
    else:
        # 問題を避けすぎて解けない
        return 10000


print(make_plan(0, 0, False))


Measured memory_bytes: 3064
s=input()

left=0
right=len(s)-1
cnt=0
while left<right:
    if s[left]==s[right]:
        left+=1
        right-=1
    elif s[left]=='x':
        left+=1
        cnt+=1
    elif s[right]=='x':
        right-=1
        cnt+=1
    else:
        print(-1)
        exit(0)
        
print(cnt)

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

int main(){
	int d, n; cin >> d >> n;
	int t[d]; rep(i, d) cin >> t[i];
	int a[n], b[n], c[n]; rep(i, n) cin >> a[i] >> b[i] >> c[i];

	int dp[d][n];
	memset(dp, 0, sizeof(dp));

	rep(i, d)rep(j, n){
		if(!i) {
			if(a[j] <= t[i] && t[i] <= b[j]) dp[i][j] = c[j];
			else dp[i][j] = -1;
		} else if(a[j] <= t[i] && t[i] <= b[j]){
			rep(k, n){
				if(dp[i-1][k] > -1){
					int base = (i == 1) ? 0 : dp[i-1][k];
					dp[i][j] = max(dp[i][j], base + abs(c[k] - c[j]));
				}
			}
		} else dp[i][j] = -1;
	}
	cout << *max_element(dp[d-1], dp[d-1]+n) << endl;

	return 0;
}



Measured memory_bytes: 3240
import * as fs from 'fs';
 
const lines = fs.readFileSync('/dev/stdin', 'utf8').split("\n");
let [h,n] = lines[0].split(" ").map(Number);
let a = lines[1].split(" ").map(Number);

let s = a.reduce((b,c) => b + c);

if (s>=h){
    console.log("Yes");
}
else{
    console.log("No");
}


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

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n) {
		for (int i = 0; i < n; i++) par[i] = i;
	}

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

	bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return false;
		par[x] = y;
		return true;
	}
};

struct edge {
	int u, v;
	long long w;
};

bool operator<(const edge &a, const edge &b) {
	return a.w < b.w;
}

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

	vector<edge> es;
	vector<long long> min_cost(n * 2, 1e10);
	for (int i = 0; i < q; i++) {
		int a, b;
		long long c;
		cin >> a >> b >> c;
		es.push_back({ a, b, c });
		min_cost[a] = min(min_cost[a], c + 1);
		min_cost[b] = min(min_cost[b], c + 2);
		min_cost[a + n] = min(min_cost[a + n], c + 1);
		min_cost[b + n] = min(min_cost[b + n], c + 2);
	}
	
	for (int i = 1; i < n * 2; i++) {
		min_cost[i] = min(min_cost[i], min_cost[i - 1] + 2);
	}

	for (int i = 0; i < n; i++) {
		es.push_back({ i, (i + 1) % n, min_cost[i + n] });
	}
	
	sort(es.begin(), es.end());

	UnionFind uf(n);

	long long ans = 0;
	for (edge e : es) {
		if (uf.unite(e.u, e.v)) {
			ans += e.w;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 12264
import bisect
def main():
    n = int(input())
    li = [int(a) for a in input().split()]
    q = int(input())

    for _ in range(q):
        k = int(input())
        l = bisect.bisect_left(li, k)
        exist = 0

        if 0 <= l <= len(li) - 1:
            if li[l] == k:
                exist = 1

        if 0 <= l - 1 <= len(li) - 1:
            if li[l-1] == k:
                exist = 1

        if 0 <= l + 1 <= len(li) - 1:
            if li[l + 1] == k:
                exist = 1

        print(exist)
main()



Measured memory_bytes: 17212
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

#define eps (1e-10)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(double k){return Point(x*k,y*k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{
    return fabs(x-p.x)<eps && fabs(y-p.y)<eps;
  }
  double dot(Point p){return x*p.x+y*p.y;}
  double det(Point p){return x*p.y-y*p.x;}
};
struct Line{
  Point p1,p2;
  Line(){}
  Line(Point p1, Point p2):p1(p1),p2(p2){}
};
int ccw(Point a,Point b,Point c){
  Point t1=b-a,t2=c-a;
  if(t1.det(t2)> eps) return 1;//counter clockwise
  if(t1.det(t2)< -eps) return -1;//clockwise
  if(t1.dot(t2)< -eps) return 2;//c-a-b online
  if(t1.norm()<t2.norm()) return -2;//a-b-c online
  return 0;//a-c-b online
}
bool intersectSS(Point a,Point b,Point c,Point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}
bool intersectSS(Line l1,Line l2){
  return intersectSS(l1.p1,l1.p2,l2.p1,l2.p2);
}
bool isOrthogonal(Point a,Point b){
  return fabs(a.dot(b))<eps;
}
bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
  return isOrthogonal(a1-a2,b1-b2);
}
bool isParallel(Point a,Point b){
  return fabs(a.det(b))<eps;
}
bool isParallel(Point a1,Point a2,Point b1,Point b2){
  return isParallel(a1-a2,b1-b2);
}
Point CrossPoint(Line l1,Line l2){
    double a=(l1.p2-l1.p1).det(l2.p2-l2.p1);
    double b=(l1.p2-l1.p1).det(l1.p2-l2.p1);
    if(fabs(a)<eps&&fabs(b)<eps) return l2.p1;
    return l2.p1+(l2.p2-l2.p1)*(b/a);
}
int main(){
    int n;
    double xp0,yp0,xp1,yp1,xp2,yp2,xp3,yp3;
    cin>>n;
    while(n--){
        cin>>xp0>>yp0>>xp1>>yp1>>xp2>>yp2>>xp3>>yp3;
        Point p0(xp0,yp0),p1(xp1,yp1),p2(xp2,yp2),p3(xp3,yp3);
        Point ans=CrossPoint(Line(p0,p1),Line(p2,p3));
        cout<<fixed<<setprecision(10)<<ans.x<<" "<<ans.y<<endl;
    }
    return 0;
}


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

int main() {
  string a;
  cin>>a;
  if(a.at(5)=='0'){
    if(a.at(6)>'4'){
      cout <<"TBD"<<endl;
    }
    else{
      cout<<"Heisei"<<endl;
    }
  }
  else{
    cout<<"TBD"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

struct Vec{
    ll x, y;
    Vec(ll _x, ll _y): x(_x), y(_y){}
};
bool operator<(const Vec& l, const Vec& r){
    return atan2(l.y, l.x) < atan2(r.y, r.x);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll x(n), y(n);
    rep(i, n){
        cin >> x[i] >> y[i];
    }
    vi del(n, 0);
    rep(i, n){
        if(x[i] == 0 && y[i] == 0){
            del[i] = 1;
        }
    }
    vector<Vec> v;
    rep(i, n){
        if(!del[i]) v.emplace_back(x[i], y[i]);
    }
    n = SZ(v);
    sort(ALL(v));
    ll ans = 0;
    rep(i, n){
        ll cumx = 0;
        ll cumy = 0;
        rep(j, n){
            ll idx = (i+j)%n;
            cumx += v[idx].x;
            cumy += v[idx].y;
            chmax(ans, cumx*cumx+cumy*cumy);
        }
    }
    cout << sqrt(ld(ans)) << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <conio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	int *colors = new int[n + 1];
	for (int i = 1; i <= n; i++)
		cin >> colors[i];

	int **grid = new int*[h];
	for (int i = 0; i < h; i++)
		grid[i] = new int[w];

	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			grid[i][j] = 0;

	bool side = false; // false for right ; true for left;
	
	int count = 0;
	int pColor = 1;

	for (int i = 0; i < h; i++)
	{
		if (!side)
		{
			for (int j = 0; j < w; j++)
			{
				if (colors[pColor] == 0)
					pColor++;
	

				grid[i][j] = pColor;
				colors[pColor]--;
			}

		}
		else{

			for (int j = w - 1; j >= 0; j--)
			{
				if (colors[pColor] == 0)
					pColor++;
				
				grid[i][j] = pColor;
				colors[pColor]--;
			}
		}
		if (side) side = false;
		else side = true;

	}

	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++)
			cout << grid[i][j] << " ";
		cout << endl;
	}
	//_getch();
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N = Integer.parseInt(sc.next())
    val W = Integer.parseInt(sc.next())
    val wv = new Array[(Long, Long)](N)

    for (i <- 0 until N) {
      wv.update(i, (Integer.parseInt(sc.next()).toLong, Integer.parseInt(sc.next()).toLong))
    }

    println(solve(N, W.toLong, wv))
  }

  def solve(N: Int, W: Long, wv: Array[(Long, Long)]): String = {
    val WV = new Array[(Int, Long)](N)
    val W1 = wv(0)._1

    for (i <- 0 until N) {
      WV(i) = (wv(i)._1.toInt, wv(i)._2)
    }

    val W1s = ((0, 0L) +: WV.filter(a => a._1 == W1)).sorted.reverse
    val W2s = ((0, 0L) +: WV.filter(a => a._1 == W1 + 1)).sorted.reverse
    val W3s = ((0, 0L) +: WV.filter(a => a._1 == W1 + 2)).sorted.reverse
    val W4s = ((0, 0L) +: WV.filter(a => a._1 == W1 + 3)).sorted.reverse

    var Max = 0L
    var n1, n2, n3, n4 = 0
    var v1, v2, v3, v4 = 0L
    for (w1 <- W1s) {
      for (w2 <- W2s) {
        for (w3 <- W3s) {
          for (w4 <- W4s) {
            val Weights = W1 * n1 + (W1 + 1) * n2 + (W1 + 2) * n3 + (W1 + 3) * n4
            val Volumes = v1 + v2 + v3 + v4
            if (Weights <= W) {
              Max = Math.max(Max, Volumes)
            }
            if (w4._1 != 0) {
              n4 += 1
              v4 += w4._2
            }
          }
          if (w3._1 != 0) {
            n3 += 1
            v3 += w3._2
          }
          n4 = 0
          v4 = 0L
        }
        if (w2._1 != 0) {
          n2 += 1
          v2 += w2._2
        }
        n3 = 0
        v3 = 0L
      }
      if (w1._1 != 0) {
        n1 += 1
        v1 += w1._2
      }
      n2 = 0
      v2 = 0L
    }
    Max.toString
  }
}

Measured memory_bytes: 27300
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n,m;
    cin >> n;
    vector<int> t(n);
    for (int i=0; i<n; i++) cin >> t[i];

    int ans = accumulate(t.begin(), t.end(), 0);
    cin >> m;

    int speedup = 0;
    for (int i=0; i<m; i++) {
        int p,x;
        cin >> p >> x;
        cout << ans - (t[p-1] - x) << endl;
    }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val line = readLine()
  if (line != null) {
    val A = Integer.parseInt(line.split(" ")[0])
    val B = Integer.parseInt(line.split(" ")[1])
    val C = Integer.parseInt(line.split(" ")[2])
    val result = C - (A - B)
    if (result >= 0) {
      println(result)
    } else {
      println(0)
    }
  }
}

Measured memory_bytes: 37908
n = int(input())

score = []
for i in range(n):
    score.append(list(map(int, input().split())))

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

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue

            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + score[i][k])

res = dp[n]
print(max(res[0], res[1], res[2]))

Measured memory_bytes: 74840
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

void solve()
{
    ll N;
    cin >> N;
    vvll to(N, vll(0));
    vector<pair<ll,ll>> vertex(N);
    vector<pair<ll,ll>> edge(N-1);
    vll p(N);
    vll C(N);
    vll d(N);
    for1(i,N) {
        vertex[i] = make_pair(0, i); // first=count of edges
        p[i] = i;
    }
    for1(i,N-1) {
        ll a,b;
        cin >> a >> b;
        --a;
        --b;
        to[a].push_back(b);
        to[b].push_back(a);
        edge[i] = make_pair(a,b);
        vertex[a].first += 1;
        vertex[b].first += 1;
    }
    for1(i,N) {
        cin >> C[i];
    }
    sort(C.begin(), C.end());

    for1(i,N) {
        sort(p.begin()+i, p.end(), [&](const ll a, const ll b){
            return vertex[a].first < vertex[b].first;
        });

        /*
        for1(j,N) {
            cout << vertex[p[j]].first << " " << vertex[p[j]].second << " " << p[j] << endl;
        }
        cout << "--" << endl;
        */
        ll vi = p[i];
        d[vi] = C[i];
        for (ll vj: to[vi]) {
            vertex[vj].first--;
        }
        vertex[vi].first = -12345;
    }
    ll ans = 0;
    for1(i,N-1) {
        ans += min(d[edge[i].first], d[edge[i].second]);
    }
    cout << ans << endl;
    for1(i,N) {
        if (i != 0) {
            cout << " ";
        }
        cout << d[i];
    }
    cout << endl;
}

int main()
{
    do {
        solve();
    } while (DEBUG);
}


Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;

int n;
map<int, int>mp;

int f(int n) {
	int ret=0;
	for (auto x : mp) {
		if (x.second >= n) {
			ret++;
		}
	}
	return ret;
}



//素数判定
bool prime(ll n) {
	if (n == 1) {
		return false;
	}
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}


int main() {
	cin >> n;

	rep(i, 2, n + 1) {
		if (prime(i)) {
			int temp = i;
			while (n/temp != 0) {
				mp[i] += n / temp;
				temp *= i;
			}
		}
	}

	cout << f(74) + f(24)*(f(2) - 1) + f(14) * (f(4) - 1) + f(4)*(f(4) - 1)*(f(2)-2) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

const int M=1e3+5;

const int N=1e3+5;

int n,m,dfsNumberCounter,dfn[N],low[N];

bool visited[N],fr[N][N],UNVISITED;

vector<int>adj[N],ans;

vector<int>S;

vector<pair<int,int> >edges;

bool taken[N];

bool ok()
{
    int in[N]={0},out[N]={0};
    for (auto X:edges)
    {
        if (taken[X.first]&&taken[X.second])
        {
            out[X.first]++;
            in[X.second]++;
        }
    }
    for (int i=1;i<=n;i++)
    {
        if (taken[i])
        {
            if (in[i]!=1||out[i]!=1)return 0;
        }
    }
    return 1;
}

void check(vector<int>v)
{
    reverse(v.begin(),v.end());
    for (int i=0;i<v.size();i++)
    {
        taken[v[i]]=1;
        for (int j=i+1;j<v.size();j++)
        {
            taken[v[j]]=1;
            if (fr[v[j]][v[i]])
            {
                if (ok()){
                for (int k=i;k<=j;k++)ans.pb(v[k]);
                return;}
                else break;
            }
        }
        taken[v[i]]=0;
        for (int j=i+1;j<v.size();j++)taken[v[j]]=0;
    }
}

void tarjanSCC(int u)
{
    low[u] = dfn[u] = ++ dfsNumberCounter; // low[u] <= dfn[u]
    S.push_back(u); // stores u in a vector based on order of visitation
    visited[u] = 1; // tis vertex is in stack

    for (auto v : adj[u])
    {
        if (dfn[v] == UNVISITED)
            tarjanSCC(v);

        if (visited[v]) // condition for update, v is in stack
            low[u] = min(low[u], low[v]);
    }

    if (low[u] == dfn[u])   // if this is a root (start) of an SCC
    {
        vector<int>tmp;
        while (1)
        {
            int v = S.back();
            S.pop_back(); // pop v out of the stack
            visited[v] = 0; // mark it as outside the stack
            tmp.pb(v);
            if (u == v)
                break;
        }
        check(tmp);
    }
}

int main()
{
    cin >> n >> m;
    for (int i=0;i<m;i++)
    {
        int u,v;
        cin >> u >> v;
        fr[u][v]=1;
        edges.pb({u,v});
        adj[u].pb(v);
    }
    for (int i=1;i<=n;i++)
    {
        if (dfn[i]==UNVISITED)
        {
            tarjanSCC(i);
            if (ans.size())break;
        }
    }
    if (ans.size()==0)
    {
        cout << -1 << endl;
        return 0;
    }
    cout << ans.size() << endl;
    for (auto X:ans)
    {
        cout << X << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        s: String,
    }
    let r = s.match_indices("R").count();
    let g = s.match_indices("G").count();
    let b = s.match_indices("B").count();
    let mut ans = r * g * b;
    let t = s.as_bytes();

    for i in 0..n {
        let mut l = 1;
        while i + 2 * l < n {
            if t[i] != t[i + l] && t[i + l] != t[i + 2 * l] && t[i + 2 * l] != t[i] { ans -= 1; }
            l += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2156
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)


memo = {}

def solve():
    N,A,B,C,D = map(int,input().split())
    global memo
    memo = {0:0,1:D}
    return process(N,N,A,B,C,D)


def process(M,N,A,B,C,D):
    # if M < 0:
    #     return D * N + 1
    global memo
    if M in memo:
        return memo[M]
    res = process((M-M%2)//2,N,A,B,C,D) + A + (M%2) * D
    res = min(res,process((M+M%2)//2,N,A,B,C,D) + A + (M%2) * D)
    res = min(res,process((M-M%3)//3,N,A,B,C,D) + B + (M%3) * D)
    res = min(res,process((M+3-M%3)//3,N,A,B,C,D) + B + (3-M%3) * D)
    res = min(res,process((M-M%5)//5,N,A,B,C,D) + C + (M%5) * D)
    res = min(res,process((M+5-M%5)//5,N,A,B,C,D) + C + (5-M%5) * D)
    res = min(res,M*D)
    memo[M] = res
    return res


def main():
    T = int(input())

    for i in range(T):
        res = solve()
        print(res)



main()


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int n,a[110],ma,mi=INF,cnt[110];

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

	cin>>n;
	REP(i,n) {
		cin>>a[i];
		ma=max(ma,a[i]);
		cnt[a[i]]++;
	}
	if(ma&1) {
		FOR(i,1,(ma+1)/2) {
			if(cnt[i]!=0) {
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
		if(cnt[(ma+1)/2]!=2) {
			cout<<"Impossible"<<endl;
			return 0;
		}
		FOR(i,(ma+1)/2+1,ma+1) {
			if(cnt[i]<2) {
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
		cout<<"Possible"<<endl;
	}
	else {
		FOR(i,1,ma/2) {
			if(cnt[i]!=0) {
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
		if(cnt[ma/2]!=1) {
			cout<<"Impossible"<<endl;
			return 0;
		}
		FOR(i,ma/2+1,ma+1) {
			if(cnt[i]<2) {
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
		cout<<"Possible"<<endl;
	}

	return 0;
}


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

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

    int n,k,s;
    cin >> n >> k >> s;

    int x = 1e9;
    if(s == 1e9) x = 1e9 - 1;

    for(int i = 0; i < n; i++){
        if(i < k) cout << s << " ";
        else cout << x << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <list>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <ostream>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <iomanip>

#define N 2005
#define INF (1 << 30)
using namespace std;
struct coordinate {
	double x, y;
};
const double PI = 2.0 * acos(0.0);
const double cos60 = cos(PI / 3.0);
const double sin60 = sin(PI / 3.0);
void koch(int n, coordinate p1, coordinate p2)
{
	if (n == 0)
	{
		printf("%.8lf %.8lf\n", p1.x, p1.y);
		return;
	}
	coordinate s, t, u;
	s.x = (2 * p1.x + p2.x) / 3.0;
	s.y = (2 * p1.y + p2.y) / 3.0;
	t.x = (p1.x + 2 * p2.x) / 3.0;
	t.y = (p1.y + 2 * p2.y) / 3.0;
	u.x = (t.x - s.x) * cos60 - (t.y - s.y) * sin60 + s.x;
	u.y = (t.x - s.x) * sin60 + (t.y - s.y) * cos60 + s.y;
	koch(n - 1, p1, s);
	koch(n - 1, s, u);
	koch(n - 1, u, t);
	koch(n - 1, t, p2);
}

int main()
{
	int n;
	cin >> n;
	coordinate p1, p2;
	p1.x = 0.0;
	p1.y = 0.0;
	p2.x = 100.0;
	p2.y = 0.0;
	koch(n, p1, p2);
	printf("%.8lf %.8lf\n", p2.x, p2.y);
	return 0;
}

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

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

    vector<vector<int>> vecPoint(n);
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            int x;
            cin >> x;
            vecPoint[i].push_back(x);
        }
    }

    int ans = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            double dist = 0;
            for(int k=0; k<d; k++)
                dist += pow(vecPoint[i][k] - vecPoint[j][k], 2);
            dist = sqrt(dist);

            int dist_int = dist;
            if(dist == dist_int)
                ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void _run(){
    string s,t;
    cin>>s>>t;
    int n= sz(s);
    int mn = 1e9;
    for(int i=0;i<n-sz(t)+1;i++){
        int cnt =0;
        for(int j=0;j<sz(t);j++){
            if(s[i+j]!=t[j]){
                cnt++;
            }
        }
        mn = min(mn,cnt);
    }
    cout<<mn;
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    vector<string> S(n);
    cin >> S;
    int ans = 0;
    REP(i, n) {
        int tmp = 0;

        bool same = true;
        REP(j, n) {
            REPF(k, j + 1, n) {
                if (S[j][(k + i) % n] != S[k][(j + i) % n]) same = false;
            }
        }
        if (same) ans += n;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
ll a[1000000+9];
using namespace std;
int main()
{
    ll n,i,s=0,r=0,x=99999999999999,d,total=0;

    cin>>n;

    for(i=0; i<n; i++)
    {
        cin>>a[i];
        total+=a[i];
    }

    s=a[0];

    for(i=1; i<n; i++)
    {
        r=total-s;
        d=(s-r);
        if(d<0)
        {
            d*=-1;
        }
        x=min(x,d);
        s+=a[i];
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define mod 1e18+10
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int32_t main() {
	int n,a,b;
	string s;
	cin>>n>>a>>b;
	cin>>s;
	for(auto c:s)
	{
		if(c=='c')
			cout<<"No\n";
		else if(c=='a')
		{
			if(a+b)
			{	cout<<"Yes\n";
				a--;
			}
			else cout<<"No\n";
		}
		else 
		{
			if(a+b && b)
			{	cout<<"Yes\n";
				b--;
			}
			else cout<<"No\n";
		}
	}
}	


Measured memory_bytes: 896
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N,M;
signed main(){
    scanf("%lld %lld",&N,&M);
    int ans=N*M;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1728