akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr *bufio.Reader

func main() {
	rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)
	solve()
}

func solve() {
	var N, K, Q int
	fmt.Scanf("%d %d %d", &N, &K, &Q)
	scores := make([]int, N)
	for i := 0; i < Q; i++ {
		a := readint()
		scores[a-1] += 1
	}

	for _, v := range scores {
		if K-Q+v > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

func readline() string {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readIntSlice(size int) []int {
	slice := make([]int, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i(v)
	}
	return slice
}

func readInt64Slice(size int) []int64 {
	slice := make([]int64, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i64(v)
	}
	return slice
}

func readint() int {
	v, _ := rdr.ReadString('\n')
	return s2i(strings.TrimRight(v, "\n"))
}

func readint64() int64 {
	return s2i64(readline())
}

// For int64
func b2i64(b bool) int64 {
	if b {
		return 1
	}
	return 0
}

func abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func min64(values ...int64) int64 {
	ret := int64(INF_INT64)
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max64(values ...int64) int64 {
	ret := -int64(INF_INT64)
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int
func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func min(values ...int) int {
	ret := INF_INT
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max(values ...int) int {
	ret := -INF_INT
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i(s string) int {
	v, ok := strconv.Atoi(s)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int")
	}
	return v
}


Measured memory_bytes: 8480
import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, *AB = map(int, read().split())
    G = [[] for _ in range(N)]
    for i, (a, b, c) in enumerate(zip(*[iter(AB)] * 3)):
        G[a - 1].append((b - 1, c, i))
        G[b - 1].append((a - 1, c, i))

    vec = [False] * M
    for i in range(N):
        dist = [INF] * N
        dist[i] = 0
        from_edge = [[] for _ in range(N)]
        hq = [(0, i)]

        while hq:
            d, v = heappop(hq)
            if dist[v] < d:
                continue
            for nv, cost, edge in G[v]:
                if dist[nv] > d + cost:
                    dist[nv] = d + cost
                    heappush(hq, (dist[nv], nv))
                    from_edge[nv] = [edge]
                elif dist[nv] == d + cost:
                    from_edge[nv].append(edge)

        for edges in from_edge:
            for e in edges:
                vec[e] = True

    ans = sum(1 for flag in vec if not flag)
    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main(){
    string s;
    cin >> s;
    int len = s.length();

    int a = stoi(s);

    int ans = 0;
    if(len == 1){
        ans += a;
    }else if(len == 2){
        ans += 9;
    }else if(len == 3){
        ans += 9;
        ans += a - 99;
    }else if(len == 4){
        ans += 909;
    }else if(len == 5){
        ans += 909;
        ans += a - 9999;
    }else{
        ans += 90909;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def process(a):
    tmp = a[1]
    pushed = set()
    cnt = 1
    while not tmp in pushed:
        if tmp == 2:
            return cnt
        pushed.add(tmp)
        tmp = a[tmp]
        cnt += 1
    return -1

if __name__ == '__main__':
    # a = [int(input().strip()) for _ in range(int(input().strip()))]
    a = list(map(int, sys.stdin))
    print(process(a))

Measured memory_bytes: 13204
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back


bool isinclude(string tar,vector<string>  a){
  rep(i,a.size()){
    string tmp = a[i].substr(1,(int)a[i].size()-2);
    if (tmp == tar)return true;
    /*
      if (search(tmp.begin(),tmp.end(),tar.begin(),tar.end()) != 
      tmp.end())return true;
    */
  }
  return false;
}


vector<string> makeans(vector<string> a){
  vector<string> ret; 
  rep(i,a.size()){
    if (!isinclude(a[i],a))ret.pb(a[i]);
  }
  return ret;
}

void solve(string in){
  vector<string> ver1,ans;
  rep(i,in.size()){
    string now="";
    REP(j,i,in.size()){
      now=now+in[j];
      if (now.size() > 2){
	string tmp=now;
	reverse(ALL(tmp));
	if (tmp == now)ver1.pb(now);
      }
    }
  }

  sort(ALL(ver1));
  ver1.erase(unique(ALL(ver1)),ver1.end());

  ans =makeans(ver1);
  sort(ALL(ans));
  rep(i,ans.size()){
    if (i)cout <<' ';
    cout << ans[i];
  }
  cout << endl;
}

main(){
  string in;
  while(getline(cin,in)){
    string tar="";
    rep(i,in.size()){
      if (isalpha(in[i]))tar+=toupper(in[i]);
    }
    solve(tar);
  }
}

Measured memory_bytes: 952
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int a, b, c, d;
int main() {
  while (cin >> a >> b >> c >> d) {
	int dx = c - a, dy = d - b;
	string res = "";
	for (int i = 0; i < dx; ++i) res += "R";
	for (int i = 0; i < dy; ++i) res += "U";
	for (int i = 0; i < dx; ++i) res += "L";
	for (int i = 0; i < dy; ++i) res += "D";
	res += "D";
	for (int i = 0; i <= dx; ++i) res += "R";
	for (int i = 0; i <= dy; ++i) res += "U";
	res += "L";
	res += "U";
	for (int i = 0; i <= dx; ++i) res += "L";
	for (int i = 0; i <= dy; ++i) res += "D";
	res += "R";
	cout << res << endl;
  }
}
		 






Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

using ll = long long;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define tc() int t; cin>>t; while(t--)
#define print(n) cout<<n<<"\n"
#define inp(n) int n; cin>>n
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define maxn 1000010
#define mod 1e9+7
#define ff  first
#define ss  second
#define fora(var, start, end) for(int var = start; var < end; var++)
int main()
{
    fast();
   string s;
   cin>>s;
   string a= s.substr(0,(s.length()/2));
   string b= s.substr(0+(s.length()/2)+1, s.length());
   debug(a);
   debug(b);
   string ad= a;
   string bd =b;
   reverse(all(a));reverse(all(b));
   if(a==ad and b==bd and a==bd)print("Yes");
   else print("No");
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#define to(k) E[k].to
#define next(k) E[k].next

using namespace std ;

const int N = 200010 ;

struct Edge{
    int to, next ;
}E[N * 2] ;
int n ;
int tot ;
int cnt ;
int q[N] ;
int p[N] ;
int d[N] ;
int fa[N] ;
int vis[N] ;
int dep[N] ;
int deg[N] ;
int head[N] ;

void add(int u, int v){
    to(++ cnt) = v, next(cnt) = head[u], head[u] = cnt ;
    to(++ cnt) = u, next(cnt) = head[v], head[v] = cnt ;
}
int dfs(int u, int faa){
    int ret = u, s ;
    fa[u] = faa, dep[u] = dep[faa] + 1 ;
    for (int k = head[u] ; k ; k = next(k)){
        if (to(k) != faa){
            s = dfs(to(k), u) ;
            if (dep[ret] < dep[s]) ret = s ;
        }
    }
    return ret ;
}
int main(){
    cin >> n ;
    int rt1, rt2, num, u, v ;
    for (int i = 1 ; i < n ; ++ i)
        scanf("%d%d", &u, &v), add(u, v) ;
    rt1 = dfs(1, 0) ; fa[rt1] = 0 ;
    dep[rt1] = 0 ; rt2 = dfs(rt1, 0) ;
    //cout << rt1 << " " << rt2 << endl ;
    for ( ; rt2 ; rt2 = fa[rt2])
        vis[rt2] = 1, d[++ tot] = rt2 ;
    //cout << tot << endl ;
    for (int i = 1 ; i <= n ; ++ i){
        if (vis[i]) continue ; bool ans = 0 ;
        for (int k = head[i] ; k ; k = next(k))
            if (vis[to(k)]) { deg[to(k)] ++, ans = 1 ; break ; }
        if (!ans) return puts("-1"), 0 ;
    }
    num = 0 ;
    for (int i = 1 ; i <= tot ; ++ i){
        for (int j = 1 ; j <= deg[d[i]] ; ++ j)
            p[num + j] = num + j + 1 ;
        p[num + deg[d[i]] + 1] = num + 1 ; num += deg[d[i]] + 1 ;
    }
    num = 0 ;
    for (int i = tot ; i >= 1 ; -- i){
        for (int j = 1 ; j <= deg[d[i]] ; ++ j)
            q[num + j] = num + j + 1 ;
        q[num + deg[d[i]] + 1] = num + 1 ; num += deg[d[i]] + 1 ;
    }
    for (int i = 1 ; i <= n ; ++ i)
        if (p[i] != q[i]){
            if (p[i] < q[i]){
                for (int j = 1 ; j <= n ; ++ j)
                    printf("%d ", p[j]) ; puts("") ;
                return 0 ;
            }
            else {
                for (int j = 1 ; j <= n ; ++ j)
                    printf("%d ", q[j]) ; puts("") ;
                return 0 ;
            }
        }
    for (int j = 1 ; j <= n ; ++ j)
        printf("%d ", p[j]) ; puts("") ;
    return 0 ; 
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

int gcd(int a,int b){
  if(a<b) swap(a,b);
  if(a%b==0) return b;
  else return gcd(b,a%b);
}


signed main(){
  cin.tie(0);	
  int n;
  int a,b,c,d;
  int p[200],q[200];
  cin>>n;
  rep(i,n){
    cin>>p[i];p[i]--;
  }
  rep(i,n){
    cin>>q[i];q[i]--;
  }
  int visited[200]={0};
  vector<pair<int,int> > mo;
  rep(i,n){
   
    //cout<<endl;
    if(visited[i]) continue;
    else{
      visited[i]=1;
      c=q[i];
      int cnt=1;
      while(c!=i){
	visited[c]=1;
	c=q[c];
	cnt++;
      }
      // debug(1);
      c=p[i];
      int cnt2=0;
      while(c!=i){
	//debug(c);
	c=q[c];
	cnt2++;
	if(cnt2>n){cout<<-1<<endl;return 0;}
      }
      //cout<<cnt<<" "<<cnt2<<endl;
      c=i;
      int cc=p[i];
      rep(j,cnt){
	cc=p[c];
	rep(k,cnt2){
	  cc=q[cc];
	}
	//cout<<cc<<endl;
	if(cc!=c){cout<<-1<<endl;return 0;}
	c=q[c];
      }
      mo.push_back(make_pair(cnt,cnt2));
    }
  }
  a=mo[0].fst;b=mo[0].scd;
  repi(i,1,mo.size() ){
    c=mo[i].fst;
    d=mo[i].scd;
    if(a<c){
      swap(a,c);
      swap(b,d);
    }
    rep(j,c){
      if(b%c==d){
	a=a*c/gcd(c,a);
	break;
      }
      b+=a;
      if(j==c-1){cout<<-1<<endl;return 0;}
    }
  }
  cout<<b<<endl;
      
    
  return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n ;
    int a[100][100];
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> a[i][j];
        }
    }
    for (int k = 0; k < 2; ++k) {
        for (int i = 1; i < n; ++i) {
            a[k][i] += a[k][i-1];
        }
    }

    int res = INT_MIN;
    for (int l = 0; l < n; ++l) {
        res = max(res, a[0][l] + a[1][n-1] - a[1][l-1]);
    }
    res = max(res, a[0][0] + a[1][n-1]);

    cout <<res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const double EPS = 1e-11;
const double PI = 2 * acos(0.0);
using ll = long long;
using ull =  unsigned long long;

#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout)
#define fast_io ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define pf printf
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sll(x,y) scanf("%lld %lld",&x,&y)

#define pii pair<int,int>
#define nl '\n'
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define uniq(a) a.erase(unique(a.begin(), a.end()), a.end())
#define out(x) cout <<"#x = "<<x<<endl
#define outt(x,y) cout <<"# "<<x<<" "<<y<<endl
#define mem(array,value) memset(array,value,sizeof(array))

const int MX = 1e5+5;

std::vector<int>node[MX];
bool vis[MX];
int dp[MX];
int n,m;

void dfs(int s)
{
	//if(!vis[s])return 0;
	vis[s]=1;
	for(auto d:node[s]){
		if(!vis[d]){
			dfs(d);
		}
		dp[s]=max(dp[s],dp[d]+1);
	}
}
int main()
{
	fast_io
	cin >>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin >>a>>b;
		node[a].pb(b);
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			dfs(i);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,dp[i]);
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1; 
  string s2;
  cin>>s1>>s2;
  int cnt=0;
  for(int i=0; i<s1.size(); i++)
  {
    if(s1[i]==s2[i])
    {
      continue;
    }
    else
      cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3920
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    
    for(int i=1; i<=n/2; i++){
      int j = n - i;
      if(n == i+j && i != j){
        count++;
      }
    }
    
    System.out.println(count);
  }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll imos[100010];

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

  ll X;
  cin>>X;

  rep(i,1000001){
    if(i*100<100010)imos[i*100]++;
    if(i*105+1<100010)imos[i*105+1]--;
  }
  rep(i,100009)imos[i+1]+=imos[i];
  if(imos[X]>0)cout<<1<<endl;
  else cout<<0<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(){
  int n, m ;
  cin >> n >> m ;
  int h[n] ;
  for(int i=0;i<n;i++){
    cin >> h[i] ;
  }
  int a, b ;
  int check[n] ;
  for(int i=0;i<n;i++) {
    check[i] = 1 ;
  }
  for(int i=0;i<m;i++){
    cin >> a >> b ;
    if(h[a-1] >= h[b-1]) check[b-1] = 0 ;
    if(h[a-1] <= h[b-1]) check[a-1] = 0 ;
  }
  int ans = 0 ;
  for(int i=0;i<n;i++){
    if(check[i] == 1) ans ++ ;
  }
  cout << ans ;
  return 0 ;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;

int N, M;
int a, b;

vector<int> G[202020];

bool dfs(int i, int v, int p)
{
    //cout << v << endl;

    if (i == 2) {
        if (v == N - 1) return true;
        else return false;
    }

    bool flag = false;
    REP(j,G[v].size()) {
        int nv = G[v][j];
        if (nv == p) continue;
        if (dfs(i + 1, nv, v)) flag = true;
    }

    return flag;
}

signed main()
{
    cin >> N >> M;
    REP(i,M) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    if (dfs(0, 0, -1)) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


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

int main() {
  int N,count = 1;
  cin >> N;
  
  vector<string> s(N);
 
  
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  
  sort(s.begin(), s.end());
  
  for(int i = 1; i < N; i++){
    if(s.at(i-1) > s.at(i) || s.at(i-1) < s.at(i)){
      count++;
    }
  }

  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 9532
#include "bits/stdc++.h"

using namespace std;

// ok[i][j] := elm[i] が s[j] で受理されるか
bool ok[12][5000];
// dp[i][j] := s[i] までで j(mask) が受理されるか
bool dp[5000][1 << 12];

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

    int n, m;
    while (cin >> n >> m, n || m)
    {
        vector<string> elm(n);
        for (int i = 0; i < n; i++)
            cin >> elm[i];
        string s = "";
        for (int i = 0; i < m; i++)
        {
            string a;
            cin >> a;
            s += a;
        }
        int m = s.size();
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                ok[i][j] = false;
        for (int i = 0; i < m; i++)
            for (int j = 0; j < (1 << n); j++)
                dp[i][j] = false;
        for (int i = 0; i < n; i++)
        {
            int sz = elm[i].size();
            for (int j = 0; j <= m - sz; j++)
            {
                if (elm[i] == s.substr(j, sz))
                {
                    ok[i][j + sz - 1] = true;
                    dp[j + sz - 1][1 << i] = true;
                }
            }
        }
        for (int i = 0; i < m; i++)
        {
            for (int j = 1; j < (1 << n); j++)
            {
                if (!dp[i][j])
                    continue;
                for (int k = 0; k < n; k++)
                {
                    int sz = elm[k].size();
                    if (i + sz >= m)
                        continue;
                    if ((j >> k) & 1)
                        continue;
                    if (!ok[k][i + sz])
                        continue;
                    dp[i + sz][j ^ (1 << k)] = true;
                }
            }
        }
        int ret = 0;
        for (int i = 0; i < m; i++)
            if (dp[i][(1 << n) - 1])
                ret++;
        cout << ret << endl;
    }
}



Measured memory_bytes: 23212
n,k=gets.split.map(&:to_i)
a,f=[gets,gets].map{|x|x.split.map(&:to_i).sort}
p (0..a.max*f.max).bsearch{|x|t=0;n.times{|i|a[-i-1]>x/f[i]&&t+=a[-i-1]-x/f[i]};t<=k}

Measured memory_bytes: 34292
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin >> x;
  if(x>=400&&x<600)
    cout << "8" << endl;
  if(x>=600 && x<800)
    cout << "7" << endl;
  if(x>=800 && x<1000)
    cout << "6" << endl;
  if(x>=1000 && x<1200)
    cout << "5" << endl;
  if(x>=1200 && x<1400)
    cout << "4" << endl;
  if(x>=1400 && x<1600)
    cout << "3" << endl;
  if(x>=1600 && x<1800)
    cout << "2" << endl;
  if(x>=1800 && x<2000)
    cout << "1" << endl;
        
        
}

Measured memory_bytes: 3624
/*
 * atcoder/abc103/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * f(m) = (m mod a_1) + (m mod a_2) + ... + (m mod a_N)
 * N = 1の時) m mod a_1 の最大値は a_1 - 1
 * N = 2の時) a_1 - 1 + a_2 - 1
 * N        ) a_1 + ... + a_N - N
 */
int N;

void solve() {
  cin >> N;
  int a;
  ll total = 0;
  loop(n,0,N) {
    cin >> a;
    total += a - 1;
  }
  cout << total << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main (){
    int s;
    scanf("%d",&s);
    int i=0;
    if(s==1||s==2) i=4;
    else{
        while(s!=4){
        if(s%2==0) s/=2;
        else s=s*3+1;
        i++;
        }
        i+=4;
    }
    printf("%d",i);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    output(A.back() - A.front());
    
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input())

txy = [[0,0,0]]
for _ in range(N):
    txy.append(list(map(int,input().split())))
txy.sort()

dtxy = []
for i in range(N):
    dt=txy[i+1][0]-txy[i][0]
    dx=txy[i+1][1]-txy[i][1]
    dy=txy[i+1][2]-txy[i][2]
    ds = dt-abs(dx)-abs(dy)
    if ds<0 or ds%2 !=0:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 27280
N = int(input())
S = []
for i in range(N):
  S.append(input())

M = int(input())
T = []
for i in range(M):
  T.append(input())

ans = 0
for s in S:
  score = 0
  for s2 in S:
    if s == s2:
      score += 1
  for t in T:
    if s == t:
      score -= 1
  ans = max(ans, score)

print(ans)


Measured memory_bytes: 38896
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int maxn = 2e6 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

int main(){
	char c;
	cin >> c;
	if(c >= 'A' && c <= 'Z') cout << "A" << endl;
	else cout << "a" << endl; 
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ll n,W;
 cin>>n>>W;
 vector<ll> w(n),v(n);
 for(ll i=0;i<n;i++) cin>>w[i]>>v[i];
 vector<vector<ll>> dp(n,vector<ll>(W+1));
 for(ll i=0;i<=W;i++){
  if(i>=w[n-1]) dp[n-1][i]=v[n-1];
 }
 for(ll i=n-2;i>=0;i--){
  for(ll j=0;j<=W;j++){
   if(j>=w[i]) dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
   else dp[i][j]=dp[i+1][j];
  }
 }
 cout<<dp[0][W]<<endl;
 return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
    //    random_device rnd;
    //    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, P;
    cin >> A >> P;
    cout << (A*3+P)/2 << endl;
}


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

using namespace std;
double a[200];
int main() {
  int n; cin >> n;
  for(int i=1; i<=n; ++i)
    cin >> a[i];
  double sm = 0;
  for(int i=1; i<=n; ++i)
    sm += (1/a[i]);
  cout << 1/sm << "\n";
  return 0;
}


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

typedef vector<int> vi;
#define ll long long
#define PI 3.14159265359
#define x first
#define y second
#define point pair<int,int>
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
ll dp[400][400];
ll OO = 1e15 + 10;

vector<ll> a, a_sum;
int main() {
    int n; cin>>n;
    a= vector<ll> (n);
    a_sum = vector<ll> (n);

    for(int i = 0; i < n; i++){
        cin>>a[i];
        a_sum[i] = a[i];
        if(i) a_sum[i]+= a_sum[i - 1];
    }


    for(int i = 0; i <  n - 1; i++){
        dp[i][i + 1] = a[i] + a[i + 1];
    }

    for(int sz = 2; sz < n; sz++){
        for(int i = 0; i < n - sz; i++){
         int j = i + sz;
         dp[i][j] = OO;

         for(int k  = i; k < j; k++)
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j]);

         dp[i][j] += a_sum[j];
         if(i - 1 >= 0) dp[i][j] -= a_sum[i - 1];
        }
    }

    cout<<dp[0][n - 1];
}


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


int main()
{
    string S;
    cin >> S;
    int count=0;
    for(int i=0; i<3; i++)
    {
        if(S.at(i)=='1')
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int H,W;
        cin>>H>>W;
        if(H==0&&W==0){
            return 0;
        }
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i%2==0 && j%2==0){
                    cout<<"#";
                }
                if(i%2==0 && j%2!=0){
                    cout<<".";
                }
                if(i%2!=0 && j%2==0){
                    cout<<".";
                }
                if(i%2!=0 && j%2!=0){
                    cout<<"#";
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3084
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] A = new int [N];
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
        }
        solve(N,A);
    }
    static void solve(int N, int[]A){
        if(N%2==0){
            even(N,A);
        }else{
            odd(N,A);
        }
    }
    static void even(int N, int[]A){
        int [] B = new int [N];
        int k=0;
        for(int i=N-1; i>=0; i-=2){
            B[k] = A[i];
            k++;
        }
        for(int i=0; i<N; i+=2){
            B[k] = A[i];
            k++;
        }
        print(N,B);
    }
    static void odd(int N, int[]A){
        int [] B = new int [N];
        int k=0;
        for(int i=N-1; i>=0; i-=2){
            B[k] = A[i];
            k++;
        }
        for(int i=1; i<N; i+=2){
            B[k] = A[i];
            k++;
        }
        print(N,B);
    }
    static void print(int N, int[]B){
        for(int i=0; i<N; i++){
            System.out.print(B[i]);
            if(i!=N-1)System.out.print(" ");
        }
    }
}

Measured memory_bytes: 93560
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
const long long int sMod = 998244353;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

Vi nxt(100030);
Vi seen(100030);
Vi res(100030);

void solve(){
    ll n,x,m;
    cin >> n >> x >> m;
    rp(i,100020){
        nxt[i]=i*i%m;
    }
    ll pos=x;
    ll ctr=1;
    ll sum=0;
    while(seen[pos]==0){
        if(ctr==n+1){
            print(sum);
            return;
        }
        seen[pos]=ctr;
        sum+=pos;
        res[ctr]=sum;
        pos=nxt[pos];
        ctr++;
    }
    sum+=(res[ctr-1]-res[seen[pos]-1])*((n+1-ctr)/(ctr-seen[pos]));
    ll rest=(n+1-ctr)%(ctr-seen[pos]);
    rp(i,rest){
        sum+=pos;
        pos=nxt[pos];
    }
    print(sum);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 5496
#include <bits/stdc++.h>
#define maxn (int)(1e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;
vector<i64>d;

void generate_divisors(i64 n){
    d.clear();
    for(i64 i=1;i*i<=n;i++){
        if(n%i==0){
            d.push_back(i);
            if(n/i != i) d.push_back(n/i);
        }
    }
}

i64 solve(i64 n){
    generate_divisors(n);
    int nod = d.size();
    i64 minVal = LLONG_MAX, ans;
    for(int i=0;i<nod;i++){
        for(int j=i;j<nod;j++){
            if(d[i]*d[j] == n) {
                ans = (d[i]-1) + (d[j]-1);
                minVal = min(minVal, ans);
            }
        }
    }
    return minVal;
}
int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    // */
    
    i64 n;
    while(scanf("%lld",&n)==1){
        printf("%lld\n", solve(n));
    }    
    return 0;
}

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

using namespace std;

#define ll long long int
#define fo(i,b,n) for(int i=(b); i<(n) ; i++)
#define xx first
#define yy second
#define pb push_back
#define sz(n) int(n.size())
#define pii pair
#define MP make_pair

#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define readl(x) scanf("%lld",&x)
#define readl2(x,y) scanf("%lld%lld",&x,&y)
#define readd(x) scanf("%lf",&x)
#define readd2(x,y) scanf("%lf%lf",&x,&y)

#define pr(n) printf("%d",n)
#define prn(n) printf("%d\n",n)
#define prl(n) printf("%lld",n)
#define prln(n) printf("%lld\n",n)
#define prd(x) printf("%lf",x)
#define prdn(x) printf("%lf\n",x)

#define TC(n) printf("Case %d: ",n)

const int N=105;
int grid[N][N];

int main()
{
    int r,c,n;
    read2(r,c);

    read(n);

    int xl,xr,yl,yr;
    xl=0;
    yl=0;
    xr=r,yr=c;

    fo(u,0,n){
        int x,y,t;
        read2(x,y);
        read(t);
        if(t==1) xl=max(xl,x);
        else if(t==2) xr=min(xr,x);
        else if(t==3) yl=max(yl,y);
        else if(t==4) yr=min(yr,y);
    }

    int ret=(xr-xl);
    int ret2=(yr-yl);
    int one=max(0, ret );
    int two=max(0, ret2 );

    prn(one*two);
    return 0;

}

















Measured memory_bytes: 384
import heapq
h = []
N, M = map(int, input().split())
As = list(map(int, input().split()))
for i in As:
    heapq.heappush(h, -i)
for _ in range(M):
    i = heapq.heappop(h)
    i = -1 * (-i // 2)
    heapq.heappush(h, i)

print(sum([-1 * heapq.heappop(h) for i in range(len(h))]))

Measured memory_bytes: 14180
def DFS(N, copyedge):
    matrix = [[] for i in range(N)]
    for a, b in copyedge:
        matrix[a] += [b]
        matrix[b] += [a]
    check = [True]*N
    check[0] = False
    Que = [0]
    
    while len(Que) != 0:
        now = Que.pop()
        for j in matrix[now]:
            if check[j] == True:
                check[j] = False
                Que.append(j)
    if check == [False]*N:
        return 0
    else:
        return 1       

ans = 0
N, M = map(int, input().split())
edge = []

for i in range(M):
    edge.append([int(i)-1 for i in input().split()])

for i in range(M):
    copyedge = edge[:i]+edge[i+1:]
    ans += DFS(N, copyedge)
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<ll> b(n);
	rep(i, n) {
		b[i] = a[i] - i;
	}
	sort(b.begin(), b.end());

	ll mid;
	if (n % 2 == 0) mid = (b[n / 2 - 1] + b[n / 2]) / 2;
	else mid = b[(n + 1) / 2 - 1];

	ll ans = 0;
	rep(i, n) {
		ans += abs(b[i] - mid);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int a=x;
  int b=y;
  int c=z;
  swap(a,b);
  swap(a,c);
  cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int digit(ll a){
	int res = 1;
	while(a/10){
		a /= 10;
		res++;
	}
	return res;
}

int f(ll a, ll b){
	return max(digit(a),digit(b));
}

int main(void) {
	ll n; cin >> n;
	int ans = INF;
	for(ll i=1; i*i<=n; i++){
		if(n%i) continue;
		ans = min(ans,f(i,n/i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n,q = gets.split.map(&:to_i)
s = gets.chomp.chars
l = []
r = []
q.times do |i|
    l[i],r[i] = gets.split.map(&:to_i)
end
sum = 0
t = []
t[0] = 0
for i in  1..(n-1)
    if s[i-1] == 'A' && s[i] == 'C'
        sum += 1
    end
    t[i] = sum
end
for j in 0..(q-1)
    puts t[r[j]-1]-t[l[j]-1]
end

Measured memory_bytes: 12796
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();
 
function main(){
  for(var i = 0, len = input.length; i < len; i++){
    var c = input[i].split('');
    
    var count = new Int8Array(11);
    for(var j = 0, jlen = c.length; j < jlen; j++){
      count[c[j]]++; // 入力の個数をカウント
    }

    var result = [];
  JLOOP:for(var j = 1; j <= 9; j++){
      // 引く牌のループ

      if(count[j] == 4 || (!count[j-1] && !count[j] && !count[j+1])){
        continue;
      }

      var count2 = new Int8Array(count);
      count2[j]++;
    
      for(var k = 1; k <= 9; k++){
        if(count2[k] < 2)
          continue;

        var count3 = new Int8Array(count2);
        count3[k] -= 2;
        
        for(var l = 1; l <= 9; l++){
          if(count3[l-1] >= 1 && count3[l] >= 1 && count3[l+1] >= 1){
            count3[l-1]--;
            count3[l]--;
            count3[l+1]--;
          }
          if(count3[l-1] >= 1 && count3[l] >= 1 && count3[l+1] >= 1){
            count3[l-1]--;
            count3[l]--;
            count3[l+1]--;
          }
          if(count3[l] >= 3){
            count3[l] -= 3;
          }
        }
        var sum = 0;
        for(var l = 1; l <=9; l++){
          sum += count3[l];
        }

        if(!sum){
          result.push(j);
          continue JLOOP;
        }
      }
    }

    console.log(result.length?result.join(' '):'0');
    

  }
  
}

Measured memory_bytes: 9952
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n, m;
  cin >> n >> m;
  cout << (1<<m)*(1900*m+100*(n-m)) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

# N 店の数
n = int(input())

# F 店の営業計画
f = [input().replace(" ", "") for i in range(n)]

# P 営業利益
p = [list(map(int, input().split())) for i in range(n)]

p_max = -999999999999999
for i in range(1, 1024):
    f_b = format(i, '010b')
    p_10 = 0
    for f_1, p_1 in zip(f, p):
        p_cnt = 0
        for j in range(10):
            if f_1[j] == '1' and f_b[j] == '1':
                p_cnt += 1
        p_10 += p_1[p_cnt]
    if p_10 > p_max:
        if p_10 == 0:
            print(str(i))
            break
        p_max = p_10

print(p_max)

Measured memory_bytes: 12504
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using arr = vector<ll>;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

string s;
ll dp[100010][15];

int main()
{
  cin >> s;
  dp[0][0] = 1;
  int n = (int)s.size();
  REP(i, n) {
    REP(j, 13)
    if (s[i] == '?') {
      REP(k, 10) {
        (dp[i + 1][(j * 10 + k) % 13] += dp[i][j]) %= MOD;;

      } 
    } else {
      int x = s[i] - '0';
      (dp[i + 1][(j * 10 + x) % 13] += dp[i][j]) %= MOD;
    }
  }
  cout << dp[n][5];
  return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<pair<int,int>> a(9);
    for(int i = 0; i < 9; i++){
     int c;
     cin >> c;
     a[i] = make_pair(c,0);
    }
    int n;
    cin >> n;
    vector<int> b(n);
    for(int i = 0; i < n; i++)
    cin>> b[i];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 9; j++){
            if(b[i] == a[j].first)
            a[j].second = 1;
        }
    }
        bool ans = false;
        for(int i = 0; i < 3; i++){
            int bingo = 0;
            for(int j = i; j < 9; j += 3){
                if(a[j].second == 1)
                bingo++;
            }
            if(bingo == 3)
            ans = true;
        }
    if((a[0].second == 1 && a[4].second == 1 && a[8].second == 1 )|| (a[2].second == 1 && a[4].second == 1 && a[6].second == 1))
        ans = true;

    for(int i = 0; i < 7; i += 3){
        if(a[i].second == 1 && a[i + 1].second == 1 && a[i + 2].second == 1)
        ans = true;
    }
    ans == true? cout << "Yes" : cout << "No";
    cout << endl;
}

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

using namespace std;


int main(){
    int A,B,C,D,E;cin >> A >> B >> C >> D >> E;
    vector<int> uku = {A,B,C,D,E};
    sort(uku.begin(),uku.end());
    int ans = 1e9;
    do{
        int t = 0;
        for(int a = 0;a< 5;a++){
            if(t % 10 != 0)t += 10-t %10;
            t += uku.at(a);
        }
        ans = min(ans,t);
    }while(next_permutation(uku.begin(),uku.end()));
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def main():

    sentence = input()
    phrase = input()
    count = 0
    for _ in range(len(sentence)):
        if phrase in sentence:
            count =  1
            break
        else:
            sentence = sentence[1:] + sentence[0]
    
    if count == 1:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


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

a = [0]*n
b = [0]*n
 
for i in range(n):
    a[i], b[i] = map(int, input().split())

a.sort()
b.sort()

youso = int(n/2)

if n % 2 != 0:
    print(b[youso]-a[youso]+1)
else:
    print((b[youso]+b[youso-1])-(a[youso]+a[youso-1])+1)

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto& x: a){
		cin >> x;
	}
	sort(a.begin(), a.end());
	vector<int> number;
	vector<int> time;
	for(int i = 0; i < n; i++){
		number.push_back(a.at(i));
		int co = 1;
		while(i<n-1){
			if(a.at(i) == a.at(i+1)){
				co++;
				i++;
			}else{
				break;
			}
		}
		time.push_back(co);
	}
	int sum = 0;
	for(int i = 0; i < number.size(); i++){
		int v_sum = time.at(i);
		int m1 = 0;
		if(i-1 >= 0) m1 = abs(number.at(i) - number.at(i-1));
		int m2 = 0;
		if(i+1 < number.size()) m2 = abs(number.at(i) - number.at(i+1));
		if(m1 == 1) v_sum += time.at(i-1);
		if(m2 == 1) v_sum += time.at(i+1);
		if(v_sum > sum) sum = v_sum;
	}
	cout << sum <<endl;
}


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

int main() {
  long n = 0;
  long m = 0;
  cin >> n >> m;
  vector <long int> arr(m);
  for(long i = 0; i < m; i++){
    cin >> arr[i];
  }
  vector <long int> arr2(m-1);
  sort(arr.begin(),arr.end());
  for(long i = 0; i < m-1; i++){
    arr2[i] = arr[i+1] - arr[i];
  }
  long long sum = 0;
  sort(arr2.begin(),arr2.end());
  for(long i = 0; i < m-n; i++){
    sum = sum + arr2[i];
  }
  cout << sum;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5;
int a[maxn+5];
int n;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    bool bo=true;
    for (int i=1;i<n;i++)
        if (a[i]==a[i+1]) bo=false;
    if (bo) printf("YES\n");
    else printf("NO\n");
    return 0;
}




Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int main() {
	int m1, d1, m2, d2;
	cin >> m1 >> d1;
	cin >> m2 >> d2;

	bool ans = m1 != m2;
	cout << (int)ans << endl;	
}

Measured memory_bytes: 2560