akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  int counter;
  cin >> s >> t;
  counter = 0;

  for(int i =0; i < s.size(); i++){
    if (s.at(i) != t.at(i)) {
        counter++;
     }
  }

  cout << counter << endl;

}

Measured memory_bytes: 3844
import java.util.Scanner;

class Main{
    final static int LEN = 105;
    public static void main(String args[]){
	int[][] graph = new int[LEN][LEN];
	int[] minCost = new int[LEN];
	int count=0;
	int v;
	Boolean[] used = new Boolean[LEN];

	Scanner in = new Scanner(System.in);

	//read
	int n = in.nextInt();
	for(int i=0; i<n; i++){
	    for(int j=0; j<n; j++){
		int k = in.nextInt();
		graph[i][j]=(k==-1? Integer.MAX_VALUE : k);
	    }
	}

	//make prim
	for(int i=0; i<n; i++){
	    minCost[i]=Integer.MAX_VALUE;
	    used[i]=false;
	}

	minCost[0]=0;

	while(true){
	    v = -1;
	    for(int i=0; i<n; i++){
		if(!used[i] && (v==-1 || minCost[i] < minCost[v]))v=i;
	    }

	    if(v==-1)break;
	    used[v]=true;
	    count+=minCost[v];

	    for(int i=0; i<n; i++){
		minCost[i]=Math.min(minCost[i], graph[v][i]);
	    }
	}

	//print
	System.out.println(count);
    }
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for(int i = 1; i * i <= m; i++){
    if(m % i != 0) continue;
    ll k = (ll)i * n;
    if(k <= m){
      ans = max(ans, i);
    }
    int j = m/i;
    k = (ll)j * n;
    if(k <= m){
      ans = max(ans, j);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split(' '))
d, e, f = map(int, input().split(' '))
g, h, i = map(int, input().split(' '))
N = int(input())
z = set()
for _ in range(N):
    z.add(int(input()))

A = (a in z) and (b in z) and (c in z)
B = (d in z) and (e in z) and (f in z)
C = (g in z) and (h in z) and (i in z)

D = (a in z) and (d in z) and (g in z)
E = (b in z) and (e in z) and (h in z)
F = (c in z) and (f in z) and (i in z)

G = (a in z) and (e in z) and (i in z)
H = (c in z) and (e in z) and (g in z)

r = A or B or C or D or E or F or G or H

print('Yes' if r else 'No')

Measured memory_bytes: 3192
a, b = map(int, input().split())
if a <= 0 and b >= 0:
    print("Zero")
elif b <= 0 and b >= 0:
    print("Zero")
elif a == 0 or b == 0:
    print("Zero")
elif a > 0 and a > 0:
    print("Positive")
elif a < 0 and b < 0:
    c = abs( b - a + 1)
    if c %2 == 1:
        print("Negative")
    else:
        print("Positive")

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

int main () {
  map<string, int> s; 
  string skey[102], tkey[102];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> skey[i];
    s[skey[i]]++;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> tkey[i];
    s[tkey[i]]--;
  }
  int ans=0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, s[skey[i]]);
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 256
use std::io;

fn main() {
    let stdin = io::stdin();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let num: usize = buf.trim().parse().unwrap();

    let mut keta = 0;

    for i in 1..(num + 1) {
        if (i.to_string().len() == 1 || i.to_string().len() == 3 || i.to_string().len() == 5) {
            keta += 1;
        }
    }

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

Measured memory_bytes: 4352
use proconio::input;

fn main() {
    input!{
        n: u32,
    }
    let mut a = "hon";
    if n % 10 == 3 {
        a = "bon";
    }
    if n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8 {
        a = "pon";
    }
    println!("{}", a);
}


Measured memory_bytes: 2096
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	a := getInts(N)
	sort.Slice(a, func(i, j int) bool {
		return a[i] > a[j]
	})
	ans := a[0]
	for i := 1; i < N-1; i++ {
		ans += a[(i-1)/2+1]
	}
	out(ans)
}


Measured memory_bytes: 5936
### constant

DELTA = 1.0e-8

### subroutines

def cross(l1, l2)
  x1, y1 = l1[0..1]
  x2, y2 = l1[2..3]
  x3, y3 = l2[0..1]
  x4, y4 = l2[2..3]

  d = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1)
  return nil if d.abs < DELTA

  k = (y4 - y3) * (x4 - x1) - (x4 - x3) * (y4 - y1)
  e = -(y2 - y1) * (x4 - x1) + (x2 - x1) * (y4 - y1)

  s = k / d
  t = e / d
  return nil if s < 0 || s > 1 || t < 0 || t > 1

  [(x2 - x1) * s + x1, (y2 - y1) * s + y1]
end

def eqpt(p1, p2)
  (p2[0] - p1[0]).abs < DELTA && (p2[1] - p1[1]).abs < DELTA
end

### main

