akhauriyash/Code-Regression huggingface dataset:
from math import sqrt
while 1:
    try:
        en=map(int,raw_input().split())
        w=en[0]
        r=en[1:]
        lr=len(r)

        dp=[[float('inf')]*lr for _ in xrange(1<<lr)]
        for i in xrange(lr):
            dp[1<<i][i]=r[i]
        for i in xrange(1<<lr):
            for j in xrange(lr):
                if i>>j&1:
                    for k in xrange(len(dp[i^(1<<j)])):
                        dp[i][j]=min(dp[i][j],dp[i^(1<<j)][k]+2*sqrt(r[k]*r[j]))

        ans=float('inf')
        for i in xrange(lr):
            ans=min(ans,dp[(1<<lr)-1][i]+r[i])
        if ans<=w:
            print('OK')
        else:
            print('NA')
    except:break

Measured memory_bytes: 8620
/* ex 9_2
   ruuu0048 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 100001

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    char tower[SIZE];
    int count =0;
    //最初のノードの指す先
    node *first = NULL;
    scanf("%s",tower);
    for(int i =0;i < strlen(tower);i++){
        if(first == NULL || first->elem == tower[i]){//スタックが空のときと同じ色のとき
            push(&first,tower[i]); //積む
        }
        else{ //違う色のとき
            //取り除く
            pop(&first);
            //数える
            count += 2;
        }
    }
    printf("%d\n",count);
    
    return 0;
}


Measured memory_bytes: 4880
#include <iostream>
#include <string>
#include <vector>

#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    fastIO;
    int a, b;
    cin >> a >> b;
    if(a > b) {
      cout << "a > b" << endl;
    } else if(a == b) {
      cout << "a == b" << endl;
    } else {
      cout << "a < b" << endl;
    }
}



Measured memory_bytes: 3132
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        public class Node
        {
            public int key;
            public Node parent;
            public Node left;
            public Node right;
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Node rootNode = null;
            for(int i=0;i<n;++i)
            {
                string[] szarr = Console.ReadLine().Split(' ');
                if (szarr[0] == "print")
                {
                    InOrder(rootNode);
                    Console.WriteLine();
                    PreOrder(rootNode);
                    Console.WriteLine();
                }
                else if( szarr[0] == "find")
                {
                    int key = int.Parse(szarr[1]);
                    Node fount = Find(rootNode, key);
                    if( fount != null)
                    {
                        Console.WriteLine("yes");
                    }else
                    {
                        Console.WriteLine("no");
                    }
                }
                else
                {
                    int key = int.Parse(szarr[1]);
                    var z = new Node();
                    z.key = key;
                    Insert(ref rootNode, z);
                }
            }

        }
        static Node Find (Node p, int k)
        {
            while( p != null && k != p.key)
            {
                if( k < p.key)
                {
                    p = p.left;
                }else
                {
                    p = p.right;
                }
            }
            return p;
        }
        static void Insert(ref Node rootNode, Node z)
        {
            Node y = null;

            Node x = rootNode;
            while(x != null)
            {
                y = x;
                if( z.key < x.key)
                {
                    x = x.left;
                }else
                {
                    x = x.right;
                }
            }
            z.parent = y;
            if(y == null)
            {
                rootNode = z;
            }else if( z.key < y.key)
            {
                y.left = z;
            }else
            {
                y.right = z;
            }
        }

        static void PreOrder(Node p)
        {
            if( p == null) { return; }
            Console.Write(" " + p.key);
            PreOrder(p.left);
            PreOrder(p.right);
        }
        static void InOrder(Node p)
        {
            if( p == null) { return; }
            InOrder(p.left);
            Console.Write(" " + p.key);
            InOrder(p.right);
        }
    }

}



Measured memory_bytes: 39180
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,x,c[20],a[20][20],maxa,flg=0,use[20],leastmoney=0x7ffffff;
void check();
bool ach();
void dfs(int x)
{
	if(x==n+1) 
	{
		check();
		return;
	}
	dfs(x+1);
	use[x]=1;
	dfs(x+1);
	use[x]=0;
}
void check()
{
 	if(!ach()) return;
 	int money=0;
	for(int i=1;i<=n;i++) if(use[i]) money+=c[i];
	leastmoney=min(money,leastmoney);
}
bool ach()
{
	int sum[20];
	for(int i=1;i<=m;i++) sum[i]=0;
	for(int i=1;i<=n;i++)
	{
		if(use[i]){
			for(int j=1;j<=m;j++) sum[j]+=a[i][j];
		}
	}
	for(int i=1;i<=m;i++) if(sum[i]<x) return false;
	return true;
}
int main()
{
//	freopen("1.txt","r",stdin);
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	dfs(1); 
	if(leastmoney==0x7ffffff) printf("-1");
	else cout<<leastmoney;
} 

Measured memory_bytes: 3740
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long a = long.Parse(input[1]);
  	long b = long.Parse(input[2]);
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long answer = 0;

    for(int i = 1; i < n; i++)
    {
      if((nums[i] - nums[i-1])*a < b) answer += (nums[i] - nums[i-1])*a;
      else answer += b;
    }
    
		Console.WriteLine(answer);
	}
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	llong N;
	vector<llong> A;

	cin >> N;
	A.resize(N);
	for (auto &in: A) {
		cin >> in;
	}

	llong ans = 0;
	llong now = 1;
	llong ok = 0;
	for (auto a: A) {
		if (a == now) {
			++now;
		} else {
			++ans;
		}
	}

	if (now == 1) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[]A = new int[N+1];

		for (int i=1; i<=N; i++){
			A[i] = sc.nextInt();
		}

		int Ans[] = new int[N+1];
		int AnsCnt=0;
		for (int i=N; i>0; i--){
			int tmp=0;
			for (int j=i*2; j<=N; j=j+i){
				tmp += Ans[j];
			}
			if ((tmp % 2) != A[i]){
				Ans[i] = 1;
				AnsCnt++;
			}
		}
		System.out.println(AnsCnt);
		for (int i=1; i<Ans.length; i++){
			if (Ans[i] == 1){
				System.out.println(i);
			}
		}
	}


}

Measured memory_bytes: 64640
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    string s;
    cin >> n;
    vector<string> st;
    vector<string> ed;
    ll sum(0);
    vector<pair<int, string> > mi;
    int i;
    rep(i, n) {
        cin >> s;
        int rn(0), re(0);
        int j;
        int balance(0);
        int now(0);
        rep(j, sz(s)) {
            if (s[j] == '(') sum++;
            else sum--;
        }
        rep(j, sz(s)) {
            if (s[j] == '(') now++;
            else now--;
            rn = min(rn, now);
        }
        balance = now;
        now = 0;
        for (j = sz(s)-1; j >= 0; j--) {
            if (s[j] == ')') now++;
            else now--;
            re = min(re, now);
        }
        if (rn == 0) {
            st.push_back(s);
        } else if (re == 0) {
            ed.push_back(s);
        } else {
            // mi.push_back({{rn, re}, balance});
            mi.push_back({-balance, s});
        }
    }
    ll r(0), l(0);
    vector<string> w;
    rep(i, sz(st)) w.pb(st[i]);
    sort(mi.begin(), mi.end());
    rep(i, sz(mi)) w.pb(mi[i].second);
    rep(i, sz(ed)) w.pb(ed[i]);
    rep(i, sz(w)) {
        string s(w[i]);
        int j;
        rep(j, sz(s)) {
            if (s[j] == '(') r++;
            else r--;
            if (r < 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    if (r != 0) {
        cout << "No" << endl;
        return 0;
    }
    for (i = sz(w)-1; i>=0;i--) {
        string s(w[i]);
        int j;
        for (j = sz(s)-1; j >= 0; j--) {
            if (s[j] == ')') l++;
            else l--;
            if (l < 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 78612
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

int prime[1000010];
bool isPrime[1000010];
int sum[1000010];
void sieve(int n){
    rep(i, 0, n) isPrime[i] = true;
    int now = 0;
    isPrime[0] = isPrime[1] = false;
    rep(i, 2, n){
        if(isPrime[i]){
            prime[now++] = i;
            for(int j = 2 * i; j < n; j += i) isPrime[j] = false;
        }
    }
    return;
}

signed main(){
    sieve(1000000);
    rep(i, 1, 1000000){
        sum[i] += sum[i - 1];
        if(isPrime[i]) sum[i]++;
    }
    int n;
    while(cin >> n){
        cout << sum[n] << endl;
    }
}

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

void swap(int &x, int &y) {
    x ^= y; y ^= x; x ^= y;
}

int main(void) {
    int select; scanf("%d", &select);
    int amida[select + 1];
    for(int r = 1; r <= select; r++) amida[r] = r;
    int horizon; scanf("%d", &horizon);
    for(int r = 0; r < horizon; r++) {
        int x, y; scanf("%d,%d", &x, &y);
        swap(amida[x], amida[y]);
    }
    for(int r = 1; r <= select; r++)cout << amida[r] << endl;
    return(0);
}

Measured memory_bytes: 1208
L = input()
n = len(L)
csum_1 = [0] * n
csum_0 = [0] * n
now1 = 0
now0 = 0
for i in range(n):
    if L[i] == '1':
        now1 += 1
    else:
        now0 += 1
    csum_1[i] = now1
    csum_0[i] = now0

mod = 10**9+7
ans = 0
# iは、「最初にL[i]=1かつai=0かつbi=0となるindex」
for i in range(n):
    if L[i] == '1':
        p = 1
        # 自分より左側の0の度に2パターン増加
        if i >= 1:
            p *= pow(2,csum_1[i-1],mod)
        #print(p)
        # 自分より右側はどの桁も3パターン増加
        p *= pow(3,n-i-1,mod)
        #print(p)
        ans += p
        ans %= mod
# L=a+bの場合
p = pow(2,csum_1[-1],mod)
#print(p)
ans = (ans+p)%mod
print(ans)

Measured memory_bytes: 13500
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, x;
    int m, minm;
    minm = 10000;
    cin >> n >> x;
    for (int i = 0; i < n; ++i)
    {
        cin >> m;
        x -= m;
        minm = min(m, minm);
    }
    cout << n + (x/minm) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[300101];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[1];

P u[1];
queue<int> q;
stack<P> s;
vector<int> v;

bool as(P a,P b)
{
  return a.x<b.x;
}

int main()
{
  scanf("%d %d",&a,&b);
  if(b==1)
  {
    printf("%d",a/2+a%2);
    return 0;
  }
  if(a%2==0)
  {
    printf("%d ",a/2);
    for(int t=1;t<b;t++)
      printf("%d ",a);
    return 0;
  }
  if(a==1)
  {
    for(int t=1;t<=b/2+b%2;t++)
      printf("1 ");
      return 0;
  }
  for(int t=1;t<=b;t++)
    o[t]=a/2;
  c=b/2;
  
  for(;c;c--)
  if(o[b]<0)
  {
    int p=b;
    for(;o[p]<0;p--);
    if(o[p]>0)
    for(int t=p+1;t<=b;t++)
    o[t]=a-1;
    o[p]--;
  }
  else
  {
    o[b]--;
  }
  for(int t=1;t<=b;t++)
  if(o[t]<0) break;
  else printf("%d ",o[t]+1);
}
//3




Measured memory_bytes: 3456
# coding: utf-8
# Your code here!
N, M = map(int,input().split())

ans = [-1]*N
Flg = True
if N == 1 and M == 0:
    Flg = False
for i in range(M):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and N != 1:
        Flg = False
        break
    elif ans[s-1] == -1:
        ans[s-1] = str(c)
    else:
        if ans[s-1] != str(c):
            Flg = False
            break
        
if Flg:
    for i in range(N):
        if ans[i] == -1 and i != 0:
            ans[i] = '0'
        elif ans[i] == -1 and i == 0:
            ans[i] = '1'
    print(''.join(ans))
elif N == 1 and M == 0:
    print(0)
else:
    print(-1)

Measured memory_bytes: 38332
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>

const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<endl;}return os;}

namespace ndifix{
template<class T>void sort(T &v){std::sort(v.begin(),v.end());}
template<class T>void rsort(T &v){std::sort(v.rbegin(),v.rend());}

}

int main(){
  int n,x;cin>>n>>x;
  vector<int> L(n);for(int i=0;i<n;i++)cin>>L[i];
  int d=0;
  int cnt=1;
  for(int i=0;i<n;i++){
    d+=L[i];
    if(d<=x)cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MAXN 200005
#define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp)
#define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
inline int lowbit(int x){
    return x & (-x);
}
inline int modadd(int x, int y){
    return (x + y >= MOD ? x + y - MOD: x + y);
}
inline int sgn(int x){
    return (x < 0 ? -1: (x > 0 ? 1: 0));
}
template<typename T>
T gcd(T a, T b){
    return (!b) ? a: gcd(b, a % b);
}
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, b >>= 1;
    }
    return res;
}
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

int n, sum[200005] = {0};
char s[200005];
void init(){
    n = read();
    scanf("%s", s);
    for (int i = 0; i < n; ++i){
        sum[i + 1] = sum[i] + (s[i] == 'W'? 1: 0);
    }
}
void solve(){
    int ans = n + 1;
    for (int t = 0; t <= n; ++t){
        int misw = sum[t], misr = n - t - (sum[n] - sum[t]);
        ans = min(ans, max(misw, misr)) ;
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 4800
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;
template <typename _Tp> inline void read(_Tp&x);
inline void print(__int128 x);

char s[200005];
int a[200005],b[200005];
int main()
{
	int n;
	cin>>n;
	scanf("%s",s+1);
	int cnt=0,ans=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='R')cnt++;
	}
	for(int i=1;i<=cnt;i++){
		if(s[i]=='W')ans++;
	}
	cout<<ans<<endl;
 	return 0;
}
template <typename _Tp> inline void read(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-')flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}
inline void print(__int128 x) {
	if(x<0) {x=-x;putchar('-');}
	if(x>9) print(x/10);
	putchar(x%10+'0');
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;

int n;
int p[200000+5];
ll a[200000+5],b[200000+5];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,n) cin >> p[i];
    ll pos[n+1]={};
    rep(i,n){
        pos[p[i]]=i;
    }
    rep2(i,1,n+1){
        a[i]=i*30000+pos[i];
        b[i]=(n+1-i)*30000;
    }
    rep2(i,1,n+1) cout << a[i] << (i!=n ? ' ' : '\n');
    rep2(i,1,n+1) cout << b[i] << (i!=n ? ' ' : '\n');
    return 0;
}


Measured memory_bytes: 1152
#include<cstdio>
#define int long long
const int N=100005;
int n,m,w[N],v[N],u,a;
inline int ib(int x){return x>0?x:-x;}
signed main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%lld%lld",&w[i],&v[i]);
	for(int i=1,j=1,k=n;i<=n;++i)
	{
		if(w[j]>m){u&&(a+=ib(u-w[k])),u=w[k],--k;continue;}
		if(w[k]<m){u&&(a+=ib(u-w[j])),u=w[j],++j;continue;}
		if(v[j]>=v[k])u&&(a+=ib(u-w[k])),u=w[k],v[j]+=v[k],--k;
		else u&&(a+=ib(u-w[j])),u=w[j],v[k]+=v[j],++j;
	}
	printf("%lld",a+ib(u-m));
	return 0;
}

Measured memory_bytes: 3296
import java.util.*;
import java.io.*;

class Main {
	static PrintStream out = System.out;
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int n = in.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = in.nextInt();
		}
		shellSort(A, n);
	}
	public static int insertionSort(int[] A, int n, int g, int cnt) {
	    for (int i = g; i < n; i++) {
	        int v = A[i];
	        int j = i - g;
	        while (j >= 0 && A[j] > v) {
	            A[j+g] = A[j];
	            j = j - g;
	            cnt++;
	        }
	        A[j+g] = v;
	    }
	    return cnt;
	}

	public static void shellSort(int[] A, int n) {
	    int cnt = 0;
	    int m = 1;
	    for (int tmp = 1; m < n; m++) {
	    	tmp = tmp * 3 + 1;
	    	if (n < tmp) break;
	    }
	    int[] G = new int[m];
	    G[m-1] = 1;
	    for (int i = m - 2; i >= 0; i--) {
	    	G[i] = G[i+1] * 3 + 1;
	    }
	    for (int i = 0; i < m; i++) {
	        cnt = insertionSort(A, n, G[i], cnt);
	    }

	    out.println(m);
	    StringBuilder sb = new StringBuilder();
	    for (int x : G) {
	    	sb.append(x).append(' ');
	    }
	    out.println(sb.toString().trim());
	    out.println(cnt);
	    for (int x : A) {
	    	out.println(x);
	    }
	}
}

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

void show(vector<ll>& vc)
{
    for(auto it:vc)cout<<it<<" ";
    cout<<endl;
}
#define M 300014



/**
int marked[M/64 + 2];

#define on(x) (marked[x/64] & (1<<((x%64)/2)))
#define mark(x)  marked[x/64] |= (1<<((x%64)/2))

void bitwiseSieve() {
  for (int i = 3; i * i <=M; i += 2) {
    if (!on(i)) {
      for (int j = i * i; j <= M; j += i + i) {
        mark(j);
      }
    }
  }
}

bool isPrime(int num) {
  return num > 1 && (num == 2 || ((num & 1) && !on(num)));
}
**/


