akhauriyash/Code-Regression huggingface dataset:
def main():
    n, m = map(int, input().split())
    if n == 1 and m == 1:
        print(0)
    elif n == 1 and m != 1:
        print(m * (m - 1) // 2)
    elif n != 1 and m == 1:
        print(n * (n - 1) // 2)
    else:
        print((m * (m - 1) // 2) + (n * (n - 1) // 2))


if __name__ == "__main__":
    main()


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

using namespace std;

 map<string,int> a;
int ans;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout.sync_with_stdio(false);
    string s;
    int n;
    cin >> n;
    for(int i = 0; i < n; i ++)
    {
        cin >> s;
        a[s] ++;
    }
    for(auto& t:a) ans = max(ans, t.second);
    for(auto& t:a)
    {
        if(t.second == ans) cout << t.first << endl;
    }
    return 0;
}

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

int main(){
  int n,a,b;
  string s;
  cin >> n >> a >> b >> s;
  int bcn=0,acn=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='c'){
      cout << "No"  << endl;
    }else if(s.at(i)=='b'){
      if(bcn<b&&acn<a+b){
        cout << "Yes" << endl;
        acn++;
        bcn++;
      }else{
        cout << "No" << endl;
      }
    }else{
      if(acn<a+b){
        cout << "Yes" << endl;
        acn++;
      }else{
        cout << "No" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3700
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            string s = cin.Read;

            int ans = 0;

            for (int i = 0; i < n; i++)
            {
                int[] prefix = ZAlgorithm(s.Substring(i));

                for (int j = 0; j < prefix.Length; j++)
                {
                    if (prefix[j] <= j && ans < prefix[j])
                    {
                        ans = prefix[j];
                    }
                }
            }

            Console.WriteLine(ans);
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

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

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }

        int[] ZAlgorithm(string s)
        {
            int[] prefix = new int[s.Length];
            for (int i = 1, j = 0; i < s.Length; i++)
            {
                if (i + prefix[i - j] < j + prefix[j])
                {
                    prefix[i] = prefix[i - j];
                }
                else
                {
                    int k = Math.Max(0, j + prefix[j] - i);
                    while (i + k < s.Length && s[k] == s[i + k]) ++k;
                    prefix[i] = k;
                    j = i;
                }
            }
            prefix[0] = (int)s.Length;
            return prefix;
        }
    }
}

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

int main() {
  string s[3];
  cin >> s[0] >> s[1] >> s[2];

  int current, next=0;
  char ans;
  while (1) {
    //cout << next << endl;
    current = next;
    if (s[current].empty()) {
      if (current == 0) {
        ans = 'A';
      } else if (current == 1) {
        ans = 'B';
      } else {
        ans = 'C';
      }
      break;
    }
    if (s[current][0] == 'a') {
      next = 0;
    } else if (s[current][0] == 'b') { 
      next = 1;
    } else {
      next = 2;
    }
    s[current].erase(0, 1);
  }

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


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

int main(){
    int k;
    cin >> k;
    int cnt = 0;
    for (int i = 1; i < 1e7;i++)
    {
        cnt = (cnt*10+7) % k;
        if(cnt == 0){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 200005
#define int long long
using namespace std;
int n,q,x,y,a,b,A[li],CEV[li];
vector<int> v[li];
void dfs(int node,int ata,int son){
	CEV[node]=son+A[node];
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i];
		if(go==ata) continue;
		dfs(go,node,son+A[node]);
	}
}
main(){
	scanf("%lld %lld",&n,&q);
	for(int i=1;i<n;i++){
		scanf("%lld %lld",&x,&y);
		v[x].pb(y);
		v[y].pb(x);
	}
	for(int i=1;i<=q;i++){
		scanf("%lld %lld",&a,&b);
		A[a]+=b;
	}
	dfs(1,0,0);
	for(int i=1;i<=n;i++) printf("%lld ",CEV[i]);
	return 0;
}





Measured memory_bytes: 28672
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    alst = list(map(int, input().split()))
    blst = list(map(int, input().split()))
    a_s = [0 for _ in range(n)]
    b_s = [0 for _ in range(n)]
    for a in alst:
        a_s[a - 1] += 1
    for b in blst:
        b_s[b - 1] += 1
    for a, b in zip(a_s, b_s):
        if a + b > n:
            print("No")
            return
    print("Yes")
    a_total = 0
    b_total = 0
    cor = -100000
    for a, b in zip(a_s, b_s):
        a_total += a
        cor = max(cor, a_total - b_total)
        b_total += b
    ans = blst[-cor:] + blst[:-cor]
    print(*ans)
        
main()

Measured memory_bytes: 40384
H,W,h,w = [int(x) for x in input().split(' ')]
if W % w != 0:
    r = W % w
    n = int(W/w)
    n = n+1
    print('Yes')
    for i in range(H):
        for k in range(W):
            if (k+1) % w == 0:
                print(-n*(w-1) - 1, end = '')
            else:
                print(n, end = '')
            if k == W-1:
                print()
            else:
                print(end = ' ')
elif H % h != 0:
    r = H % h
    n = int(H/h)
    n = n + 1
    print('Yes')
    store = 0
    for i in range(H):
        if (i+1) % h == 0:
            store = -n*(h-1) - 1
        else:
            store = n
        for k in range(W):
            if k == W-1:
                print(store)
            else:
                print(store, end=' ')
else:
    print('No')


Measured memory_bytes: 4680
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;

int main()
{
	int n;
	long long a[100005];
	long long sum1 = 0,sum2 = 0;
	cin >> n;
	for(int i = 1;i<=n;i++){
		cin >> a[i];
	}
	int l = 1,r = n;
	sort(a + 1, a + n + 1);
	sum1 = abs(a[l] - a[r]);
	sum2 = abs(a[l] - a[r]);
		if(n % 2 == 0){
			for(int i = 2;i <= (n+1)/2;i++){
				sum1 += abs(a[l] - a[n - i + 1]);
				sum1 += abs(a[r] - a[i]);
				l++;
				r--;
			}
		}else{
			l = 1,r = n;
			long long x = a[(n+1)/2];
			for(int i = 2;i < (n+1)/2;i++){
				sum2 += abs(a[r] - a[i]);
				sum2 += abs(a[l] - a[n - i + 1]);
				l++;
				r--;
			}
			sum2 += max(abs(x - a[(n+1)/2 + 1]) , abs(x - a[(n+1)/2 - 1]));
		}
	cout << max(sum1,sum2) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    ULL *A;
    ULL N;
    ULL x,y;
    ULL i,j;
    ULL mod = 1000000007;
    ULL count[70];
    ULL ans;
    ULL a;
    cin >> N;
    A = new ULL[N];
    for(i=0;i<70;i++){
        count[i] = 0;
    }
    for(i=0;i<N;i++){
        cin >> a;
        j=0;
        while( a > 0){
            if( a & 0x01 ){
                count[j]++;
            }
            a = a >> 1;
            j++;
        }
    }
    ans = 0;
    for(i=0;i<70;i++){
        x = count[i] * ( N - count[i]);
        for(j=0;j<i;j++){
            x *= 2;
            x = x % mod;
        }
        ans += x;
        ans = ans % mod;
        //y = y << i;
        //ans += x * y;
        //ans += ( ( x % mod ) * (y % mod) ) % mod;  
        //ans = ans % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   cin>>n;

   cout<<(n-2)*180;

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works


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

#define ll long long
#define endl '\n'

ll n;

void test() {
    cin>>n;
    vector<int> k;
    int tmp;
    while (n) {
        tmp=n%26;
        if (!tmp) tmp=26;
        k.emplace_back(tmp);
        n=(n-tmp)/26;
    }
    for (int i=k.size()-1; i>=0; --i) {
        cout << (char)(k[i]-1+'a');
        // cout << k[i] << ' ';
    }
    cout << endl;
}

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

    // int t;
    // cin >> t;
    // while (t--) {
    //     test();
    // }
    test();
    return 0;
}

Measured memory_bytes: 3652
use proconio::{input, fastout};
use std::collections::HashMap;

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

// fn divisor()

#[fastout]
fn main() {
  input!{
    n: usize,
    mut aa: [u64; n]
  };
  let mut amap = HashMap::new();
  for a in &aa {
    *amap.entry(*a).or_insert(0) += 1;
  }
  let mut ans = 0;
  for a in &aa {
    // dbg!(a);
    let x = *a;
    let mut is_ans = true;
    match amap.get(&x) {
      Some(v) => {
        if *v != 1 {
          continue;
        }
      },
      None => {}
    }
    if x != 1 && amap.contains_key(&1) {
      is_ans = false;
    }
    for d in 2.. {
      if x < d * d {
        match amap.get(&x) {
          Some(v) => {
            if x != *a || *v != 1 {
              is_ans = false;
            }
          },
          None => { }
        }
        break;
      }
      if x % d == 0 {
        let dd = x / d;
        if amap.contains_key(&dd) || amap.contains_key(&d) {
          is_ans = false;
          break;
        }
      }
    }
    // if x % 2 == 0 {
    //   if amap.contains_key(&2) {
    //     // is_ans = false;
    //     if 2 != *a || *amap.get(&2).unwrap() != 1 {
    //       // dbg!("here", &x);
    //       is_ans = false;
    //     }
    //   }
    //   while x % 2 == 0 {
    //     x /= 2;
    //     if amap.contains_key(&x) {
    //       // dbg!("fff", &x);
    //       is_ans = false;
    //     }
    //   }
    // }
    // for d in (3..).step_by(2) {
    //   if x == 1 {
    //     break;
    //   }
    //   if x < d * d {
    //     match amap.get(&x) {
    //       Some(v) => {
    //         if x != *a || *v != 1 {
    //           is_ans = false;
    //         }
    //       },
    //       None => { }
    //     }
    //     break;
    //     // if amap.contains_key(&x) {
    //     //   if x != *a || *amap.get(&x).unwrap() != 1 {
    //     //     // dbg!("here", &x);
    //     //   }
    //     //   break;
    //     // }
    //   }
    //   while x % d == 0 {
    //     x /= d;
    //     if amap.contains_key(&x) {
    //       // dbg!("hhh", &x);
    //       is_ans = false;
    //       break;
    //     }
    //     match amap.get(&d) {
    //       Some(v) => {
    //         if d != *a || *v != 1 {
    //           is_ans = false;
    //         }
    //         break;
    //       },
    //       None => { }
    //     }
    //     // if amap.contains_key(&d) {
    //     //   if d != *a || *amap.get(&d).unwrap() != 1 {
    //     //     // dbg!("here", &x);
    //     //     is_ans = false;
    //     //   }
    //     //   break;
    //     // }
    //   }
    // }
    if is_ans {
      // dbg!(a);
      ans += 1;
    }
  }
  echo!(ans);
}


Measured memory_bytes: 11556
<?php

// $input = STDIN;
// var_dump($input);
$d = [];
foreach(range(1,4) as $b){
    foreach(range(1,3) as $f){
        $d[$b][$f] = array_fill(1, 10, 0);
    }
}

$n = (int)trim(fgets(STDIN));

for($i=0; $i<$n; $i++){
    list($b, $f, $r, $v) = array_map("intval", explode(" ", trim(fgets(STDIN))));
    $d[$b][$f][$r] += $v;
}


$dlm = str_repeat('#', 20) . "\n";
foreach(array_slice($d, 0, 3) as $blog){
    foreach($blog as $flr){
        print(' ' . implode(" ", $flr) . "\n");
    }
    print $dlm;
}
foreach($d[4] as $flr) print(' ' . implode(' ', $flr) . "\n");

?>


Measured memory_bytes: 9360
#include <bits/stdc++.h>
using namespace std;
int main() {
  string mozi;
  cin >> mozi;
  vector<int> count(26);
  for (int i = 0; i < mozi.size(); i++) {
    if (mozi[i] == 'a') {
      count[0]++;
    }
    if (mozi[i] == 'b') {
      count[1]++;
    }
    if (mozi[i] == 'c') {
      count[2]++;
    }
    if (mozi[i] == 'd') {
      count[3]++;
    }
    if (mozi[i] == 'e') {
      count[4]++;
    }
    if (mozi[i] == 'f') {
      count[5]++;
    }
    if (mozi[i] == 'g') {
      count[6]++;
    }
    if (mozi[i] == 'h') {
      count[7]++;
    }
    if (mozi[i] == 'i') {
      count[8]++;
    }
    if (mozi[i] == 'j') {
      count[9]++;
    }
    if (mozi[i] == 'k') {
      count[10]++;
    }
    if (mozi[i] == 'l') {
      count[11]++;
    }
    if (mozi[i] == 'm') {
      count[12]++;
    }
    if (mozi[i] == 'n') {
      count[13]++;
    }
    if (mozi[i] == 'o') {
      count[14]++;
    }
    if (mozi[i] == 'p') {
      count[15]++;
    }
    if (mozi[i] == 'q') {
      count[16]++;
    }
    if (mozi[i] == 'r') {
      count[17]++;
    }
    if (mozi[i] == 's') {
      count[18]++;
    }
    if (mozi[i] == 't') {
      count[19]++;
    }
    if (mozi[i] == 'u') {
      count[20]++;
    }
    if (mozi[i] == 'v') {
      count[21]++;
    }
    if (mozi[i] == 'w') {
      count[22]++;
    }
    if (mozi[i] == 'x') {
      count[23]++;
    }
    if (mozi[i] == 'y') {
      count[24]++;
    }
    if (mozi[i] == 'z') {
      count[25]++;
    }
  }
  bool ab = true;
  for (int i = 0; i < 26; i++) {
    if (count[i]%2!=0) {
      ab = false;
    }
  }
  if (ab) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3588
s = raw_input()
chrindex = []
for i in range(0, 26):
	chrindex.append([])
for i in range(0, len(s)):
	chrindex[ord(s[i])-97].append(i)
K = int(raw_input())
sublist = []
for i in range(0, K):
	sublist.append('')
for i in range(0, 26):
	for j in range(0, len(chrindex[i])):
		word = ''
		for k in range(chrindex[i][j], len(s)):
			word = word + s[k]
			if sublist[-1] < word and sublist[-1] != '': break
			if word not in sublist:
				for p in range(0, K):
					if word < sublist[p]:
						for q in range(0, K-p-1):
							sublist[-1-q] = sublist[-2-q]
						sublist[p] = word
						break
					if sublist[p] == '':
						sublist[p] = word
						break
	if '' not in sublist: break
print sublist[-1]

Measured memory_bytes: 32540
//
// Created by Myabu on 2020/01/29.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int A,B,K;

    cin>>A>>B>>K;

    for (int i = A; i <=B ; ++i) {
        if((A+K > i && A<=i)  || (B-K < i && B>=i)){
            cout<<i<<endl;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	//入力
	int N;
	cin >> N;
	vector<int> x(N), y(N);
	vector<ll> h(N);
	int non_zero_cnt = 0;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] != 0) {
			non_zero_cnt++;
		}
	}

	ll H0, count;
	for (int Cx = 0; Cx <= 100; Cx++) {
		for (int Cy = 0; Cy <= 100; Cy++) {
			count = 0;
			for (int i = 0; i < N; i++) {
				if (h[i] > 0) {
					H0 = h[i] + abs(x[i] - Cx) + abs(y[i] - Cy);
					break;
				}
			}

			for (int i = 0; i < N; i++) {
				if (h[i] == max(H0 - abs(x[i] - Cx) - abs(y[i] - Cy), 0ll)) {
					count++;
				}
				else {
					break;
				}
			}
			if (count == N) {
				cout << Cx << " " << Cy << " " << H0 << endl;
				return 0;
			}
		}
	}



	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N, K;
bool hate[10];

bool check(int x)
{
	for(; x; x/=10){
		if(hate[x%10]) return false;
	}
	return true;
}

int main(void)
{
	cin >> N >> K;
	
	int d;
	for(int i = 0; i < K; i++){
		cin >> d;
		hate[d] = true;
	}
	
	for(int i = N; ; i++){
		if(check(i)){
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main(void){
  int a, h, x = 0;
  bool fail = false;
  cin >> h >> a;
  
  vector<int> att(a);
  for(int i=0; i<a; i++){
    cin >> att.at(i);
  }
  
  for(int i=0; i<a; i++){
    h -= att.at(i);
  }
  
  if(h>0)cout << "No" << endl;
  else cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main()
{
    char s[20];
    int i;
    scanf("%s",&s);
    for(i=0; i<strlen(s); i++)
    {
        if(s[i]==',')
        {
            s[i]=' ';
        }
        else
        {
            s[i]=s[i];
        }
    }
    for(i=0; i<strlen(s); i++)
    {
        printf("%c",s[i]);
    }
    return 0;
}


Measured memory_bytes: 128
k=int(input())
data=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(data[k-1])

Measured memory_bytes: 38384
n = STDIN.gets.chomp.to_i
n.times do 
  xa, ya, ra, xb, yb, rb = STDIN.gets.chomp.split(" ").map { |item| item.to_f }
  dist = Math.sqrt((xa-xb)**2 + (ya-yb)**2)
  if ra > rb && dist < ra - rb then
    puts 2
  elsif rb > ra && dist < rb - ra then
    puts -2
  elsif dist <= ra + rb && dist >= ra - rb then
    puts 1
 else 
    puts 0
  end
end

Measured memory_bytes: 8612
#include<iostream>
#include<map>
#include<string>

using namespace std;

int main()
{
	int n;
	string order;
	string str;
	map < string, string > mp;

	cin >> n;
	do {
		cin >> order;
		cin >> str;
		if (order=="insert") {
			mp[str] = "yes\n";
		}
		else if (order=="find") {
			auto it = mp.find(str);
			if (it!=mp.end()) {
				cout << mp[str];
			}
			else {
				cout << "no\n";
			}
		}
		n--;
	} while (n!=0);

    return 0;
}


Measured memory_bytes: 49848
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  ll r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  ll ans = 0;
  for (ll i = 0; i < k; i++) {
    if (t[i] == 'r') ans += p;
    else if (t[i] == 's') ans += r;
    else ans += s;
  }
  for(ll i = k; i < t.size(); i++) {
    if (t[i] == 'r') {
      if (t[i-k] == 'r') {
        t[i] = '0';
      }
      else {
        ans += p;
      }
    }
    else if (t[i] == 's') {
      if (t[i-k] == 's') {
        t[i] = '0';
      }
      else {
        ans += r;
      }
    }
    else {
      if (t[i-k] == 'p') {
        t[i] = '0';
      }
      else {
        ans += s;
      }
    }
  }
  cout << ans << '\n';
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int a, b;
	cin >> a >> b;
	cout << max(0, a - 2 * b);

	return 0;
}



Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

a,b = I()
if a*b%2 == 0:
    print('Even')
else:
    print('Odd')

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

long long count(long long low, long long high, long long div){

    if(low % div == 0 && low > 0)
        return high / div - low / div + 1;

    return high / div - low / div;

}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long n, k;
    cin >> n >> k;

    long long tot = 0;

    for(long long b = k + 1; b <= n; ++b){

        // a % b >= k

        // b - k valid remainders

        long long lowest    = k;
        long long remainder = n % b;
        long long highest   = n - n % b;

        //cout << highest << " " << (b - k) * count(lowest, highest, b) + max(0LL, remainder - k + 1) << endl;

        tot += (b - k) * count(lowest, highest, b) + max(0LL, remainder - (k == 0 ? 1 : k) + 1);

    }

    cout << tot;

    return 0;
}


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

int main() {
  string N;
  cin >> N;
  
  if(N.at(0) != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  
  auto itr = count(N.begin()+2, N.end()-1, 'C');
  if(itr != 1){
    cout << "WA" << endl;
    return 0;
  }

  int count = 0;
  for ( int i = 0; i < N.size(); i++){
    if(isupper(N.at(i))) count++;
  }
    
  if (count != 2){
    cout << "WA" << endl;
    return 0;
  }
       
  cout << "AC" << endl;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int h,w;
vector<int> dp;

bool dfs(vector<char> &ch,vector<string> &c,int s){
  if(dp[s]!=-1) return dp[s];
  if(s==(1<<ch.size())-1){
    return true;
  }
  bool isok=false;
  for(int col=0;col<ch.size();col++){
    bool piyo=true;
    if(s&(1<<col)) continue; 
    int l=100;
    int r=0;
    int u=100;
    int b=0;      
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(c[i][j]==ch[col]){
	  l=min(l,j);
	  r=max(r,j);
	  u=min(u,i);
	  b=max(b,i);
	}
      } 
    }
    b++,r++;
    stack<pair<int,int>> st;
    for(int i=u;i<b;i++){
      for(int j=l;j<r;j++){
	if(!isalpha(c[i][j])){
	  piyo=false;
	}
	else{
	  if(c[i][j]==ch[col]){
	    c[i][j]='.';
	    st.push(make_pair(i,j));
	  }
	}	    
      }
    }
    piyo&=dfs(ch,c,s+(1<<col));
    while(!st.empty()){
      pair<int,int> val=st.top();st.pop();
      c[val.first][val.second]=ch[col];
    }
    isok|=piyo;
  }
  return dp[s]=isok;
}


int main(){
  int n;
  cin>>n;
  for(int loop=0;loop<n;loop++){
    dp.clear();

    cin>>h>>w;
    vector<string> c(h);
    for(auto &v:c) cin>>v;
    set<char> s;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(c[i][j]!='.') s.insert(c[i][j]);
      }
    }
    vector<char> ch(s.begin(),s.end());
    dp.resize((1<<ch.size())+1,-1);
    bool res=dfs(ch,c,0); 
    cout<<(res ? "SAFE" : "SUSPICIOUS")<<endl;
  }
  return 0;

}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int a,b,c,k;
  cin>>a>>b>>c;
  cin>>k;
  int d=0;
  while(b<=a) b=b*2,d++;
  while(c<=b) c=c*2,d++;
  if(d<=k) cout<<"Yes\n";
  else cout<<"No\n";
  //cout<<d;
  return 0;
}


Measured memory_bytes: 3620
A,B,C,X,Y=map(int,input().split())

if A+B<=2*C:
    print(A*X+B*Y)
    
else:
    if X>=Y:
        print(min(A*(X-Y)+C*Y*2,C*X*2))
    else:
        print(min(B*(Y-X)+C*X*2,C*Y*2))

Measured memory_bytes: 9120
n,m=map(int,input().split())
ac = [0]*(n+1)
wa = [0]*(n+1)
for _ in range(m):
  p,s = tuple(input().split())
  p = int(p)
  if ac[p]==1: continue
  if s == 'WA': wa[p]+=1
  else: ac[p] = 1
pena = 0
for a,w in zip(ac,wa):
  pena += a*w
print(sum(ac),pena)

Measured memory_bytes: 10388
n = int(input())
w = []
while True:
  try:
    w.append(input())
  except:
    break

uni = len(list(set(w)))
if uni!=n:
  print("No")
  exit()
  
for i in range(n-1):
  if w[i][-1]==w[i+1][0]:
    continue
  else:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
// Prioridade
typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (int)(b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)/__gcd(a, b)) * b)
#define W(x) cerr << "\033[31m"<<  #x << " = " << x << "\033[0m" << endl;
// fim da Prioridade
int dp[11][10][2][2];
int seen[11][10][2][2];
int timer = 0;
string s;
int solve(int idx = 0, int last = 0, int can = 0, int put = 0){
	if(idx == (int)s.size()){
		return put;
	}
	if(seen[idx][last][can][put] == timer) return dp[idx][last][can][put]; 
	seen[idx][last][can][put] = timer;
	int ans = 0;
	if(!idx || !put){
		int num = can ? 9 : s[idx] - '0';
		for(int i = 0; i <= num ; i++){
			ans += solve(idx + 1, i, can | (i != num), put | (i != 0));
		}
	}else{
		int num = can ? 9 : s[idx] - '0';
		for(int i = -1; i <= 1; i++){
			if(0 <= last + i and last + i <= num){
				ans += solve(idx + 1, last + i, can | ((last + i) != num), 1);
			}
		}
	}
	return dp[idx][last][can][put] = ans;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll lo = 1LL, hi = 3234566670LL, mid;
	int k;	
	cin >> k;
	while(lo <= hi){
		mid = (lo + hi)>>1;
		s = to_string(mid);
		timer++;
		if(solve() < k){
			lo = mid + 1;
		}else{
			hi = mid - 1;
		}
	}
	cout << hi + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<vector>
 
#define mx(ans, cnt) ans = max(ans, cnt)
#define fauto(a) for(auto i : a) cout << i << " "; cout << endl;
#define sp(n) fixed << setprecision(n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define _ << " " <<
#define swp(x, y) if (x > y) swap(x, y);
#define swpg(x, y) if (x < y) swap(x, y);
#define ff first
#define ss second
#define xx first
#define yy second
#define pb push_back
#define nn end1
 
 
using ll = long long;
using ull = unsigned long long;
using namespace std;
int main ()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,i,j,k,c=0;
        vector<ll> v;
        cin>>n;
        for(i=0;i<n;i++)
        {ll q; cin>>q; v.pb(q);}
        for(i=0;i<n;i++)
        {
            for(j=i+1;j<n;j++)
            {
                if(v[i]!=v[j])
                {
                    for(k=j+1;k<n;k++)
                    {
                        if(v[i]!=v[k] && v[j]!=v[k])
                        {
                            if((v[i]+v[j] > v[k])&&(v[i]+v[k] > v[j])&&(v[k]+v[j] > v[i]))
                            {c++;}
                        }
                    }
                }
                
            }
        }
        cout<<c<<endl;
    }
    return 0;
}

Measured memory_bytes: 3616
cnt = [0]*(10**6+1)
conv = [0]*(10**6+1)

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

for i in A:
    cnt[i] += 1

ans = 0##割り切れないものの数
for i in range(1,10**6+1):
    if cnt[i] == 1 and conv[i] == 0:##配列に1回のみ出現&&他の倍数でない
        ans += 1 
    if conv[i] == 1 or cnt[i] == 0:
        continue
    for j in range(10**6//i+1):##その数の倍数をメモ
        conv[i*j] = 1

print(ans)

Measured memory_bytes: 47696
import java.util.*;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int size = Integer.parseInt(sc.nextLine());
      int[] arr = new int[size];
      
      String[] input = sc.nextLine().split(" ");
      
      for(int i = 0; i < size; i ++) {
         arr[i] = Integer.parseInt(input[i]);
      }
      printArray(arr);
      
      for(int i = 1; i < size; i ++) {
         int key = arr[i];
         int index = i - 1;
         
         while (index >= 0 && arr[index] > key) {
            arr[index + 1] = arr[index];
            index --;
         }
         
         arr[index + 1] = key;
         printArray(arr);
      }
   }//main
   public static void printArray(int[] arr) {
      for(int i = 0; i < arr.length; i ++) {
         System.out.print(arr[i]);
         if(i != arr.length - 1) {
            System.out.print(" ");
         } else {
            System.out.println();
         }
      }
         
   }
      
      
}