while true
  line = gets.strip
  break if line == '0 0 0 0'

  l1 = line.split(' ').map{|s| s.to_f}
  l2 = gets.split(' ').map{|s| s.to_f}
  l3 = gets.split(' ').map{|s| s.to_f}

  c1 = cross(l1, l2)
  c2 = cross(l2, l3)
  c3 = cross(l3, l1)

  if c1.nil? || c2.nil? || c3.nil? ||
      eqpt(c1, c2) || eqpt(c2, c3) || eqpt(c3, c1)
    puts 'kyo'
  else
    v1 = [c2[0] - c1[0], c2[1] - c1[1]]
    v2 = [c3[0] - c1[0], c3[1] - c1[1]]
    s = (v1[0] * v2[1] - v1[1] * v2[0]).abs / 2

    if s >= 1900000
      puts 'dai-kichi'
    elsif s >= 1000000
      puts 'chu-kichi'
    elsif s >= 100000
      puts 'kichi'
    else
      puts 'syo-kichi'
    end
  end
end

Measured memory_bytes: 6164
# Union-Find木
# 木構造を用いて、グループ分けを行うデータ構造
# 同じ木に属している場合、同じグループであるということになる
# 同じ木に属しているかどうかは、根となるノードが同じであるかどうかで判定をする
# 同じグループに属しているかどうかを、根ノードの値を参照するだけなのでO(1)で求められる
class UnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
    # 根ノードのindexに、連結成分の大きさを記録する
    @size = Array.new(size, 1)
  end

  # node_xとnode_yを連結し、同じグループにする
  # 連結するときには、@sizeにそれぞれの頂点の大きさを足し合わせる
  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
      @size[x_parent] += @size[y_parent]
    else
      @parent[x_parent] = y_parent
      @size[y_parent] += @size[x_parent]
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  # node_xの親ノードの番号を取得する
  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end

  # node_x, node_yが連結しているか確かめる
  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end

  # 根ノードに記録された連結成分の大きさを返す
  def size(id_x)
    @size[get_parent(id_x)]
  end
end

def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

require 'set'

n, m, k = input_a
union = UnionFind.new(n)
# すでに友人、またはブロック関係にある人間
alreadys = Array.new(n).map {Set.new}

# 友人
m.times do
  a, b = input_a
  a = a - 1
  b = b - 1
  union.unite(a, b)
  alreadys[a].add(b)
  alreadys[b].add(a)
end

# ブロック
k.times do
  c, d = input_a
  c = c - 1
  d = d - 1
  # すでに同じ連結成分に属している場合ブロック関係を追加してしまうと重複するので飛ばす
  next if !union.same_parent?(c, d)
  alreadys[c].add(d)
  alreadys[d].add(c)
end

n.times do |i|
  # 連結成分の大きさ(指定されたノードに繋がっているノードの数。not隣接で、nホップ以上を含む)
  # ※連結成分から自分自身を取り除いているので-1
  graph = union.size(i) - 1
  # 連結成分から友人またはブロック関係の人数を除外
  friends = graph - alreadys[i].size
  print "#{friends} "
end


Measured memory_bytes: 66172
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

//#define INF 100000000
//#define MOD (int) (1e9+7)
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

const int MAX = 1000000;
const int MOD = 998244353;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> p(m), y(m);

    int i;
    for(i = 0; i < m; i++){
        cin >> p[i] >> y[i];
        p[i]--;
    }

    vector<vector<int>> v(n);
    for(i = 0; i < m; i++){
        v[p[i]].push_back(y[i]);
    }

    for(i = 0; i < n; i++){
        //ソートする
        sort(v[i].begin(), v[i].end());

        //ダブりを消す
        v[i].erase(unique(v[i].begin(), v[i].end()), v[i].end());
    }

    for(i = 0; i < m; i++){
        printf("%06d", p[i]+1);

        //座圧との対応付け
        int id = lower_bound(v[p[i]].begin(), v[p[i]].end(), y[i]) - v[p[i]].begin();
        printf("%06d\n", id+1);
    }
}

Measured memory_bytes: 7808
N = int(input())
k = 1
n = 0
while n < N:
    n += k
    k += 1
if n!=N:
    print('No')
    exit()
print('Yes')
print(k)
ans = [[] for _ in range(k)]
v = 1
for i in range(k-1):
    for j in range(i+1,k):
        ans[i].append(v)
        ans[j].append(v)
        v += 1
for row in ans:
    print(*([len(row)] + row))


Measured memory_bytes: 76360
#include<stdio.h>

int D[107][7],i,j,N;
int G[55][6]={
	{1,2,3},{1,3,5},{1,5,4},{1,4,2},
	{2,1,4},{2,4,6},{2,6,3},{2,3,1},
	{3,1,2},{3,2,6},{3,6,5},{3,5,1},
	{4,1,5},{4,2,1},{4,6,2},{4,5,6},
	{5,1,3},{5,3,6},{5,4,1},{5,6,4},
	{6,2,4},{6,4,5},{6,5,3},{6,3,2}};