/**
vector<ll>phi(M+2);
bool p[M+2];

void euler_phi(void)
{

    for(ll i=0;i<=M;i++)phi[i]=i;
    memset(p,0,sizeof p);
    p[1]=1;
    p[0]=1;
    phi[1] = 0;

    for(ll i=2; i<=M; i++)
    {

        if(!p[i])
        {

            for(ll j=i; j<=M; j+=i)
            {
                p[j]=1;
                phi[j]/=i;
                phi[j]*=(i-1);

            }
            p[i]=0;
        }
    }


}
//**/


/**
bool p[M+2];
vector<ll>prime;
void seive(void)
{

    memset(p,0,sizeof p);
    p[1]=1;
    p[0]=1;

    for(ll i=4; i<=M; i+=2)
    {
        p[i]=1;

    }

    for(ll i=3; i*i<=M; i+=2)
    {

        if(!p[i])
        {

            for(ll j=i*i; j<=M; j+=2*i)
            {
                p[j]=1;

            }
        }
    }

    prime.push_back(2);
    for(ll i=3; i<=M; i+=2)prime.push_back(i);
}
//**/


/**
ll dx[] = {-1,-1,0,-1,1,0,1,1};
ll dy[] = {-1,0,-1,1,-1,1,0,1};
**/

/**
typedef pair<ll, ll> pii;
#define x first
#define y second


pii extendedEuclid(ll a, ll b)   // returns x, y | ax + by = gcd(a,b)
{
    if(b == 0) return pii(1, 0);
    else
    {
        pii d = extendedEuclid(b, a % b);
        return pii(d.y, d.x - d.y * (a / b));
    }
}

ll modularInverse(ll a, ll n)
{
    pii ret = extendedEuclid(a, n);
    return ((ret.x % n) + n) % n;
}
//**/



