akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

int main(void) {
    
    string s;
    cin>>s;
    fin(stringcount(s,'+')-stringcount(s,'-'));
}


Measured memory_bytes: 256
x,y=map(int,input().split())
if(x==0 or y==0):
    print('Zero')
elif(x>0 and y>0):
    print('Positive')
elif(x<=0 and y>=0):
    print("Zero")
else:
    z=abs(y-x)
    if(z%2==0):
        print("Negative")
    else:
        print("Positive")



Measured memory_bytes: 61812
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (PrintWriter out = new PrintWriter(System.out); Scanner sc = new Scanner(System.in);) {
			Task task = new Task();
			task.solve(sc, out);
			out.flush();

		} catch (Exception e) {
			// DO NOT USE
		}
	}

	static class Task {
		public void solve(Scanner sc, PrintWriter out) {
			// TODO
			int a = nint(sc) - 1;
			int b = nint(sc) - 1;
			out.print(a * b);
		}
	}

	// method
	static int nint(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static long nlong(Scanner sc) {
		return Long.parseLong(sc.next());
	}

	static double ndouble(Scanner sc) {
		return Double.parseDouble(sc.next());
	}

	static float nfloat(Scanner sc) {
		return Float.parseFloat(sc.next());
	}

	static String nstr(Scanner sc) {
		return sc.next();
	}

	static long[] longLine(Scanner sc, int size) {
		long[] lLine = new long[size];
		for (int i = 0; i < size; i++) {
			lLine[i] = nlong(sc);
		}
		return lLine;
	}

	static int[] intLine(Scanner sc, int size) {
		int[] iLine = new int[size];
		for (int i = 0; i < size; i++) {
			iLine[i] = nint(sc);
		}
		return iLine;
	}

	static String[] strLine(Scanner sc, int size) {
		String[] strLine = new String[size];
		for (int i = 0; i < size; i++) {
			strLine[i] = nstr(sc);
		}
		return strLine;
	}

	static long maxFromList(List<Long> longList) {
		return longList.stream().max(Comparator.naturalOrder()).get();
	}

	static long minFromList(List<Long> longList) {
		return longList.stream().min(Comparator.naturalOrder()).get();
	}

	public static int sumDigits(int n) {
		int sum = 0;
		while (n != 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}

	public static long sumDigits(long n) {
		long sum = 0;
		while (n != 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}

	static List<Integer> getIntegerList(Scanner sc, int size) {
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < size; i++) {
			list.add(nint(sc));
		}
		return list;
	}

	static List<Long> getLongList(Scanner sc, int size) {
		List<Long> list = new ArrayList<>();
		for (int i = 0; i < size; i++) {
			list.add(nlong(sc));
		}
		return list;
	}
}


Measured memory_bytes: 21844
n, m = [int(_) for _ in input().split()]
a = []
for _ in range(n):
  a.append([int(_) for _ in input().split()])
b = []
for _ in range(m):
  b.append(int(input()))

for ai in a:
  print(sum([a_c * b_c for a_c, b_c in zip(ai, b)]))

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

int main () {

    char c;

    cin >> c;

    if (c == 'a') {
        cout << "vowel" << endl;
    }

    else if (c == 'i') {
        cout << "vowel" << endl;
    }

    else if (c == 'u') {
        cout << "vowel" << endl;
    }

    else if (c == 'e') {
        cout << "vowel" << endl;
    }

    else if (c == 'o') {
        cout << "vowel" << endl;
    }

    else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int a,b,c,x,y;
    cin >> a >> b >>c >> x >> y;
    ll ans = 100000000000000000;
    for (int i=0;i<=100000;i++){
        ll tmp = i*2*c + a * max(0,x-i) + b*max(0,y-i);
        ans = min(ans,tmp);
    }
    cout << ans << endl;
}


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

char Sa[105];
char Sb[105];
char Sc[105];

int main(){

	scanf("%s",Sa);
	scanf("%s",Sb);
	scanf("%s",Sc);

	int len_A=strlen(Sa);
	int len_B=strlen(Sb);
	int len_C=strlen(Sc);

	int i,j,k,turn;

	i=0;
	j=0;
	k=0;
	turn=1;

	while(1){


		if(i==len_A&&turn==1){
			break;
		}
		if(j==len_B&&turn==2){
			break;
		}
		if(k==len_C&&turn==3){
			break;
		}


		if(turn==1){
			if(Sa[i]=='a'){
				turn=1;
			}
			else if(Sa[i]=='b'){
				turn=2;
			}
			else{
				turn=3;
			}
			i++;
		}
		else if(turn==2){
			if(Sb[j]=='a'){
				turn=1;
			}
			else if(Sb[j]=='b'){
				turn=2;
			}
			else{
				turn=3;
			}
			j++;
		}
		else{
		if(Sc[k]=='a'){
				turn=1;
			}
			else if(Sc[k]=='b'){
				turn=2;
			}
			else{
				turn=3;
			}
			k++;
		}

	}

	if(turn==1){printf("A\n");}
	else if(turn==2){printf("B\n");}
	else{printf("C\n");}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 100
#define INF 1000000
#define true 1
#define false 0

int G[MAX][MAX], p[MAX], d[MAX], is_visited[MAX];

void dijkstra() {
  int i, j, u;
  int mincost;

  p[0] = -1;
  d[0] = 0;

  while(1) {
    mincost = INF;

    for(i = 0;i < MAX;i++) {
      if(is_visited[i] == false && d[i] < mincost) {
        mincost = d[i];
        u = i;
      }
    }

    if(mincost == INF) break;
    is_visited[u] = true;

    for(i = 0;i < MAX;i++) {
      if(G[u][i] != INF && is_visited[i] == false) {
        if(d[u] + G[u][i] < d[i]) {
          d[i] = d[u] + G[u][i];
          p[i] = u;
        }
      }
    }
  }
}

int main() {
  int n, i, j, k, u, v;

  for(i = 0;i < MAX;i++) {
    p[i] = -1;
    d[i] = INF;
    for(j = 0;j < MAX;j++)
      G[i][j] = INF;
  }

  scanf("%d", &n);
  for(i = 0;i < n;i++) {
    scanf("%d %d", &u, &k);
    for(j = 0;j < k;j++) {
      scanf("%d", &v);
      scanf("%d", &G[u][v]);
    }
  }

  dijkstra();

  for(i = 0;i < n;i++)
    printf("%d %d\n", i, d[i]);

  return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
        int x = sc.nextInt();
        int y = sc.nextInt();
        if(x==0&&y==0){
            break;
        }if(x<y){
            System.out.println(x+" "+y);
        }if(y<x){
            System.out.println(y+" "+x);
        }if(x==y){
            System.out.println(x+" "+y);
        }
        }
    }
}


