akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            long c = sc.nextLong();
            long d = sc.nextLong();

            if (a < b) {
                System.out.println("No");
            } else if (d < b) {
                System.out.println("No");
            } else if (b <= c) {
                System.out.println("Yes");
            } else {
                long g = gcd(b, d);
                long max = b - g + (a % g);
                System.out.println(max <= c ? "Yes" : "No");
            }
        }
    }

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

        return gcd(b, a % b);
    }

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


Measured memory_bytes: 23572
a, b = raw_input().split()

dic = {
    "A":10,
    "B":11,
    "C":12,
    "D":13,
    "E":14,
    "F":15}
aa = dic[a]
bb = dic[b]

if(aa < bb):
    y = "<"
elif(aa > bb):
    y = ">"
else:
    y = "="
    
print(y)

Measured memory_bytes: 2568
import sys
from itertools import combinations
N, K = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
lbt = 0
rbt = 0
for combi in combinations(a_ls,2):
    if combi[0] > combi[1]:
        lbt += 1
    elif combi[1] > combi[0]:
        rbt += 1
cnt = 0
cnt += lbt * int(K * (K-1) // 2 + K)
cnt += rbt * int(K * (K-1) // 2)
cnt %= (10 ** 9 + 7)
print(cnt)

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

typedef long long ll;

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

    int N, D;

    cin >> N >> D;

    if(N % (D * 2 + 1) != 0) {
        cout << N / (D * 2 + 1) + 1 << endl;
    } else {
        cout << N / (D * 2 + 1) << endl;
    }
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}
macro_rules ! readl { ( $ t : ty ) => { { let s = getline ( ) ; s . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,+ ) => { { let s = getline ( ) ; let mut iter = s . trim ( ) . split ( ' ' ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; }
macro_rules ! readlvec { ( $ t : ty ) => { { let s = getline ( ) ; let iter = s . trim ( ) . split ( ' ' ) ; iter . map ( | x | x . parse ( ) . unwrap ( ) ) . collect ::< Vec <$ t >> ( ) } } }
macro_rules ! mvec { ( $ v : expr , $ s : expr ) => { vec ! [ $ v ; $ s ] } ; ( $ v : expr , $ s : expr , $ ( $ t : expr ) ,* ) => { vec ! [ mvec ! ( $ v , $ ( $ t ) ,* ) ; $ s ] } ; }
macro_rules ! debug { ( $ x : expr ) => { println ! ( "{}: {:?}" , stringify ! ( $ x ) , $ x ) } }
fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display,
{
    for (i, e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}
struct ContestPrinter {
    s: String,
}
impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter { s: String::new() }
    }
    fn print<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}", x).as_str());
    }
    fn println<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}
impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}
static MOD: i64 = 1e9 as i64 + 7;
fn is_max_i64(num: i64) -> bool {
    if num == i64::max_value() {
        true
    } else {
        false
    }
}
fn main() {
    let mut pr = ContestPrinter::new();
    let (N, L) = readl!(usize, usize);
    let v = readlvec!(usize);

    let mut pos = usize::max_value();
    for i in 0..N-1 {
        if (v[i] + v[i+1]) >= L {
            pos = i;
        }
    }

    if pos == usize::max_value() {
        pr.println("Impossible");
        return;
    }

    pr.println("Possible");
    for i in 0..pos { pr.println(i + 1); }
    for i in (pos+2..N).rev() { pr.println(i); }
    pr.println(pos + 1);
}

Measured memory_bytes: 8444
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
long long xo = 0;
long long L;
int N;
struct Trie{
  Trie *f[2];
  Trie(){
     memset(f,0,sizeof(f));
  }
}*T;
void ins(Trie *T,string &s,int pos){
   if(pos == (int)s.size()){
      return ;
   }
   if(T->f[s[pos] - '0'] == NULL){
      T->f[s[pos] - '0'] = new Trie;
   }
   ins(T->f[s[pos] - '0'],s,pos + 1);
}
long long get(long long val){
   int rez = 0;
   while(! (val & 1)){
      val >>= 1;
      rez++;
   }
   return 1LL << rez;
}
void dfs(Trie * T,int lvl){
   int nrfi = 0;
   if(T->f[0] != NULL){
      nrfi++;
      dfs(T->f[0],lvl + 1);
   }
   if(T->f[1] != NULL){
      nrfi++;
      dfs(T->f[1],lvl + 1);
   }
   if(nrfi ==  1){
      xo ^= get(L - lvl);
   }
}
int main() {
    T = new Trie;
    cin >> N >> L;
    for(int i = 1;i <= N;i++){
       string a;
       cin >> a;
       ins(T,a,0);
    }
    dfs(T,0);
    cout << (xo == 0 ? "Bob" : "Alice");
    return 0;
}

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

typedef long long ll;

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

    ll L, R;

    cin >> L >> R;

    if(R - L > 3000) {
        cout << 0 << endl;
    } else {
        ll min = 2019;
        for(ll i = L; i < R; i++) {
            for(ll j = L + 1; j <= R; j++) {
                if(i * j % 2019 < min) {
                    min = i * j % 2019;
                }
            }
        }
        cout << min << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;

int main(){
    ll n,m,x;
    cin>>n>>m>>x;
    ll ans=INF;
    vector<ll> c(n);
    vector<vector<ll> > a(n,vector<ll>(m));
    for(ll i=0;i<n;i++){
        cin>>c[i];
        for(ll j=0;j<m;j++) cin>>a[i][j];
    }

    for(ll bit=0;bit<(1<<n);bit++){
        ll cost=0;
        vector<ll> ability(m,0);
        for(ll i=0;i<n;i++){
            if(!(bit&(1<<i))) continue;
            cost+=c[i];
            for(ll j=0;j<m;j++){
                ability[j]+=a[i][j];
            }
        }
        bool f=true;
        for(ll j=0;j<m;j++){
            if(ability[j]<x) f=false;
        }
        if(f) ans=min(ans,cost);
    }
    if(ans==INF) ans=-1;
    cout<<ans<<endl;

}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S; cin >> S;
  vector<string> v = { "", "A" };
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        for (int l = 0; l < 2; l++) {
          string T = v.at(i) + "KIH" + v.at(j) + "B" + v.at(k) + "R" + v.at(l);
          if (S == T) {
            cout << "YES" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

void solve() {
    int n;
    cin >> n;

    int curr = 0;
    ll res = 0;
    F0R(i, n) {
        int k;
        cin >> k;

        if(k < curr)
            res += curr - k;
        ckmax(curr, k);
    }
    cout << res << endl;

}

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

    int tc = 1;
    FOR(i, 1, tc + 1) {
        //cout << "Case #" << i << ": ";
        solve();
    }
}



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

namespace AtCoder.Question
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            var (n, k) = ReadHelper.ReadValue<decimal, int>();

            decimal bunbo = 1 / n;
            var result = 0M;
            for (int i = 1; i <= n; i++)
            {
                var point = i;
                var kakuritu = 1M;
                while (point < k)
                {
                    kakuritu /= 2;
                    point *= 2;
                }
                result += kakuritu;
            }
            result *= bunbo;
            Console.WriteLine(result.ToString());
        }

        static class ReadHelper
        {
            internal static T ReadValue<T>()
            {
                return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
            }
            internal static (T1, T2) ReadValue<T1, T2>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)));
            }
            internal static (T1, T2, T3) ReadValue<T1, T2, T3>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)));
            }
            internal static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)), (T4)Convert.ChangeType(input[3], typeof(T4)));
            }
            internal static T[] ReadValues<T>()
            {
                var input = Console.ReadLine().Split(' ');
                return input.Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
            }
        }

        static class MathAlgorithm
        {
            internal static bool IsPrime(long n)
            {
                if (n == 2) return true;
                if (n < 2 || n % 2 == 0) return false;
                var sqrt = Math.Sqrt(n);
                for (int i = 3; i <= sqrt; i += 2) if (n % i == 0) return false;
                return true;
            }
            internal static IEnumerable<long> EnumeratePrimes(long n)
            {
                var i = 2L;
                while (i * i <= n)
                {
                    if (n % i == 0)
                    {
                        n /= i;
                        yield return i;
                    }
                    else
                    {
                        i += i == 2 ? 1 : 2;
                    }
                }
                if (n != 1) yield return n;
            }
        }
    }
}