ll bigmod(ll a, ll b, ll c)
{
    if(b==0)return 1;
    if(b%2)
    {
        ll p = bigmod(a,b-1,c);
        return (a*p)%c;
    }
    else
    {
        ll p = bigmod(a,b/2,c);
        return (p*p)%c;
    }
}
//**/





void solve(ll t)
{


    ll a,b,c;
    cin>>a>>b>>c;
    if(a==5 && b== 5 && c==7)
    {
        cout<<"YES"<<endl;
    }
    else if(a==5 && b==7 && c==5)
    {
        cout<<"YES"<<endl;
    }
    else if(a==7 && b==5 && c==5)
    {
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }


}


int main()
{
//     freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);

    /**seive();        //**/
    /** euler_phi();    //**/
    /** show(phi);      //**/
    /** bitwiseSieve(); //**/




    ll t=1;
    //scanf("%lld",&t);
    ll T=t;



    while(t--)
    {


        solve(T-t);

    }
    return 0;
}


Measured memory_bytes: 3564
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int t = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }

            int[] suffixMax = new int[n];
            suffixMax[n - 2] = arr[n - 1];
            for (int i = n - 3; i >= 0; i--) {
                suffixMax[i] = Math.max(suffixMax[i + 1], arr[i + 1]);
            }

            int maxDiff = 0;
            for (int i = 0; i < n - 1; i++) {
               maxDiff = Math.max(maxDiff, suffixMax[i] - arr[i]);
            }

            int maxDiffCount = 0;
            for (int i = 0; i < n - 1; i++) {
                if (suffixMax[i] - arr[i] == maxDiff) {
                    maxDiffCount++;
                }
            }

            out.println(maxDiffCount);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 44312