Measured memory_bytes: 33928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 202;
const ll MOD = 998244353;

typedef complex<ll> point;

ll cross (const point &p1, const point &p2) {
    return (conj(p1)*p2).imag();
}

ll mpow (ll bs, ll ep) {
    ll ret = 1;
    while (ep) {
        if (ep & 1) {
            ret = ret * bs % MOD;
        }
        ep >>= 1;
        bs = bs * bs % MOD;
    }
    return ret;
}

int n;
ll ans;
point p[MAXN];

ll md (ll x) {
    return (x % MOD + MOD) % MOD;
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;
    ans = mpow(2, n) - 1 - n;
    REP (i, n) {
        int x, y;
        cin >> x >> y;
        p[i] = {x, y};
    }

    REP (i, n) {
        REP (j, i) {
            ll c = 0;
            REP (k, n) {
                if (cross(p[i]-p[j], p[k]-p[j]) == 0) {
                    c++;
                }
            }
            ans -= md(mpow(2, c) - 1 - c) * mpow(c*(c-1)/2, MOD-2) % MOD;
            ans = md(ans);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 0
minus = 0
mimax = - float('inf')
B = []
for i in range(N):
    if A[i] < 0:
        minus += 1
        B.append(-A[i])
    else:
        B.append(A[i])

if minus % 2 == 0:
    print(sum(B))
else:
    print(sum(B) - 2 * min(B))




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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> Interval;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}
const int maxn = 1e5+5;
int A[maxn];

int main()
{
    int N;
    cin >> N;
    int min_h = maxn;
    int max_h = 0;
    _for(i,0,N){
        cin >> A[i];
        min_h = min(min_h,A[i]);
        max_h = max(max_h,A[i]);
    }

    if(max_h > min_h + 1){
        printf("No\n");
    }
    else if(max_h == min_h + 1){
        int cmin = 0,cmax = 0;
        int ok = 1;
        _for(i,0,N){
            if(A[i] == min_h) cmin++;
            else cmax++;
        }
        if(cmin >= max_h) ok = 0;
        max_h -= cmin;
        if(cmax/2 < max_h) ok = 0;
        if(ok) printf("Yes\n");
        else printf("No\n");
    }
    else{
        if(N == max_h+1){
            printf("Yes\n");
            return 0;
        }
        if(N/2 >= max_h){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }

    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sd second
#define ft first

#define ios                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int32_t main()
{
    ios;
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    map<int, int> mp, rmp;
    mp[1] = 0;
    rmp[0] = 1;
    int last = 1, i = 0, temp = k;
    bool flag = false;

    while (k != 0)
    {
        if (mp.find(a[last - 1]) == mp.end())
        {
            mp[a[last - 1]] = ++i;
            rmp[i] = a[last - 1];
            last = a[last - 1];
            k--;
        }
        else
        {
            flag = true;
            break;
        }
    }
    if (!flag)
    {
        cout << last << endl;
    }
    else
    {
        int len = i - mp[a[last - 1]] + 1, beg = mp[a[last - 1]];
        int index = beg + (temp - beg) % len;
        if (beg == 0)
        {
            cout << rmp[temp % len] << endl;
        }
        else
        {
            cout << rmp[index] << endl;
        }
    }
    return 0;
}

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

int main() {
  int64_t N;
  cin >> N;
  int64_t sum;
  sum = 0;
  for(int i = 1;i < N + 1; i++){
    if((i % 3 == 0)||(i % 5 == 0)){
      continue;
    }
    else{
      sum += i;
    }
  }
  cout << sum << endl;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};




int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 


  int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<"\n";


}

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


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

  int N, M;
  cin >> N >> M;
  dsu d(N);

  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    if(!d.same(x, y)){
      d.merge(x, y);
    }
  }

  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    A[i] = d.leader(i);
  }
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  
  ll ans = A.size() - 1;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4440
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    int c = sc.nextInt();
	    
	    if(a+b+c == 17) {
	    	System.out.println("YES");
	    }else {
			System.out.println("NO");
		}
	}
	
}