int ch(int a,int b)
{
	int i;
	for(i=0;i<24;i++)
	{
		if(D[a][1]==D[b][G[i][0]]&&
		   D[a][2]==D[b][G[i][1]]&&
		   D[a][3]==D[b][G[i][2]]&&
		   D[a][6]==D[b][7-G[i][0]]&&
		   D[a][5]==D[b][7-G[i][1]]&&
		   D[a][4]==D[b][7-G[i][2]])
		return 1;
	}
	return 0;
}

int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
		for(j=1;j<=6;j++)
			scanf("%d",&D[i][j]);
	for(i=0;i<N;i++)
		for(j=i+1;j<N;j++)
		{
			if(ch(i,j))
			{
				puts("No");
				return 0;
			}
		}
	puts("Yes");
	return 0;
}

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

using namespace std;

// This is the template of Errichto which can be found on https://codeforces.com/submissions/Errichto

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
#define LOCAL 1
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

//int dirs[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
//int dirs[8][2]={{-1,0},{0,-1},{0,1},{1,0},{1,1},{-1,-1},{-1,1},{1,-1}};

int main()
{
    ios::sync_with_stdio(false);
    //freopen("inp.in","r",stdin);
    //freopen("outp.out","w",stdout);
    int N;
    cin >> N;
    vector<int> ans(N+1,0);
    for(int x=1; x<=100; x++)
    {
        for(int y=1; y<=100; y++)
        {
            for(int z=1; z<=100; z++)
            {
                int val=x*x+y*y+z*z+x*y+x*z+y*z;
                if(1<=val && val<=N)
                {
                    ans[val]++;
                }
            }
        }
    }
    for(int i=1; i<=N; i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する


int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N), B(N), bit;
    int biti = 0;
    int lim = 1;
    ll ans = 0;
    int size = 0;

    rep(i, 0, N) {
        cin >> A[i] >> B[i];
    }

    for (int i = 0; 1 << i <= K; i++) {
        if (!(K >> i & 1)) {
//            size++;
//            bit.push_back(i);
            biti |= (1 << i);
        }
    }
    if(biti == 0){
        rep(i,0,N){
            if(A[i] <= K){
                ans += B[i];
            }
        }
        cout << ans << endl;
        return 0;
    }

    for(;biti <= K;){
        ll mans = 0ll;
        rep(i,0,N){
            if((A[i] & biti) == 0 && A[i] <= K){
                mans += B[i];
            }
        }

        ans = max(ans,mans);
        biti += (biti & -biti);

    }




    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	int n,m;
	cin>>n>>m;
	if (m%2 || m<n*2 || m>n*4)  cout<<"No";
	else  cout<<"Yes";
	re 0;
}

Measured memory_bytes: 3620
while 1:
    try:
        d = list(int(_) for _ in input().split())
        s = d[0] + d[1]
        p = 0
        ans = "NO"
        for i in range(1,11):
            if i != d[0] and i != d[1] and i != d[2]:
                if s + i <= 20:
                    p += 1
        if p / 7 >= 0.5:
            ans = "YES"                
        print(ans)
    except:
        break


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define ll long long int 
#define vi vector<int> 
#define vl vector<ll> 
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpii vector<pii>
#define vpll vector<pair<ll,ll>>
#define umap unordered_map
#define uset unordered_set
#define all(c) c.begin(), c.end()
#define maxarr(A) *max_element(A, A+n) 
#define maxvec(v) *max_element(all(v)) 
#define minarr(A) *min_element(A, A+n);
#define minvec(v) *min_element(all(v));
#define lb(v,elem) lower_bound(all(v),elem)
#define ub(v,elem) upper_bound(all(v),elem)
#define pb push_back 
#define ff first 
#define ss second
#define sz(z) (int)z.size()
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define rev(i,a,b) for(int i=a; i>=b; i--)
#define debug(v) for(ll i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define debugn(v,n) for(ll i=0; i<n; i++) cout<<v[i]<<" "; cout<<endl;
#define deb(sum) cout<<"sum = "<<sum<<endl;
#define mod 1000000007
#define INF (ll)1e18
#define endl "\n"
#define pi 3.142857142857143

  
ll binpow(ll a, ll b) {
	if (b == 0)
		return 1;
	ll res = binpow(a, b / 2);
	if (b % 2)
		return res * res * a;
	else
		return res * res;
}

ll modexpo(ll x, ll y, ll p){  
	ll res = 1;  
	x = x % p; 
	if (x == 0) return 0;
	while (y > 0){   
		if (y & 1)  
			res = (res*x) % p;  
		y = y>>1;
		x = (x*x) % p;  
	}  
	return res;  
}

vector<int> getPrimes(int M){
	
	vi p(M,1);
	vector<int>prime;
	for(int i=2; i*i <= M; ++i){
		if(p[i]){
			for(int j = i*i; j<=M; j+=i) 
				p[j] = 0;
		}
	}
	rep(i,2,M) if(p[i]) prime.push_back(i);
	return prime;
}  


