akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const int INF = 1 << 30;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll mx = max({ a,b,c });
	cout << ((mx - a) + (mx - b) + (mx - c)) / 2+(((mx - a) + (mx - b) + (mx - c)) % 2==1?2:0) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int W = sc.nextInt();
			int H = sc.nextInt();
			int[][] f = new int[H + 1][W + 1];
			for (int i = 0; i < N; ++i) {
				int X = sc.nextInt();
				int Y = sc.nextInt();
				f[Y][X]++;
			}
			int[][] sum = new int[H + 1][W + 1];
			for (int i = 1; i <= H; ++i) {
				for (int j = 1; j <= W; ++j) {
					sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + f[i][j];
				}
			}
			int S = sc.nextInt();
			int T = sc.nextInt();
			int ans = 0;
			for (int i = T; i <= H; ++i) {
				for (int j = S; j <= W; ++j) {
					ans = Math.max(ans, sum[i][j] - sum[i - T][j] - sum[i][j - S] + sum[i - T][j - S]);
				}
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 34960
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N; cin >> N;
    vector<int> vA(N+2, 0); for(int i=1; i<=N; ++i){ cin >> vA[i]; }
    vector<int> vA_sum(N+2, 0); for(int i=1; i<=N+1; ++i){ vA_sum[i] = vA_sum[i-1] + abs(vA[i]-vA[i-1]); }
    
    for(int i=1; i<=N; ++i){
        int r = vA_sum[N+1] - vA_sum[i+1]; // [N+1, i+1)
        int m = abs(vA[i+1] - vA[i-1]);    // [i+1, i-1)
        int l = vA_sum[i-1] - vA_sum[0];   // [i-1, 0  )
        cout << r + m + l << endl;
    }
    
    return 0;
}

// 6
// -679 -2409 -3258 3095 -3291 -4462

// -4462 -3291 -3258 -2409 -679 3095
// 0 => -679 => -2409 => -3258 => 3095 => -3291 => -4462 => 0
//                        3258*2 +3095*2          + 4462*2 = 21630

// 0 => -679  =>  -2409   => -3258  =>  3095  => -3291  => -4462 => 0
// | 679 |  2409-679  |3258-2409|3095+3258|3291+3095|4462-3291| 4462|

/*
3
3 5 -1
vA     = [ 0 3 5 -1 0 ]
vA_sum = [ 0 3 5 11 12 ]
*/

Measured memory_bytes: 2048
s = gets.chomp.split("")

alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "s", "t", "u", "v", "w", "x", "y", "z"]

s.sort!.uniq!

ans = alphabet - s
if ans.empty? then
  puts "None"
else
  puts ans[0]
end

Measured memory_bytes: 7928
a,b,x = gets.split.map(&:to_i)

=begin
while a % x != 0 do
  if a == b
    puts 0
    exit
  end
  a += 1
end

while b % x != 0 do
  if a == b
    puts 0
    exit
  end
  b -= 1
end
=end

if a % x != 0
  a = x * (a / x + 1)
end

if b % x != 0
  b = x * (b / x)
end

work = b - a
puts work / x + 1