Measured memory_bytes: 21972
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)

	x := make([][]int, n)
	for i := 0; i < n; i++ {
		x[i] = make([]int, d)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < d; j++ {
			fmt.Scan(&x[i][j])
		}
	}

	c := 0

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i == j || i > j {
				continue
			}
			sum := 0.0
			for k := 0; k < d; k++ {
			 	sum += math.Pow(float64(x[i][k] - x[j][k]), 2)
			}
			dist := math.Sqrt(sum)
			if math.Ceil(dist) == math.Trunc(dist) {
				c++
			}
		}
	}
	fmt.Println(c)
}


Measured memory_bytes: 512
def count2(a):
    cnt = 0
    while 1:
        if a % 2 == 0:
            a = a / 2
            cnt += 1
        else:
            return cnt

N = int(input())
A = list(map(int, input().strip().split(' ')))
print(sum([count2(a) for a in A]))

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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, ll> P;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

ll pow2(ll a) {
    ll b = a;
    b *= a;
    b *= a;
    b *= a;
    b *= a;
    return b;
}


int main() {

    ll x;
    cin >> x;
    vector<P> xs;

    for (ll i = 0; pow2(i) <= 10e17; i++) {
        xs.emplace_back(i, pow2(i));
        xs.emplace_back(-i, pow2(-i));
    }

    for (P a : xs) {
        for (P b : xs) {
            if (a.second - b.second == x) {
                cout << a.first << ' ' << b.first << endl;
                ret();
            }
        }
    }


}