int main() { 
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL); 
  //freopen("1.in","r",stdin);
  
  int t=1;
  //cin>>t;
  while(t--){
  	 int x,n;
  	 cin>>x>>n;
  	 vi p(102,1);
  	 rep(i,0,n){
  	 	int x;
  	 	cin>>x;
  	 	p[x] = -1;
  	 }
  	 int mn = INT_MAX, v=-1;
  	 rep(i,0,102){
        if(p[i]!=-1){
        	if(abs(i-x)<mn){
        		mn = abs(i-x);
        		v = i;
        	}
        }
  	 }
  	 cout<<v;

  	 
  } 
  return 0;
} 


Measured memory_bytes: 3660
import os
import heapq
import sys
import math
import bisect
import operator
from collections import defaultdict
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]


# def bubbleSort(arr,b):
#     n = len(arr)
#     for i in range(n):
#         for j in range(0, n - i - 1):
#             if arr[j] > arr[j + 1] and b[j]!=b[j+1]:
#                 arr[j], arr[j + 1] = arr[j + 1], arr[j]
#                 b[j],b[j+1]=b[j+1],b[j]
def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    #for _ in range(int(input())):
    #n=int(input())
    n,k=inar()
    arr=inar()
    res=[]
    for i in range(k,n):
        if arr[i]>arr[i-k]:
            res.append("Yes")
        else:
            res.append("No")

    for i in range(len(res)):
        print(res[i])














BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


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