#include<stdio.h>
#define MAX 100000
int A[MAX],n;

int partition(int p,int r){
  int x,i,j,t;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i++;
      /*A[i]とA[j]を入れ替える*/
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
    /*A[i]とA[r]を入れ替える */
    t=A[i+1];
    A[i+1]=A[r];
    A[r]=t;
    return i+1;
}
int main(){
  int i,q;
  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&A[i]);
    q=partition(0,n-1);
    for(i=0;i<n;i++){
      if(i)printf(" ");
      if(i==q)printf("[");
      printf("%d",A[i]);
      if(i==q)printf("]");
    }
    printf("\n");
  
  return 0;
}

Measured memory_bytes: 992
import math
while True:
    q = int(input())
    
    if q==-1:
        break    
    x = q/2
    
    while True:
        if math.sqrt((x**3-q)**2) < 0.00001*q :
            print(f'{x:.6f}')
            break        
        x = x - (x**3-q)/(3*x**2)


Measured memory_bytes: 5736
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<ll> v(n);
	ll ans = 0;
	for(ll &x: v)cin >> x;
	for(int i = 1;i < n;i++)
	{
		if(v[i] < v[i-1])
		{	
			ans += v[i-1] - v[i];
			v[i] = v[i-1];
		}
	}
	cout << ans;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define MOD 998244353LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll fact[3000005];

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll& e){
	e=0;
	if(n==0)return 1;
	ll res=mod_fact(n/p,p,e);
	e+=n/p;
	if(n/p%2!=0){
		return res*(p-fact[n%p])%p;
	}
	return res*fact[n%p]%p;
}

