akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let ans = if S.len() >= 4 && S[0] == 'Y' && S[1] == 'A' && S[2] == 'K' && S[3] == 'I' {
        "Yes"
    } else {
        "No"
    };

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


Measured memory_bytes: 4352
<?php

fscanf(STDIN,'%d',$n);
$dll= new \splDoublyLinkedList();
for($i=0; $i<$n;$i++) {
  $line=trim(fgets(STDIN));
  if($line[0]==='i') {
    //先頭に要素を追加
    $dll->unshift(substr($line,7));
  } elseif($line[6]==='F') {
    //先頭からノードを取り出す
    $dll->shift();
  } elseif($line[6]==='L') {
    //末尾からノードを取り出す
    $dll->pop();
  }else{
    $check=substr($line, 7);
    foreach($dll as $key=>$val) {
      if($val === $check) {
        //指定したindexの値を削除する
        $dll->offsetUnset($key);
        break;
      }
    }
  }
}
$str = array();
while(true) {
  try{
    //先頭から取り出す
    $val = $dll->shift();
    $str[]=$val;
  }catch(Exception $e) {
    echo implode(' ',$str), PHP_EOL;
    break;
  }
}



Measured memory_bytes: 136132
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m;
  cin >> n >> m;
  long long a[n],b[n],c[m],d[m],ans[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<m;i++){
    cin >> c[i] >> d[i];
  }
  for(int i=0;i<n;i++){
    ans[i]=1e9;
    for(int j=m-1;j>=0;j--){
      ans[i]=min(ans[i],abs(a[i]-c[j])+abs(b[i]-d[j]));
    }
  }
  for(int i=0;i<n;i++){
    int x=0;
    for(int j=0;j<m;j++){
      if(ans[i]==abs(a[i]-c[j])+abs(b[i]-d[j])&&x==0){
        cout << j+1 << endl;
        x++;
      }
    }
  }
  return 0;
}


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

using namespace std;

int main(){
    int N, K, C;
    while(cin >> N >> K >> C){
        string S; cin >> S;
        vector<int> back(N+C+2, 0);
        int best = 0;
        for(int i=N-1;i>=0;i--){
            int add = back[i+C+1];
            back[i] = max(best, add + (S[i] == 'o' ? 1 : 0));
            best = max(back[i], best);
        }
        best = 0;
        int idx = -C;
        vector<int> front(N, 0);
        for(int i=0;i<N;i++){
            if(S[i] == 'o'){
                if(best + back[max(idx+C+1, i+1)] < K) cout << i+1 << endl;
            }
            int add = (i-C-1 >= 0 ? front[i-C-1] : 0);
            front[i] = max(best, add + (S[i] == 'o' ? 1 : 0));
            if(front[i] > best){
                best = front[i];
                idx = i;
            }
        }
    }
}

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

struct uftree{
	int par[100005],rank[100005];
	uftree(){
		for(int i=0;i<100005;i++){
			par[i]=i;
		}
	}
	int find(int x){
		if(x==par[x])return x;
		return (par[x]=find(par[x]));
	}

	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(rank[x]<rank[y]){
			par[x]=y;
		}else{
			if(rank[x]==rank[y])rank[x]++;
			par[y]=x;
		}
	}
};

uftree uf;

string str;
int n;
int l[100005],r[100005];
int diff[100005];
int sum[100005];