Measured memory_bytes: 27576
# nを素因数分解したリストを返す
def decomposition_prime(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(int(n))
    return table

A, B = map(int, input().split())
Ap = set(decomposition_prime(A))
Bp = set(decomposition_prime(B))
print(len(Ap & Bp)+1)

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

int main(){
  long N, count, tmp, ans;
  cin >> N;
  vector<long> vec(N);
  count = 0;
  rep(i, N){
    cin >> vec[i];
    count += vec[i];
  }
  ans = abs(count - 2 * vec[0]);
  rep(i, N - 1){
    if(i == 0) tmp = count - 2 * vec[0];
    else{
      tmp -= 2 * vec[i];
      ans = min(ans, abs(tmp));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,i,x,y,sum=0;
    string s;
    cin>>n;
    map<string,int>mp;
    for (i=0;i<n;i++){
        cin>>s>>x;
        sum+=x;
        mp[s]=sum;
    }
    cin>>s;
    cout<<sum-mp[s];
}

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


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

using namespace std;

using ll = long long int;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;

	cout << "ABC" << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void query1(const int &p, const char &c, vector<set<int>> &a) {
	for (int i = 0; i < 26; i++) {
		if (a[i].count(p)) {
			a[i].erase(p);
			break;
		}
	}
	a[c - 'a'].insert(p);
}
void query2(const int &l, const int &r, const vector<set<int>> &a) {
	int cnt = 0;
	for (int i = 0; i < 26; i++) {
		auto itr = a[i].lower_bound(l);
		if (itr != a[i].end()) {
			if (itr != a[i].end()) {
				if (*itr <= r) cnt++;
			}
		}
	}
	printf("%d\n", cnt);
}
int main() {
	int n;
	scanf("%d", &n);
	char s[n];
	scanf("%s", s);
	vector<set<int>> a(26);
	for (int i = 0; i < n; i++) a[s[i] - 'a'].insert(i);
	int q;
	scanf("%d", &q);
	while (q--) {
		int p;
		scanf("%d", &p);
		if (p == 1) {
			int i;
			char c;
			scanf("%d %c", &i, &c);
			query1(i - 1, c, a);
		} else {
			int l, r;
			scanf("%d%d", &l, &r);
			query2(l - 1, r - 1, a);
		}
	}
	return 0;
}

Measured memory_bytes: 26240
N, Y = list(map(int,input().split()))

def main():
    for x in range(0,N+1):
        for y in range(0, N+1-x):
            z = N - x -y
            if(10000 * x + 5000 * y + 1000*z == Y):
                print(x,y,z)
                return
    print("-1 -1 -1")


main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  ll a, b, n;
  cin >> a >> b >> n;
  if(b-1 <= n) cout << a*(b-1)/b << endl;
  else cout << a*n/b << endl;
}


Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(b%a==0){
        cout << a+b << endl;
    }
    else cout << b-a << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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 int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
template<typename T>
vector<T> divisor(T N) {
    vector<T> res;
    for(T i = 1; i * i <= N; i++){
        if(N % i == 0){
            res.push_back(i);
            if(i * i != N)res.push_back(N / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
template<typename T> 
map<T,int> factorize(T x){
    map<T,int> mp;
    for (T i = 2; i*i <= x; i++){
        while (x%i == 0) {
            x /= i;
            mp[i]++;
        }
        if (x == 1) break;
    }
    if (x != 1) mp[x]++;
    return mp;
}

int A[200010];
int mp[2000100];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    //map<ll,int> mp;
    rep(i, N){
        cin >> A[i];
        mp[A[i]]++;
    }
    //sort(all(A));
    int ans = 0;
    vector<bool> ok(N, true);
    rep(i,N){
        /*
        auto v = divisor(A[i]);
        for(auto &p: v){
            if(mp[p] > 0){
                ok = false;
                break;
            }
        }*/
        if(mp[A[i]] > 1){
            ok[i] = false;
            continue;
        }
        mp[A[i]]--;
        for(ll j = 1; j * j <= A[i]; j++){
            if(A[i] % j == 0){
                //res.push_back(i);
                if(mp[j] > 0){
                    ok[i] = false;
                }
                if(j * j != A[i]){
                    //res.push_back(N / i);
                    if(mp[A[i]/j] > 0){
                        ok[i] = false;
                    }
                }
            }
        }
        mp[A[i]]++;
    }
    rep(i,N)if(ok[i])ans++;
    cout << ans << endl;
}

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

namespace _0580
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long[,] fishes = new long[x[0], 6];
			HashSet<long>[] zahyo = new HashSet<long>[3];
			for (int i = 0; i < 3; i++) zahyo[i] = new HashSet<long>();
			for (int i = 0; i < x[0]; i++)
			{
				long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
				for (int j = 0; j < 3; j++)
				{
					zahyo[j].Add(a[j]); zahyo[j].Add(a[j + 3]);
					fishes[i, j] = a[j]; fishes[i, j + 3] = a[j + 3];
				}
			}
			List<long>[] len = new List<long>[3];
			List<long>[] list = new List<long>[3];
			for (int i = 0; i < 3; i++)
			{
				var arr = zahyo[i].ToArray(); Array.Sort(arr); len[i] = arr.ToList();
				list[i] = new List<long>();
				for (int j = 0; j < arr.Count(); j++) list[i].Add(0);
				for (int j = 0; j < x[0]; j++)
				{
					list[i][Array.BinarySearch(arr, fishes[j, i])] ^= 1L << j;
					list[i][Array.BinarySearch(arr, fishes[j, i + 3])] ^= 1L << j;
				}
			}
			for (int i = 0; i < 3; i++)
			{
				long now = 0;
				for (int j = 0; j < list[i].Count; j++)
				{
					now ^= list[i][j];
					list[i][j] = now;
				}
			}
			long ret = 0;
			for (int i = 0; i < list[0].Count - 1; i++)
			{
				for (int j = 0; j < list[1].Count - 1; j++)
				{
					for (int k = 0; k < list[2].Count - 1; k++)
					{
						long now = list[0][i] & list[1][j] & list[2][k];
						int count = 0;
						for (int m = 0; m <= 60; m++)
							if ((now & (1L << m)) > 0) count++;
						if (count >= x[1])
							ret += (len[0][i + 1] - len[0][i]) *
								   (len[1][j + 1] - len[1][j]) *
								   (len[2][k + 1] - len[2][k]);
					}
				}
			}
			Console.WriteLine(ret);
		}
	}
}


Measured memory_bytes: 16808
n=int(input())
s=input()
a=[]
for i in s:
    if i=='W': a.append(1)
    else: a.append(-1)
a2=[-1*i for i in a]
suma=[sum(a)-a[0]]
for i in range(len(a)-1):
    suma.append(-a[i+1]+suma[i])
suma2=[0]
for i in range(len(a2)-1):
    suma2.append(suma2[i]+a2[i])
#print(a,a2)
count=0
for i in range(len(a)):
    d=suma[i]+suma2[i]
    if count<d:count=d
    #print(sum(a[i+1:]),sum(a2[:i]),d)
print((n-1-count)//2)

Measured memory_bytes: 32032
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define index_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIndex find_by_order
#define indexOf order_of_key
#define MOD 1000000007
#define endl '\n'
#define MAX 200005

int dp[MAX];

void get_all_primes(int upto_primes, vector<int> &primes){
    primes.clear();
    vector < bool > mark(upto_primes +2,true);

    for(int i=3 ; i * i <= upto_primes ; i+=2){
        if(mark[i]){
            for(int j=i*i ; j<=upto_primes ; j+=2*i){
                mark[j]=false;
            }
        }
    }
    primes.push_back(2);
    for(int i=3 ; i<=upto_primes ; i+=2 ){
        if(mark[i]){
            primes.push_back(i);
        }
    };
}

void solve(vector<int> &primes) {
    int n;
    cin>>n;
    int i = 0;
    for(int j = 0 ; j < primes.size() ; j++){
        if(primes[j] % 10 == 7){
            cout<<primes[j]<<" ";
            i++;
        }
        if(i == n){
            break;
        }
    }
    cout<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> primes;
    get_all_primes(55555 , primes);
    int t = 1;
    //cin>>t;
    while (t--)
        solve(primes);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}

const int mod = 1000000007;
const int max_n = 2000050;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint P(int n, int k){
    return fact[n]*ifact[n-k];
  }
}comb(max_n);

int main(){
    ll n;cin >> n;
    if(n==1)cout << 0 <<endl,exit(0);
    mint ans=0;
    mint ten=10,nine=9,e=8,t=2;
    repl(i,2,n+1){
        ll len=n-i;//0でも9でもない
        mint ret=e.pow(len);
        ret*=t.pow(i)-2;
        ret*=comb(n,i);
        ans+=ret;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 34148
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll H, W;
char maze[55][55];
ll dist[55][55];
int main() {
    cin >> H >> W;

    ll black = 0;
    rep(i, H)rep(j, W) {
        cin >> maze[i][j];
        if (maze[i][j] == '#') black++;
    }
    rep(i, 55)rep(j, 55) dist[i][j] = INF;

    queue<P> que;
    dist[0][0] = 0;
    // start
    que.push(P(0, 0));
    while (que.size()) {
        P p = que.front(); que.pop();
        if (p.first == H - 1 && p.second == W - 1) break;

        int dy[] = {0, 0, 1, -1};
        int dx[] = {1, -1, 0, 0};

        for (int i = 0; i < 4; i++) {
            ll ny = p.second + dy[i], nx = p.first + dx[i];

            if (0 <= ny && ny < H && 0 <= nx && nx < W && maze[ny][nx] == '.' && dist[ny][nx] == INF) {
                que.push(P(nx, ny));
                dist[ny][nx] = dist[p.second][p.first] + 1; 
            }
        }
    }
    // goal H - 1, W - 1
    // cout << dist[H - 1][W - 1] << endl;
    if (dist[H - 1][W - 1] == INF) {
        cout << -1 << endl;
    } else {
        ll tmp = dist[H - 1][W - 1] + 1;
        cout << H * W - tmp - black << endl; 
    }
}

Measured memory_bytes: 256
n = int(input())
l = [[0]*30 for i in range(n)]
for i in range(n):
    for c in list(input()): l[i][ord(c)-97]+=1
ans = ""
for i in range(30):
    tmp = 50
    for j in range(n):tmp=min(tmp, l[j][i])
    ans += chr(i+97)*tmp
print(ans)

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

int W, H;
bool Buildings[102][102] = {0};
bool visible[102][102] = { false };

void visibilityDiffusion(int w, int h){
	if (w == 0 || h == 0 || w == W + 1 || h == H + 1) return;
	if (visible[w][h]) return;

	visible[w][h] = true;

	if (!Buildings[w - 1][h]) visibilityDiffusion(w - 1, h);
	if (!Buildings[w + 1][h]) visibilityDiffusion(w + 1, h);
	if (!Buildings[w][h - 1]) visibilityDiffusion(w, h - 1);
	if (!Buildings[w][h + 1]) visibilityDiffusion(w, h + 1);
	if (h % 2 == 1){
		// odd
		if (!Buildings[w + 1][h - 1]) visibilityDiffusion(w + 1, h - 1);
		if (!Buildings[w + 1][h + 1]) visibilityDiffusion(w + 1, h + 1);
	}
	else{
		// even
		if (!Buildings[w - 1][h - 1]) visibilityDiffusion(w - 1, h - 1);
		if (!Buildings[w - 1][h + 1]) visibilityDiffusion(w - 1, h + 1);
	}
}

int main(){
	cin >> W >> H;
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			cin >> Buildings[j][i];
		}
	}

	// 建物がない場所のうち、外から見える部分を探索する
	for (int i = 1; i <= W; i++){
		if (!Buildings[i][1]) visibilityDiffusion(i, 1);
		if (!Buildings[i][H]) visibilityDiffusion(i, H);
	}
	for (int i = 1; i <= H; i++){
		if (!Buildings[1][i]) visibilityDiffusion(1, i);
		if (!Buildings[W][i]) visibilityDiffusion(W, i);
	}

	int ans = 0;
	int hole = 0;
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			if (Buildings[j][i]){
				ans += 6;
				if (Buildings[j+1][i]) ans -= 2;
				if (Buildings[j][i+1]) ans -= 2;
				if (i % 2 == 1){
					if (Buildings[j+1][i+1]) ans -= 2; // odd
				}
				else{
					if (Buildings[j-1][i+1]) ans -= 2; // even
				}
			}
			else if (!visible[j][i]){
				hole += 6;
				if (!Buildings[j+1][i]) hole -= 2;
				if (!Buildings[j][i+1]) hole -= 2;
				if (i % 2 == 1){
					if (!Buildings[j+1][i+1]) hole -= 2; // odd
				}
				else{
					if (!Buildings[j-1][i+1]) hole -= 2; // even
				}
			}
		}
	}

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

Measured memory_bytes: 1708
import sys
word = input()
if ((word[0] == 'A') & (word[2:-1].count('C') == 1)):
  word = word.replace("A","")
  word = word.replace("C","")
  if (word.islower()):
    print('AC')
  else:
    print('WA')
else:
  print('WA')

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

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

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG 0x3fffFFFFffffFFFFL
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef pair<ll, ll> lpair;
typedef pair<int, int> ipair;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

//C++17からstd::に含まれた
//ll gcd(ll a, ll b){ if (a % b) return (gcd(b, a % b)); else return b; }
//ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

signed main()
{
//    cout << fixed << setprecision(9);

    int A, P; cin >> A >> P;

    P += A * 3;
    int api = P / 2;

    cout << api << endl;

    return 0;
}


Measured memory_bytes: 256
let a, b = Scanf.scanf " %s %s" @@ fun a b -> a, b
let n, m = String.length a, String.length b
let _ = print_endline @@
  if n < m then "LESS" else if n > m then "GREATER"
  else if a < b then "LESS" else if a > b then "GREATER" else "EQUAL"

Measured memory_bytes: 2432
def cumulative_sum(l):
    cumu = [0]
    s = 0
    for num in l:
        s += num
        cumu.append(s)
    return cumu

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

A.sort()

C = cumulative_sum(A)

AM = [C[i+1] for i in range(N)]

ans = 1
for i in range(1,N):
    if 2*AM[-1-i] >= A[-i]:
        ans += 1
    else:
        break
print(ans)

Measured memory_bytes: 14320
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pb push_back
#define pq priority_queue
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define MODNUM 1000000007
#define lp(i,a,b) for(ll i=a; i<b; i++)
 
using namespace std;
 
ll mex(ll a, ll b, ll m) {
	if(b==0) return 1;
	if(b%2) return a*mex((a*a)%m,(b-1)/2,m)%m;
	else return mex((a*a)%m,b/2,m);
}
 
int x,y;
void exteu(ll a, ll m) {
	if(m==0) { x=1;y=0; }
	else {
		exteu(m,a%m);
		ll temp = x;
		x=y;
		y=temp-(a/m)*y;
	}
}
 
ll fact(ll n) 
{	ll prod=1;
	for(ll i=2; i<=n; i++) {
		prod*=i;
	}
	return prod;
}
 
ll gcd(ll a, ll b) {
	if(b==0) return a;
	return gcd(b, a%b);
}
 
// bool isprime[100001];
// void makesieve() {
// 	memset(isprime, true, sizeof(isprime));
// 	for (int i = 2; i <= sqrt(200000); ++i)
// 	{
// 		if(isprime[i]) {
// 			for (int j = i*i; j <= 200000; j+=i)
// 			{
// 				isprime[j]=false;
// 			}
// 		}
// 	}
// }
// 
// 1 2 4 5 8
void solve() {
	ll n,k; cin>>n>>k;
	vll p(n); lp(i,0,n) cin>>p[i];
	sort(p.begin(), p.end());
	ll s=0;
	for (int i = 0; i < k; ++i)
	{
		s += p[i];
	}
	cout<<s;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1;
	// cin >> TESTS;
	// makesieve();
	while(TESTS--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, H, W;
    while(1){
        scanf("%d %d",&H, &W);
        if( H==0 && W==0)
            break;
        
        for(a=1; a<=H; a++){
            for(b=1; b<=W; b++){
                if((a+b)%2 == 0)
                    printf("#");
                else
                    printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353

bool bit(ll subset, ll Rsift){ return ((subset)>>(Rsift))&1; }

ll XOR(ll a, ll b){
    ll res=0;
    rep(i, 60){
        res += (bit(a,i) != bit(b,i)) << i;
    }
    return res;
}

ll XORSUM_allarray(vl A, ll m){
    //all elements is long long int.
    ll N=A.size(), res=0;
    rep(digit, 62){
        ll cnt1=0;
        rep(i, N) {
            cnt1 += bit(A[i], digit);
        }
        res += (cnt1 * (N-cnt1))%m * ((1LL<<digit)%m);
        res %= m;
    }
    return res;
}


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

    // solution comes here

    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    cout << XORSUM_allarray(A, MOD) << nl;
}


Measured memory_bytes: 4992
/*  */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define sti				set<int>
#define stpii			set<pair<int, int> >
#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define clr				clear
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1
#define getBits(x)		__builtin_popcount(x)
#define getBitIdx(x)	__builtin_ffs(x)

typedef long long LL;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// #ifndef ONLINE_JUDGE
		// freopen("data.in", "r", stdin);
		// freopen("data.out", "w", stdout);
	// #endif
	
	string s;
	
	for (int i=0; i<3; ++i) {
		cin >> s;
		char ch = s[0]-'a'+'A';
		cout << ch;
	}
	cout << endl;
	
	// #ifndef ONLINE_JUDGE
		// printf("time = %ldms.\n", clock());
	// #endif
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		//int a = sc.nextInt();
		//List<Integer> check=new ArrayList<Integer>();
		//array = new int[h+1][w+1];
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//Collections.reverse(list);

		String s=sc.next();
		if(s.equals("Sunny"))
			System.out.println("Cloudy");
		else if(s.equals("Cloudy"))
			System.out.println("Rainy");
		else if(s.equals("Rainy"))
			System.out.println("Sunny");
	}

}


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

int main(){
    int a[9];
    int c[9] = {0,0,0,0,0,0,0,0,0};
    int n;
    for(int i=0;i<9;i++){
        cin >> a[i];     
    }
    cin >> n;
    int b[n];
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int j=0;j<9;j++){
        for(int i=0;i<n;i++){        
            if(a[j] == b[i]) c[j] = 1;
        }
    }
    int flag = 0;
    if(c[0]==1 && c[1] ==1 && c[2] == 1) flag = 1;
    if(c[3]==1 && c[4] ==1 && c[5] == 1) flag = 1;
    if(c[6]==1 && c[7] ==1 && c[8] == 1) flag = 1;
    if(c[0]==1 && c[3] ==1 && c[6] == 1) flag = 1;
    if(c[1]==1 && c[4] ==1 && c[7] == 1) flag = 1;
    if(c[2]==1 && c[5] ==1 && c[8] == 1) flag = 1;
    if(c[0]==1 && c[4] ==1 && c[8] == 1) flag = 1;
    if(c[2]==1 && c[4] ==1 && c[6] == 1) flag = 1;

    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    long long int ans = 0;
    for(int i=0;i<N; i++) {
        ans -= (i%2 * 2 - 1) * A.at(i%N);
    }
    cout << ans << " ";
    for(int i=0; i<N-1; i++) {
        ans = -ans + 2*A.at(i);
        cout << ans << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			


n,m=input2()
H=input_array()
# G=[[0]*n]*n #グラフ
counts=[]
la=[1]*n
for i in range(m):
	a,b=input2()
	if H[a-1]>H[b-1]:
		la[b-1]=0
	elif H[a-1]<H[b-1]:
		la[a-1]=0
	else:
		la[a-1]=0
		la[b-1]=0



print(sum(la))




Measured memory_bytes: 38388
class WeightedUnionFind:
    """ あっとさんありがとうございます """

    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    uf = WeightedUnionFind(N)
    LRD = [[int(i) for i in input().split()] for j in range(M)]
    for le, ri, d in LRD:
        if uf.same(le, ri):
            if uf.diff(le, ri) != d:
                return print("No")
        uf.union(le, ri, d)
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 123824
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> W(N);
	int sum_w = 0;
	int min_diff_sum = 1e9;

	REP(i, N) {
		cin >> W[i];
	}

	REP(i, N) {
		sum_w += W[i];
	}

	REP(i, N) {
		int sum_w2 = 0;
		REP(j, i + 1) {
			sum_w2 += W[j];
		}
		if (min_diff_sum >= abs(sum_w - 2 * sum_w2)) {
			min_diff_sum = abs(sum_w - 2 * sum_w2);
		}
	}

	cout << min_diff_sum << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
class Program
{
    static void Main()
    {
        int[] inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(inputs);
        long ans = inputs[0] * inputs[1] / 2;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <string.h>

int main(void)
{
	int		 a,b, ans, i=0;

	while(scanf("%d %d",&a, &b) != EOF){
		ans = a+b ;
		i=0;
		while(ans != 0){
			ans = ans / 10;
			++i;
		}
		printf("%d\r\n", i);
	}
	return 0;	 
}

Measured memory_bytes: 600
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int dp[102][10002];
int v[102];
int w[102];
int main(void) {
  int N, W;
  cin >> N >> W;
  for (int i = 0; i < N; i++) {
    cin >> v[i] >> w[i];
    // cout << "i = " << i << " v = " << v[i] << " w = " << w[i] << endl;
  }

  for (int i = 0; i < N; i++) {
    dp[i][0] = 0;
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      // cout << "i + 1 = " << i + 1 << endl;
      if (j >= w[i]) {
        // cout << "dp[" << i << "][" << j - w[i] << "] = " << dp[i][j - w[i]]
        //      << " dp[" << i << "][" << j << "] = " << dp[i][j]
        //      << " v[i] = " << v[i] << " i = " << i << endl;
        dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }
  cout << dp[N][W] << endl;

  return 0;
}


Measured memory_bytes: 7004
import java.util.Scanner;class Main{public static void main(String[] q){Scanner c=new Scanner(System.in);for(;;){int n=c.nextInt(),s=c.nextInt();if(n==0&&s==0)break;System.out.println(f(0,0,s,n));}}static int f(int x,int a,int t,int n){return n==0?x==t?1:0:a>9?0:f(x+a,a+1,t,n-1)+f(x,a+1,t,n);}}

Measured memory_bytes: 26260
#include <iostream>
using namespace std;
int w, h;
int c[64][64];
int d[] = {1, -1, 0};

void rec(int x, int y) {
  if(x < 0 || x >= w || y < 0 || y >= h) return;
  if(!c[y][x]) return;

  c[y][x] = 0;
  for(int i = 0;i < 3; i++) {
    for(int j = 0;j < 3; j++) {
      rec(x+d[i], y+d[j]);
    }
  }
  return;
}

int main(void) {
  while(cin >> w >> h, w+h) {
    for(int i = 0;i < h; i++)
      for(int j = 0;j < w; j++)
        cin >> c[i][j];

    int ans = 0;
    for(int i = 0;i < h; i++) {
      for(int j = 0;j < w; j++) {
        if(c[i][j]) {
          ans++;
          rec(j, i);
        }
      }
    }

    cout << ans << endl;
  }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> ans;
  int z = N;
  if(z!=0){
    while(N!=1){
      if((-1*N)%2==1 && N < 0) {
        int x = (-1*N)%2;
        ans.push_back(x);
        N-=1;
      }
      else{
        ans.push_back(N%2);
      }
      N/=-2;
    }
    ans.push_back(N);
    for(int i=ans.size()-1; i > -1; i--){
      cout << ans[i];
    }
    cout << endl;
  }
  if(z==0){
    cout << 0 << endl;
  }
  return 0;
}

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

long long N;
long long A[100000];
long long co = 0;
string flag = "none";

long long solve()
{

	for (int i = 0; i < N-1; i++) {
		if (flag == "up" && A[i + 1] - A[i] < 0) {
			co += 1;
			flag = "none";
		}else
		if (flag == "down" && A[i + 1] - A[i] > 0) {
			co += 1;
			flag = "none";
		}else
			if (flag == "none") {
				if (A[i + 1] - A[i] > 0)flag = "up";
				else if (A[i + 1] - A[i] < 0)flag = "down";
		}
	}
	return co+1;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	cout << solve() << "\n";

	return 0;
}

Measured memory_bytes: 1024