/*動的計画法で解く*/
int main(){
	int n;
	std::cin >> n;
	//dp[i][j]はi+1項まで計算した結果がj(0≦j≦20)である数
	std::vector<std::vector<long long int> > dp(n, std::vector<long long int>(21, 0));
	//入力の数値保存用
	std::vector<int> num(n, 0);
	//数値入力
	for(int i = 0; i < n; ++i){
		int x;
		std::cin >> x;
		num[i] = x;
	}
	//初期値
	dp[0][num[0]] = 1;
	for(int i = 1; i < n - 1; ++i){ //2項からN-1項までの計算
		for(int j = 0; j < 21; ++j){
			//もし1つ前の計算結果がjの場合の数があればその加減を求める
			if(dp[i - 1][j] > 0){
				//それがもし0以上20以下なら
				if((j + num[i]) <= 20){
					dp[i][j + num[i]] += dp[i - 1][j];
				}
				if((j - num[i]) >= 0){
					dp[i][j - num[i]] += dp[i - 1][j];
				}
			}
		}
	}
	//必要な結果はn - 1項まで計算した結果がnum[n-1]である数
	std::cout << dp[n - 2][num[n - 1]] << std::endl;
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int c = a % 2;
  int d = b % 2;
  if (c == 0 || d == 0) {
    cout << "Even" << endl;
  }
  else cout << "Odd" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] a = new long[N];
        boolean foundNonZero = false;
        HashMap<Long, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextLong();
            if (!map.containsKey(a[i])) {
                map.put(a[i], 0);
            }
            int count = map.get(a[i]);
            map.put(a[i], count+1);
            if (0 < a[i]) {
                foundNonZero = true;
            }
        }
        if (!foundNonZero) {
            System.out.println("Yes");
            return;
        }
        if (map.size() == 1 || 3 < map.size()) {
            System.out.println("No");
            return;
        }
        if (map.size() == 3) {
            if (N % 3 != 0) {
                System.out.println("No");
                return;
            }
            if (!count_check(map, N)) {
                System.out.println("No");
                return;
            }
            if (check_xor(map)) {
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        if (map.size() == 2) {
            if (!has_zero(map)) {
                System.out.println("No");
                return;
            }
            if (N % 3 != 0) {
                System.out.println("No");
                return;
            }
            if (!count_check_size_2(map, N)) {
                System.out.println("No");
                return;
            }
            System.out.println("Yes");
            return;
        }
    }
    private boolean check_xor(HashMap<Long, Integer> map) {
        List<Long> list = new ArrayList<>();
        for (long x : map.keySet()) {
            list.add(x);
        }
        list.sort(Comparator.naturalOrder());
        return (list.get(0) ^ list.get(1)) == list.get(2);
    }
    private boolean count_check(HashMap<Long, Integer> map, int N) {
        int count = N / 3;
        for (long x : map.keySet()) {
            if (count != map.get(x)) {
                return false;
            }
        }
        return true;
    }
    private boolean count_check_size_2(HashMap<Long, Integer> map, int N) {
        int zero_count = N / 3;
        int nonzero_count = N * 2 / 3;
        boolean result = true;
        for (long x : map.keySet()) {
            if (x == 0 && zero_count != map.get(x)) {
                result = false;
                break;
            }
            if (x != 0 && nonzero_count != map.get(x)) {
                result = false;
            }
        }
        return result;
    }
    private boolean has_zero(HashMap<Long, Integer> map) {
        for (long x : map.keySet()) {
            if (x == 0) {
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 61868
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false; }
template <typename T> bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false; }

struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} IoSetup;

int main() {
  int n;
  cin >> n;
  string s;
  vector <char> correct = {'M','A','R','C','H'};
  vector <lint> eSm(5);
  vector <string> vec;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    for (int j = 0; j < 5; ++j) {
      if (s[0] == correct[j]) {
        vec.push_back(s);
        (++eSm[j]);
      }
    }
  }
  lint ans = 0;
  sort(eSm.begin(), eSm.end());
  for (int i = 0; i < 5; ++i) {
    for (int j = i+1; j < 5; ++j) {
      for (int k = j+1; k < 5; ++k) {
        ans += eSm[i]*eSm[j]*eSm[k];
      }
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 5748
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <numeric>
// #include <fstream>
 
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; }

const long long mod = 1e9 + 7;

int main()
{
    long long int n; std::cin >> n;
    std::string s; std::cin >> s;

    // 個数だけ引く
    long long int cntr = std::count(s.begin(), s.end(), 'R');   
    long long int cntg = std::count(s.begin(), s.end(), 'G');
    long long int cntb = std::count(s.begin(), s.end(), 'B');
    long long int ans = cntr * cntg * cntb, sub = 0;
    for(long long int i=0; i<n; i++)
    {
        for(long long int j=i+1; j<n; j++)
        {
            if(s[i]==s[j]) continue;
            long long int k = 2 * j - i;
            if(k>=n || s[j]==s[k] || s[i]==s[k]) continue;
            sub++;
        }
    }
    
    std::cout << ans - sub << std::endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using  ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";


void SetAns() {
	/// normal_input
	int D;
	cin >> D;

	vector<int> c(26);
	vector<vector<int>> s(D, vector<int>(26));
	rep(i, 26) cin >> c[i];
	rep(i, D) rep(j, 26) cin >> s[i][j];;

	/// special_input
	vector<int> t(D);
	rep(i, D) cin >> t[i];

	int M;
	cin >> M;
	rep(_i, M) {
		vector<int> last(26, -1);
		int satisfy = 0;

		int d, q;
		cin >> d >> q;
		t[d - 1] = q;

		rep(date, D) {
			last[t[date] - 1] = date;
			satisfy += s[date][t[date] - 1];
			rep(i, 26) satisfy -= c[i] * (date - last[i]);
		}
		cout << satisfy << endl;
	}
	return;
}

int main() {
	SetAns();
	//cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<int> v(N);
    for (auto &&i : v) {
        cin >> i;
    }

    ll ans = 0;
    ll sum = 0;
    REP(i, N) {
        if (v[i] == 0) {
            ans += sum / 2;
            sum = 0;
        }
        sum += v[i];
    }
    ans += sum / 2;

    print(ans);

    return 0;
}

Measured memory_bytes: 640
// AOJ 2511 Sinking islands
// 2018.2.28 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 202

/* UNION-FIND library */
int id[MAX], size[MAX]; int cnt;
void init(int n) { int i; for (i = 0; i < n; i++) id[i] = i, size[i] = 1; }
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
int connected(int p, int q) { return root(p) == root(q); }
void unite(int p, int q) { int i = root(p), j = root(q); if (i == j) return;
cnt++; if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
}

int N, M;
int h[MAX], t[MAX], t2[MAX], s[MAX];
typedef struct { int a, b, c, t; } C;
C c[20000], c2[20000];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int tcmp(int *a, int *b) { return *a - *b; }
int ccmp(C *a, C *b) { return a->c - b->c; }
int c2cmp(C *a, C *b) { if (b->t - a->t) return b->t - a->t; return a->c - b->c; }

int uniq(int *a, int n)
{
	int i, j, k;

	s[0] = N;
	for (i = 0, j = 1; j < n; j++) {
		k = j; while (j < n && a[j] == a[i]) j++;
		s[i+1] = s[i] - (j-k+1);
		if (j < n) if (++i != j) a[i] = a[j];
	}
	return i+1;
}

int check(int id)
{
	int i, a, b, tm;

	init(N); cnt = 1; tm = t[id];
	for (i = 0; i < M; i++) {
		if (c2[i].t < tm) break;
		a = c2[i].a, b = c2[i].b;
		if (!connected(a, b)) unite(a, b);
		if (cnt == s[id]) return 0;
	}
	return 1;
}

int main()
{
	int i, j, k, tsz, tm, ans;
	int a, b;

	while (N = in()) {
		init(N); cnt = 1;

		M = in();
		for (i = 0; i < N; i++) h[i] = t[i] = in();
		for (i = 0; i < M; i++) {
			c[i].a = a = in()-1, c[i].b = b = in()-1, c[i].c = in();
			if (t[a] <= t[b]) c[i].t = t[a]; else c[i].t = t[b]; 
			unite(a, b);
		}
		if (cnt < N) { puts("0"); continue; }

		qsort(t, N, sizeof(int), tcmp);
		tsz = uniq(t, N);
		memcpy(c2, c, sizeof(C)*M);
		qsort(c, M, sizeof(C), ccmp);
		qsort(c2, M, sizeof(C), c2cmp);

		for (i = 1; i < tsz; i++) if (check(i)) break;
		k = i-1, tm = t[k];

		ans = 0;
		init(N);
		for (i = 0; i < M; i++) {
			a = c[i].a, b = c[i].b;
			if (h[a] >= tm && h[b] >= tm && !connected(a, b)) ans += c[i].c, unite(a, b);
		}
		for (j = k-1; j >= 0; j--) {
			for (i = 0; i < M; i++) {
				if (c2[i].t < t[j]) break;
				a = c2[i].a, b = c2[i].b;
				if (!connected(a, b)) ans += c2[i].c, unite(a, b);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<P> sc(m);
    if (m!=0) {
        rep(i, m) {
            cin >> sc[i].first >> sc[i].second;
        }
        rep(i, m) {
            if (n!=1 && sc[i].first==1 && sc[i].second==0) {
                cout << -1 << endl;
                return 0;
            }
        }
        rep(i, m) {
            rep(j, m) {
                if (i!=j && sc[i].first==sc[j].first && sc[i].second!=sc[j].second && sc[i].first<=n) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
        sort(all(sc));
    }
    
    string ans = "";
    int count = 1;
    bool ok = false;
    rep(i, n) {
        rep(j, m) {
            if (sc[j].first==i+1) {
                cout << sc[j].second;
                ok = true;
                break;
            }
        }
        if (!ok) {
            if (i==0 && n!=1) cout << 1;
            else cout << 0;
        }
        ok = false;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int h, w;
	int i, j;
	char p[52][53]={NULL};

	scanf("%d%d", &h, &w);

	for(i=0; i < h; i++){
		scanf("%s", &p[i+1][1]);
	}

	for(i=1; i <= h; i++){
		for(j=1; j <= w; j++){
			if(p[i][j] == '#' && p[i-1][j] != '#' && p[i+1][j] != '#' && p[i][j-1] != '#' && p[i][j+1] != '#'){
				break;
			}
		}
		if(j != w+1){break;}
	}


	if(i == h+1 && j == w+1){
		printf("Yes");
	}
	else{
		printf("No");
	}


return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int abs(int n){
		if(n<0){
		return -1*n;}else
		return n;}
int main(void)
{int N,A,M,B,X,C,x,i,a,b,c,l,r,g,m,tmp;
	scanf("%d%d%d",&X,&A,&B);
if(B<=A){
	printf("delicious");}
	else if(B<=A+X){
		printf("safe");}
		else{
			printf("dangerous");}


	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int l,r,u,d,n,x,y,a,ans;
	while(~scanf("%d%d%d",&r,&u,&n)){
		l = 0;d = 0;
		for(int i = 1;i <= n;i++){
			scanf("%d %d %d",&x,&y,&a);
			if(a == 1) l = max(l,x);
			else if(a == 2) r = min(r,x);
			else if(a == 3) d = max(d,y);
			else if(a == 4) u = min(u,y);
		}
		if(r - l <= 0 || u - d <= 0) ans = 0;
		else ans = (r - l) * (u - d);
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b, c; cin >> a >> b >> c;
	cout << ( ( a+b >= c ) ? "Yes" : "No" ) << endl;
	return 0;
}

Measured memory_bytes: 256
# jsc2019-qualB - Kleene Inversion
class BIT:  # Binary Indexed Tree (Fenwick Tree)
    def __init__(self, lim):
        self.size = lim
        self.tree = [0] * (lim + 1)  # 1-idx

    def add(self, i, x):  # add x to tree[i], O(logN)
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def sum(self, i):  # sum of [1, i], O(logN)
        ret = 0
        while i > 0:
            ret += self.tree[i]
            i -= i & -i
        return ret

    def range_sum(self, l, r):  # range sum of [l, r]
        return self.sum(r) - self.sum(l - 1)


def main():
    N, K = tuple(map(int, input().split()))
    A = tuple(map(int, input().split()))
    MOD = 10 ** 9 + 7
    bit = BIT(2000)
    x = 0
    for i, a in enumerate(A, 1):  # internal inversion
        bit.add(a, 1)
        x += i - bit.sum(a)
    y = -x
    for i, a in enumerate(A, 1):  # external inversion
        bit.add(a, 1)
        y += i + N - bit.sum(a)
    ans = (x * K + y * K * (K - 1) // 2) % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9364
from collections import Counter

N = int(input())

def factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

factors = Counter()

for n in range(2,N+1):
    factors += factorize(n)

ans = 1
MOD = 10**9+7
for v in factors.values():
    ans *= (v+1)
    ans %= MOD
print(ans)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(ll i=s;i<=e;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 998244353
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define set0(x) memset(x, 0, sizeof(x))

ll fastPowMod(ll a, ll p,ll mod){ if(p==0) return 1; ll z = fastPowMod(a,p/2,mod); z = (z*z)%mod; if(p%2) z = (z*a)%mod; return z; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}


void solve()
{
    ll N,W,V=0;
    cin>>N>>W;
    vll w(N+1,0),v(N+1,0);
    srep(i,1,N) {cin>>w[i]>>v[i];V+=v[i];}
    vll dp(V+1,(ll)1e11);
    
    dp[0] = 0;
    srep(i,1,N)
    {
        for(ll j=V;j>=v[i];j--)
        {
            dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
        }
    }

    rrep(i,V+1)
    {
        if(dp[i]<=W) {cout<<i;return;}
    }
}

int main()
{
    fastio;
    /*int t;
    cin>>t;
    
    rep(i,t)
    {*/
        solve();
        cout<<"\n";
    //}
    return 0;
}

Measured memory_bytes: 1024
import numpy as np
n = int(input())
red = [list(map(int, input().split())) for i in range(n)]
blue = [list(map(int, input().split())) for i in range(n)]

points = red + blue
points.sort()
temp = []
ans = 0
for p in points:
    if p in red:
        temp.append(p)
    else:
        temp.sort(key=lambda x: x[1], reverse=True)
        for t in temp:
            if t[0] < p[0] and t[1] < p[1]:
                temp.remove(t)
                ans += 1
                break

print(ans)

Measured memory_bytes: 21668
from collections import deque

N = int(input())                            # 頂点数

conj = [[] for _ in range(N)]
for i in range(N):                          # 各頂点での進める先の候補の集合
    L = list(map(int, input().split()))
    for a in L[2:]:
        conj[i].append(a-1)         # 頂点番号をデクリメント

start = 0

visit = [False]*N                           # 訪れたかどうかをメモ
second_visit = [False]*N                    # 二度目に訪れた事をメモ
next_set = deque()                          # 次に進む候補を列挙する。スタック（右から取り出す = pop）だと深さ優先になり、キュー（左から取り出す = popleft）だと幅優先になる
next_set.append((start, 0))                 # スタート地点を決める。第二成分は時刻を表す。
visit[start] = True                         # スタート地点は最初から踏んでいる。
res = [-1 for _ in range(N)]
res[0] = 0

while next_set:                             # p = [] になったら止める
    p, t = next_set.popleft()               # 要素を消去して、消去した要素を出力
    for q in conj[p]:                       # 頂点 p から進める経路の候補から一つ選ぶ
        if not visit[q]:                    # 訪れた事がない場所のみ進む。壁などの条件がある場合は、ここに " grid[p] != 壁 " 等を追加する
            visit[q] = True                 # 頂点 q に一度訪れた事をメモ (for の前に書くと、ここで選ばれた q が最短であるはずなのに、違う経路でvisit = Trueを踏んでしまう可能性がある)
            res[q] = t + 1
            next_set.append((q, t + 1))     # p から q へと移動。時刻を 1 進める


for i in range(N):
    print(i+1, res[i])


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

int main() {

  int N;
  cin >> N;
  string S;
  for (int i = 0; i < N || S=="Y"; i++) {
    cin >> S;
    if(S=="Y"){
      cout << "Four" << endl;
      break;
    }
  }
  if(S!="Y") cout << "Three" << endl;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b, c;
    int ans;
    
    scanf("%d%d%d", &a, &b, &c);
    
    if (a==b) {
        ans=c;
    } else if (b==c) {
        ans=a;
    } else {
        ans = b;
    }
    
    printf("%d", ans);
    
    return 0;
}



Measured memory_bytes: 1700
S = list(input())
result = True
for i in range(len(S)):
  if (i+1) % 2 == 0:
    if S[i] == 'R':
      result = False
      break
  elif (i+1) % 2 != 0:
    if S[i] == 'L':
      result = False
      break
print('Yes' if result else 'No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define fi first
#define se second
const int inf = 1e9+7;
int mod = 1e9+7;

int a[10000], b[10000][300];
int segn = 1;
P seg[20000];
void init(int n){
	while(segn < n)segn *= 2;
	rep(i,2*n)seg[i] = P(0, 0);
}
//k番目の値をxに変更
void add(int k, int x){
	k += segn-1;
	seg[k] = P(x, k-(segn-1));
	while(k > 0){
		k = (k-1)/2;
		seg[k] = max(seg[k*2+1], seg[k*2+2]);
	}
}
//[a,b)の最大値を求める
P get(int a, int b, int k, int l, int r){
	if(b <= l || r <= a)return P(0, 0);
	if(a <= l && r <= b)return seg[k];
	P vl = get(a, b, k*2+1, l, (l+r)/2);
	P vr = get(a, b, k*2+2, (l+r)/2, r);
	return max(vl, vr);
}

int has[6000][6000];
void rui(int Y1, int Y2, int X1, int X2, int x){
	has[Y1][X1] += x;has[Y1][X2+1] -= x;
	has[Y2+1][X1] -= x;has[Y2+1][X2+1] += x;
}

void dfs(int l, int r, int k){
	if(l >= r)return ;
	P p = get(l, r, 0, 0, segn);
	rui(l+1, p.se+1, p.se+1, r, p.fi);
	dfs(l, p.se, k);
	dfs(p.se+1, r, k);
}

signed main(){
	int n, m;
	scanf("%lld%lld", &n, &m);
	repi(i,2,n+1)scanf("%lld", &a[i]);
	rrep(i,n)rrep(j,m)scanf("%lld", &b[i][j]);
	
	rrep(j,m){
		init(n);
		//fill((int*)has, (int*)(has+100), 0);
		rrep(i,n)add(i-1, b[i][j]);
		dfs(0, n, j);
	}
	
	rrep(i,n)rrep(j,n)has[i][j] += has[i][j-1];
	rrep(i,n)rrep(j,n)has[i][j] += has[i-1][j];
	
	int ans = 0;
	rrep(i,n)a[i] += a[i-1];
	rrep(i,n)rrep(j,n){
		if(i > j)continue;
		int d = a[j]-a[i];
		ans = max(ans, has[i][j]-d);
	}
	printf("%lld\n", ans);
	/*printf("\n");
	rrep(i,n){
		rrep(j,n)printf("%2lld ", has[i][j]);
		printf("\n");
		//P p = get(i,i+1,0,0,segn);
		//printf("%lld %lld\n", p.fi, p.se);
	}*/
	return 0;
}


Measured memory_bytes: 249984
N = int(input())
S = input()
c1 = S.count("#")
c2 = S.count(".")
r1 = [0] * N
r2 = [0] * (N + 1)
if S[0] == "#":
    r1[0] = 1
for i in range(1, N):
    if S[i] == "#":
        r1[i] = r1[i - 1] + 1
    else:
        r1[i] = r1[i - 1]
r2[N - 1] = 1 * (S[N - 1] == ".")
r2[N] = r2[N - 1]
for i in range(N - 2, -1, -1):
    if S[i] == ".":
        r2[i] = r2[i + 1] + 1
    else:
        r2[i] = r2[i + 1]
res = N
for i in range(N):
    res = min(res, r1[i] + r2[i + 1])
print(min(res, c1, c2))

Measured memory_bytes: 12784
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	while( cin >> n && n ){
		vector< pair< double, int > > list1;
		vector< pair< double, int > > list2;
		for( int i = 0; i < n; ++i ){
			int id, h, w;
			cin >> id >> h >> w;
			double hh = static_cast< double >( h ) / 100;
			double bmi = w / ( hh * hh );
			if( bmi >= 22.0 ){
				list1.push_back( make_pair( bmi, id ) );
			}else{
				list2.push_back( make_pair( bmi, id ) );
			}
		}
		sort( list1.begin(), list1.end() );
		sort( list2.begin(), list2.end() );
		pair< double, int > high, low;
		if( !list1.empty() ){
			high = list1[ 0 ];
		}
		if( !list2.empty() ){
			low = list2[ list2.size() - 1 ];
			vector< pair < double, int > >::reverse_iterator itr = list2.rbegin();
			while( itr != list2.rend() ){
				if( itr->first < low.first ){
					break;
				}
				low = *itr;
				++itr;
			}
		}
		int result = 0;
		if( list1.empty() ){
			result = low.second;
		}else if( list2.empty() ){
			result = high.second;
		}else if( high.first - 22.0 < 22.0 - low.first ){
			result = high.second;
		}else{
			result = low.second;
		}
		cout << result << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
int main() {
    char c;
    string ans;
    cin >> c;
    if(c == 'a'|| c == 'i'|| c == 'u'|| c == 'e'|| c == 'o'){
        ans = "vowel";
    }
    else{
        ans = "consonant";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
 
    int N;
    int ans = 0;
    int A[200] = {};
    
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];

    
    while(true){
        
        for(int i = 0; i < N; i++){
            if(A[i] % 2 == 0) A[i] /= 2; 
            else{
                cout << ans << endl;
                return 0;
            }
        }
        ans++;
    }
    

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

vvi g;
vi dist;
void dfs(int now, int par){
    for(auto ne: g[now])if(ne != par){
        dist[ne] = dist[now] + 1;
        dfs(ne,now);
    }
}

int ans = 0;
void dfs2(int now, int par, int d){
    ans = max(ans, dist[now]);
    for(auto ne: g[now])if(ne != par){
        if(d+1 < dist[ne]){
            dfs2(ne, now, d+1);
        }
    }
}
signed main(void) {
    int n,u,v;
    cin >> n >> u >> v;//vが鬼
    u--,v--;
    g = vvi(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dist = vi(n,0);
    dfs(v,-1);
    dfs2(u,-1,0);
    cout << ans-1 << endl;
}


Measured memory_bytes: 10496