Measured memory_bytes: 3772
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std ;
 
typedef long long ll ;
typedef long double ld ;

 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = ( int ) 1e5 + 10 ;

int n , cnt [ N ] , m ; 

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m ;
	while ( m -- ) {
		int u , v ;
		cin >> u >> v ;
		++ cnt [ -- u ] ;
		++ cnt [ -- v ] ; 
	}
	for ( int j = 0 ; j < n ; ++ j )
		if ( cnt [ j ] & 1 )
			return cout << "NO\n" , 0 ;
	cout << "YES\n" ; 
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
#define mod 1000000007
#define sz size();
using namespace std;
ll n,m,a,b,parent[N],child[N];

ll Parent(ll x){
	if(x!=parent[x])parent[x]=Parent(parent[x]);
	return parent[x];
}

void merge(ll x,ll y){
	x=Parent(x);
	y=Parent(y);
	if(x==y)return;
	if(child[x]<child[y])swap(x,y);
	parent[y]=x;
	child[x]+=child[y];
	return;
}

int main(){

	ios::sync_with_stdio(0);
	
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		child[i]=1;
		parent[i]=i;
	}
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		merge(a,b);
	}
	ll ans=-1;
	for(int i=1;i<=n;i++){
		if(child[Parent(i)]!=0)ans++,child[Parent(i)]=0;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 5112
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c, d; cin >> a >> b >> c >> d;

    int l = a + b, r = c + d;
    string res = "Balanced";
    if(l > r){
        res = "Left";
    }
    else if(l < r){
        res = "Right";
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
s= input()
a=""
for i in range(len(s)):
    c = s[i]
    if i == k-1:
      if s[k-1] == "A":
        c = "a"
      elif s[k-1] == "B":
        c = "b"
      elif s[k-1] =="C":
        c = "c"
    a = a+c
print(a)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans=0,aa,bb;
	cin>>aa>>bb;
	while(1)
	{
		int ta=1.0*ans*0.08,tb=1.0*ans*0.1;
		if((ta>=aa)&&(tb>=bb)) break;
		ans+=1000;
	}
	ans-=1000;
	while(1)
	{
		int ta=1.0*ans*0.08,tb=1.0*ans*0.1;
		if((ta>=aa)&&(tb>=bb)) break;
		++ans;
	}
	int ta=1.0*ans*0.08,tb=1.0*ans*0.1;
	if((ta==aa)&&(tb==bb)) printf("%d\n",ans);
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 256
##S->H->C->D
$array=Array.new(4).map{Array.new(14, 0)}
$suits=["S","H","C","D"]
N=gets.to_i
i=0
def suit(str)
 if(str=="S")
  return 0
 elsif(str=="H")
  return 1
 elsif(str=="C")
  return 2
 else
  return 3
end
end
while(i<N)
s,a=gets.chomp.split(" ").map(&:to_s);
 $array[suit(s)][a.to_i]=1
i=i+1
end
for m in 0..3 do
 for n in 1..13 do
  if$array[m][n]==0
   print("#{$suits[m]} #{n}\n")
  end
 end
end


Measured memory_bytes: 6876
n,m = map(int,input().split())
listA = [list(map(int, input().split())) for i in range(n)]
listB = [list(map(int, input().split())) for j in range(m)]
listC=[]

for k in range(n):
  b=0
  c=0
  for l in range(m):
    a=abs(listA[k][0]-listB[l][0])+abs(listA[k][1]-listB[l][1])
    if a<b or l==0:
      b=a
      c=l
  print(c+1)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

// 一行読み出し
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 文字列リバース関数
func strReverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

// 引数個の数値を読み込む
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func main() {
	var l, r int
	fmt.Scan(&l, &r)

	if l+4038 < r {
		r = l + 4038
	}

	ans := 2018
	for i := l; i <= r; i++ {
		for j := i + 1; j <= r; j++ {
			x := (i * j) % 2019
			if x < ans {
				ans = x
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640