Measured memory_bytes: 1788
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt();
		sc.close();
		char field[][] = new char[100][100];
		

		char white = '.';
		char black = '#';
		
		if(A>B){
			int tmp = A;
			A = B;
			B = tmp;
			white = '#';
			black = '.';
		}
		//ここからはA(=w)の方が小さい
		

		int white_cnt = 0, black_cnt = 0;
		int h=0; int w = 0;
		while(white_cnt<A-1) {
			if((h%2==0&&w%2==0)||(h%2==1&&w%2==1)) {
				field[h][w]=white;
				white_cnt++;
			}else {
				field[h][w]=black;
				black_cnt++;
			}
			if(w==99) {
				h++;
				w=0;
			}else w++;
		}
		
		for(int i=w;i<100;i++) {
			field[h][i]=black;
		}		
		h++;
		for(int i=0;i<100;i++) {
			field[h][i]=black;
		}
		
		//System.out.println("削ったのは:"+(black_cnt%50 + (99-w)/2));
		
		black_cnt -= (black_cnt%50 + (99-w+1)/2);
		black_cnt = Math.max(0, black_cnt);
		black_cnt ++ ;
		
		h++;
		while(h<=99) {
			for(int i=0;i<100;i++) {
				field[h][i]=white;
			}
			h++;
		}
		white_cnt++;
		//もう白は作らなくてOK
		
		h = 99;
		w = 0;
		while(black_cnt<B) {
			if(w%2==0) {
				field[h][w]=black;
				black_cnt++;
			}
			if(w==99) {
				h-=2;
				w=0;
			}else w++;
		}
		System.out.println();
		
		//debug
		//System.out.println("white:" + white_cnt + "black:"+black_cnt );
		
		//out
		StringBuilder sb = new StringBuilder();
		sb.append(100 + " "+ 100 + "\n");
		for(int i=0;i<100;i++) {
			for(int j=0;j<100;j++) {
				sb.append(field[i][j]);
			}
			sb.append("\n");
		}
		System.out.println(sb.toString());
		
	}
}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(br.readLine());
        int cnt = 0;
        for(int i =0; i<n;i++){
            String[] str = br.readLine().split(" ");
            int l = Integer.parseInt(str[0]);
            int r = Integer.parseInt(str[1]);
            cnt += r - l + 1;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 23124
# -*- coding: utf-8 -*-

list = list( map( int, input().split() ) )

#-----
list_sort=[]

for num in list:
  less_count=0
  
  for check in list:
    if num > check:
      less_count += 1
      
  list_sort.append( [less_count, num] )

list_ans=[]
for i in range( len(list_sort) ):
  for L in list_sort:
    if L[0] == i: list_ans.append(str(L[1]))

print(' '.join(list_ans))


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

int main(){
  long long n;
  cin >> n;
  string ans = "";
  while(n){
    n--;
    ans += (char)('a'+n%26);
    n/=26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}
    

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

using namespace std;

int main(void) {
  string s;
  bool b = true;
  char c;
  
  cin >> s;
  c = s[0];
  for (int i = 1; i < s.length(); i++) {
    if (s[i] == c) {
      b = false;
      break;
    }
    c = s[i];
  }
  
  cout << (b ? "Good" : "Bad") << endl;
  
  return 0;
}
  

Measured memory_bytes: 256
//abc114c
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
int n;
int ans;
int moji[3] = {3,5,7};

signed main(){
  cin >> n;
  for(int digit=3;digit<=9;digit++){
    for(int i=0;i<pow(3,digit);i++){
      int k = i;
      int a = 0;
      int f[3]={0,0,0};
      for (int j=0;j<digit;j++){
        int now = k%3;
        k /= 3;
        f[now] = 1;
        a = a*10+moji[now];
      }
      //dump(a);
      if(a<=n&&f[0]*f[1]*f[2]==1) ans ++;
    }
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 384
// GRL_5_D Range Query on a Tree (heavy-light)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <stack>
#include <vector>

#define MAXN 101000

using namespace std;

struct {
  int to, wt, next;
} par[MAXN], E[MAXN];
int LE[MAXN];

struct Seg {
  vector<int> v;

  Seg(vector<int> &in) : v(pow(2, 1 + ceil(log2(in.size())))) {
    for (int i = 0; i < in.size(); ++i)
      v[v.size() / 2 + i] = par[in[i]].wt;
    for (int k = v.size() / 2 - 1; k > 0; --k)
      v[k] = v[2 * k] + v[2 * k + 1];
  }

  int Add(int i, int x) {
    i += v.size() / 2;
    v[i] += x;
    while (i = i / 2)
      v[i] = v[2 * i] + v[2 * i + 1];
  }

  int Get(int i) {
    i += v.size() / 2;
    int rs = 0;
    while (i) {
      if (i == 1) // not a child
        return v[1];
      if (i % 2) { // right child
        i /= 2;
      } else { // left child
        rs += v[i];
        if (!((i / 2) & (i / 2 - 1)))
          return rs;
        i = (i / 2) - 1;
      }
    }
    return rs;
  }
};
Seg *aux[MAXN];
int tidx[MAXN];
int jump[MAXN];
int size[MAXN];

void Build(int i, vector<int> &a) {
  a.push_back(i);
  for (int j = LE[i]; j != -1; j = E[j].next) {
    if (size[E[j].to] > size[i] / 2) { // heavy
      Build(E[j].to, a);
      aux[i] = aux[E[j].to];
      jump[i] = jump[E[j].to];
      tidx[i] = tidx[E[j].to] - 1;
    } else {
      vector<int> newa;
      Build(E[j].to, newa);
    }
  }
  // handle last node on heavy chain
  if (a.size() > 1 && !aux[i]) {
    aux[i] = new Seg(a);
    jump[i] = par[a.front()].to;
    tidx[i] = a.size() - 1;
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  fill(LE, LE + n, -1);
  fill(size, size + n, 1);
  fill(jump, jump + n, -1);
  fill(aux, aux + n, nullptr);
  par[0] = {-1, 0, -1};

  for (int s = 0, i = 0; s < n; ++s) {
    int k, t;
    cin >> k;
    while (k-- > 0) {
      cin >> t;
      par[t] = {s, 0, -1};
      E[i] = {t, 0, LE[s]};
      LE[s] = i;
      ++i;
    }
  }

  stack<int> dfs;
  dfs.push(0);
  vector<bool> visited(n);
  while (!dfs.empty()) {
    int u = dfs.top();
    dfs.pop();
    if (visited[u] && par[u].to >= 0)
      size[par[u].to] += size[u];
    if (!visited[u]) {
      visited[u] = true;
      dfs.push(u);
      for (int j = LE[u]; j != -1; j = E[j].next)
        dfs.push(E[j].to);
    }
  }

  vector<int> a;
  Build(0, a);

  int q;
  cin >> q;
  for (int kind, u, v; cin >> kind >> u;) {
    if (kind == 0) {
      cin >> v;
      if (aux[u]) {
        aux[u]->Add(tidx[u], v);
      } else {
        par[u].wt += v;
      }
    } else {
      int rs = 0;
      while (u > 0) {
        if (aux[u]) {
          rs += aux[u]->Get(tidx[u]);
          u = jump[u];
        } else {
          rs += par[u].wt;
          u = par[u].to;
        }
      }
      cout << rs << endl;
    }
  }
}



Measured memory_bytes: 19124
#include <stdio.h>

main(){
  int i,j,h[10],tmp;
  for(i=0;i<10;i++){
    scanf("%d",&h[i]);
  }
  for(i=0;i<9;i++){
    for(j=i+1;j<10;j++){
    if(h[i] < h[j]){
      tmp = h[j];
      h[j] = h[i];
      h[i] = tmp;
    }
    }
  }
  printf("%d\n",h[0]);
  printf("%d\n",h[1]);
  printf("%d\n",h[2]);
  return 0;
}

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

int main() {

    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    int N, M;
    cin >> N >> M;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec[i];
    }
    
    vector<vector<int>> road(N,vector<int>(0));
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        road[a].push_back(b);
        road[b].push_back(a);
    }
    
    int cnt = 0;
    
    for(int i=0; i<N; i++){
        bool flag = true;
        for(int j=0; j<road[i].size(); j++){
            if(vec[i] <= vec[road[i][j]]){
                flag = false;
            }
        }
        if(flag){
            cnt++;
        }
    }
    
    cout << cnt << endl;

}


Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std; 
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << ' ' << b << ' ' << c << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long X,K,oldX,bigK;
  	cin >> oldX >> K;
 	oldX %= K;  
  	X = abs(oldX - K);
  	if(oldX < X){
  		cout << oldX;
    }else{
    	cout << X;
    }
 }


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



class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        var N = cin.next();
        var ret = "No";
        foreach(var c in N)
        {
            if (c.Equals('9'))
            {
                ret = "Yes";
            }
        }
        Console.WriteLine(ret);
    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11092
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  bool to_n[n] = {};
  int a[m],b[m];
  REP(i,m){
    cin >> a[i] >> b[i];
    if(b[i]==n){
      to_n[a[i]-1]=true;
    }
  }
  REP(i,m){
    if(a[i]==1){
      if(to_n[b[i]-1]==true){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 2048
n=int(input())
s=list(map(int,input().split()))
flag=0
ans=0
old=s[0]
for i in range(n):
    new=s[i]
    if flag==1 and new<old:
        ans+=1
        flag=0
    elif flag==-1 and new>old:
        ans+=1
        flag=0
    else:
        if new>old:
            flag=1
        elif new<old:
            flag=-1
    old=new
print(ans+1)

Measured memory_bytes: 14224
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define	abs(a) ((a)<0?-(a):(a))



int main(void){
	char *s;
	int i;
	s = calloc(sizeof(char),13);
	scanf("%s",s);
	for(i=0;i<4;i++){
		printf("%c", s[i]);
	}
	printf(" ");
	for(i=4;i<12;i++){
		printf("%c", s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>

int main(int argc, char const* argv[])
{
    uint64_t n;
    std::cin >> n;

    auto vec = std::vector<uint64_t>(n * 3);
    for (auto& power : vec) {
        std::cin >> power;
    }
    std::sort(vec.begin(), vec.end(), std::greater<uint64_t>());

    uint64_t result = 0;
    for (int i = 0; i < n * 2; ++i)
    {
        if(i % 2 == 1)
        {
            result += vec[i];
        }
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 2560
H,W,h,w=gets.split.map &:to_i;X=500
m=H.times.map{[X]*W}
(h-1).step(H-1,h){|i|(w-1).step(W-1,w){|j|m[i][j]=-(h*w-1)*X-1}}
s=0
H.times{|i|W.times{|j|s+=m[i][j]}}
puts *[s>0 ? ['Yes',*m.map{|e|e*' '}] : ['No']]

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N, T, A;
    cin >> N >> T >> A;

    vector<int> H(N);
    rep(i, N) cin >> H[i];

    double min = abs((double)A - (T - H[0] * 0.006));
    int index = 0;

    repd(i, 1, N) {
        if (min > abs((double)A - (T - H[i] * 0.006))) {
            min = abs((double)A - (T - H[i] * 0.006));
            index = i;
        }
    }

    cout << index + 1 << endl;

    return 0;
}

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

namespace _7_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var nx = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                var n = nx[0];
                var x = nx[1];
                var count = 0;
                if (n == 0 && x == 0) break;
                for (var i = 1; i <= n - 2; i++)
                {
                    for (var j = i + 1; j <= n - 1; j++)
                    {
                        for (var k = j + 1; k <= n; k++)
                        {
                            if (i + k + j == x)
                                count++;
                        }

                    }
                }
                Console.WriteLine(count);
            }
        }
    }
}



Measured memory_bytes: 17748
N,L=map(int,input().split())
S=[input() for i in range(N)]

T=[]
for i in range(N):
    s=min(S)
    T.append(s)
    S.pop(S.index(s))

Ts=""
for i in range(len(T)):
    Ts+=T[i]

print(Ts)

Measured memory_bytes: 3064
n = int(raw_input())
score_taro, score_hana = 0, 0

for i in range(n):
    taro, hana = raw_input().split(" ")

    if taro > hana:
        score_taro += 3
    elif taro < hana:
        score_hana += 3
    else:
        score_taro += 1
        score_hana += 1

print(str(score_taro) + " " + str(score_hana))

Measured memory_bytes: 6392
h, w, m = map(int, input().split())
lo = 0x80000
t = [tuple(map(int, input().split())) for _ in range(m)]
seg = [0] * (lo * 2)
def modify(k, v):
    i = k + lo
    seg[i] += v
    i >>= 1
    while i:
        seg[i] = max(seg[i << 1], seg[(i << 1) | 1])
        i >>= 1
wow = [[] for _ in range(h + 3)]
for x, y in t:
    wow[x].append(y)
    modify(y, 1)
ans = 0
for x in range(1, h + 1):
    cc = 0
    for y in wow[x]:
        cc += 1
        modify(y, -1)
    ans = max(ans, cc + seg[1])
    for y in wow[x]:
        modify(y, 1)
print(ans)

Measured memory_bytes: 167996
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int N, M, ans=0;
	cin >> N >> M;
	VI k(M), p(M);
	VVI s(M, VI(N));

	rep(i, M){
		cin >> k[i];
		rep(j, k[i]){
			cin >> s[i][j];
		}
	}
	rep(i, M){
		cin >> p[i];
	}

	rep(i, (1<<N)){
		bool AllOn = true;
		rep(j, M){
			int on=0;
			rep(l, k[j]){
				if(i&(1<<(s[j][l]-1))) on++;
			}
			if((on%2) != p[j]){
				AllOn = false;
				break;
			}
		}
		if(AllOn) ans++;
	}

	cout << ans << endl;


}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 3640
unittest
{
	assert( [ "3 5", "3 3", "4 4", "2 5" ].parse.expand.solve == 8 );
	assert( [ "3 6", "3 3", "4 4", "2 5" ].parse.expand.solve == 9 );
	assert( [ "7 14", "10 5", "7 4", "11 4", "9 8", "3 6", "6 2", "8 9" ].parse.expand.solve == 32 );
}



import core.bitop;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ nk[ 0 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	return tuple( nk[ 1 ], abs );
}

auto solve( long k, long[ 2 ][] abs )
{
	// i+1桁目を繰り下げしてi桁目以下が0でも1でもいいビットマスクを作成
	auto ms = [ k ];
	foreach( i; 0L .. k.bsr )
	{
		auto b = 1L << i;
		if( ms.back & b ) continue;
		ms ~= ms.back - b;
	}
	
	// ビットマスクごとに価値の総和を計算
	auto ans = 0L;
	foreach( m; ms )
	{
		auto t = 0L;
		foreach( ab; abs )
		{
			if( ( ab[ 0 ] & ~m ) == 0 ) t += ab[ 1 ];
		}
		ans = max( ans, t );
	}
	return ans;
}


Measured memory_bytes: 4860
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
	ll N, M;
	cin >> N >> M;
	ll ans = 0;
	M /= 2;
	ans += min(N, M);
	M -= ans;
	ans += M / 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i,n) cin >> w[i];
    int ans = 100000000;
    rep(t, n) {
        int s1 = 0, s2 = 0;
        rep(i,n) {
            if(i<t) s1+=w[i];
            else s2+=w[i];
        }
        ans = min(ans ,abs(s1-s2));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int W,H;
        while(cin >> H >> W)
        if(W>=3&&H<=300){
            for(int j=0; j<W; j++)
                cout << '#';
                cout << endl;
                for(int k=0; k<H-2; k++){
                    cout << '#';
                    for(int i=0; i<W-2;i++)
                    cout << '.';
                    cout << '#';
                    cout << endl;
                }
            for(int j=0; j<W; j++)
                cout << '#';
                cout << endl << endl;
}
}


Measured memory_bytes: 3068
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int asc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}
int main()
{
	string s,t;
	int sa[30],ta[30];
	int a=0,b=0,i;
	bool bo=true;
	cin>>s>>t;
	for (i=0;i<30;i++)
	{
		sa[i]=ta[i]=0;
	}
	for (i=0;i<s.size();i++)
	{
		sa[s[i]-'a']++;
		ta[t[i]-'a']++;
	}
	for (i=0;i<='z'-'a';i++)
	{
		if (sa[i]) a++;
		if (ta[i]) b++;
	}
	qsort(sa,sizeof(sa)/sizeof(int),sizeof(int),asc);
	qsort(ta,sizeof(ta)/sizeof(int),sizeof(int),asc);
	for (i=0;i<='z'-'a';i++)
	{
		if (sa[i]!=ta[i]) bo=false;
	}
	if (bo) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9
#define common cout << "Case #" << w+1 << ": "


int main()
{
    int n,k;
    cin >> n >> k;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    int l=0;
    for(int i=k;i<n;i++)
    {
        if(v[i]>v[l])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        l+=1;
    }
}

Measured memory_bytes: 4044
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

ans = 0
for e in p[0:k]:
  ans += (e + 1) / 2
anses = [ans]

for i in range(n - k):
  ans -= (p[i] + 1) / 2
  ans += (p[k + i] + 1) / 2
  anses.append(ans)

print(max(anses))


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

int n,A[100];
void print_seq(void);

int main(){
  int i,j,v;
  
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&A[i]);
    print_seq();
    
    for(i=1;i<n;i++){
        v=A[i];
        for(j=i-1;j>=0 && A[j]>v;j--)
            A[j+1]=A[j];
        A[j+1]=v;
	print_seq();
    }
}

void print_seq(void){
  int i;
  for(i=0;i<n;i++){
    if(i<n-1) printf("%d ",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
}



Measured memory_bytes: 2068
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    int mi = 1e9, ma = -mi;
    ll s = 0;
    while (n--){
        int a;
        cin >> a;
        mi = min(mi,a);
        ma = max(ma,a);
        s += a;
    }
    printf("%d %d %lld\n", mi, ma, s);
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	long double ans = (long double)w * (long double)h / 2;
	double sx = (double)w / 2, sy = (double)h / 2;
	cout << fixed;
	cout << setprecision(10) << ans;
	if (sx == x && sy == y)
		cout << " 1\n";
	else
		cout << " 0\n";
	return 0;
}

Measured memory_bytes: 256
[N, K] = list(map(int, input().split()))
all_A =[]
AB = []
for i in range(1, N + 1):
    all_A.append(i)
for j in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    AB = AB + A
last_A = set(all_A) ^ set(AB)
print(len(last_A))

Measured memory_bytes: 9312
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from bisect import bisect_left, bisect_right
def resolve():
    n, m = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(n)]
    AB.sort()
    AB.append([INF, 0])
    for i in range(n, 0, -1):
        AB[i][1] ^= AB[i - 1][1]
    X = [b for a, b in AB]

    E = [[] for _ in range(n + 1)]
    for i in range(m):
        u, v = map(int, input().split())
        l = bisect_left(AB, [u, 0])
        r = bisect_right(AB, [v, 1])
        E[l].append((r, i + 1))
        E[r].append((l, i + 1))

    ans = []
    used = [False] * (n + 1)
    def dfs(v):
        if used[v]:
            return 0
        used[v] = True
        stack = [(~v, -1, -1), (v, -1, -1)]
        while stack:
            v, p, i = stack.pop()
            if v >= 0:
                for nv, i in E[v]:
                    if used[nv]:
                        continue
                    used[nv] = True
                    stack.append((~nv, v, i))
                    stack.append((nv, v, i))
            else:
                v = ~v
                if p != -1:
                    if X[v]:
                        ans.append(i)
                        X[p] ^= 1
                else:
                    return X[v]

    for v in range(n + 1):
        if dfs(v):
            print(-1)
            return

    print(len(ans))
    if ans:
        print(*sorted(ans))
resolve()

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp[ohara],cmpp[ohara],m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,t;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){

       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>s>>t;
      map<char,ll> mpt;
      map<char,ll> mps;
      rep(i,Size(t))mpt[t[i]]++;
      rep(i,Size(s))mps[s[i]]++;
      rep(i,Size(s)){
        if(mps[s[i]]==0)continue;
        if(mpt[t[i]]>0){
          if(mps[s[i]]<mpt[t[i]]){
            Cout("No");
            return 0;
          }
          mpt[t[i]]=0;
          mps[s[i]]=0;
        }
        else{
          cmp[cnt++]=mps[s[i]];
          mps[s[i]]=0;
        }
      }
      ll cntt=0;
      rep(i,Size(t)){
        if(mpt[t[i]]==0)continue;
        cmpp[cntt++]=mpt[t[i]];
        mpt[t[i]]=0;
      }
      sort(cmp,cmp+cnt);
      sort(cmpp,cmpp+cntt);
      if(cnt!=cntt)Cout("No");
      else{
        rep(i,cnt){
          if(cmp[i]!=cmpp[i]){
            Cout("No");
            return 0;
          }
        }
        Cout("Yes");
      }
    
       
return 0;
}


Measured memory_bytes: 916
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
 
using namespace std;
 
typedef long long ll;
 
const ll INF = 1e9, MOD = 1e9 + 7;


ll n, m, d[3002][3001][2];

void add_self (ll& a, ll b)
{
	a += b;
	if (a >= MOD) a -= MOD;
}

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

	for (int i = 0; i <= n; i++)
		d[0][i][0] = 1;

	for (int i = 0; i <= m; i++)
		for (int j = 0; j <= n; j++)
		{
			int x = j, y = n - j;
			if (!x)
			{
				d[i][j][1] += d[i][j][0];
				d[i][j][0] = 0;
			}

			if (x)
			{
				if (x == 1) 
				{
					add_self (d[i + 1][j][1], d[i][j][0]);
					add_self (d[i + 1][j - 1][1], d[i][j][0]);
				}
				else 
				{
					add_self (d[i + 1][j][0], d[i][j][0]);
					add_self (d[i + 1][j - 1][0], d[i][j][0]);
				}

				add_self (d[i + 1][j][1], d[i][j][1]);
				add_self (d[i + 1][j - 1][1], d[i][j][1]);
			}

			if (y)
			{
				if (!x) 
				{
					add_self (d[i + 1][j][1], d[i][j][0]);
					add_self (d[i + 1][j + 1][1], d[i][j][0]);
				}
				else 
				{
					add_self (d[i + 1][j][0], d[i][j][0]);
					add_self (d[i + 1][j + 1][0], d[i][j][0]);
				}

				add_self (d[i + 1][j][1], d[i][j][1]);
				add_self (d[i + 1][j + 1][1], d[i][j][1]);
			}
		}

	ll ans = 0;

	for (int i = 0; i <= n; i++)
		add_self (ans, d[m][i][1]);

	cout << ans;
}

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