Measured memory_bytes: 35432
#include <iostream>

using namespace std;

int main() {

	int endOfInput;
	int h[1000], w[1000];

	for (int i = 0;; i++) {

		cin >> h[i] >> w[i];

		if (h[i] == 0 && w[i] == 0) {
			endOfInput = i;
			break;
		}

	}

	for (int i = 0; i < endOfInput; i++) {
		for (int j = 0; j < h[i]; j++) {
			for (int k = 0; k < w[i]; k++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;

}

Measured memory_bytes: 3080
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

int main()
{   
    ll x;
    cin>>x;
    if(x == 0) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}   
    

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

using namespace std;

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

    vector<int> H(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }

    double min = 999999.0;
    int minIndex = 0;
    for(int i = 0; i < N; i++) {
        double diff = abs(A - (T - H[i] * 0.006));
        if(diff < min) {
            minIndex = i + 1;
            min = diff;
        }
    }

    cout << minIndex << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())
ans = 0
for i in range(1, n-1):
    x = set(s[:i])
    y = set(s[i:])
    cnt = 0
    for c in x:
        if c in y:
            cnt += 1
    if cnt > ans:
        ans = cnt

print(ans)


Measured memory_bytes: 3060
N, M = [int(x) for x in input().split()]

cities = [[] for i in range(N)]

for i in range(M):
    a, b = [int(x) for x in input().split()]
    cities[a-1].append(i)
    cities[b-1].append(i)

for city in cities:
    print(len(city))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

int main()
{
    string s;
    cin >> s;
    int a[26] = {0};
    string ans = "yes";
    for(int i = 0; i < s.size(); i++){
        a[s[i] - 'a']++;
    }
    for(int i = 0; i < s.size(); i++){
        if(a[i] >= 2){
            ans = "no";
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    long long int n,m;
    cin>>n>>m;
    long long int count=0;
    long long int h[n+1],a[n+1];
    for(long long int i=1;i<=n;i++){
        cin>>h[i];
        a[i]=1;
    }
    while(m--){
        long long int x,y;
        cin>>x>>y;
        if(h[x]>h[y] && a[x]==1){
            a[x]=1;
            a[y]=0;
        }
        else if (h[x]>h[y] && a[x]==0){
            a[x]=0;
            a[y]=0;
        }
        else if (h[y]>h[x] && a[y]==0){
            a[x]=0;
            a[y]=0;
        }
        else if (h[y]>h[x] && a[y]==1){
            a[x]=0;
            a[y]=1;
        }
        else if (h[x]==h[y]){
            if(a[x]==1) a[x]=0;
            if(a[y]==1) a[y]=0;
        }
    }
    for(long long int i=1;i<=n;i++){
        if(a[i]==1) count++;
    }
    cout<<count;
    return 0;
}

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

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

    int A, B;
    string S;
    cin >> A >> B >> S;

    if(S.length() != A + B + 1) {
        cout << "No" << endl;
        return 0;
    }

    int c = 0;

    for(int i = 0; i < S.length(); i++) {
        if(S[i] == '-') c++;
    }

    if(c != 1) {
        cout << "No" << endl;
        return 0;
    }

    if(S[A] != '-') {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
package main

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

var (
	s = bufio.NewScanner(os.Stdin)
	w = bytes.Buffer{}
	n = 0
	a = []int{}
)

func main() {
	n = nextInt(s)
	a = atoi(s)
	_ = nextInt(s)
	m := atoi(s)

	for _, v := range m {
		i := 0
		if solve(i, v) {
			w.WriteString("yes\n")
			continue
		}
		w.WriteString("no\n")
	}
	fmt.Println(strings.TrimRight(w.String(), "\n"))
}

func nextInt(s *bufio.Scanner) int {
	s.Scan()
	r, err := strconv.Atoi(s.Text())
	if err != nil {
		panic(err)
	}
	return r
}

func atoi(s *bufio.Scanner) []int {
	s.Scan()
	a := strings.Fields(s.Text())
	i := []int{}

	for _, v := range a {
		j, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		i = append(i, j)
	}
	return i
}

func solve(i, m int) bool {
	if m == 0 {
		return true
	} else if i >= n {
		return false
	}
	return solve(i+1, m) || solve(i+1, m-a[i])
}



Measured memory_bytes: 1148
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    n,*A = get_all_int()
    A = list(A)
    A.sort(reverse=True)

    c = 1
    ans = A[0]
    i = 1
    flag = False
    while(c < n-1):
        ans += A[i]
        c += 1
        if flag:
            i+=1
            flag = False
        else:
            flag = True
    
    print(ans)


main()

Measured memory_bytes: 106956
import java.util.*;
public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		 int b[]=new int[a];
		 for(int i=0;i<a;i++)
			 b[i]=sc.nextInt();
		int c=1;
		int s=b[0];
		for(int i=1;i<a;i++){
			if(s<=b[i]){
			  s=b[i];
			  c++;
		  }
		  		}
		System.out.println(c);
	}
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int h,w; cin >> h >> w;

  rep(i,w+2) cout << '#';
  cout << endl;
  string a;
  rep(i,h){
    cin >> a;
    cout << "#"+a+"#" << endl;
  }
  rep(i,w+2) cout << '#';
  cout << endl;
}


Measured memory_bytes: 256
n=int(input())
w=[input() for i in range(n)]    
count=0
if len(set(w))<len(w):
    print('No')
else:
    for i in range(n-1):
        if w[i][-1]==w[i+1][0]:
            count+=1
    if count==n-1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
N, T = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

diff_max = 0
diff_pattern = 0

min = 10**9+1

as.each do |a|
    if a - min > diff_max
        diff_max = a - min
        diff_pattern = 1
    elsif a - min == diff_max
        diff_pattern += 1
    end
    min = a if min > a
end

puts diff_pattern

Measured memory_bytes: 8452
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double a = Math.log(n) / Math.log(2);
        int a1 = (int) a;
        System.out.println((int) Math.pow(2, a1));
    }
}

Measured memory_bytes: 23764
N,M,X,Y = map(int,input().split())
lis_x = list(map(int,input().split()))
lis_y = list(map(int,input().split()))
m_x = max(lis_x)
m_y = min(lis_y)
if m_x < m_y and X < m_y and m_x < Y:
    print("No War")
else:
    print("War")

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i, n) {
    cin >> a.at(i);
    cin >> b.at(i);
  }
  ll res = 0;
  per(i, n) {
    int aa = a.at(i);
    int bb = b.at(i);
    ll r = (aa + res) % bb;
    if (r != 0) {
      ll tmp = bb - r;
      res += tmp;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4052
MIN, MAX = 1, 10 ** 9
 
n, k, s = map(int, input().split())
 
def solve(n, k, s):
    mid = MAX // 2
    a = s
    b = MIN if s > mid else MAX
    return [a] * k + [b] * (n - k)
 
print(*solve(n, k, s))

Measured memory_bytes: 5868
let rec seq a b = if a > b then [] else a :: seq (a+1) b
let rec dig_sum x = if x = 0 then 0 else x mod 10 + dig_sum (x / 10)
let () =
  Scanf.scanf "%d %d %d" @@ fun n a b ->
    seq 1 n
    |> List.fold_left (fun s x ->
        let d = dig_sum x in
        if a <= d && d <= b then s+x else s) 0
    |> Printf.printf "%d\n"

Measured memory_bytes: 768
n=int(input())
a=list(map(int,input().split()))
if a[0]!=0:print(0)
else:
  a.sort()
  mod=998244353
  if n==1:print(1)
  elif a[1]==0:print(0)
  else:
    li=[]
    ans=1
    a+=[a[-1]+1]
    check=0
    for i in range(1,n):
      if abs(a[i]-a[i+1])>=2:print(0);exit()
      if a[i]!=a[i+1]:
        if li==[]:
          li.append(i)
          check=i
        else:
          li.append(i-check)
          check=i
    for i in range(len(li)-1):
      ans=ans*(li[i]**li[i+1])
      ans%=mod
    print(ans%mod)


Measured memory_bytes: 56364
from operator import itemgetter

n = int(input())
red = [list(map(int, input().split())) for i in range(n)]
blue = [list(map(int, input().split())) for i in range(n)]

red.sort()
blue.sort(key=itemgetter(1))

ans = 0
for i in range(n):
    a,b = red[-i-1]
    for j in range(len(blue)):
        c,d = blue[j]
        if a<c and b<d:
            ans += 1
            blue[j]=[0,0]
            break
print(ans)

Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;

long long Ftr(long long x){
    if(x > 1) return (x % MOD * Ftr(x - 1) % MOD) % MOD;
    else return 1;
}

int main(){
    long long n, m, ans = 1;
    cin >> n >> m;
    if(abs(n - m) <= 1){
        ans *= Ftr(n) % MOD;
        ans *= Ftr(m) % MOD;
        if(!(abs(n - m))) ans = (ans * 2) % MOD;
    }else ans = 0;

    cout << ans % MOD << endl;

    return 0;
}

Measured memory_bytes: 3328
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, x = map(int, readline().split())
    A = list(map(int, readline().split()))
    ans = 0
    if A[0]>x:
        ans += A[0]-x
        A[0] = x
    for i in range(N-1):
        p = A[i] + A[i+1] -x
        if p>0:
            ans += p
            A[i+1] = max(0,A[i+1]-p)

    print(ans)


if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >> N;

  vector<int> V(N);
  vector<int> C(N);

  int ans =0;

  for(int i=0;i<N;i++){
    cin >> V[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
  }

  vector<int> sa(N);

  for(int i = 0;i<N;i++){
    sa[i] = V[i] - C[i];
  }

  sort(sa.begin(),sa.end());

  for(int i=0 ; i<N ; i++){
    if(sa[i]>=0) ans += sa[i];
  }

  cout << ans << endl;

}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

int main(){
    string s;
    int a[10];
    while(getline(cin, s)){
        REP(i,10) a[i] = s[i]-'0';
        REVREP(i,10) REP(j,i) a[j] = (a[j]+a[j+1]) % 10;
        cout << a[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1172
#include<stdio.h>
int main()
{
    int a,b,c,box;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b)
    {
        box=a;
        a=b;
        b=box;

    }
    if(b>c)
    {
     box=b;
     b=c;
     c=box;

    }
    if(a>b)
    {
     box=a;
     a=b;
     b=box;
    }
     printf("%d %d %d\n",a,b,c);
    return 0;
}

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

int main(void){
  char w[8],w1[]="Sunny",w2[]="Cloudy",w3[]="Rainy";

  scanf("%s",&w);
  if (strcmp(w,w1)==0){
    printf("%s\n",w2);
  }else if(strcmp(w,w2)==0){
    printf("%s\n",w3);
  }else{
    printf("%s\n",w1);
  }
  return 0;
}


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

using namespace std;

void showIntArray(int a[], int n) {
  for (int i=0; i<n; i++) {
    cout << a[i] << ' ';
  } cout << endl;
}

int main() {
  int A, B, C;
  cin >>  A >> B >> C;
  if ((C > A && C < B) || (C < A && C > B)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
//----------------------------------------------------------------------------------------------------------------------------------------------------

#define PI 3.14159265358979323846
int main()
{
	fast;
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	double minAngle = 6.0*m;
	double hourAngle = 30.0*h+0.5*m;
	double ang = abs(minAngle-hourAngle);
	double ans = sqrt(a*a+b*b-2*a*b*cos(ang*PI/180.0));
	cout<<setprecision(20)<<ans;
	return 0;
}


Measured memory_bytes: 4244
W,H, N = map(int, input().split())
w=[0]*W
h=[0]*H
for i in range(N):
    x,y, a = map(int, input().split())
    if a==1:
        for i in range(x):
            w[i]=1
    if a==2:
        for i in range(x,W):
            w[i]=1
    if a==3:
        for i in range(y):
            h[i]=1
    if a==4:
        for i in range(y,H):
            h[i]=1

print(w.count(0)*h.count(0))


Measured memory_bytes: 9132
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

class Main {

	public static Map<Integer, Integer> winnerFishesMap = new HashMap<Integer,Integer>();


	public static void main(String[] args){

		Scanner input = new Scanner(System.in);

		String[] menAndEvents = input.nextLine().split(" ");

		int numPlayer = Integer.parseInt(menAndEvents[0]);
		int numEvents = Integer.parseInt(menAndEvents[1]);

		if(numPlayer >= 1 && numPlayer <= 1000000 && numEvents >= 1 && numEvents <= 100000){

			int bestWinner = 0;
			int bestFish =0;
			for(int iEvent = 0; iEvent < numEvents; iEvent++){
				//String[] winnerFishes = input.nextLine().split(" ");
				int winner = input.nextInt();//Integer.parseInt(winnerFishes[0]);
				int numFish = input.nextInt();//Integer.parseInt(winnerFishes[1]);

				if(winner >= 1 && winner <= numPlayer && numFish >= -100 && numFish <= 100 && numFish != 0){
					int tmpNumFish = 0;
					if(winnerFishesMap.containsKey(winner)){
						tmpNumFish = winnerFishesMap.get(winner);
					}

					winnerFishesMap.put(winner, tmpNumFish + numFish);

					if(numFish < 0 && winner == bestWinner){

						List<Entry<Integer,Integer>> winnerFishesEntryList = new ArrayList<Entry<Integer,Integer>>(winnerFishesMap.entrySet());

						Collections.sort(winnerFishesEntryList, new Comparator<Entry<Integer,Integer>>(){
			                public int compare(Entry<Integer,Integer> o1, Entry<Integer,Integer> o2){
			                    return o2.getValue().compareTo(o1.getValue());
			                }
			            });

						Iterator<Entry<Integer,Integer>> winnerFishesEntryItr = winnerFishesEntryList.iterator();
						Entry<Integer,Integer> tmpEntry = winnerFishesEntryItr.next();
						bestWinner	= tmpEntry.getKey();
						bestFish	= tmpEntry.getValue();
						while(winnerFishesEntryItr.hasNext()){
							Entry<Integer,Integer> tmpWinnerFishesEntry = winnerFishesEntryItr.next();
							if(bestFish == tmpWinnerFishesEntry.getValue() && bestWinner > tmpWinnerFishesEntry.getKey()){
								bestWinner	= tmpWinnerFishesEntry.getKey();
								bestFish	= tmpWinnerFishesEntry.getValue();
							}
						}
					} else {
						if(tmpNumFish + numFish > bestFish){
							bestWinner	= winner;
							bestFish	= tmpNumFish + numFish;
						} else if(tmpNumFish + numFish == bestFish && bestWinner > winner){
							bestWinner	= winner;
						}
					}
					System.out.println(bestWinner + " " + bestFish);
				}
			}
		}
		input.close();
	}

}

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

int main(void){
    int n,k,r,s,p;
    string T;
    cin >> n >> k >> s >> p >> r >> T;
    ll sum = 0;
    rep(i,T.size()){
        if(i-k<0 || T[i]!=T[i-k] || T[i-k]=='a'){
            if(T[i]=='r'){
                sum += r;
            }else if(T[i]=='s'){
                sum += s;
            }else{
                sum += p;
            }
        }else if(T[i]==T[i-k]){
            T[i] = 'a';
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <utility>
using namespace std;

const int MAX = 10000;
const int INF = 1 << 29;

int n;
vector<pair<int, int>> cost[MAX];

void solve()
{
	int ans[MAX];
	bool visited[MAX];
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> PQ;

	for (int i = 0; i < n; i++) {
		ans[i] = INF;
		visited[i] = false;
	}

	ans[0] = 0;

	PQ.push(make_pair(0, 0));

	while (PQ.empty() == false) {
		pair<int, int> p = PQ.top();
		PQ.pop();

		visited[p.second] = true;

		if (ans[p.second] < p.first) {
			continue;
		}

		for (unsigned int i = 0; i < cost[p.second].size(); i++) {
			int v = cost[p.second][i].second;

			if (visited[v] == true) {
				continue;
			}

			if (ans[v] > ans[p.second] + cost[p.second][i].first) {
				ans[v] = ans[p.second] + cost[p.second][i].first;
				PQ.push(make_pair(ans[v], v));
			}
		}
	}


	for (int i = 0; i < n; i++) {
		cout << i << " " << ans[i] << endl;
	}
}

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num >> num;

		for (int j = 0; j < num; j++) {
			int v, c;
			cin >> v >> c;
			cost[i].push_back(make_pair(c, v));//(?????¢,?????????
		}
	}


	solve();

	return 0;
}

Measured memory_bytes: 7980
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 13:15:13 2020

@author: NEC-PCuser
"""

N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A.append(input())

for i in range(M):
    B.append(input())

result = "No" 
for i in range(N - M + 1):
    for j in range(N - M + 1):
        for k in range(M):
            for l in range(M):
                if (A[i + k][j + l] != B[k][l]):
                    break
            else:
                continue
            break
        else:
            result = "Yes"
            break

print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ll long long
using namespace std;

void solve() {
    int n;
    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 == 0 || i % 5 == 0)
            continue;
        sum += i;
    }
    cout << sum << endl;
    return;
}

int main() {
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3192
N = int(input())
D = list(map(int, input().split()))
d = [0 for _ in range(max(D)+1)]
mod = 998244353
for i in D:
    d[i] += 1
if D[0] != 0 or d[0] != 1 or d.count(0) > 0:
    print(0)
else:
    ans = 1
    for i in range(len(d)-1):
        ans *= d[i]**d[i+1]%mod
    print(ans%mod)

Measured memory_bytes: 56244
#include <stdio.h>

int const N = 200000;
int merge(int a[N], int l, int m, int r){
	int b[N / 2 + 1], c[N / 2 + 1], i, j = 0, k = 0;
	for(i = l; i <= m; i++){
		b[j++] = a[i];
	}
	b[j] = 1000000001;
	for(i = m + 1; i <= r; i++){
		c[k++] = a[i];
	}
	c[k] = 1000000001;
	j = k = 0;
	for(i = l; i <= r; i++){
		if(b[j] <= c[k]){
			a[i] = b[j];
			j++;
		}
		else{
			a[i] = c[k];
			k++;
		}
		
	}
 
}
 
 
int merge_sort(int a[N], int l, int r){
	int m = (l + r) / 2;
	if(l < r){
		merge_sort(a, l, m);
		merge_sort(a, m + 1, r);
		merge(a, l, m , r);
		
	}
}

int main(){
	int n, i;
	int a[200000];
	int cnt = 0;
	long long res = 0;
	scanf("%d", &n);
	for(i = 0; i < n ; i++){
		scanf("%d", &a[i]);
	}
	merge_sort(a, 0, n - 1);
	i = n - 1;
	while(cnt < n - 1){
		if(i == n - 1){
			res += a[i];
			cnt++;
			
		}
		else if(cnt + 2 <= n - 1){
			res += 2 * a[i];
			cnt += 2;
		}
		else{
			res += a[i];
			cnt++;
		}
		//printf("%d %d %d\n", i, cnt, res);
		i--;
	}
	printf("%lld\n", res);

	return 0;
}

Measured memory_bytes: 3256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int dc=100000;
#define MAX 100010
#define MOD 998244353
typedef long int li;

char tr[3]={'R','G','B'};
int made[8]={};
// \0,R,G,B,RG,RB,GB,RGB
//  0 1 2 3  4  5  6   7
void find(char c,int* i,int* j){
  if(df)printf("%c ",c);
  int x;
  if(c=='R'){
    if(df)printf("6: %d,2: %d,3: %d",made[6],made[2],made[3]);
    if(made[6]) {*i=6; *j=7; return;}
    else if(made[2]) {*i=2; *j=4; return;}
    else if(made[3]) {*i=3; *j=5; return;}
    else {*i=0; *j=1; return;}
  }
  if(c=='G') {
    if(df)printf("5: %d,1: %d,3: %d",made[5],made[1],made[3]);
    if(made[5]) {*i=5; *j=7; return;}
    else if(made[1]) {*i=1; *j=4; return;}
    else if(made[3]) {*i=3; *j=6; return;}
    else {*i=0; *j=2; return;}
  }
  if(c=='B') {
    if(df)printf("4: %d,1: %d,2: %d",made[4],made[1],made[2]);
    if(made[4]) {*i=4; *j=7; return;}
    else if(made[1]) {*i=1; *j=5; return;}
    else if(made[2]) {*i=2; *j=6; return;}
    else {*i=0; *j=3; return;}
  }
}



int main(){
  if(df)printf("*** debug mode ***\n");
  int n;
  scanf("%d",&n);
  char S[3*n+10];
  scanf(" %s",S);
  if(df)printf("%d %s\n",n,S);
  int i,dec,inc,len=strlen(S);
  li ans=1;
  made[0]=n;
  if(df){
    for(i=0;i<8;i++)
      printf("%d ",made[i]);
    printf("\nlen: %d\n",len);
  }
  for(i=0;i<len;i++){
    find(S[i],&dec,&inc);
    if(df) printf("%d,%d\n",dec,inc);
    ans*=made[dec];
    ans%=MOD;
    made[dec]--;
    made[inc]++;
  }
  
  printf("%ld",ans);
  return 0;
}


/// confirm df==0 ///


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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
    long long p, q; cin >> p >> q;
    long long d = GCD(p, q);
    q /= d;
    for (long long v = 2; v*v <= q; ++v) {
        while (q % (v*v)== 0) q /= v;
    }
    cout << q << endl;
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    string s;
    cin >> s;

    string ans = "";
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'B' && ans.length() > 0) ans.pop_back();
        else if(s[i] == '0' || s[i] == '1') ans += s[i];
    }

    cout << ans << endl;

    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);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		long k = sc.nextLong();
		if (k % 2 == 0) {
			System.out.println(a - b);
		} else {
			System.out.println(b - a);
		}
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s1, s2;
	cin>>n>>s1>>s2;
	int s=0;
	ll ans;
	bool width=false;
	if(s1[0]!=s2[0]){
		ans=6;
		width=true;
		s=2;
	}
	else{
		ans=3;
		s=1;
	}
	FOR(i, s, n){
		if(s1[i]!=s2[i]){
			++i;
			if(width){
				ans=(ans*3)%MOD;
			}
			else{
				ans=(ans*2)%MOD;
				width=true;
			}
		}
		else{
			if(!width){
				ans=(ans*2)%MOD;
			}
			width=false;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define swap(x,y) {x+=y;y=x-y;x-=y;}
int main(){
  int x,y,r;
    scanf("%d%d",&x,&y);
  if( x < y)
    swap(x, y);
  while (y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  printf("%d\n",x);
  return 0;
    }

Measured memory_bytes: 592
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var a = read();
		var s = new int[a[0]].SelectMany(_ => read().Select((x, i) => new { x, i })).OrderBy(_ => -_.x).ToArray();

		int h = a[1], c = 0;
		for (; ; c++)
			if (s[c].i == 0)
			{
				c += h / s[c].x + (h % s[c].x == 0 ? 0 : 1);
				break;
			}
			else
			{
				h -= s[c].x;
				if (h <= 0) { c++; break; }
			}
		Console.WriteLine(c);
	}
}


Measured memory_bytes: 34864
use std::collections::VecDeque;
use std::io::*;
struct Io<'a> {
    r: BufReader<StdinLock<'a>>,
    w: BufWriter<StdoutLock<'a>>,
    buf: VecDeque<String>,
    buf_str: String,
}
impl<'a> Io<'a> {
    fn r<T: std::fmt::Debug, S: std::str::FromStr<Err = T>>(&mut self) -> S {
        if self.buf.len() == 0 {
            self.r.read_line(&mut self.buf_str).unwrap();
            for w in self.buf_str.split_whitespace() {
                self.buf.push_back(w.to_owned());
            }
            self.buf_str.clear();
        }
        self.buf.pop_front().unwrap().parse().unwrap()
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.w, "{}", v).unwrap();
    }
    fn iter<'b, T: std::fmt::Debug, S: std::str::FromStr<Err = T>>(
        &'b mut self,
    ) -> IoIter<'a, 'b, T, S> {
        IoIter {
            io: self,
            p: std::marker::PhantomData,
            q: std::marker::PhantomData,
        }
    }
}
struct IoIter<'a: 'b, 'b, T: std::fmt::Debug, S: std::str::FromStr<Err = T>> {
    io: &'b mut Io<'a>,
    p: std::marker::PhantomData<T>,
    q: std::marker::PhantomData<S>,
}
impl<'a, 'b, T: std::fmt::Debug, S: std::str::FromStr<Err = T>> Iterator for IoIter<'a, 'b, T, S> {
    type Item = S;
    fn next(&mut self) -> Option<S> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let r = BufReader::new(stdin.lock());
    let w = BufWriter::new(stdout.lock());
    let io = Io {
        r: r,
        w: w,
        buf: VecDeque::new(),
        buf_str: String::new(),
    };
    problem(io);
}

fn problem(mut io: Io) {
    let n: usize = io.r();
    let m: usize = io.r();
    let a: Vec<usize> = io.iter().take(n).collect();
    let vote_count: usize = a.iter().sum();
    let min_vote = (vote_count + 4 * m - 1) / (4 * m);
    let count = a.iter().filter(|v| **v >= min_vote).count();
    if count >= m {
        io.w("Yes");
    } else {
        io.w("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  ll n;
  cin >>n;
  ll a[n],ans,res=0;
  map<int,int>mp;

  rep(i,n){
    cin >> a[i];
    if(mp.find(a[i])==mp.end())mp[a[i]]=0;
    mp[a[i]]++;
  }
  //res除くもの
  rep(i,n){
    if(mp[a[i]]>a[i]){
      ans+=mp[a[i]]-a[i];
      mp.erase(a[i]);
    }else if(mp[a[i]]<a[i]){
      ans+=mp[a[i]];
      mp.erase(a[i]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5504
#include <stdio.h>
#include <algorithm>

using namespace std;

//long long
const long long maxn = 210000;
long long n;
long long a[maxn];
long long dp[maxn][6];
long long ans;
void work () {
	long long i , j;
	scanf ( "%lld" , &n );
	for ( i = 1 ; i <= n ; i++ ) {
		scanf ( "%lld" , &a[i] );
		for ( j = 0 ; j <= 4 ; j++ ) dp[i][j] = 2147483647777777ll;
	}
	for ( i = 0 ; i < n ; i++ ) {
		for ( j = 1 ; j <= 4 ; j++ ) dp[i][j] = min ( dp[i][j] , dp[i][j-1] );
		dp[i+1][0] = dp[i][0] + a[i+1];
		dp[i+1][1] = dp[i][1] + (a[i+1]%2) + (a[i+1]==0?2:0);
		dp[i+1][2] = dp[i][2] + ((a[i+1]%2)^1);
		dp[i+1][3] = dp[i][3] + (a[i+1]%2) + (a[i+1]==0?2:0);
		dp[i+1][4] = dp[i][4] + a[i+1];
		//printf ( "%lld %lld %lld %lld %lld\n" , dp[i][0] , dp[i][1] , dp[i][2] , dp[i][3] , dp[i][4] );
	}
	ans = 2147483647777777ll;
	for ( j = 0 ; j <= 4 ; j++ ) ans = min ( ans , dp[n][j] );
	printf ( "%lld\n" , ans );
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <algorithm>

using namespace std;
static const int MAX =200000;

int main() {
    int n;
    cin >> n;
    int R[n];
    for(int i = 0; i < n; i++) cin >> R[i];

    int max_dif;
    int minv = R[0];
    for(int i = 1; i < n; i++) {
        if(i == 1)
            max_dif = R[i] - minv;
        else
            max_dif = max(max_dif, R[i] - minv);
        minv = min(minv, R[i]);
    }
    cout << max_dif << endl;
}


Measured memory_bytes: 3912
#include<iostream>
#include<vector>
using namespace std;
const int INF=1001001001;
int a[12][12];
int main(){
int n,m,x;
  cin>>n>>m>>x;
  vector<int>c(n);
  for(int i=0;i<n;i++){
    cin>>c[i];
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  int ans=INF;
  for(int s=0;s<(1<<n);s++){
    int cost=0;
    vector<int> d(m);
    for(int i=0;i<n;i++){
      if(s>>i&1){
        cost+=c[i];
        for(int j=0;j<m;j++) d[j]+=a[i][j];
      }
    }
    bool ok=true;
    for(int j=0;j<m;j++) if(d[j]<x) ok=false;
      if(ok) ans=min(ans,cost);
    
  }
    if(ans==INF) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
  
}


Measured memory_bytes: 3632
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬               
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬             
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬     ╬╬╬╬╬            
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬          ╬   ╬      
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬     ╬╬            
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬  ╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬     ╬          
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬  ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬    ╬╬╬╬╬╬╬   ╬╬╬╬╬╬╬╬╬╬      ╬      
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬  ╬   ╬╬╬╬╬╬╬  ╬      ╬╬╬╬  ╬╬╬╬        
# ╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬ ╬    ╬╬╬╬╬╬╬╬╬        ╬ ╬        ╬╬ ╬╬╬                    
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬    ╬     ╬╬╬           ╬ ╬╬╬    ╬  ╬╬  ╬╬╬╬╬╬╬╬              
# ╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬                        ╬╬╬╬╬╬╬╬╬  ╬   ╬╬╬╬╬╬╬╬   ╬╬╬        
# ╬╬  ╬╬╬  ╬╬╬╬     ╬╬╬╬╬                  ╬╬╬╬╬╬╬       ╬╬ ╬╬╬╬  ╬    ╬      
# ╬╬      ╬   ╬╬╬╬╬╬╬╬╬╬╬ ╬                 ╬╬╬╬         ╬  ╬╬╬           ╬   
# ╬╬       ╬╬╬╬╬    ╬                                  ╬    ╬╬               ╬
# ╬╬     ╬╬╬╬╬╬╬╬                                    ╬╬    ╬                  
# ╬╬     ╬╬╬╬╬╬╬╬╬╬╬╬╬╬                      ╬          ╬                     
# ╬╬╬╬  ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬                                      ╬                
# ╬╬╬╬╬       ╬╬╬╬╬                                          ╬                
# ╬╬╬╬╬╬╬                                    ╬╬╬                              
# ╬╬╬╬╬╬╬╬╬╬                          ╬  ╬╬╬╬╬╬╬╬                             
# ╬╬╬╬╬╬╬╬╬ ╬  ╬                  ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬         ╬                   
# ╬╬╬╬╬╬╬╬╬╬╬╬                  ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬        ╬                    
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬                ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬       ╬                      
# ╬    ╬╬╬╬╬╬╬╬╬╬╬                 ╬╬╬╬╬╬╬╬╬╬                                 
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬                                                           
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬                           ╬                            
# ╬╬╬╬╬╬╬╬╬╬╬╬  ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬           ╬╬                               

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    if v[i] - c[i] > 0:
        ans += v[i] - c[i]

print(ans)

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

using Graph = std::vector<std::vector<uint32_t>>;

int main() {
  uint32_t n = 0;
  std::cin >> n;
  Graph G(n + 1);
  for (size_t i = 1; i <= n; i++) {
    uint32_t k = 0;
    std::cin >> i >> k;
    if (k > 0) G[i] = std::vector<uint32_t>(k);
    for (size_t j = 0; j < k; j++) std::cin >> G[i][j];
  }

  Graph mat(n + 1, std::vector<uint32_t>(n + 1, 0));
  for (size_t i = 1; i < G.size(); i++) {
    for (size_t j = 0; j < G[i].size(); j++) mat[i][G[i][j]] = 1;
  }

  for (size_t i = 1; i < mat.size(); i++) {
    for (size_t j = 1; j < mat[i].size(); j++) {
      std::cout << mat[i][j] << (j + 1 == mat[i].size() ? "" : " ");
    }
    std::cout << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3176
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

int N;

int main()
{
  scanf( "%d", &N );

  bool fl = true;

  rep( i, N )
  {
    int a;
    scanf( "%d", &a );

    fl &= a % 2 == 0;
  }

  puts( fl ? "second" : "first" );

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

const int M=620,M2=310;
int h,w;
int a[M][M],b[M][M];

ll f(int B){
	ll res=0;
	for(int i=0;i<M;i++) for(int j=1;j<M;j++) b[i][j]=a[i][j]+b[i][j-1];
	for(int i=0;i<M;i++) for(int j=0;j<M;j++) if(a[i][j]){
		for(int k=j+1;k<M;k++) if(a[i][k]){
			int d=k-j;
			if(i+d<M) res+=b[i+d][k-B]-b[i+d][j-1+B];
			if(d<=i) res+=b[i-d][k-B]-b[i-d][j-1+B];
		}
	}
	for(int i=0;i<M;i++) for(int j=0;j<M;j++) b[M-j-1][i]=a[i][j];
	for(int i=0;i<M;i++) for(int j=0;j<M;j++) a[i][j]=b[i][j],b[i][j]=0;
	return res;
}

int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		char c;
		cin>>c;
		if(c=='#') a[i+j+1][i-j+M2+1]++;
	}
	cout<<f(0)+f(1)<<endl;
}

Measured memory_bytes: 3328
from collections import defaultdict

def solve(n, A):
    d = defaultdict(lambda: False)
    count = 0
    for a in A:
        if not d[a]:
            d[a] = True
            count += 1
        else:
            d[a] = False
            count -= 1
    return count

_n = int(input())
_A = [int(input()) for _ in range(_n)]
print(solve(_n, _A))


Measured memory_bytes: 16632