int main(void){
	cin >> str;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&l[i],&r[i]);
		l[i]--;
		uf.unite(l[i],r[i]);
	}
	n=str.size();
	diff[0]=(str[0]-'a');
	for(int i=0;i<n-1;i++){
		diff[i+1]=(str[i+1]-'a')-(str[i]-'a');
		if(diff[i+1]<0)diff[i+1]+=26;
	}
	diff[n]=26-(str[n-1]-'a');
	for(int i=0;i<(n+1)/2;i++){
		uf.unite(i,n-i);
	}
	for(int i=0;i<=n;i++){
		int v=uf.find(i);
		sum[v]+=diff[i];
	}
	for(int i=0;i<=n;i++){
		if(sum[i]%26!=0){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long ll;
 
int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}
 
struct dat {
	int l,r;
	bool operator<(const dat &A) const {
		return r<A.r;
	}
} a[N];
 
int n,pre1[N],suf1[N],pre2[N],suf2[N],ans;
 
int len(int l,int r) {
	if(l>r) return 0;
	return r-l+1;
}
 
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) a[i].l=gi(),a[i].r=gi();
	sort(a+1,a+n+1);
	pre2[0]=1e9;
	for(int i=1;i<=n;i++) {
		pre1[i]=max(pre1[i-1],a[i].l);
		pre2[i]=min(pre2[i-1],a[i].r);
	}
	suf2[n+1]=1e9;
	for(int i=n;i;i--) {
		suf1[i]=max(suf1[i+1],a[i].l);
		suf2[i]=min(suf2[i+1],a[i].r);
	}
	for(int i=1;i<=n;i++) {
		int L=max(pre1[i-1],suf1[i+1]);
		int R=min(pre2[i-1],suf2[i+1]);
		ans=max(ans,a[i].r-a[i].l+1+len(L,R));
		if(i^n) ans=max(ans,len(pre1[i],pre2[i])+len(suf1[i+1],suf2[i+1]));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5980
require 'date'
meiji = Date.new(1868, 9, 8)
taisho = Date.new(1912, 7, 30)
showa = Date.new(1926, 12, 25)
heisei = Date.new(1989, 1, 8)
years_stan = [1867, 1911, 1925, 1988]
readlines.each do |date|
  year, month, day = date.chomp.split.map(&:to_i)
  today = Date.new(year, month, day)
  if today - meiji < 0
    puts "pre-meiji"
  elsif today - taisho < 0
    puts "meiji #{year - years_stan[0]} #{month} #{day}"
  elsif today - showa < 0
    puts "taisho #{year - years_stan[1]} #{month} #{day}"
  elsif today - heisei < 0
    puts "showa #{year - years_stan[2]} #{month} #{day}"
  else
    puts "heisei #{year - years_stan[3]} #{month} #{day}"
  end
end

Measured memory_bytes: 6240
#include <stdio.h>

int main(void)
{
  int N, M, X;
  int left = 0, right = 0;
  int i;
  
  scanf("%d %d %d", &N, &M, &X);
  
  for(int i = 0; i < M; i++) {
    int A;
    scanf("%d", &A);
   	if(A < X) left++;
    else right++;
  }
  
  if(left < right) printf("%d\n", left);
  else printf("%d\n", right);
  
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>

using namespace std;

struct Tree {
	int key;
	Tree *left;
	Tree *right;
	Tree *parent;
};

// Tree::Tree(int k, Tree *l, Tree *r): key(k), left(l), right(r){}

void printTreeMid(Tree *tree) {
	// cout << "mid" << endl;
	if(tree == nullptr) return;
	printTreeMid(tree->left);
	printf(" %d", tree->key);
	printTreeMid(tree->right);
}

void printTreePro(Tree *tree) {
	if(tree == nullptr) return;
	printf(" %d", tree->key);
	printTreePro(tree->left);
	printTreePro(tree->right);
}


void insert(Tree *tree, int key) {
	Tree *y = nullptr;
	Tree *x = tree->right;
	while(x != nullptr) {
		// cout << "in while" << endl;
		y = x;
		if(x->key < key) {
			x = x->right;
		} else {
			x = x->left;
		}
	}
	Tree *z = new Tree();
	z->parent = y;
	z->key = key;
	z->left = nullptr;
	z->right = nullptr;
	if(z->parent == nullptr) {
		tree->right = z;
		return;
	}
	if(y->key < key) {
		y->right = z;
	} else {
		y->left = z;
	}
}


//8:00
int main() {
	int n;
	cin >> n;
	Tree *NIL = new Tree();
	NIL->right = nullptr;
	for (size_t i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		if(s == "insert") {
			int k;
			cin >> k;
			// if(tree != nullptr) {
			// 	cout << "root: " << tree->key;
			// }
			insert(NIL, k);
		} else {
			printTreeMid(NIL->right);
			cout << endl;
			printTreePro(NIL->right);
			cout << endl;
		}
	}
}



Measured memory_bytes: 26684
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int main()
{
  LL a,b,k;
  cin>>a>>b>>k;
  if(k<=a) cout<<a-k<<' '<<b;
  else cout<<0<<' '<<max(0LL,b-(k-a))<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7

n, m = map(int, readline().split())
a = list(map(int, read().split()))

dp = [0] * (n + 1)
ng = [0] * (n + 1)

for i in a:
    ng[i] = 1

dp[0] = 1
if ng[1] != 1:
    dp[1] = 1

for i in range(2, n + 1):
    if ng[i - 1] == 1 and ng[i - 2] == 1:
        print(0)
        exit()
    elif ng[i - 1] == 1:
        dp[i] = dp[i - 2]
    elif ng[i - 2] == 1:
        dp[i] = dp[i - 1]
    else:
        dp[i] = dp[i - 1] + dp[i - 2]
    if dp[i] > MOD:
        dp[i] %= MOD

print(dp[-1])

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

vote = {}

for i in range(n):
  s = input()
  if s in vote.keys():
    vote[s] += 1
  else:
    vote[s] = 1
m = max(vote.values())
vote=sorted(vote.items() , key = lambda x:x[0])
for i in vote:
  if i[1] == m:
    print(i[0])

Measured memory_bytes: 44764
N,M=list(map(int,input().split()))
number=[-1 for i in range(N)];
flag=True
for i in range(M):
    s,c=list(map(int,input().split()))
    if number[s-1]==-1:
        number[s-1]=c
    else:
        if number[s-1]!=c:
            flag=False

if (number[0]==0)&(N!=1):
    flag=False
if not flag:
    print(-1)
else:
    if N==1:
        print(max(number[0],0))
    else:
        if number[0]==-1:
            number[0]=1

        for i in range(1,N):
            number[i]=max(number[i],0)

        T=""
        for i in range(0,N):
            T+=str(number[i])
        print(T)


Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    input! {
        n: u64,
        m: u64,
    }

    let d = 10u64.pow(9)+7;
    let mut v = vec![];
    factorization(m, &mut v);

    let mut ans = 1;
    for b in v.iter() {
        ans = (ans * comb(*b, n, d)) % d;
    }

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

fn factorization(t: u64, v: &mut Vec<u64>) {
    let mut i = 2;
    let mut m = t;

    while i * i <= m {
        let mut count = 0;
        while m % i == 0 {
            count = count + 1;
            m = m / i;
        }
        v.push(count);
        i = i + 1;
    }

    if m != 1 {
        v.push(1);
    }
}

fn comb(b: u64, n: u64, d: u64) -> u64{
    let num: u64 = (1..b+n).rev().take(b as usize).fold(1, |n, i| n*i%d);
    let den: u64 = (1..b+1).fold(1, |n, i| n*i%d);

    num*modinv(den, d) % d
}

fn modinv (a: u64, d: u64) -> u64 {
    modpow(a, d - 2, d)
}

fn modpow(x: u64, y: u64, d: u64) -> u64 {
    let mut res = 1;
    let mut a = x;
    let mut n = y;
    while n > 0 {
        if n & 1 != 0 {
            res = res * a % d;
        }
        a = a * a % d;
        n = n >> 1;
    }
    res
}

Measured memory_bytes: 4352
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int a;
  std::string s;

  std::cin >> a >> s;

  std::cout << (a >= 3200 ? s : "red")  << std::endl;

  return 0;
}


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

using namespace std;

template <class T> struct FenwickTree {
  std::vector<T> in;
  int N;
  FenwickTree(int N) : N(N), in(N) {}
  void update(int at, T by) {
    for (int i = at; i < N; i += (i & -i)) {
      in[i] += by;
    }
  }
  T query(int at) {
    T sum = 0;
    for (int i = at; i; i -= (i & -i)) {
      sum += in[i];
    }
    return sum;
  }
};

int main(int argc, char *argv[]) {
  string s;
  cin >> s;
  int n = s.size();
  FenwickTree<int> fw(s.size() + 1);
  vector<deque<int>> g(255);
  for (int i = 0; i < n; i++) {
    g[s[i]].push_back(i + 1);
    fw.update(i + 1, 1);
  }
  int cnt = 0;
  for (int i = 'a'; i <= 'z'; i++) {
    cnt += (g[i].size() & 1);
  }
  if (cnt > 1) {
    cout << -1 << endl;
    return 0;
  }
  long long ans = 0;
  for (int i = 0; i < s.size(); i++) {
    int c = s[i];
    if (fw.query(i + 1) - fw.query(i) == 0) {
      continue;
    }
    if (g[c].size() == 1) {
      ans += fw.query(n) / 2;
    } else {
      int z = fw.query(n) - fw.query(g[c].back());
      ans += z;
      fw.update(g[c].back(), -1);
      g[c].pop_back();
    }
    g[c].pop_front();
    fw.update(i + 1, -1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2308
n = int(input())
a1 = list(map(int, input().split(" ")))
a2 = list(map(int, input().split(" ")))
sum_list = []
for m in range(n):
    sum_list.append(sum(a1[0:m+1]) + sum(a2[m:n]))
print(max(sum_list))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main(){
	string str;
	getline(cin,str);
	for(int i=0;i<str.size();i++){
		if(str[i]>='a'&&str[i]<='z'){
		str[i]-=32;
		cout<<str[i];
		}else{
		cout<<str[i];
		}
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 3100
N = int(input())
p_list = list(map(float, input().split()))

dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    for j in range(i+1):
        dp[i][j] += dp[i-1][j] * (1-p_list[i-1])
        if j > 0:
            dp[i][j] += dp[i-1][j-1] * p_list[i-1]
ans = 0       
start = N//2 + 1
for p in dp[N][start:]:
    ans += p
print(ans)

Measured memory_bytes: 203492
from collections import Counter

N = int(input())

def factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def factor_factorize(n, d):
    if n == 1:
        return d
    d.extend(factorize(n))
    return factor_factorize(n-1, d)

F = Counter(factor_factorize(N, []))

# (4, 4, 2), (14, 4), (24, 2), (74,)
cases = []

n1 = [True for v in F.values() if v >= 4].count(True)
m1 = [True for v in F.values() if 4 > v >= 2].count(True)
cases.append(n1 * (n1-1) // 2 * max(0, m1+n1-2))

n2 = [True for v in F.values() if v >= 14].count(True)
m2 = [True for v in F.values() if 14 > v >= 4].count(True)
cases.append(n2 * max(0, m2+n2-1))

n3 = [True for v in F.values() if v >= 24].count(True)
m3 = [True for v in F.values() if 24 > v >= 2].count(True)
cases.append(n3 * max(0, m3+n3-1))

n4 = [True for v in F.values() if v >= 74].count(True)
cases.append(n4)

print(sum(cases))


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
stack<double> st;

double calc(string e){
  double num2 = st.top(); st.pop();
  double num1 = st.top(); st.pop();
  if(e == "+") return num1 + num2;
  else if(e == "-") return num1 - num2;
  else if(e == "*") return num1 * num2;
  else return num1 / num2;
}

int main(){
  string str;
  while(cin >> str){
    if(str == "+" || str == "-" || str == "*" || str == "/"){
      st.push(calc(str));
    } else {
      st.push(atoi(str.c_str()));
    }
    if(getchar() == '\n'){
      printf("%.10f\n",st.top());
      st.pop();
    }
  }
}

Measured memory_bytes: 1252
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str;
    int i,j,l,count1;
    while (cin >> str)
    {
        count1=0;
        l = str.length();
        for (i = 0,j = l-1; i <= j; i++,j--)
        {
            if (str[i] != str[j])
            {
                count1++;
            }
        }
        cout<<count1<<endl;

}
  return 0;
}


Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	int a,b;
	cin>>a>>b;	

	if(a>=13){
		cout<<b<<endl;
	}else if(a>5){
		cout<<b/2<<endl;
	}else{
		cout<<0<<endl;
	}
	

	return 0;
}

Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main(){
  int i,N,M;
  double judge,sum,ans;
  string go;
  cin>>N>>M;
  double A[N];
  sum=ans=0;
  
  for(i=0;i<N;i++){
    cin>>A[i];
    sum+=A[i];
  }
  judge=sum/M/4;

  for(i=0;i<N;i++){
    if(A[i]>=judge){
      ans++;
    }
  }
  
  if(ans>=M){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
//typedef pair<ll, ll> P;
const ll INF=1LL<<60;
//構造体（外側だけ）
struct Sieve{
  //素因数分解（素数、何個あるか）
  vector<pair<long long,int>>factor(long long x){
    vector<pair<long long,int>>res;
    for(long long i=2;i*i<=x;++i){
      int y=0;
      while(x%i==0){
        x/=i;
        ++y;
      }
      if(y!=0)res.emplace_back(x,y);
    }
    if(x!=1)res.emplace_back(x,1);
    return res;
  }
};
int gcd(int a, int b){
   if (a%b == 0)return(b);
   else return(gcd(b, a%b));
}
int main(){
  long long a,b;
  cin>>a>>b;
  ll n=gcd(a,b);
  Sieve s;
  auto fs=s.factor(n);
  int ans=fs.size()+1;
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
  int n;
  cin>>n;
  if (n%10 == 2 or n%10 == 4 or n%10 == 5 or n%10 == 7 or n%10 == 9)
  {
    cout<<"hon";
    return 0;
  }
  if (n%10 == 0 or n%10 == 1 or n%10 == 6 or n%10 == 8)
  {
    cout<<"pon";
    return 0;
  }
  if (n%10 == 3)
  {
    cout<<"bon";
    return 0;
  }
}


Measured memory_bytes: 3056
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
signed main() {
	string s;
	cin >> s;
	int n = s.size();
	if (n < 4) {
		cout << "No" << endl;
	}
	else if (s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I') {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc;
	private void run(){
		sc = new Scanner( System.in );
		while( true ){
			int n = sc.nextInt();
			int r = sc.nextInt();
			if( n == 0 && r == 0 ){ return; }
			int[] cards = new int[ n ];
			for( int i = 0; i < n; i++ ){
				cards[ i ] = n - i;
			}
			for( int i = 0; i < r; i++ ){
				int p = sc.nextInt();
				int c = sc.nextInt();
					int[] pcards = new int[ p + 1 ];
					for( int j = 0; j < p - 1; j++ ){
						pcards[ j ] = cards[ j ];
					}
					for( int j = 0; j < c; j++ ){
						cards[ j ] = cards[ p - 1 + j ];
					}
					for( int j = 0; j < p - 1; j++ ){
						cards[ c + j ] = pcards[ j ];
					}
			}
			System.out.println( cards[ 0 ] );
		}
	}
	public static void main( String[] args ){
		new Main().run();
	}
}

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

int main() {

    int n;

    cin >> n;

    for(int i = 1; i < 10;i++){
        for(int j = 1;j < 10;j++){
          
            if(n == i*j){
               cout << "Yes";
                
                return 0;
            }
        }
    }
  
        cout << "No";
    
    

}

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

using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll a,b,n,w;
    cin>>n>>w;
    ll dp[n+1][100004];
    for(int i=0;i<=100001;i++){
        dp[0][i]=-1;
    }
    for(int i=0;i<=n;i++){
        dp[i][0]=0;
    }
    for(int i=1;i<=n;i++){
        cin>>a>>b;
        for(int j=1;j<=100001;j++){
            if(dp[i-1][j]>=0){
                if(j-b>=0){
                    if(dp[i-1][j-b]>0){
                        dp[i][j]=min(a+dp[i-1][j-b],dp[i-1][j]);
                    }
                    else{
                        dp[i][j]=dp[i-1][j];
                    }
                }
                else{
                    dp[i][j]=dp[i-1][j];
                }
            }
            else{
                if(j-b>=0){
                    if(dp[i-1][j-b]>0){
                        dp[i][j]=dp[i-1][j-b]+a;
                    }
                    else{
                        dp[i][j]=-1;
                    }
                }
                else{
                    dp[i][j]=-1;
                }
            }
        }
        if(dp[i-1][b]>0){
            dp[i][b]=min(dp[i-1][b],a);
        }
        else{
            dp[i][b]=a;
        }
    }
    
   //for(int i=0;i<=n;i++){
   //    for(int j=0;j<=140;j++){
   //        cout<<dp[i][j]<<" ";
   //    }
   //    cout<<endl;
   //}

    int ans=0;
    for(int i=100001;i>=0;i--){
        if(dp[n][i]>0&&dp[n][i]<=w){
            cout<<i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 79232
cards = input()
cards_s = cards.split()

porker_list = ['2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '1']

alice_str = cards_s[0]
alice_s = porker_list.index(alice_str)
alice = int(alice_s)

bob_str = cards_s[1]
bob_s = porker_list.index(bob_str)
bob = int(bob_s)

if alice > bob:
    print('Alice')
elif alice == bob:
    print('Draw')
else:
    print('Bob')


Measured memory_bytes: 3064
import math

a,b,h,m = map(int,input().split())
m = m + 60*h
deg = (5.5 * m)%360
ans = (a - b * math.cos(math.radians(deg)))**2 + (b * math.sin(math.radians(deg)))**2
ans = ans**0.5

print(ans)

Measured memory_bytes: 9504
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

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

    dpa = [a[0]]+[0]*(n-1)
    dpb = [b[0]]+[0]*(n-1)
    dpc = [c[0]]+[0]*(n-1)
    for i in range(1,n):
        dpa[i] = max(dpb[i-1],dpc[i-1]) + a[i]
        dpb[i] = max(dpc[i-1],dpa[i-1]) + b[i]
        dpc[i] = max(dpa[i-1],dpb[i-1]) + c[i]
    print(max(dpa[-1],dpb[-1],dpc[-1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 27876
#include<stdio.h>
int main()
{
	int a[105]={0};
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		if(a[x]==0)
		{
			ans++;
			a[x]=1;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(void) {
	int N;
	string S;
	cin >> N >> S;

	bool ans = false;
	if (N % 2 == 0) {
		string s1 = S.substr(0, N / 2);
		string s2 = S.substr(N / 2);
		if (s1 == s2)
			ans = true;
	}

	cout << (ans ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

class Dice {
private:
	int surface [6];
	void next(int a, int b, int c, int d);


public:
	Dice(int surface[6]);
	Dice();
	void role(char dir);
	void set(int pos, int num);
	int get(int pos);
};

int main(void) {
	Dice dice;

	for (int i = 0; 6 > i; i++) {
		int buf;
		scanf("%d", &buf);
		dice.set(i, buf);
	}
	char order;
	while (scanf(" %c", &order) != EOF) {
		dice.role(order);
	}
	printf("%d\n", dice.get(0));
	return 0;
}

void Dice::next(int a, int b, int c, int d)
{
	swap(surface[c], surface[d]);
	swap(surface[b], surface[c]);
	swap(surface[a], surface[b]);
}

Dice::Dice(int surface[6])
{
	for (int i = 0; 6 > i; i++)
		Dice::surface[i] = surface[i];
}

Dice::Dice()
{
	for (int i = 0; 6 > i; i++) surface[i] = 0;
}

void Dice::role(char dir)
{
	switch (dir) {
	case 'W': next(0,3,5,2);  break;
	case 'E': next(0,2,5,3);  break;
	case 'N': next(0,4,5,1);  break;
	case 'S': next(0,1,5,4);  break;
	}
}

void Dice::set(int pos, int num)
{
	surface[pos] = num;
}

int Dice::get(int pos)
{
	return surface[pos];
}

Measured memory_bytes: 1188
#include<stdio.h>
int flg[10001];
int main(void){
	int n,i,j;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=2;i<=n;i++){
			if(flg[i]==0){
				for(j=i+i;j<=n;j+=i){
					flg[j]=1;
				}
			}
		}
		for(i=n;i>0;i--){
			if(flg[i]==0&&flg[i-2]==0){
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2628
import java.util.Scanner;

class Vector {
	double x, y;

	public Vector(double x, double y) {
		super();
		this.x = x;
		this.y = y;
	}

}

public class Main {
	static final Vector p1 = new Vector(0.0, 0.0),
			p2 = new Vector(100.0, 0.0);
	static final double angle60 = Math.toRadians(60);

	public static void kock(Vector a, Vector b, int n) {
		if (n == 0) {

		} else {
			n--;
			double sx = (a.x * 2.0 + b.x) / 3.0;
			double sy = (a.y * 2.0 + b.y) / 3.0;
			double tx = (a.x + b.x * 2.0) / 3.0;
			double ty = (a.y + b.y * 2.0) / 3.0;
			double ux = (tx - sx) * Math.cos(angle60) -
					(ty - sy) * Math.sin(angle60) + sx;
			double uy = (tx - sx) * Math.sin(angle60) +
					(ty - sy) * Math.cos(angle60) + sy;
			Vector s = new Vector(sx, sy);
			Vector t = new Vector(tx, ty);
			Vector u = new Vector(ux, uy);
			kock(a, s, n);
			printVec(s);
			kock(s, u, n);
			printVec(u);
			kock(u, t, n);
			printVec(t);
			kock(t, b, n);
		}
	}

	public static void printVec(Vector v) {
		System.out.println(v.x + " " + v.y);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		printVec(p1);
		kock(p1, p2, n);
		printVec(p2);
	}
}


Measured memory_bytes: 32148
#include<bits/stdc++.h>
using namespace std;
int n,k;
int Mod(int x){return n/k+((x%k?x%k:k)<=n%k);}
int main(){
	cin>>n>>k;
	cout<<(k&1?0ll:(long long)Mod(k/2)*Mod(k/2)*Mod(k/2))+(long long)Mod(0)*Mod(0)*Mod(0)<<endl;
	return 0;
}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
H = list(map(int, input().split()))
d = [float('inf')]*N

if N <= 3:
    print(abs(H[0]-H[-1]))
else:
    d[0] = 0
    d[1] = abs(H[1]-H[0])
    d[2] = abs(H[2]-H[0])
    for i in range(3, N):
        d[i] = min(d[i-1]+abs(H[i]-H[i-1]), d[i-2]+abs(H[i]-H[i-2]))
    print(d[-1])


Measured memory_bytes: 14004
#include<iostream>
using namespace std;
int main(){
	int M, N, D, s[150][150] = { 0 }, co = 0,co2=0, c, c2;
	cin >> N >> M >> D;
	char p[150][150] = {};
	for (int i = 0; i < N; i++){
		for (int j = 0; j < M; j++){
			cin >> p[i][j];
			if (p[i][j] == '#'){ s[i][j] = 1; }
			else if (p[i][j] == '.'){ s[i][j] = 0; }
		}
	}
	for (int i = 0; i < N ; i++){
		for (int j = 0; j < M+1-D; j++){
			c = 0;
			for (int k = 0; k < D; k++){
				if (s[i][j+k] == 0){
					c++;
				}
			}
			if (c == D){
				co++;
			}
		}
	}
	for (int i = 0; i < N+1-D; i++){
		for (int j = 0; j < M; j++){
			c2 = 0;
			for (int l = 0; l < D; l++){
				if (s[i + l][j] == 0){
					c2++;
				}
			}
			if (c2 == D){
				co2++;
			}
		}
	}
	cout << co+co2 << endl;
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 * 2 + 100;
ll Cc(ll n, ll m)
{
    if (m > n / 2)
        m = n - m;
    ll a = 1, b = 1;
    for (int i = 1; i <= m; i++)
    {
        a *= n + 1 - i;
        b *= i;
        if (a % b == 0)
        {
            a /= b;
            b = 1;
        }
    }
    return a / b;
}
int x[maxn], cnt[maxn];
ll c[maxn];
int main()
{
    int n;
    cin >> n;
    int mm = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i];
        cnt[x[i]]++;
        mm = max(x[i], mm);
    }
    ll ans = 0;
    for (int i = 2; i <= n; i++)
        c[i] = Cc(i, 2);
    for (int i = 1; i <= mm; i++)
        if (cnt[i])
            ans += c[cnt[i]];

    for (int i = 1; i <= n; i++)
    {
        ll t = ans;
        t -= c[cnt[x[i]]];
        t += c[cnt[x[i]] - 1];
        printf("%lld\n", t);
    }
    return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <vector>
using namespace std;
#define MOD 1000000007

int main() {
    int n, M;
    cin >> n >> M;
    vector<int> oks(n+1, true);
    for (int i = 0; i < M; i++) {
        int a; cin >> a;
        oks[a] = false;
    }

    vector<int> dp(n+1);
    dp[0] = 1;
    for (int now = 0; now < n; ++now) {
        for (int next = now+1; next <= min(n, now+2); ++next) {
            if (oks[next]) {
                dp[next] += dp[now];
                dp[next] %= MOD;
            }
        }
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<cstring>
using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)

int n,m;
string s;
map<string,int> var;
vector<int> g[2000],rg[2000];
vector<int> vs;
bool used[2000];
int cmp[2000];

void add_edge(int f,int t){
  g[f].push_back(t);
  rg[t].push_back(f);
}

void dfs(int v){
  used[v] = true;
  for(int i=0;i<g[v].size();i++){
    if(!used[g[v][i]])dfs(g[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v,int k){
  used[v] = true;
  cmp[v] = k;
  for(int i=0;i<rg[v].size();i++){
    if(!used[rg[v][i]])rdfs(rg[v][i],k);
  }
}

int scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<=2*m;v++){
    if(!used[v])dfs(v);
  }

  memset(used,0,sizeof(used));
  int k = 0;
  for(int i=vs.size()-1;i>=0;i--){
    if(!used[vs[i]])rdfs(vs[i],k++);
  }
  return k;
}

string extract(string x){
  REP(i,0,x.size()){
    if( ('A'<=x[i] && x[i]<='Z') || ('a'<=x[i] && x[i]<='z') ){
      string tmp = ""; int dif = 0;
      while(i+dif<x.size() && ('A'<=x[i+dif] && x[i+dif]<='Z')
	    || ('a'<=x[i+dif] && x[i+dif]<='z')){
	tmp += x[i+dif];
	dif++;
      }
      return tmp;
    }
  }
  return "";
}

int neg(int x){
  if(x<=m)return x+m;
  return x-m;
}

void parse(void){
  bool f=false;
  REP(i,0,s.size()){
    if(s[i] == '&' || s[i] == '|'){
      f = true;
      
      int k=0,x,n1,n2,flag,num;
      string tmp;
      for(x=i-1;x>=0;x--){
	if(s[x]=='(')k--;
	if(s[x]==')')k++;
	if(k<0)break;
      }
      if(x<0)x=0;

      tmp = extract(s.substr(x,i-x));
      if(var.find(tmp) == var.end())var[tmp] = var.size();
      n1 = var[tmp];
      
      num = 0;
      REP(j,x,i)if(s[j]=='~')num++;	  
      if(num&1)n1 += m;
      
      flag = 0;
      REP(j,0,x)if(s[j]=='~')flag++;

      tmp = extract(s.substr(i+1));
      if(var.find(tmp) == var.end())var[tmp] = var.size();
      n2 = var[tmp];

      num = 0;
      REP(j,i+1,s.size())if(s[j]=='~')num++;	  
      if(num&1)n2 += m;

      if(s[i] == '|'){
	if(flag&1){
	  n1 = neg(n1); n2 = neg(n2);
	  add_edge(0,n1); add_edge(n1,0);
	  add_edge(0,n2); add_edge(n2,0);
	}else{
	  add_edge(neg(n1),n2); add_edge(n2,n1);
	}
      }else if(s[i] == '&'){
	if(!(flag&1)){
	  add_edge(0,n1); add_edge(n1,0);
	  add_edge(0,n2); add_edge(n2,0);
	}else{
	  add_edge(n1,neg(n2)); add_edge(neg(n2),neg(n1));
	}
      }	
    }
  }
  
  if(!f){
    int num = 0;
    REP(i,0,s.size())if(s[i]=='~')num++;

    string tmp = extract(s);
    if(var.find(tmp) == var.end())var[tmp] = var.size();

    int hoge = var[tmp];
    if(num&1)hoge += m;
    
    add_edge(0,hoge); add_edge(hoge,0);
  }
}
   
int main(){
  cin >> n >> m;

  REP(i,0,n){
    cin >> s; s = s.substr(0,s.size()-1); parse();
  }
  scc();

  REP(i,1,m+1){
    if(cmp[i] == cmp[i+m]){
      cout << "reject" << endl;
      return 0;
    } 
  }
  cout << "accept" << endl;
}

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

using namespace std;

int main() {
	unordered_map<string, int> mp;
	mp["AC"] = 0;
	mp["WA"] = 0;
	mp["TLE"] = 0;
	mp["RE"] = 0;

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        1000005
#define mod         1000000007  
#define pi          3.1415926535897932384626433
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,flag=0;
    cin>>n;
    ll a[n],b[n];
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(i=0;i<n-2;i++){
        if((a[i]==b[i]) && (a[i+1]==b[i+1]) && (a[i+2]==b[i+2])){
            flag=1;
        }
    }
    if(flag==1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#include<chrono>
using namespace std;
typedef long long ll;
vector<int>e[200];
int main(){
	int n;
	cin>>n;
	string s="";
	for(int i=0;i<n;i++){
		s+='0';
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			s[i]='1';
			s[j]='1';
			cout<<"? "+s<<endl;
			s[i]='0';
			s[j]='0';
			int r;
			cin>>r;
			if(r==1){
				e[i].push_back(j);
			}
		}
	}
	cout<<"!";
	for(int i=0;i<n;i++){
		for(int j=0;j<e[i].size();j++){
			if(e[i][j]>i){
				cout<<" ("+to_string(i)+','+to_string(e[i][j])+')';
			}
		}
	}
	cout<<endl;
}


Measured memory_bytes: 852
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] array = new int[n];
        int count = 0;
        
        //初期化
        for(int i = 0; i < n; i++){
		    array[i] = sc.nextInt();
		}
		
		//計算
		for(int i = 0; i < n-2; i++){
		    if(array[i] < array[i+1] && array[i+1] < array[i+2] ||
		       array[i] > array[i+1] && array[i+1] > array[i+2] ){
		        count++;
		    }
		    
		}
		System.out.println(count);
    }
}

Measured memory_bytes: 22224
m = ["{:02}".format(i) for i in range(1, 13)]
s = input()
a = s[:2] in m
b = s[2:] in m
ans = "NA"

if a and b:
    ans = "AMBIGUOUS"
elif a:
    ans = "MMYY"
elif b:
    ans = "YYMM"

print(ans)


Measured memory_bytes: 2940
import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

k,a,b = MAP()
if(b-a<=1):
    ans = 1 + k
else:
    n = (1+k-a)//2
    ans = 1 + k - 2*n + (b-a)*n
print(ans)

Measured memory_bytes: 9996
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long long n,tn;
vector<long long> v1,v2;
set<long long> ss;
vector<long long> factors(long long x){
	vector<long long> ff;
	for(long long i=1;i*i<=x;i++){
		if(x%i) continue;
		ff.push_back(i);
		if(x/i!=i)
			ff.push_back(x/i);
	}
	return ff;
}
bool checkit(long long xx){
	tn=n;
	while(tn%xx==0LL)
		tn/=xx;
	if(tn%xx==1LL)
		return true;
	return false;
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	v1=factors(n-1LL);
	v2=factors(n);
	for(int i=0;i<v1.size();i++){
		if(n%v1[i]==1LL){
			ss.insert(v1[i]);
		}
	}
	for(int i=1;i<v2.size();i++){
		if(checkit(v2[i])){
			ss.insert(v2[i]);
		}
	}
	cout<<ss.size()<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }
    sort(all(l));
    reverse(all(l));

    int res = 0;
    for (int i = 0; i < K; i++) {
        res += l[i];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int osen[10][10000];
int main() {
    int r, c;
    while (scanf("%d%d",&r,&c)) {
        if (!r&&!c) break;
        for (int i=0; i<r; i++) for (int j=0; j<c; j++) {
            scanf("%d", &osen[i][j]);
        }
        int res=0;
        for (int S=0; S < 1<<r; S++) {
            for (int i=0; i<r; i++) {
                if (S>>i&1) {
                    for (int j=0; j<c; j++) osen[i][j]^=1;
                }
            }
            int cnt=0;
            for (int i=0; i<c; i++) {
                int one=0;
                for (int j=0; j<r; j++) one+=osen[j][i];
                cnt+=max(one,r-one);
            }
            for (int i=0; i<r; i++) {
                if (S>>i&1) {
                    for (int j=0; j<c; j++) osen[i][j]^=1;
                }
            }
            res=max(res,cnt);
        }
        printf("%d\n",res);
    }
}

Measured memory_bytes: 1152
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)

c=0

import bisect

for i in range(n-2):
    for j in range(i+1, n-1):
        c += bisect.bisect_left(l, l[i]+l[j]) - j - 1
print(c)

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Palindromic Numbers
            var line = ReadLine();
            int A = line[0];
            int B = line[1];
            int ans = 0;

            for(int i = A; i <= B; i++)
            {
                var s = i.ToString();
                var reverse = String.Join("", s.Reverse());

                if (s == reverse)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 17472
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    ll h,w; cin >>h >> w;
    if(h==1||w==1) cout <<1;
    else{
        if((h*w)%2==0) cout << h*w/2;
        else cout << (h*w+1)/2;
    }
    return 0;
}

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

class DSU {
	private:
		vector<int> comp, siz;
	public:
		DSU(int n) : comp(n), siz(n, 1) {
			for (int i = 0; i < n; ++i) comp[i] = i;
		}
		int getc(int i) {
			if (comp[i] != i) comp[i] = getc(comp[i]);
			return comp[i];
		}
		bool join(int a, int b) {
			a = getc(a);
			b = getc(b);
			if (a == b) return false;

			if (siz[a] < siz[b]) swap(a, b);
			siz[a] += siz[b];
			comp[b] = a;
			return true;
		}
		int compSize(int i) { return siz[getc(i)]; }
};

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

	int n;
	cin >> n;

	// Loop points left to right, maintain for every component the lowest y

	vector<pair<pair<int, int>, int>> points(n);
	for (int i = 0; i < n; ++i) {
		cin >> points[i].first.first >> points[i].first.second;
		points[i].second = i;
	}
	sort(points.begin(), points.end());

	DSU dsu(n);
	vector<pair<int, int>> que;
	for (auto pr : points) {
		int y = pr.first.second;
		int ind = pr.second;
		int comp_y = y;
		while(! que.empty() && que.back().first <= y) {
			comp_y = min(comp_y, que.back().first);
			dsu.join(ind, que.back().second);
			que.pop_back();
		}
		que.push_back({comp_y, ind});
	}
	for (int i = 0; i < n; ++i) cout << dsu.compSize(i) << '\n';
}


Measured memory_bytes: 7452
n=int(input())
h=list(map(int, input().split()))
ok=1
for i in range(n-2, -1, -1):
    if h[i] > h[i+1]:
        h[i] -= 1
    if h[i] > h[i+1]:
        ok=0
print(('No','Yes')[ok])

Measured memory_bytes: 14704
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int x, n, count;
		while(true)
		{
			x = input.nextInt();
			n = input.nextInt();
			if(x == 0  && n == 0)
				break;
			else {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			}
		}
	}
}

Measured memory_bytes: 26212
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
// typedef complex<long double> point;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;
	cin >> n;
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
	}
	ll s = 0;
	for (int z=0;z<n;z++){
		for (int x=z+1;x<n;x++){
			s += arr[z]*arr[x];
		}
	}
	cout << s << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    long int n, x;
    scanf("%ld",&n);
    x = sqrt(n);
    if (x * x < n)
        printf("%ld\n",x * x);
    if (x * x == n)
        printf("%ld\n",n);
}

Measured memory_bytes: 128
n=int(input())
p=list(map(float,input().split()))
dp=[[0.0 for i in range(n+1)] for j in range(n+1)]
dp[1][0]=1-p[0]
dp[0][0]=1
for i in range(2,n+1):
    dp[i][0]=dp[i-1][0]*(1-p[i-1])

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

print(ans)

Measured memory_bytes: 120156
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
g=0
if b-a>k or c-b>k or d-c>k or e-d>k or c-a>k or d-a>k or e-a>k or d-b>k or e-b>k or e-c>k: #k以下の時通信可能
  g=1

if g==0: #通信できる
  print("Yay!")
elif g==1:
  print(":(")


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=100010;
int n,ans=1,cnt=0;
int a[N];
int main()
{
	scanf("%d",&n);
	for(int k=1;k<=n;k++)
	{
		int x;
		scanf("%d",&x);
		if(x!=a[cnt]) a[++cnt]=x;
	}
	for(int k=2;k<cnt;k++)
	{
		if(a[k]>a[k-1]&&a[k]>a[k+1]) k++,ans++;
		else if(a[k]<a[k-1]&&a[k]<a[k+1]) k++,ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
//#include <stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
#define PI 3.14159265359;

class Hoge{
  public:
					long int i0;
	int i1,N0;
	int iX,iY;
					string s0;
					int* iarray0;
					Hoge(int);
					void func0();
					void array0();
	void printarray0();
	~Hoge();
  private:
	int ianswer;
	void search0();
	void inputarray(int*,int);
	void inputarray2(int*,int*,int);
	void printarray(int*,int);
					};


Hoge::Hoge(int itemp){
	
	i0=itemp;
	//cout<<"i0="<<i0<<endl;
	
									}

void Hoge::func0(){
	//cout<<"N0?"<<endl;
	//cin>>N0;
	 
	//iarray0=new int[N0];
	

	cin>>iX>>iY;
	int itotal0=0;
	bool judge=0;
	
	for(int b=0;b<26;b++){
		
		itotal0=2*(iX-b)+4*b;
		if(((itotal0==iY)&&((iX-b)>=0))){
			
			judge=1;
							}
										}

	if(judge){
		
		cout<<"Yes"<<endl;
		
	}
	else{cout<<"No"<<endl;}
	//int N1=3;int N2=2;
	//int* iarray1=new int[N1];
	//int* iarray2=new int[N1];

	//inputarray(iarray0,N0);
	//search0();
	//printarray(iarray0,N0);
	//inputarray2(iarray1,iarray2,N1);
	
	//delete [] iarray1;
	//delete [] iarray2;
	
								}

void Hoge::search0(){
	//cout<<N0<<endl;
	for (int i0=0;i0<N0;i0++){
		//cout<<"i0="<<i0<<endl;
		//cout<<"iarray0[i0]="<<iarray0[i0]<<endl;
		if(iarray0[i0]==0){
			ianswer=i0+1;
			//cout<<"iarray0[i0]"<<iarray0[i0]<<endl;
		}
			
	}
	cout<<ianswer<<endl;
								}
void Hoge::array0(){

	cout<<"N0?";
	cin>>N0;
	
	
	for (int i0=0;i0<N0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray0[i0];
		
		
	}
}

void Hoge::inputarray(int* itemp,int itempn){
	//cout<<"hoge00"<<endl;
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		//cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
	}
}
void Hoge::inputarray2(int* itemp,int* itemp2,int itempn){
	
	int* iarray=itemp;
	int* iarray2=itemp2;
	int n0=itempn;
	
	for (int i0=0;i0<n0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
		cin>>iarray2[i0];
	}
}

void Hoge::printarray(int* itemp,int itempn){
	
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		cout<<"iarray["<<i0<<"]="<<iarray[i0]<<endl;
	
	}
}
	
	void Hoge::printarray0(){
							 
							 for (int i0=0;i0<N0;i0++){
			cout<<"iarray0["<<i0<<"]="<<iarray0[i0]<<endl;
			
							 
							 }
	
	
}
Hoge::~Hoge(){
	
//delete [] iarray0;
							}
int main(){
				int N;
				//cin>>N;
	
	Hoge* hoge=new Hoge(N);
	hoge->func0();
	
	//hoge->array0();
	//hoge->printarray0();
	return 0;
	//delete hoge;
}//end of main

Measured memory_bytes: 3636