typedef long long LL;
int ans, n;

void dfs(LL cur, int v3, int v5, int v7){
    if(cur <= n && v3 && v5 && v7) ++ans;
    if(cur > n) return;
    dfs(cur*10+3, 1, v5, v7);
    dfs(cur*10+5, v3, 1, v7);
    dfs(cur*10+7, v3, v5, 1);
}

int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    ans = 0;
    cin >> n;
    dfs(0,0,0,0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

/*aのb進数時の桁数*/
ll digits(ll a, ll b){return a/b?1+digits(a/b,b):1;}
/*nをa進数にしたときの、i桁目の数*/
ll placenai(ll n, ll a, ll i){return i==1?n%a:placenai(n/a,a,i-1);}
/*aのn乗(mod) 繰り返し二乗法*/
ll modpow(ll a, ll n, ll mod){
    ll s[digits(n,2)],ans=1;
    rep(i,0,digits(n,2)){
        s[i]= i==0 ? a : s[i-1]*s[i-1]%mod ;
        ans*=placenai(n,2,i+1)==1?s[i]:1; ans%=mod;
    }
    return n?ans:1;
}
ll inv[200005],finv[200005];
void makeinv(ll n){
    inv[1]=1;finv[0]=finv[1]=1;
    rep(i,2,n+1){
        inv[i]=MOD1 - inv[MOD1%i] * (MOD1 / i) % MOD1;
        finv[i] = finv[i - 1] * inv[i] % MOD1;
    }
}
ll modfac(ll n, ll mod){
    ll x=1;
    rep(i,2,n+1){x*=i%mod;x%=mod;}
    return x;
}

int main(void){
    ll n,a,b,ans=0;
    scanf("%lld%lld%lld",&n,&a,&b);
    makeinv(200003);
    ans = modpow(2,n,MOD1) + mod(-1);
    ll tmp=1;
    
    rep(i,0,a){
        tmp = tmp * inv[i+1] %MOD1 * (n-i) %MOD1;
    }
    ans += mod(-tmp);
    
    rep(i,a,b){
        tmp = tmp * inv[i+1] %MOD1 * (n-i) %MOD1;
    }
    ans += mod( -tmp );

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


Measured memory_bytes: 3328
import java.util.Scanner;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        sc.close();

        double total_prob = 0.0;
        for (int start=1; start<N+1; start++) {
            int total = start;

            int count = 0;
            while (!(total==0 || total>=K)) {
                total *= 2;
                count++;
            }
            total_prob += (double)1/N * Math.pow(0.5, count);
        }
        System.out.println(total_prob);
    }
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  bool a=false;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j==n)
        a=true;
    }
  }
  if(a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int n,k;
char s[100005];
int ans[100005];
int main() {
	scanf("%s",s+1),n=strlen(s+1);
	for(int i=1; i<=n; i++) {
		if(s[i]=='L') {
			if((i-k)&1)ans[k+1]++;
			else ans[k]++;
		} else k=i;
	}
	for(int i=n; i>=1; i--) {
		if(s[i]=='R') {
			if((k-i)&1)ans[k-1]++;
			else ans[k]++;
		} else k=i;
	}
	for(int i=1;i<=n;i++)printf("%d ",ans[i]);
	return 0;
}


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

using namespace std;

typedef long long ll;
const int MOD = 998244353;
ll n, a, b, k, inv[300005], n1 = 1;

ll pw(ll a, ll b = MOD - 2) {
	if(b == 0) return 1ll;
	long long temp = pw(a * a % MOD, b >> 1) % MOD;
	return temp * (b & 1 ? a : 1) % MOD;
}

ll C(ll k) {
	if(k == 0) return 1ll;
	if(k < 0) return 0;
	return (n1 * inv[n - k] % MOD) * inv[k] % MOD;
}

int main() {
	inv[0] = 1;
	for(int i = 1; i <= 3e5+5; i++) {
		inv[i] = inv[i - 1] * pw(i) % MOD;
	}
	cin >> n >> a >> b >> k;
	for(int i = 2; i <= n; i++) {
		n1 = n1 * i % MOD;
	}
	ll ans = 0;
	for(int i = 0; i <= n; i++) {
		if((k - a * i) % b == 0 && (k-a*i)/b <= n) {
			ans += C(i) * C((k - a * i) / b) % MOD;
			ans %= MOD;
		}
	}
	cout << ans;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
    char s[100000];
    char ans[100000];
    int i=0, j=0;
    scanf("%s", s);
    while(s[i] != '\0'){
        if(i%2 == 0){
            ans[j] = s[i];
            j++;
        }
        i++;
    }
    i++;
    ans[j] = '\0';
    printf("%s", ans);
    
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  string s,t;
  cin >> s >> t;
  int maxSub = -1;
  int tmp;

  if(s.size() != t.size()){

    for(ii=0;ii<s.size()-t.size();ii++){

      tmp = 0;

      for(jj=0;jj<t.size();jj++){
        if(s[ii+jj] == t[jj]){
          tmp++;
        }
      }
    
      //cout <<"ii:" << ii << "tmp:" << tmp << endl;
      if(tmp >= maxSub){
        maxSub = tmp;
      }
    }
  }
  else{
    //cout << "size" << s.size() << endl;
    tmp = 0;
    for(ii=0;ii<s.size();ii++){
      if(s[ii] == t[ii]){
        tmp++;
      }
    }
    maxSub = tmp;
  }

       
  cout << t.size() - maxSub << endl;

  return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll n,i,j,grid[257][257];
       memset(grid,0,sizeof(grid));
       for(i=0;i<257;i++)
       {
           for(j=0;j<257;j++)
           {
               ll i1,j1;
                i1=i-128;
                j1=j-128;
               grid[i][j]=power(i1,5)-power(j1,5); 
           }
       }
       cin>>n;
       for(i=0;i<257;i++)
       {
           for(j=0;j<257;j++)
           {
               //cout<<grid[i][j]<<" ";
               if(grid[i][j]==n)
               {
                   cout<<i-128<<" "<<j-128;
                   return 0;
               }
           }
           //cout<<"\n";
       }
       //cout<<grid[128][127];
   }
}

