akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static int[] dp;
        static int[] H;
        static void Main(string[] args)
        {
            var NK = Slist();
            var N = NK[0];
            var K = NK[1];
            H = Sarray();

            dp = new int[N + K + 1].Select(_ => int.MaxValue).ToArray();
            dp[0] = 0;
            for (var i = 0; i < N; ++i)
                for (var k = 1; k <= K; ++k)
                    if (i + k < N)
                        dp[i + k] = Min(dp[i + k], dp[i] + Abs(H[i + k] - H[i]));
            WriteLine(dp[N - 1]);
        }
    }
}


Measured memory_bytes: 19552
#include<iostream>
using namespace std;
int main(){
	int h,w;
	int i,j;
	cin>>h>>w;
	char m[102][102];
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			cin>>m[i][j];
		}
	}
	for(i=0;i<=h+1;i++){
		for(j=0;j<=w+1;j++){
			if(i==0||j==0||i==h+1||j==w+1){
				cout<<"#";
			}
			else{
				cout<<m[i][j];
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def norm_str(s):
  ls = list(s)
  return "".join(sorted(ls))
  
ans = 0
pool = {}
n = int(input())
for i in range(n):
  s = input()
  norm = norm_str(s)
  
  if norm in pool:
    pool[norm] += 1
    ans += pool[norm]
    
  else:
    pool[norm] = 0
  
print(ans)

Measured memory_bytes: 17892
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 10
#define MAX_M 10
#define MAX_G 9

int sx, sy;
int n;
int scx[MAX_N], scy[MAX_N];

bool
b_survival()
{
	bool field[MAX_M][MAX_M];
	int px[MAX_G], py[MAX_G];
	const int dx2[12] = {-1, 0, 1, 2, 2, 2,-1, 0, 1,-2,-2,-2};
	const int dy2[12] = {-2,-2,-2,-1, 0, 1, 2, 2, 2,-1, 0, 1};

	int ix = 0;
	px[ix] = sx, py[ix] = sy;
	ix++;

	for (int u = 0; u < n; ++u)
	{
		for (int dy = -1; dy <= 1; ++dy)
		{
			for (int dx = -1; dx <= 1; ++dx)
			{
				int nx = scx[u] + dx, ny = scy[u] + dy;
				if (0 <= nx && nx < MAX_M && 0 <= ny && ny < MAX_M)
					field[ny][nx] = false;
			}
		}

		for (int i = 0; i < ix; ++i)
		{
			for (int j = 0; j < 12; ++j)
			{
				int nx = px[i] + dx2[j], ny = py[i] + dy2[j];
				if (0 <= nx && nx < MAX_M && 0 <= ny && ny < MAX_M)
					field[ny][nx] = true;
			}
		}

		ix = 0;
		for (int dy = -1; dy <= 1; ++dy)
		{
			for (int dx = -1; dx <= 1; ++dx)
			{
				int nx = scx[u] + dx, ny = scy[u] + dy;
				if (0 <= nx && nx < MAX_M && 0 <= ny && ny < MAX_M && field[ny][nx])
				{
					px[ix] = nx;
					py[ix] = ny;
					ix++;
				}
			}
		}

		if (ix == 0)
			return false;
	}

	return true;
}

int
main(int argc, char **argv)
{
	int lineno = 0;
	while (true)
	{
		lineno++;
		scanf("%d%d", &sx, &sy);
		if (sx == 0 && sy == 0)
			break;

		lineno++;
		scanf("%d", &n);

		lineno++;
		for (int i = 0; i < n; ++i)
			scanf("%d%d", &scx[i], &scy[i]);

		printf("%s\n", b_survival() ? "OK" : "NA");
	}

	return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
const int maxn=5005;
#define ll long long
#define p 1000000007
ll bigpow(ll a,ll b)
{
    ll ans=1%p;
    for(;b;b>>=1)
    {
        if(b&1) ans=(ll)ans*a%p;
        a=(ll)a*a%p;
    }
    return ans;
}
int main()
{ll n;
cin>>n;
ll a1=bigpow(10,n);
ll a2=bigpow(9,n);
ll a3=bigpow(8,n);
ll ans=a1%p-a2%p-a2%p+a3%p;
ans%=p;
cout<<(ans+p)%p<<endl;

    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long N,sum=0;
  cin >> N;
  map<long long,long long> m;
  vector<long long> vec(N);
  for(long long i=0;i<N;i++){
    cin >> vec[i];
    m[vec[i]]++;
  }
  for(long long i=0;i<N;i++){
    if(m[i+1]!=0){
      sum+=(m[i+1]*(m[i+1]-1))/2;
    }
  }
  for(long long i=0;i<N;i++){
    cout << sum-m[vec[i]]+1 << endl;
  }
}

Measured memory_bytes: 16640
def resolve():
    N, M = map(int, input().split()) 
    A_list = list(map(int, input().split()))

    A_SUM = sum(A_list)
    THRESHOLD = A_SUM * (1 / (4 * M))

    count = 0
    for a in A_list:
        if THRESHOLD <= a:
            count += 1

    if M <= count:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    resolve()

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

using ll = long long;
using namespace std;



int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    int k;
    cin >> n >> k;
    vector<int> a(n);
    for(auto &x:a) cin >> x;
    vector<bool> dp(k+1);
    dp[0]=false;
    for(int i=1; i<=k; ++i)
    {
        for(auto x:a)
        {
            if (i-x<0) dp[i]=false;
            else  if (dp[i-x]==false)
            {
                dp[i]=true;
                break;
            }
        }
    }
    if (dp[k]) cout << "First"; else cout << "Second";
    return 0;
}



Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($A,$B) =  explode(" ",trim(fgets(STDIN)));
//$l = explode(" ",trim(fgets(STDIN)));

for($i=0;$i<10;$i++) {
  for($j=0;$j<10;$j++) {
    if ($i*$j==$N) {
      printf("Yes\n");
      exit;
    }
  }
}
printf("No\n");


Measured memory_bytes: 4732
n = []
while True:
    a, b = [int(i) for i in input().split()]
    if a == 0 and b == 0:
        break
    else:
        for i in range(a):
            d = ""
            for j in range(b):
                if i % 2 == 0:
                    if j % 2 == 0:
                        d += "#"
                    else:
                        d += "."
                else:
                    if j % 2 == 0:
                        d += "."
                    else:
                        d += "#"
            n.append(d)
        for i in n:
            print(i)
        print()
        n = []



Measured memory_bytes: 5616
program tenquestionfour
 implicit none
 integer A, B, C, X, i, j, k, res, sum
 read(*,*) A
 read(*,*) B
 read(*,*) C
 read(*,*) X
 res = 0
 sum = 0
 do i=0,A
  do j=0,B
   do k=0,C
   sum = 500*i + 100*j + 50*k
   if(sum.eq.X) then
   res = res + 1
   end if
   end do
  end do
 end do
 write(*,*) res
end program

Measured memory_bytes: 256
N, X = map(int, input().split())

a = [1]
p = [1]
for i in range(N):
  a.append(a[i]*2 + 3)
  p.append(p[i]*2 + 1)
def f(n, x):
#  print (n, a[n], x)
  if n == 0:
    return 0 if x<= 0 else 1
  elif n == 1:
    return "BPPPB"[:x].count("P")
  else: 
    if x <= 0:
      return 0
    elif x <= 1 + a[n-1]:
      return f(n-1, x-1)  
    else:
      return p[n-1] + f(n - 1,x - 2 - a[n-1]) + 1
print (f(N, X))

Measured memory_bytes: 3064
n, m, k = map(int, input().split())
A = [0] + list(map(int,input().split()))
B = [0] + list(map(int,input().split()))
 
for i in range(2,n+1):
    A[i] += A[i-1]
for i in range(2,m+1):
    B[i] += B[i-1]

j = m
ans = 0
for i in range(n+1):
    if A[i] > k:
        break 
    while B[j] > k-A[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 39876
from collections import deque

H, W = map(int,input().split())

table = []
for _ in range(H):
    table.append(["k"] + list(input()) + ["k"])
    
table = [["k"]*(W+2)] + table + [["k"]*(W+2)]

q = deque()

min_memo = [[None]*(W+2) for _ in range(H+2)]

all_cnt = 0
for y, r in enumerate(table):
    for x, c in enumerate(r):
        if c == "#":
            q.append([y,x,0])
            min_memo[y][x] = 0
            all_cnt += 1

if all_cnt == H*W:
    print(0)
else:          
    while True:
        y, x, cnt = q.popleft()
        for dy,dx in [(-1,0),(1,0),(0,-1),(0,1)]:
            if table[y+dy][x+dx] == ".":
                if min_memo[y+dy][x+dx] == None:
                    min_memo[y+dy][x+dx] = cnt+1
                    q.append([y+dy, x+dx, cnt+1])
                    all_cnt += 1
        if all_cnt >= H*W:
            print(cnt+1)
            break


Measured memory_bytes: 166408
N = int(input())
A = list(map(int,input().split()))

color = [0] * 9

for a in A:
  if a <= 399:
    color[0] = 1
  elif a <= 799:
    color[1] = 1
  elif a <= 1199:
    color[2] = 1
  elif a <= 1599:
    color[3] = 1
  elif a <= 1999:
    color[4] = 1
  elif a <= 2399:
    color[5] = 1
  elif a <= 2799:
    color[6] = 1
  elif a <= 3199:
    color[7] = 1
  else:
    color[8] += 1
    
max_num = sum(color)
min_num = max(1, sum(color[:-1]))
 
print(min_num, max_num)

Measured memory_bytes: 9196
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <bitset>
#include <limits.h>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
int a, b, c;
/**********************************************/

signed main(){
    cin >> a >> b >> c;

    if(a+b >= c) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
int a , b ;
cin>>a>>b;
for(int i = 0 ; i<1009  ; i++){

    if(floor(i*0.08)==a && floor(i*0.1)==b)
    {
        cout<<i;
         return 0 ;
    }
}
 cout<<-1;
return 0;




}


Measured memory_bytes: 256
#include<cstdio>
int main(){
    char s[51],t[]="AKIHABARA";
    scanf("%s",s);
    int i=0,j=0;
    while(s[i]!='\0'&&t[j]!='\0'){
        if(s[i]==t[j]){i++;j++;}
        else if(s[i]!='A'&&t[j]=='A')j++;
        else{
            printf("NO");
            return 0;
        }
    }
    if(s[i]=='\0'&&j>7)printf("YES");
    else printf("NO");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, m, ans = 0;
    cin >> n >> m;
    vector<int> k(m), p(m);
    vector<vector<int>> s(m, vector<int>(n));
    rep(i, m){
        cin >> k.at(i);
        s[i].resize(k.at(i));
        rep(j, k.at(i))cin >> s[i][j];
    }
    rep(i, m)cin >> p.at(i);
    int swi[n];
    rep(bit, (1<<n)){
        rep(i, n){
            if(bit & (1<<i))swi[i] = 1;
            else swi[i] = 0;
        }
        int now = 0;
        bool ok = true;
        rep(i, m){
            rep(j, k.at(i))now += swi[s[i][j]-1];
            if(now % 2 != p.at(i))ok = false;
            now = 0;
        }
        if(ok)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

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


Measured memory_bytes: 3972
import java.util.Arrays; 
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static class Edge implements Comparable<Edge>{
		double cost;
		int start, end;
		
		public Edge(double cost, int start, int end) {
			super();
			this.cost = cost;
			this.start = start;
			this.end = end;
		}

		@Override
		public int compareTo(Edge o) {
			if(this.cost < o.cost){
				return -1;
			}else if(this.cost > o.cost){
				return 1;
			}else{
				return 0;
			}
		}
	}
	
	public static class UnionFind{
		int[] par;
		
		UnionFind(int n){
			par=new int[n];
			for(int i=0;i<n;i++)par[i]=i;
		}
		
		public int find(int x){
			if(par[x]==x)return x;
			return par[x]=find(par[x]);
		}
		public Boolean same(int x,int y){
			return find(x)==find(y);
		}
		public void unite(int x,int y){
			if(find(x)==find(y))return;
			par[find(x)]=find(y);
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			double[] x_pos = new double[n];
			double[] y_pos = new double[n];
			double[] z_pos = new double[n];
			double[] rad = new double[n];
			
			for(int i = 0; i < n; i++){
				x_pos[i] = sc.nextDouble();
				y_pos[i] = sc.nextDouble();
				z_pos[i] = sc.nextDouble();
				rad[i] = sc.nextDouble();
			}
			
			PriorityQueue<Edge> queue = new PriorityQueue<Edge>();
			
			for(int i = 0; i < n; i++){
				for(int j = i + 1; j < n; j++){
					queue.add(new Edge(Math.max(0, Math.sqrt((x_pos[i] - x_pos[j])*(x_pos[i] - x_pos[j]) + 
													(y_pos[i] - y_pos[j])*(y_pos[i] - y_pos[j]) +
													(z_pos[i] - z_pos[j])*(z_pos[i] - z_pos[j])) - (rad[i] + rad[j])), i, j));
				}
			}
			
			UnionFind union = new UnionFind(n);
			
			int count = 0;
			double sum = 0;
			while(count < (n - 1)){
				Edge edge = queue.poll();
				
				if(union.same(edge.start, edge.end)){
					continue;
				}else{
					union.unite(edge.start, edge.end);
					sum += edge.cost;
				}
				
				count++;
			}
			
			System.out.printf("%.3f\n", sum);
		}
		
	}
}

Measured memory_bytes: 13000
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main() {
int N;
cin>>N;
int table[N+1];

    rep3(i,N){
        table[i]=1;

    }
    rep4(i,2,N){
        for(int j=i;j<=N;j+=i)table[j]++;
    }
    ll ans =0;
    rep3(i,N){
        ans+=i*table[i];
    }
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 42692
#include<iostream>
#include <stdio.h>
using namespace std;
  
int main(){
	char op;
	int a,b;
	while(1){
			cin>>a>>op>>b;
if ( op == '+' ){
	cout<<a+b<<endl;
} else if ( op == '-' ){
	cout<<a-b<<endl;
} else if ( op == '*' ){
    cout<<a*b<<endl;
} else if ( op == '/' ){
    cout<<a/b<<endl;
} else{break;} }
	return 0;}


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

int main() {
  string s;
  cin>>s;
  long long int len,tot1=0,tot2=0,cnt=0,ans;
  len=s.length();

  rep(i,0,len){
    if(s.substr(i,1)=="B"){tot1+=i;cnt++;}
  }

  rep(i,1,cnt+1){
    tot2+=len-i;
  }
  
  ans=tot2-tot1;

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


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

int main() {
  int n, m, a, b;
  vector<int> c;
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    cin >> a >> b;
    if(a == 1)
      c.push_back(b);
    if(b == n)
      c.push_back(a);
  }
  sort(c.begin(), c.end());
  for(int i = 0; i < c.size(); i++) {
    if(i) {
      if(c[i - 1] == c[i]) {
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1400
a, b = map(int, input().split(' '))

if a <=  b:
  str_all = str(a)
  for _ in range(b - 1):
    str_all = str_all + str(a)

else:
  str_all = str(b)
  for _ in range(a - 1):
    str_all = str_all + str(b)

print(str_all)

Measured memory_bytes: 2940
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

from collections import Counter
from heapq import heappop,heappush
q=[]

c=Counter(a)
for key in c:
	heappush(q,(-key,c[key]))

for _ in range(m):
	b,c=map(int,input().split())
	heappush(q,(-c,b))
ans=0
cnt=0

while cnt<n:
	v,no=heappop(q)
	nn = min(no,n-cnt)
	ans+=v*nn
	cnt+=nn
print(-ans)

Measured memory_bytes: 92312
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int n,t,a;
	cin >> n >> t >> a;
	vector<pair<double,int> > arr(n);
	for(int i = 0; i < n; i++) {
		int h;
		cin >> h;
		arr[i] = pair<double,int>(fabs(t-h*0.006-a),i);
	}
	sort(arr.begin(),arr.end());
	cout << (arr[0].second+1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n;
  cin >> n;
  vector<int> s(n+1,1);
  for(int i=2;i<=n;i++){
    for(int j=1;i*j<=n;j++){
      s.at(i*j)++;
    }
  }
  long long ans = 0;
  for(long long i=1;i<=n;i++)ans += i * s.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 42252
N, M = map(int, input().split())
s = []
for i in range(M):
  k = list(map(int, input().split()))
  k.pop(0)
  s.append(k)
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
  c = []
  for j in range(N):
    c.append((i >> j)&1)
  flag = True
  for j in range(M):
    count =  0
    for l in range(len(s[j])):
      if c[s[j][l]-1]==1:
        count+=1
    if count % 2 != p[j]:
      flag = False
  if flag:
    ans += 1
print(ans)

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

int main() {
	int N, M, a, b, c, INF = 1000000000, ans = 0;
	static int R[100][100] = {}, F[100][100] = {};
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			R[i][j] = F[i][j] = INF;
			if (i == j) R[i][j] = F[i][j] = F[j][i] = 0;
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		a--, b--;
		R[a][b] = F[a][b] = F[b][a] = c;
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				F[i][j] = min(F[i][j], F[i][k] + F[k][j]);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (R[i][j] != INF) {
				if (R[i][j] != F[i][j]) ans++;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 384
def main():
    s = input()
    t = input()
    if not set(t).issubset(set(s)):
        return -1
    m = 0
    st = s
    for i in t:
        if i in st:
            j = st.index(i)
            m += j + 1
            st = st[j+1:]
        else:
            m += len(st)
            st = s
            j = st.index(i)
            st = st[j+1:]
            m += j + 1
    return m
print(main())


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  rep(i, n - m + 1) rep(j, n - m + 1) {
    bool ok = true;
    rep(k, m) {
      if (a[i + k].substr(j, m) != b[k]) ok = false;
    }
    if (ok == true) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3612
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define pb push_back
#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int MX = 3e5 + 12; //check the limits, dummy

int main()
{

    ios_base::sync_with_stdio (0);
    cin.tie (0);

    ll n;
    cin >> n;

    if (n & 1) {
        cout << 0 << '\n';
    } else {
        n /= 2;
        ll cnt = 0;
        for (ll i = 5; n / i >= 1; i *= 5) {
            cnt += (n / i);
        }
        cout << cnt << '\n';
    }

    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
void chmin(int &a, int b) {if(a > b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for(ll i = k  ; i <= n + 1  ; i++){
        ans = (ans + ((2*n-i+1)*i/2 - (i-1)*i/2 + 1)) % mod;
    }
    cout << ans%mod;
}

Measured memory_bytes: 3632
n=int(input())
a=[list(map(int,input().split()))for i in range(n)]
a.insert(0,[0,0,0])
for i in range(1,n+1):
    t=a[i][0]-a[i-1][0]
    dis=abs(a[i][1]-a[i-1][1])+abs(a[i][2]-a[i-1][2])
    if t<dis:
        print("No")
        exit()
    elif (t-dis)%2!=0:
        print("No")
        exit()
print("Yes")



Measured memory_bytes: 27300
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll n;
  cin >> n;
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
  string ans = "";
  for(ll i = 1; n != 0; i *= -2){
    if(n % (i * 2) != 0){
      n -= i;
      ans = "1" + ans;
    }else{
      ans = "0" + ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
    int n;
    cin >> n;
    int prev;
    cin >> prev;
    int ret = 1;
    for (int i = 1; i < n; i++) {
        int now;
        cin >> now;
        if (now <= prev) ret++;
        prev = now;
    }
    cout << ret << endl << n << endl;
    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
// priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
priority_queue<ll> PQ;

ll sum[1000006];
int main(){
  int n;

  scanf("%d", &n);

  int i,j,k;
  int s;
  int t = 0;
  int ans[10006] = {0};

    for(i = 1;i <= 100;i++){
      for(j = 1;j <= 100;j++){
        for(k = 1;k <= 100;k++){
          s = i*i + j*j + k*k + i*j + i*k + j*k;
          if(s > n) break;
          sum[t++] = s;
      }
    }
  }

  for(i = 0;i < t;i++){
    ans[sum[i]]++;
  }

  for(i = 1;i <= n;i++) printf("%d\n", ans[i]);

  return 0;

}

Measured memory_bytes: 5764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


// Modint
struct Mint {
    static const long long mod = (long long)(1e9 + 7);
    long long val;

    Mint() { val = 0; }
    Mint(long long a) { val = a; verify_value(); }

    void verify_value() {
        if (val >= mod) val %= mod;
        if (val < 0) val %= mod, val += mod;
    }

    Mint pow(long long p) const {
        Mint cur = Mint(val), ret = 1;
        while (p > 0) {
            if (p & 1) ret *= cur;
            cur *= cur;
            p >>= 1LL;
        }
        return ret;
    }
    Mint inv() const {
        if (val == 0)
            std::cerr << "WARNING: inv() is called with 0." << std::endl;
        return pow(mod - 2);
    }

    Mint operator+() const { return *this; }
    Mint operator-() const { return Mint(mod - val); }

    Mint operator+=(const Mint &a) {
        val += a.val;
        if (val >= mod) val -= mod;
        return Mint(val);
    }
    Mint operator*=(const Mint &a) {
        val *= a.val;
        if (val >= mod) val %= mod;
        return Mint(val);
    }
    Mint operator-=(const Mint &a) { return *this += -a; }
    Mint operator/=(const Mint &a) { return *this *= a.inv(); }

    Mint operator++() { return *this += Mint(1); }
    Mint operator--() { return *this -= Mint(1); }
    Mint operator++(int) {
        Mint ret = *this;
        ++(*this);
        return ret;
    }
    Mint operator--(int) {
        Mint ret = *this;
        --(*this);
        return ret;
    }

    operator long long() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
    long long ret = a.val + b.val;
    if (ret >= Mint::mod) ret -= Mint::mod;
    return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
    long long ret = a.val * b.val;
    if (ret >= Mint::mod) ret %= Mint::mod;
    return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

std::ostream &operator<<(std::ostream &out, const Mint &a) { return out << a.val; }
std::istream &operator>>(std::istream &in, Mint &a) {
    in >> a.val;
    a.verify_value();
    return in;
}

Mint pow(Mint a, long long b) {
    return a.pow(b);
}


int main() {
    std::string s; std::cin >> s;
    int n = s.size();
    std::vector<std::vector<Mint>> dp(n + 2, std::vector<Mint>(15));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] == '?') {
            for (int d = 0; d <= 9; d++) {
                for (int j = 0; j < 13; j++) {
                    dp[i + 1][(10 * j + d) % 13] += dp[i][j];
                }
            }
        }
        else {
            int d = s[i] - '0';
            for (int j = 0; j < 13; j++) {
                dp[i + 1][(10 * j + d) % 13] += dp[i][j];
            }
        }
    }
    std::cout << dp[n][5] << std::endl;
    return 0;
}


Measured memory_bytes: 15232
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#include<math.h>
#define Max 1000000
#define INF 1000000000000000000
using namespace std;

long long int gcd(long long int a,long long int b){
	if(a%b == 0)
		return b;
	return gcd(b,a%b);
}

int main(){

	long long int a,b;
	scanf("%lld%lld",&a,&b);
	long long int tmp;
	if(a<b){
		tmp = b;
		b = a;
		a = tmp;
	}

	tmp = gcd(a,b);
	tmp = (a*b)/tmp;
	printf("%lld\n",tmp);

	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)













ll h, w;
vector<string> s;
vector<vector<ll>> y_c, x_c;
ll yy, xx;

ll dfs1(ll y, ll x, ll cnt){
    yy = max(yy, y);
    if(y >= h || s[y][x] == '#') return cnt;
    return y_c[y][x] = dfs1(y + 1, x, cnt + 1);
}

ll dfs2(ll y, ll x, ll cnt){
    xx = max(xx, x);
    if(x >= w || s[y][x] == '#') return cnt;
    return x_c[y][x] = dfs2(y, x + 1, cnt + 1);
}


int main(){
    cin >> h >> w;
    s.resize(h);
    REP(i, h){
        cin >> s[i];
    }
    y_c.resize(h, vector<ll>(w));
    x_c.resize(h, vector<ll>(w));
    REP(j, w){
        yy = 0;
        ll i = 0;
        while(i < h){
            dfs1(i, j, 0);
            i = yy + 1;
        }
    }
    REP(i, h){
        xx = 0;
        ll j = 0;
        while(j < w){
            dfs2(i, j, 0);
            j = xx + 1;
        }
    }
    ll ans = 0;
    REP(i, h){
        REP(j, w){
            ans = max(ans, y_c[i][j] + x_c[i][j] - 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 67072
n, t = map(int, input().split())

least = 10000

for _ in range(n):
	thisCost, thisTime = map(int, input().split())
	
	if thisTime <= t:
		if thisCost < least:
			least = thisCost
			
if least == 10000:
	print("TLE")
else:
	print(least)

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n); for(auto&&i:a)cin>>i;
	int xorr=a.front();
	for(auto i=a.begin()+1;i!=a.end();++i)xorr^=*i;
	int ans=xorr^a.front();
	cout<<ans;
	for(auto i=a.begin()+1;i!=a.end();++i){
		ans=xorr^*i;
		cout<<" "s<<ans;
	}
	cout<<"\n"s;
}

Measured memory_bytes: 3984
import java.util.*;

public class Main {

    static class Edge {
        int from, to, id;

        public Edge(int from, int to, int id) {
            this.from = from;
            this.to = to;
            this.id = id;
        }
    }

    static class Pair implements Comparable<Pair> {
        int id, prevColor;

        public Pair(int id, int prevColor) {
            this.id = id;
            this.prevColor = prevColor;
        }

        @Override
        public int compareTo(Pair o) {
            return id - o.id;
        }
    }

    static void bfs(int at) {
        visited = new boolean[N];
        visited[at] = true;

        Deque<Pair> deq = new ArrayDeque<>();
        deq.offer(new Pair(0, -1));

        while(!deq.isEmpty()) {
            Pair node = deq.poll();
            int color = 1;
            if (color == node.prevColor) ++color;

            for (Edge edge : graph.get(node.id)) {
                if (visited[edge.to]) continue;
                deq.offer(new Pair(edge.to, color));
                visited[edge.to] = true;
                res[edge.id] = color;
                ++color;
                if (color == node.prevColor) ++color;
            }
        }
    }

    static int N;
    static int maxDeg = 0;
    static List<List<Edge>> graph;
    static int[] res;
    static boolean[] visited;
    static List<Pair> edges;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        graph = new ArrayList<>();
        res = new int[N-1];
        for (int i = 0; i < N; ++i) graph.add(new ArrayList<>());

        edges = new ArrayList<>();
        for (int i = 0; i < N-1; ++i) {
            int a = Integer.parseInt(sc.next()) - 1;
            int b = Integer.parseInt(sc.next()) - 1;
            graph.get(a).add(new Edge(a, b, i));
            graph.get(b).add(new Edge(b, a, i));
        }

        int maxColor = 0;
        for (int i = 0; i < N; ++i) {
            maxColor = Math.max(maxColor, graph.get(i).size());
        }

        for (int i = 0; i < N; ++i) {
            maxDeg = Math.max(maxDeg, graph.get(i).size());
        }


        bfs(0);

        System.out.println(maxColor);
        for (int i = 0; i < res.length; ++i) {
            System.out.println(res[i]);
        }
    }
}

Measured memory_bytes: 74804
#include <iostream>
using namespace std;
int main(){
	int n; cin>>n;
	int r[] = {1,1,2};
	if( n<=2 ){
		cout<<r[n]<<endl;
		return 0;
	}
	while( n>0 ){
		int tmp = r[1] + r[2];
		r[0] = r[1]; r[1] = r[2]; r[2] = tmp;
		n = n-1;
	}
	cout<<r[0]<<endl;
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        String S = sc.next();
        boolean move = true;
        boolean oikoshi = true;
      for (int i=A-1;i<Math.max(C,D)-1;i++){
        String judge = S.substring(i,i+2);
        if (judge.equals("##")){
          move = false;
        }
      }
      if (C>D){
        oikoshi = false;
        for (int i=B-2;i<D-1;i++){
          String judge = S.substring(i,i+3);
          //System.out.println(judge);
          if (judge.equals("...")){
          oikoshi = true;
        }
      }
      }
      if (move&&oikoshi){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
       
    }
}

Measured memory_bytes: 40792
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll ans;
    if (n==3) cout << "2 5 63\n";
    else if (n%2 == 0) {
        vll ans = {2, 10, 3, 9, 4, 8, 6, 12};
        ll j=0;
        while ((j+1)*8 <=n) {
            for (ll i=0; i<8; i++) {
                cout << ans[i]+12*j;
                if (i!=7) cout << ' ';
            }
            if ((j+1)*8==n) cout << '\n';
            else cout << ' ';
            j++;
        }
        for (ll i=0; i<n%8; i++) cout << ans[i]+12*j << (i==(n%8)-1?'\n':' ');
    } else {
        vll ans = {6, 2, 10, 3, 9, 4, 8, 12};
        ll j=0;
        while ((j+1)*8 <=n) {
            for (ll i=0; i<8; i++) {
                cout << ans[i]+12*j;
                if (i!=7) cout << ' ';
            }
            if ((j+1)*8==n) cout << '\n';
            else cout << ' ';
            j++;
        }
        for (ll i=0; i<n%8; i++) cout << ans[i]+12*j << (i==(n%8)-1?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);

double dp[20][20][10000]={};

#include <complex>
typedef complex<double> P;
double angle(P a, P b, P c)
{
   return arg((c-b)/(b-a));
}
int main(){
	int n;
	cin>>n;
	double r,theta;
	cin>>r>>theta;
	double radian_theta=theta*PI/180;
	vector<P> coords(n);
	REP(i,n){
		int x,y;
		cin>>x>>y;
		coords[i]=P(x,y);
	}
	REP(i,20)REP(j,20)REP(k,10000){
		dp[i][j][k]=9999999;
	}
	dp[0][0][0]=0;
	vector<vector<double> > dist(n,vector<double>(n));
	REP(i,n){
		REP(j,n){
			dist[i][j]=abs(coords[i]-coords[j]);
		}
	}
	vector<vvi> isDirOk(n,vvi(n,vi(n)));
	REP(i,n){
		isDirOk[0][0][i]=1;
	}
	REP(i,n){
		REP(j,n){
			REP(k,n){
				if(i==j||j==k){
					continue;
				}
				double a=angle(coords[i],coords[j],coords[k]);
				isDirOk[i][j][k]=(abs(a)<radian_theta+EPS);
			}		
		}
	}
	int ans=0;
	REP(carrot,10000){
		REP(cur,n){
			REP(prev,n){
				REP(next,n){
					if(cur==next)continue;
					if(isDirOk[prev][cur][next]&&dp[cur][prev][carrot]+dist[cur][next]<r){
						dp[next][cur][carrot+1]=min(dp[next][cur][carrot+1],dp[cur][prev][carrot]+dist[cur][next]);
						ans=max(ans,carrot+1);
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}

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

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  
  vector<vector<int>> vec(N, vector<int>(M+1));
  for (int i = 0; i < N; i++) {
    int C;
    cin >> C;
    vec.at(i).at(0) = C;
    for (int j = 0; j < M; j++) {
      int A;
      cin >> A;
      vec.at(i).at(j+1) = A;
    }
  }
  bool imp = false;
  vector<int> sum(M+1,0);
  for (int j = 0; j < M+1; j++) {
    for (int i = 0; i < N; i++) {
      sum.at(j) += vec.at(i).at(j);
    }
    if (j > 0 && sum.at(j) < X) {
      cout << -1 << endl;
      imp = true;
      break;
    }
    while (imp) {
      break;
    }
  }
  
  int ans = 100000000;
  for (int bit = 0; bit < (1<<N); bit++) {
    vector<int> newsum(M+1,0);
    for (int j = 0; j < M+1; j++) {
      for (int i = 0; i < N; ++i) {
        if (bit & (1<<i)) {
          newsum.at(j) += vec.at(i).at(j);
        }
      }
    }
    int cnt = 0;
    for (int j = 0; j < M+1; j++) {
      if (j > 0 && newsum.at(j) < X) {
        break;
      }
      cnt++;
    }
    if (cnt == M+1) {
      chmin(ans, newsum.at(0));   
    }
  }
  
  if (ans != 100000000) {
  cout << ans << endl;
  }
}

Measured memory_bytes: 3644
s = input()
N = len(s) + 1

A = [0] * N
B = [0] * N

for i in range(1, N):
    if s[i-1] == "<":
        A[i] = A[i-1] + 1
for i in range(N-1)[::-1]:
    if s[i] == ">":
        B[i] = B[i+1] + 1

C = [max(A[i], B[i]) for i in range(N)]
print(sum(C))

Measured memory_bytes: 86092
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
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;
}
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

void solve() {
    int n;
    cin >> n;
    ll ans = 0;
    V<ll> A(n);
    rep(i, n) cin >> A[i];
    rep(i, n) {
        ll a = A[i];
        ans += a / 2;
        a = a % 2;
        if (a == 1 and i < n - 1 and A[i + 1] > 0) {
            ans += 1;
            A[i + 1]--;
        }
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if(4*a*b < (c-a-b)*(c-a-b) && c-a-b>0) PR("Yes");
    else PR("No"); 

    return 0;
}

/*

a + 2sqrt(ab) + b < c
4ab < (c-a-b)^2

*/

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] initials = {'M', 'A', 'R', 'C', 'H'};
        int n = sc.nextInt();
        HashMap<Character, Long> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            String name = sc.next();
            char initial = name.charAt(0);
            if(initial == 'M' || initial == 'A' || initial == 'R' || initial == 'C' || initial == 'H') {
                map.put(initial, map.getOrDefault(initial, 0L) + 1);
            }
        }
        long count = 0;
        for(int i = 0; i < 3; i++) {
            for(int j = i + 1; j < 4; j++) {
                for(int k = j + 1; k < 5; k++) {
                    count += (map.getOrDefault(initials[i], 0L) * map.getOrDefault(initials[j], 0L) * map.getOrDefault(initials[k], 0L));
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 44432
#include <iostream>
#include <vector>

using namespace std;

using Graph = vector<vector<int>>;

void RoyFloyd(Graph &g)
{
    int n = g.size();
    for (int k = 0; k < n; k += 1) {
        for (int i = 0; i < n; i += 1) {
            for (int j = 0; j < n; j += 1) {
                if (i == j || i == k || j == k) {
                    continue;
                }
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

int main()
{
    int rows, cols;
    cin >> rows >> cols;

    Graph graph(10, vector<int>(10));
    for (auto &row : graph) {
        for (auto &num : row) {
            cin >> num;
        }
    }
    RoyFloyd(graph);

    int sum = 0;
    for (int i = 0; i < rows; i += 1) {
        for (int j = 0; j < cols; j += 1) {
            int num;
            cin >> num;
            sum += (num == -1 ? 0 : graph[num][1]);
        }
    }

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


Measured memory_bytes: 256
import math
def prime(num):
    judge = True
    for i in range(2, int(math.sqrt(num)+1)):
        if num % i == 0:
            judge = False
    return judge
    
n = int(input())
cnt = 0
ns=[]
for i in range(n):
    num = int(input())
    if prime(num):
        cnt += 1
print(cnt)


Measured memory_bytes: 5676
#include <stdio.h>

#define MAX_CHAR 4

int main(void)
{
	char str[MAX_CHAR] = {'\0'};
	int x = 0;

	if (fgets(str, MAX_CHAR, stdin) != NULL) {
		x = atoi(str);
		printf("%d\n", x*x*x);
		return 0;
	} else {
		return 1;
	}
}

Measured memory_bytes: 528
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int scoreCount = sc.nextInt();
            if (scoreCount == 0) {
                break;
            }

            int[] scores = new int[scoreCount];
            for (int i = 0; i < scores.length; i++) {
                scores[i] = sc.nextInt();
            }

            Arrays.sort(scores);

            int sum = 0;
            for (int i = 1; i < scores.length - 1; i++) {
                sum += scores[i];
            }
            int ave = sum / (scores.length - 2);

            System.out.println(ave);
        }

        sc.close();
    }
}


Measured memory_bytes: 29472
#include <stdio.h>
  
int main(void)
{
    int H, W, i, j;
  
 
 
    while(1){
    scanf("%d %d", &H, &W);
        if(H!=0 || W!=0){
            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if(i == 0 || i == H-1 || j == 0 || j == W-1){ 
                    printf("#");
                    }
                    else{printf(".");}
                    }
            printf("\n");
            }
            printf("\n");
            }
        else{
            break;
        }
    }
    return 0;
}  

Measured memory_bytes: 572
#coding:utf-8
import numpy as np
N, M = map(int,input().split())
X = list(map(int,input().split()))
X = sorted(X)
d = np.diff(X)
d = sorted(d)
if N == 1:
    print (sum(d))
else:
    print (sum(d[:-(N-1)]))


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    ll N;
    cin >> N;

    vector<pair<ll,ll>> pos;
    for (ll i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        pos.push_back({x, y});
    }

    sort(all(pos));

    map<pair<ll,ll>,ll> freq;
    for (ll i = 0; i < N; i++) {
        for (ll j = i+1; j < N; j++) {
            freq[make_pair(pos[i].first-pos[j].first, pos[i].second- pos[j].second)]++;
        }
    }

    ll maxval = 0;
    for (auto itr = freq.begin(); itr != freq.end(); itr++) {
        if (maxval < itr->second) {
            maxval = itr->second;
        }
    }

    cout << N - maxval << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 384