ll mod_comb(ll n,ll k,ll p){
	if(n<0 || k<0 || n<k)return 0;
	ll e1,e2,e3;
	ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
	if(e1>e2+e3)return 0;
	return a1*mod_inverse(a2*a3%p,p)%p;
}


int n,m;

int main(void){
	fact[0]=1;
	scanf("%d%d",&n,&m);
	for(ll i=1;i<3000000;i++){
		fact[i]=fact[i-1]*i%MOD;
	}
	ll ans=0;
	for(int i=0;i<=m;i++){
		ll val=mod_comb(n,i,MOD);
		if((3*m-i)%2==1)continue;
		int cnt=(3*m-i)/2;
		ll val2=mod_comb(cnt+n-1,cnt,MOD);
		ans+=val*val2%MOD;
		ans%=MOD;
	}
	//printf("%lld\n",ans);

	for(int i=0;i<=m;i++){
		ll val=mod_comb(n,i,MOD);
		if((m-i)%2==1)continue;
		int cnt=(m-i)/2;
		ll val2=mod_comb(cnt+n-1,cnt,MOD);
		ans+=(ll)MOD-(val*val2%MOD)*n%MOD;
		ans%=MOD;
	}
	//printf("%lld\n",ans);

	for(int i=0;i<=m;i++){
		ll val=mod_comb(n-1,i,MOD);
		if((m-i)%2==1)continue;
		int cnt=(m-i)/2;
		ll val2=mod_comb(cnt+n-2,cnt,MOD);
		ans+=(ll)(val*val2%MOD)*n%MOD;
		ans%=MOD;
	}

	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int X, Y;
    cin >> X >> Y;
    for(int i = 0; i <= X; i++){
        int num = i*2 + (X-i)*4;
        if(num == Y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int ans=0;
  for(int i = 0; i < S.length()/2; i++){
    if(S[i]!=S[S.length()-i-1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
pair<P,int> p[100000];
int x[100000];
priority_queue<P,vector<P>,greater<P>> q;
signed main(){
	int n,m,z=1,zz=0;
	cin>>n>>m;
	f(i,n){
		if(i)x[i]=INF;
	}
	f(i,m){
		cin>>p[i].F.F>>p[i].F.S>>p[i].S;
		p[i].F.S--;
		p[i].F.F--;
	}
	sort(p,p+m);
	while(z<n){
		for(;zz<m&&p[zz].F.F<z;zz++){
			q.push(P(p[zz].S+x[p[zz].F.F],zz));
		}
		if(q.empty()){
			puts("-1");
			return 0;
		}
		P pa=q.top();
		q.pop();
		for(;z<=p[pa.S].F.S;z++){
			x[z]=pa.F;
		}
	}
	cout<<x[n-1]<<endl;
}


Measured memory_bytes: 5364
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int a,b,c;cin>>a>>b>>c;

    if((b-a) == (c-b)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int x,y,z; ll k;
	cin >>x >>y >>z >>k;
	VI a(x), b(y), c(z);
	rep(i,x) cin>>a[i];
	rep(i,y) cin>>b[i];
	rep(i,z) cin>>c[i];

	VI ab; ab.reserve(x*y);
	rep(i, x) rep(j, y) ab.push_back(a[i]+b[j]);
	sort(ab.rbegin(), ab.rend());
	if(sz(ab)>k ) ab.resize(k);
	
	VI abc; abc.reserve(z*sz(ab));
	sort(c.rbegin(), c.rend());
	rep(i, sz(ab)) rep(j, z){
		if((i+1)*(j+1) > k) break;
		abc.push_back(ab[i]+c[j]);
	}
	sort(abc.rbegin(), abc.rend());
	
	rep(i, k) cout<< abc[i] <<"\n";
	
	return 0;
}

Measured memory_bytes: 10240
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;
use text_io::read;

fn main() {
    input! {
        s: Chars,
    }

    let n = s.len();
    let bef = Vec::from(&s[0..n / 2]);
    let mut aft = Vec::from(&s[(n + 1) / 2..n]);
    aft.reverse();

    let mut ans = 0;

    for i in 0..n / 2 {
        if bef[i] != aft[i] {
            ans += 1;
        }
    }

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


Measured memory_bytes: 2112
N = int(input())
A = list(map(int,input().split()))
cnt = 0
A_abs = list(map(abs, A))
for i in A:
    if i < 0:
        cnt += 1
if cnt % 2 == 0:
    print(sum(A_abs))
else:
    print(sum(A_abs) - 2 * min(A_abs))


Measured memory_bytes: 14252
#include<stdio.h>

int main()
{

   int arr[1000],i,j,k,tc,cnt=0;

   scanf("%d",&tc);

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

     scanf("%d",&arr[i]);

   }

   for(j=1;j<(tc-1);j++)
   {

    if((arr[j]>arr[j-1]&&arr[j]<arr[j+1])||(arr[j]<arr[j-1]&&arr[j]>arr[j+1]))
    {
        cnt++;
    }

   }

   printf("%d",cnt);

   return 0;
}


Measured memory_bytes: 1736
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int area[99999], N, M, D, spa, cnt = 0;
	char AREA[101][101];
	cin >> N >> M >> D;
	for (int i = 0; i < N; i++)
	{
		scanf("%s", &AREA[i]);
		spa = 0;
		for (int j = 0; j < M; j++)
		{
			if (AREA[i][j] == '.')
				spa++;
			if (spa >= D)
			{
				if (AREA[i][j] == '#' || j == M - 1)
				{
					area[cnt] = spa;
					spa = 0;
					cnt++;
				}
			}
			if (AREA[i][j] == '#')
				spa = 0;
		}
	}

	for (int i = 0; i < M; i++)
	{
		spa = 0;
		for (int j = 0; j < N; j++)
		{
			if (AREA[j][i] == '.')
				spa++;
			if (spa >= D)
			{
				if (AREA[j][i] == '#' || j == N - 1) {
					area[cnt] = spa;
					spa = 0;
					cnt++;
				}
			}
			if (AREA[j][i] == '#')
				spa = 0;
		}
	}

	int ans = 0;
	for (int i = 0; i < cnt; i++) {
	ans += area[i] - D + 1;
	}
	cout << ans << endl;
	return 0;
}
/*
#include<cstdio>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
int min() {
	int AREA[101][101], N, M, D;
	char line[101];
	cin >> N >> M >> D;
	for (int i = 0; i < N; i++) {
		scanf("%s", &line);
		for (int j = 0; j < M; j++) {
			if (line[j] == '.')
				AREA[i][j] = 0;
			else if (line[j] == '#')
				AREA[i][j] = 1;
		}
	}

}
*/


Measured memory_bytes: 3156
//#include"pch.h"
#include<stdio.h>

int main() {

	int A, B, C;

	//scanf_s("%d %d %d", &A, &B, &C);
	scanf("%d %d %d", &A, &B, &C);

	int SM = 0;

	for (int i = 0; i < C; i++) {
		if (B - A >= 0) {
			B -= A;
			SM++;
		}
	}

	printf("%d", SM);

	return(0);
}

Measured memory_bytes: 128
x,y,a,b,c=map(int,input().split())
p=[0]+sorted(list(map(int,input().split())))[a-x:]
q=[0]+sorted(list(map(int,input().split())))[b-y:]
r=[0]+sorted(list(map(int,input().split())))
pi=-1
qi=-1
ri=-1
gs=0
rs=0
ws=0
s=0              
while gs+rs+ws!=x+y:
    if r[ri]>=q[qi]>=p[pi]:
        s += r[ri]
        ws+=1
        ri-=1

    elif r[ri]>=p[pi]>=q[qi]:
        s += r[ri]
        ws += 1
        ri -= 1

    elif q[qi]>=r[ri]>=p[pi]:
        s += q[qi]
        gs += 1
        qi -= 1

    elif q[qi]>=p[pi]>=r[ri]:
        s += q[qi]
        gs += 1
        qi -= 1

    elif p[pi]>=r[ri]>=q[qi]:
        s += p[pi]
        rs += 1
        pi -= 1

    elif p[pi]>=q[qi]>=r[ri]:
        s += p[pi]
        rs += 1
        pi -= 1

print(s)


Measured memory_bytes: 28372
#include <iostream>
#include<algorithm>
using namespace std;
int k(int n){
    int sum =1;
    for(int i = 0;i<n;i++){
        sum*=2;
    }
    return sum;
}
int main()
{
   int a[3];
   while(cin>>a[0]>>a[1]>>a[2]){
        sort(a,a+3);
        int t;
        cin>>t;
        int sum = a[0]+a[1];
        int ss = a[2];
        for(int i = 0 ;i<t;i++){
            ss*=2;
        }
        cout<<ss+sum;
        cout<<endl;
   }
}


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

public class Program
{
    public static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var n = int.Parse(inputs[0]);
        var k = int.Parse(inputs[1]);
        var q = int.Parse(inputs[2]);

        var kihonten = k - q;

        var kaitousyas = new Dictionary<int, int>();
        for (var i = 0; i < q; i++)
        {
            var a = int.Parse(Console.ReadLine());
            if (kaitousyas.ContainsKey(a))
            {
                kaitousyas[a] += 1;
            }
            else
            {
                kaitousyas[a] = 1;
            }
        }

        for (var i = 1; i <= n; i++)
        {
            Console.WriteLine(kihonten + (kaitousyas.ContainsKey(i) ? kaitousyas[i] : 0) > 0 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 20316
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
//#include <cstdio>
//#include <cstdlib>
//#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	int N;
	// char ;

	cin >> N;

	cout <<N * N * N <<endl;

	return 0;
}

/*
for(i=0;i<N;i++){
	cin >> X[i];
}


for(i=0;i<N;i++){
	for(j=0;j<N;j++){
		cin >> X[i][j];
	}
}
*/

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int a, b;
  cin >> a >> b;
  if(a <= b){
    REP(i, b){
      cout  << a;
    }
    cout << endl;
  }else{
    REP(i, a){
      cout  << b;
    }
    cout << endl;

  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 305;

struct edge
{
    int st;
    vi vec;
    edge(){};
    edge(int a,vi b){
        st = a,vec = b;
    }
};

vector<edge> eda;
int memo[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,e,t;
    cin >> n >> e >> t;
    --t;
    fill(memo,memo+n,INF);
    rep(i,n){
        int a;
        cin >> a;
        if(a){
            memo[i] = 1;
        }
    }
    rep(i,e){
        int a,b;
        vi hoge;
        cin >> a >> b;
        rep(j,b){
            int c;
            cin >> c;
            hoge.pb(c-1);
        }
        eda.emplace_back(a-1,hoge);
    }
    while(1){
        bool update = false;
        rep(i,e){
            edge& e = eda[i];
            vi hoge;
            bool ok = true;
            each(it,e.vec){
                if(memo[it] == INF){
                    ok = false;
                }
                hoge.pb(memo[it]);
            }
            if(ok){
                int val = len(hoge);
                sort(all(hoge));
                rep(j,len(hoge)){
                    cmx(val,hoge[j]+len(hoge)-1-j);
                }
                if(val < memo[e.st]){
                    memo[e.st] = val;
                    update = true;
                }
            }
        }
        if(!update) break;
    }
    if(memo[t] == INF){
        cout << "-1\n";
    }else{
        cout << memo[t] << "\n";
    }
    return 0;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define M 500000
#define MAX 10000000000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main()
{
	int n;
	cin>>n;
	int p[n],mx = 0,ans = 0;
	for(int i=0;i<n;i++)
		cin>>p[i];
	mx = p[0];
	for(int i=0;i<n;i++)
	{
		if(mx >= p[i])
			ans++;
		mx = min(mx,p[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
S = []
count = 0
for i in range(N):
    S.append(sorted(input()))
S = sorted(S)
a = 'sing'
for j in range(N):
    if a != S[j]:
        f = 0
        a = S[j]
    else:
        f += 1
        count += f
print(count)

Measured memory_bytes: 25420
n = int(input())
p = list(map(float, input().split()))
    
dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1

for i in range(0, n):
    for j in range(0, i+1):
        dp[i+1][j+1] = dp[i][j]*p[i]
        dp[i+1][j] = dp[i][j]*(1-p[i]) + dp[i][j-1]*p[i]
        
ans = sum([dp[n][i] for i in range(n//2+1,n+1)])
print(ans)

Measured memory_bytes: 256008
#include<stdio.h>
#include<stdlib.h>
int fun(char *,char *);
int fun(char *s1,char *s2)
{
    if(s1[0]!=s2[2]||s1[1]!=s2[1]||s1[2]!=s2[0])
    {return 0;}
    return 1;
}
int main()
{
    char a[4];
    char b[4];
    scanf("%s%s",a,b);
    printf((fun(a,b)==1)?"YES\n":"NO\n");
    return 0;
}

Measured memory_bytes: 128
from itertools import accumulate


def solve(n, rev):
    def existence_right(rev_c):
        n2 = n * 2
        acc = [[0] * n2]
        row = [0] * n2
        for x in rev_c:
            row[n2 - x - 1] += 1
            acc.append(list(reversed(list(accumulate(row)))))
        return acc

    # How many white/black ball lower than 'k' righter than index x? (0<=x<=2N-1)
    # cost[color][k][x]
    cost = list(map(existence_right, rev))

    dp = [[0] * (n + 1) for _ in range(n + 1)]
    for w, x in enumerate(rev[0]):
        dp[w + 1][0] = dp[w][0] + cost[0][w][x]
    for b, y in enumerate(rev[1]):
        dp[0][b + 1] = dp[0][b] + cost[1][b][y]
    for w, x in enumerate(rev[0]):
        dpw0, dpw1 = dp[w], dp[w + 1]
        cost_wx, cost_w1 = cost[0][w][x], cost[0][w + 1]
        for b, y in enumerate(rev[1]):
            dpw1[b + 1] = min(dpw0[b + 1] + cost_wx + cost[1][b + 1][x],
                              dpw1[b] + cost_w1[y] + cost[1][b][y])
    return dp[n][n]


n = int(input())
# White/Black 'k' ball is what-th in whole row?
rev = [[0] * n, [0] * n]
for i in range(n * 2):
    c, a = input().split()
    a = int(a) - 1
    rev[int(c == 'B')][a] = i
print(solve(n, rev))


Measured memory_bytes: 195716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    ll d,t,s;
    cin >> d >> t >> s;
    if(s * t >= d){
        cout << "Yes" << endl;
        
    }else{
        cout << "No" << endl;

    }

    return 0;
}

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

ll solve(string s){
    ll ans = 0,cnt = 0;

    for(int i = 0;i < s.size()-1;i ++){
        if(s[i]=='A') cnt ++;
        else if(s[i]=='B' && s[i+1]=='C') ans += cnt,i ++;
        else cnt = 0;
    }
    return ans;
}

int main(){
    string s;
    cin >> s;

    cout << solve(s) << endl;
    return 0;
}

Measured memory_bytes: 772
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
int main(){
        int n,k;
        while(~getII(n,k)){
                int ans=0;
                F(i,0,n){
                        VgetI(x);
                        if(x>=k) ans++;
                }
                printf("%d\n",ans);
        }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, vector<int> arr){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
const ll mod = 1e9 + 7;
vector<int> solve(int n){
    vector<int> temp;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            temp.push_back(i);
            temp.push_back(n/i);
        }
    }
    return temp;
}
int freq[1000005] = {};
int main()
{
    Hello
    int n;
    cin >> n;
    int arr[n + 5];
    vector<vector<int>> v;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        v.push_back(solve(arr[i]));
        freq[arr[i]]++;
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        int cntr = 0;
        for(int j = 0; j < v[i].size(); j++){
            if(v[i][j] == arr[i] && freq[arr[i]] >= 2) cntr++;
            else if(v[i][j] != arr[i] && freq[v[i][j]]) cntr++;
        }
        if(!cntr)
            ans++;
    }
    cout << ans;
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    long long int n,i,j,k,flag=0,count=0;
    cin>>n;
    long long int l[n];
    for(i=0;i<n;i++)
    {
       cin>>l[i]; 
    }
    sort(l,l+n);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if((l[i]+l[j]>l[k]))
                count++;
                else
                break;
            }
        }
    }
    cout<<count;

     

  return 0;
    
}
    


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

using namespace std;

int main(void) {
	int h, w;
	char s[60][60];


	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	int c[4][2] = {
		{-1,0 },
		{0,1},
		{1,0},
		{0,-1}
	};

	bool can = true;
	for (int i = 0; i < h; i++)
		for (int j = 0; j <= w; j++) {
			if (s[i][j] == '#') {
				bool can2 = false;
				for (int k = 0; k < 4; k++) {
					int y = i + c[k][0];
					int x = j + c[k][1];
					if (0 <= y && y <= h
						&& 0 <= x && x <= w) {
						if (s[y][x] == '#') can2 = true;
					}
				}
				if (!can2) can = false;
			}
		}


	if (can) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3068