Measured memory_bytes: 4132
import java.util.*;
public class Main {
	Scanner sc;
	void run() {
		sc = new Scanner(System.in);
		while (true) {
			int n= sc.nextInt();
			if(n == 0) break;
			int min = 1000;
			int max = 0;
			int score = 0;
			for(int i=0;i<n;i++) {
				int s = sc.nextInt();
				score += s;
				min = Math.min(s, min);
				max = Math.max(s, max);
			}
			System.out.println(( score-(min+max) ) / (n-2)  );
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
def honponbon(n)
  i = n.to_s[-1]
  return 'hon' if %w[2 4 5 7 9].include? i
  return 'pon' if %w[0 1 6 8].include? i
  'bon'
end

i = gets.chomp.to_i
puts honponbon(i)

Measured memory_bytes: 14252
N=int(input())
A=[]
B=[]
for _ in range(N):
    x,y=map(int, input().split())
    A.append(x+y)
    B.append(x-y)

A=sorted(A)
B=sorted(B)

print(max(A[-1]-A[0],B[-1]-A[0],A[-1]-A[0],B[-1]-B[0]))

Measured memory_bytes: 107948
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  ll k;std::cin >> k;
  set<string> candi;
  for(int i=0;i<s.size();i++){
    string t = "";
    for(int j=0;j<5&&i+j<s.size();j++){
      t+=s[i+j];
      if(candi.find(t)==candi.end()) candi.insert(t);
    }
  }
  int l = 1;
  for(auto itr=candi.begin();itr!=candi.end();l++,itr++){
    if(l==k) {
      std::cout << *itr << '\n';
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace Project
{
    class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var X = cin.ReadInt;
            var N = cin.ReadInt;
            var p = cin.ReadIntArray(N);
            var ans = 0;
            var abs_dif = X;

            for(int i = 1; i <= 101; i++)
            {
                if (p.Contains(i) == false)
                {
                    if (abs_dif > Abs(X-i))
                    {
                        abs_dif = Abs(X - i);
                        ans = i;
                    }
                }
            }
            WriteLine(ans) ;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } } // intの範囲は-2147483648～2147483648
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N)
        { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N)
        { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N)
        { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }

    }
}


Measured memory_bytes: 28296
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

bool check(long i) {
    vector<bool> n(10);
    while(i > 0) {
        n[ i%10 ] = true;
        i/=10;
    }
    return n[3] && n[5] && n[7];
}

int dfs(const long n, long i) {
    if (i > n) return 0;
    long res = dfs(n, i*10+3) + dfs(n,i*10+5) + dfs(n,i*10+7);
    return res + check(i);
}

int main() {
    long n;
    cin >> n;
    long ans = dfs(n,0);

    cout << ans << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define INF (int)1e5
#define nax (ll)2e5+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
 
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
// look for  all edge cases
//search for a pattern




int main(){
	fast;
	double n;
	cin>>n;
	cout<<fixed<<setprecision(9);
	double pi = 3.141592653589793238;
	cout<<2*(pi)*n;
	return 0;
}

	


Measured memory_bytes: 3804
N = int(input())
S = input()
 
ans = []
st = 0
for c in S:
    if c == '(':
        st += 1
        ans.append('(')
    else:
        if st > 0:
            st -= 1
        else:
            ans.insert(0, '(')
        ans.append(')')
 
ans.extend(')' * st)
 
print(*ans, sep='')

Measured memory_bytes: 3060
n,k,q=map(int,input().split())
a=[]
for i in range(q):
    a.append(int(input()))
ans=[-1]+[0]*n

for i in range(q):
    ans[a[i]]+=1

for i in range(1,n+1):
    if k-(q-ans[i])>0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14492