akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  FromDihPout
 *    created: 2020-07-29
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vector<int> range = {3200, 2800, 2400, 2000, 1600, 1200, 800, 400, 1};
    const int COLS = range.size();
    
    int n;
    cin >> n;
    vector<int> cnt(COLS);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        for (int j = 0; j < COLS; j++) {
            if (x >= range[j]) {
                cnt[j]++;
                break;
            }
        }
    }
    
    int unique = 0;
    for (int i = 1; i < COLS; i++) {
        unique += cnt[i] > 0;
    }
    
    if (unique == 0 && cnt[0] > 0) {
        cout << 1 << ' ';
    }
    else {
        cout << unique << ' ';
    }
    cout <<  unique + cnt[0] << '\n';
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string s, t;
int z1[600005], z2[600005];

void Z_algorithm(string s, int z[])
{
	z[0] = s.size();
	
	int x = 0, y = 0;
	for(int i = 1; i < s.size(); i++){
		if(i > y){
			z[i] = 0;
			for(int j = 0; j < s.size(); j++){
				if(i+j > s.size() || s[i+j] != s[j]) break;
				z[i]++;
			}
			x = i, y = i + z[i] - 1;
		}
		else if(i + z[i-x] <= y) z[i] = z[i-x];
		else{
			z[i] = y-i+1;
			for(int j = y-i+1; j < s.size(); j++){
				if(i+j > s.size() || s[i+j] != s[j]) break;
				z[i]++;
			}
			x = i, y = i + z[i] - 1;
		}
	}
}

int main(void)
{
	cin >> s >> t;
	
	string a = t + "#" + s;
	string b = s + "#" + t;
	reverse(b.begin(), b.end());
	
	Z_algorithm(a, z1);
	Z_algorithm(b, z2);
	
	int ans = 0;
	for(int i = 0; i <= s.size() - t.size() ; i++){
		if(z1[i+t.size()+1] + z2[s.size()-i+1] == t.size() - 1) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

int N, M, Q;
veci A(10, 1);
vector<veci> q;

ll recursive(int d, int n, ll best) {
    if (d < N) {

        if (n > M) {
            if (d == 0) return best;
            return recursive(d - 1, A[d - 1] + 1, best);
        }
        A[d] = n;
        return recursive(d + 1, n, best);
    }

    for (int i = n; i <= M; ++i) {
        A[d] = i;
        ll ans = 0;
        for (int k = 0; k < Q; ++k) {
            if (A[q[k][1]] - A[q[k][0]] == q[k][2]) ans += q[k][3];
        }

        best = max(best, ans);
    }

    return recursive(d - 1, n + 1, best);

}

int main(void) {
    cin >> N >> M >> Q;

    q.assign(Q, veci(4, 0));
    rep(i, Q) {
        cin >> q[i][0] >> q[i][1] >> q[i][2] >> q[i][3];
        q[i][0]--;
        q[i][1]--;
    }

    ll ans = recursive(0, 1, 0);

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int X, Y;
  cin >> X >> Y;
  bool exist = false;
  for (int i=0; i<=X; i++) {
    // 鶴がi匹、亀がX-i匹
    if (2*i+4*(X-i)==Y) {
      exist = true;
      cout << "Yes" << endl;
      break;
    }
  }
  if (!exist) cout << "No" << endl;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vvi to(n);
  vvi id(n);
  vi co(n - 1);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].push_back(b);
    to[b].push_back(a);
    id[a].push_back(i);
    id[b].push_back(i);
  }
  int mx = -1;
  rep(i, n) maxs(mx, (int)to[i].size());
  dump(mx);

  deque<P> q;
  vector<int> used(n);
  q.push_back(P(0, 0));
  while (!q.empty()) {
    int u, c;
    tie(u, c) = q.front();
    q.pop_front();
    if (used[u]) continue;
    used[u] = 1;
    rep(i, to[u].size()) {
      int v = to[u][i];
      if (used[v]) continue;
      c = (c + 1) % mx;
      co[id[u][i]] = c;
      dump(id[u][i]);
      q.push_back(P(v, c));
    }
  }
  dump(co);
  cout << mx << endl;
  rep(i, n - 1) cout << co[i] + 1 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
int main()
{
      ios::sync_with_stdio(false),cin.tie(0), cout.tie(0);
      int k , a, b;
      cin >> k >> a >> b;
      for (int i=a; i<=b; i++)
      {
            if (i%k==0)
            {
                  cout << "OK" << endl;
                  return 0;
            }
      }cout << "NG" << endl;
 	return 0;
}


Measured memory_bytes: 3640
package main

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

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n, m := scanInt(), scanInt()
	fmt.Println((n*(n-1))/2 + (m*(m-1))/2)
}


Measured memory_bytes: 1772
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int t[18][18];
int dx[2]={0,-1};
int dy[2]={-1,0};
int main()
{
	while(1)
	{
		memset(t,0,sizeof(t));
		int a,b;
		cin >> a >> b;
		if(a==0&&b==0)break;
		int n;
		cin >> n;
		for(int i=0;i<n;i++)
		{
			int p,q;
			cin >> p >> q;
			t[p][q]=-1;
		}
		for(int i=1;i<=a;i++)
		{
			if(t[i][1]==-1)break;
			t[i][1]=1;
		}
		for(int i=1;i<=b;i++)
		{
			if(t[1][i]==-1)break;
			t[1][i]=1;
		}
		for(int i=2;i<=b;i++)
		{
			for(int j=2;j<=a;j++)
			{
				if(t[j][i]==-1)continue;
				for(int k=0;k<2;k++)
				{
					if(t[j+dx[k]][i+dy[k]]==-1)continue;
					t[j][i]+=t[j+dx[k]][i+dy[k]];
				}
			}
		}
		cout << t[a][b] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from __future__ import division
import math


def get_min(w, h):
    m = 1e11
    for x in [w // 3, w // 3 + 1]:
        if x == 0: continue
        a = [x*h, (w-x)*(h//2), (w-x)*(h - h//2)]
        print a
        m = min(m, max(a) - min(a))
    return m

digits = raw_input()
a, b = [int(x) for x in digits.split(' ')]
g_1 = [1, 3, 5, 7, 8, 10, 12]
g_2 = [4, 6, 9, 11]
g_3 = [2]
if (a in g_1 and b in g_1) or (a in g_2 and b in g_2) or (a in g_3 and b in g_3):
    print 'Yes'
else:
    print "No"

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

int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
int W, H;
string mem[20];
bool res[20][20];

int dfs(int sx, int sy)
{
  for(int i = 0; i < 20; i++)
    for(int j = 0; j < 20; j++)
      res[i][j] = 0;
  queue<int> q;
  q.push(sx);
  q.push(sy);
  while(!q.empty())
  {
    int x = q.front(); q.pop();
    int y = q.front(); q.pop();
    res[y][x] = true;
    for(int i = 0; i < 4; i++)
    {
      
      int tx = x + dx[i];
      int ty = y + dy[i];
      if(tx >= 0 && ty >= 0 && tx < W && ty < H && mem[ty][tx] == '.' && !res[ty][tx])
      {
        q.push(tx);
        q.push(ty);
      }
    }
  }
  int ans = 0;
  for(int y = 0; y < H; y++)
    for(int x = 0; x < W; x++)
      ans += res[y][x];
  return ans;
}

int main()
{
loop:
  for(int i = 0; i < 20; i++)
    mem[i] = "";
  int sx = -1, sy;
  cin >> W >> H;
  if(!(W || H))
    return 0;
  for(int i = 0; i < H; i++)
  {
    cin >> mem[i];
    if(sx != -1)
      continue;
    for(int j = 0; j < W; j++)
    {
      if(mem[i][j] == '@')
      {
        sx = j;
        sy = i;
        break;
      }
    }
  }
  cout << dfs(sx, sy) << endl;
  goto loop;
}

Measured memory_bytes: 4256
#include <cstdio>
#include <cstring>

typedef struct{
	char name[10];
	int time;
}QUEUE;

QUEUE q[1000000];
int head, tail;

void enqueue(char *name, int time){
	int len = strlen(name);
	for(int i = 0; i < len; i++){
		q[tail].name[i] = name[i];
	}
	q[tail].time = time;
	tail = (tail+1) % 1000000;
}

QUEUE *dequeue(){
	head = (head + 1) % 1000000;
	if(head == 0){
		return &q[999999];
	}
	return &q[head-1];
}

int main(){
	int n, q;
	char name[10];
	int time;
	QUEUE *queue;
	
	scanf("%d %d", &n, &q);
	for(int i = 0; i < n; i++){
		scanf("%s %d", name, &time);
		enqueue(name, time);
	}
	time = 0;
	while(tail != head){
		queue = dequeue();
		queue->time -= q;
		time += q;
		if(queue->time <= 0){
			time += queue->time;
			printf("%s %d\n", queue->name, time);
		}else {
			enqueue(queue->name, queue->time);
		}
	}
	return 0;
}

Measured memory_bytes: 5124
n = int(input())
a = [int(input()) for i in range(n)]

a.sort()
ans = sum(a)

if ans % 10 != 0:
    print(ans)
    exit()
for i in range(n):
    if a[i] % 10 != 0:
        print(ans - a[i])
        exit()
print(0)


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
//#include <queue>

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

using namespace std;

typedef long long ll;

const long long int INF = 1 << 30; //10^10
const ll MOD = 998244353;

inline void maxch(int& a, int b) { if (a < b) a = b; }



int main() {
	int n;
	cin >> n;
	vector<char> s(n);
	rep(i,n) cin >> s[i];
	bool yes = true;
	if(s.size() % 2 == 0) {
	  rep(i,s.size() / 2) if(s[i] != s[i + s.size()/2]) {yes = false; break;}
	  if(yes) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(lambda x: int(x)-1, input().split())
        edges[a].append(b)
        edges[b].append(a)

    visited = [False]*N
    visited[0] = True
    ans = 0

    def dfs(v: int):
        nonlocal visited
        nonlocal ans
        if all(visited):
            ans += 1
            return
        for n in edges[v]:
            if visited[n]:
                continue
            visited[n] = True
            dfs(n)
            visited[n] = False
        return

    dfs(0)
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n;cin>>n;
  string s;
  string word="MARCH";
  map<char,ll>mp;
  rep(i,n){
    cin>>s;
    mp[s[0]]++;
  }

  ll ans=0;

  rep(i,word.size()-2){
    for(int j=i+1;j<word.size()-1;j++){
      for(int k=j+1;k<word.size();k++){
        ans+=mp[word[i]]*mp[word[j]]*mp[word[k]];
      }
    }
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;

int main()
{
    int n,i,min=MOD,s1=0,s2=0;
    int w[100];
    scanf("%d",&n);
    for(i=0; i<n; i++) {
        scanf("%d",w+i);
        s2 += w[i];
    }
    for(i=0; i<n; i++) {
        s1 += w[i];
        s2 -= w[i];
        min = MIN(min, abs(s1-s2));
    }
    printf("%d",min);
    return 0;
}


Measured memory_bytes: 128
n = []
for i in range(3):
    n.extend(list(map(int, input().split())))

m = int(input())
for i in range(m):
    num = int(input())
    if num in n: n[n.index(num)] = 0

check = "No"

for j in range(3):
    if n[j + 0] == 0 and n[j + 3] == 0 and n[j + 6] == 0:
        check = "Yes"
        break
    if n[j * 3] == 0 and n[j * 3 + 1] == 0 and n[j * 3 + 2] == 0:
        check = "Yes"
        break

if n[0] == 0 and n[4] == 0 and n[8] == 0:
        check = "Yes"
if n[2] == 0 and n[4] == 0 and n[6] == 0:
        check = "Yes"

print(check)


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    int n,a,b;
    Int ans=0;
    cin>>n>>a>>b;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin>>p[i];
    }
    int cnt1=0,cnt2=0,cnt3=0;
    for (int j = 0; j < n  ; ++j) {
        if(p[j]<=a)cnt1++;
        else if(p[j]<=b) cnt2++;
        else cnt3++;
    }
    ans=min({cnt1,cnt2,cnt3});


    cout<<ans;

    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	vector<pii> v;
	REP(i, n){
		int x;
		cin >> x;
		v.eb(x, 0);
	}
	REP(i, m){
		int x;
		cin >> x;
		v.eb(x, 1);
	}
	sort(ALL(v));
	ll ans = 0;
	for(const auto &it : v){
		int x, t; tie(x, t) = it;
		if(t == 0){
			ans += (ll)(m + 1) * x;
			n --;
		}else{
			ans += (ll)(n + 1) * x;
			m --;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2420
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

int N, M;

int IsBipartiteGraph(const vector<vector<int>> &g) {
  int n = g.size();
  vector<int> color(n, -1);
  int white_cnt = 0;
  function<bool(int, int, int)> dfs = [&](int u, int prev, int c) {
    color[u] = c;
    if (c == 1) white_cnt++;
    for (auto v : g[u])
      if (v != prev) {
        if (color[v] == -1) {
          if (!dfs(v, u, 1 - c)) return false;
        } else if (color[v] != 1 - c) {
          return false;
        }
      }
    return true;
  };
  if (!dfs(0, -1, 0)) return 0;
  return white_cnt;
}

signed main() {
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int tmp = IsBipartiteGraph(G);
  if (tmp) {
    cout << tmp * (N - tmp) - M << endl;
  } else {
    cout << N * (N - 1) / 2 - M << endl;
  }
}


Measured memory_bytes: 7808
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int n,maxv = 0;
  cin >> n;
  vector<int> v(n),c(n);
  for (int i = 0; i < n; i++){
    cin >> v[i];
  }
  for (int i = 0; i < n; i++){
    cin >> c[i];
    if (v[i] - c[i] > 0){
      maxv += v[i] - c[i];
    }
  }
  cout << maxv << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
	int n = scanner.nextInt();
	int max = 0;
	int min = 1000;
	for (int i = 0; i < n; i++) {
		int t = scanner.nextInt();
		if (t > max) {
			max = t;
		}
		if (t < min) {
			min = t;
		}
	}
	System.out.println(max-min);
	scanner.close();
}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    ll x;
    if (B <= N)x = B-1;
    else x = N;

    cout << (A*x/B) - A*(x/B) << endl;

}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans=0;
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int x=0,y=0;
  rep(i,n){
    if(i%2==0) x+=a[i];
    else y+=a[i];
  }
  cout << x-y << endl;
}

Measured memory_bytes: 3564
n = int(input())
ans = [0]*10001

for i in range(1, 101):
    for j in range(1, 101):
        for z in range(1, 101):
            aaa = i**2+j**2+z**2+i*j+j*z+z*i
            if aaa <= 10**4:
                ans[aaa] += 1
for i in range(n):
    print(ans[i+1])


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

using namespace std;
#define N 111111
typedef long long ll;

ll a[N],dp[N];
int n;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i];
    dp[0]=dp[1]=0; dp[2]=abs(a[2]-a[1]);
    for (int i=3; i<=n; i++){
        //dp[i]+=min(abs(a[i]-dp[i-1]),abs(a[i]-dp[i-2]));
        dp[i]+=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <tuple>

using namespace std;
using PLL = pair<long long, long long>;

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

	vector<PLL> vec(n);
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		vec[i] = make_pair(a, b);
	}

	sort(vec.begin(), vec.end(),
		[](const PLL &x, const PLL &y) {
			long long x_sum = x.first + x.second;
			long long y_sum = y.first + y.second;

			if (x_sum == y_sum) {
				return x.first > y.first;
			} else {
				return x_sum > y_sum;
			}
		}
	);

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			ans += vec[i].first;
		} else {
			ans -= vec[i].second;
		}
	}

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


Measured memory_bytes: 1792
# 直前の活動とその活動での幸福度の総和の最大値が分かっていれば良い

puts gets.to_i.times.map { gets.split.map &:to_i }.inject([0, 0, 0]) { |(a, b, c), (d, e, f)| [ [b + d, c + d].max, [a + e, c + e].max, [a + f, b + f].max ] }.max


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

int N, x;
VI as;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> N >> x;
	rep (i, N) {
		int a;
		cin >> a;
		as.pb(a);
	}
	LL ans = 0LL;
	rep (i, as.size() - 1) {
		if (as[i] + as[i + 1] > x) {
			int temp = as[i] + as[i + 1] - x;
			ans += temp;
			if (as[i + 1] - temp < 0) {
				as[i + 1] = 0;
				temp -= as[i + 1];
				as[i] -= temp;
			} else {
				as[i + 1] -= temp;
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 892
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP (i,m,n) for(int i=( int)m ; i < (int ) n ; ++i )
#define rep (i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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

int main() {
                string s;
                cin >> s;
                 int res = 0;
                 for(int i =0; i < s.size();i++) {
                                 if (s[ i] == '1') res++;
                }
                cout << res << endl;
                 return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn=85;
ll a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    ll cur=1000;
    for(int i=1;i<n;i++)
        if(a[i+1]>a[i])
            cur=cur%a[i]+cur/a[i]*a[i+1];
    printf("%lld\n",cur);
    return 0;
}


Measured memory_bytes: 1732
n=int(input())
l=list(map(int,input().split()))
l.sort()
count=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i]!=l[j] and l[j]!=l[k]:
                if l[i]+l[j]>l[k]:
                    count+=1
print(count)

Measured memory_bytes: 9196
import java.util.*;

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

    int n = sc.nextInt();
    int k = sc.nextInt();

    int ans = (int)Math.pow(k - 1, n - 1) * k;
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cassert>
#include <string.h>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n;i>0;i--)
#define  REP(i,a,b) for(int i=a;i<b;i++)
typedef long long int lld;
typedef vector<lld> vl;
typedef vector<int> vi;
typedef vector<string> vs;



//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();

int main() {

	int a,b;
	cin>>a>>b;
	cout<<max(a*2-1,max(b*2-1,a+b));
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <numeric>
#include <vector>
#include <math.h>
#include <string>
#include <queue>

using namespace std;

bool score[10000];

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

	int n = T / A;
	n *= B;

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  string s;
  cin >> s;
  if(int(s.size()) % 2 == 1) return cout << "No", 0;
  for(int i = 0; i < int(s.size()) - 1; i += 2){
    if(s[i] != 'h' || s[i + 1] != 'i') return cout << "No", 0;
  }
  cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>  // istringstream
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{   
    long long A;
    string B;
    cin >> A >> B;

    long long B_long = stoi(B.erase(1, 1));

    // long long B_100 = B * 100;
    // long long ans = A * B_100;

    cout << A*B_long/100 << endl;
    return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};

const int MOD = (int)(1e9) + 7;
int N; string S;
ll dp[100001][13];
int mod[13];

ll solve(){
    REP(i, N - 1){
        REP(j, 10) mod[j] = mod[j] * 10 % 13;
        if(S[N - 2 - i] == '?'){
            REP(j, 13){
                REP(k, 10){
                    dp[i + 1][(j + mod[k]) % 13] += dp[i][j];
                    dp[i + 1][(j + mod[k]) % 13] %= MOD;
                }
            }
        }else{
            int x = S[N - 2 - i] - '0';
            REP(j, 13){
                dp[i + 1][(j + mod[x]) % 13] += dp[i][j];
                dp[i + 1][(j + mod[x]) % 13] %= MOD;
            }
        }
    }
    /*
    REP(i, N){
        REP(j, 13){
            cerr << dp[i][j] << " ";
        }
        cerr << endl;
    }
    */
    return dp[N - 1][5];
}

signed main(){
    cin >> S;
    N = S.length();
    REP(i, N) REP(j, 13) dp[i][j] = 0;
    REP(j, 13){
        if(S[N - 1] == '?') dp[0][j] = (j < 10);
        else dp[0][(S[N - 1] - '0')] = 1;
        mod[j] = j;
    }
    PRINT(solve());
    return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
    vector<ll> L(87);L[0]=2;L[1]=1;
    rep0(i,85){
        L[i+2]=L[i+1]+L[i];
    }
    ll N; cin>>N;
    cout<<L[N]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
lld ctl(char x,char an='a') {return (lld)(x-an);}
char ltc(lld x,char an='a') {return (char)(x+an);}
#define bit(x,j) ((x>>j)&1)
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mxm(a,b) a = max(a,b)
#define mnm(a,b) a = min(a,b)
#define endl '\n'
#define fre freopen("1.in","r",stdin); freopen("1.out","w",stdout);
#define N 505
lld a[N][N],cc[N][3],cost[N][N];
int main()
{
    //sync;
    rep(i,0,3) rep(j,0,N) cc[j][i] = LLINF;
    lld n,c;
    cin>>n>>c;
    rep(i,1,c+1) rep(j,1,c+1) cin>>cost[i][j];
    rep(i,1,n+1) rep(j,1,n+1) cin>>a[i][j];
    rep(col,1,c+1) {
        lld curr[3];
        rep(i,0,3) curr[i] = 0;
        rep(i,1,n+1) rep(j,1,n+1) if(a[i][j] != col) curr[(i+j)%3] += cost[a[i][j]][col];
        rep(i,0,3) cc[col][i] = min(cc[col][i], curr[i]);
    }
    lld ans = LLINF;
    rep(i,1,c+1) rep(j,1,c+1) rep(k,1,c+1) {
        if(i==j or j==k or i==k) continue;
        ans = min(ans, cc[i][0] + cc[j][1] + cc[k][2]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline void read(rel &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  x=f?x:-x;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
int a=read(),b=read(),i,j,ans=0;
for (i=1;i<=a;++i){
  if (i==a){
    for (j=1;j<=b;++j) if (j==a) ++ans;
    }
  else{
    if (i==1||i==3||i==5||i==7||i==8||i==10||i==12){
      for (j=1;j<=31;++j) if (j==a) ++ans;
	  }
	else if (i==2){
	  for (j=1;j<=28;++j) if (j==a) ++ans;
	  }
	else
	for (j=1;j<=30;++j) if (j==a) ++ans;
    }
  }
cout<<ans;
}

Measured memory_bytes: 256
from collections import Counter
h, w, n = map(int,input().split())
x, y = map(int,input().split())
S = input()
T = input()
cs = Counter(S)
u = x
d = h-x+1
l = y
r = w-y+1
if not (u <= cs['U'] or d <= cs['D'] or l <= cs['L'] or r <= cs['R']):
    print('YES')
    exit()

a = x
if u <= cs['U']:
    for s, t in zip(S, T):
        if s == 'U':
            a -= 1
        if a < 1:
            print('NO')
            exit()
        if t == 'D' and a < h:
            a += 1
        if a < 1:
            print('NO')
            exit()
    
a = x   
if d <= cs['D']:
    for s, t in zip(S, T):
        if s == 'D':
            a += 1
        if a > h:
            print('NO')
            exit()
        if t == 'U' and a > 1:
            a -= 1
        if a > h:
            print('NO')
            exit()

a = y
if l <= cs['L']:
    for s, t in zip(S, T):
        if s == 'L':
            a -= 1
        if a < 1:
            print('NO')
            exit()
        if t == 'R' and a < w:
            a += 1
        if a < 1:
            print('NO')
            exit()
            
a = y
if r <= cs['R']:
    for s, t in zip(S, T):
        if s == 'R':
            a += 1
        if a > w:
            print('NO')
            exit()
        if t == 'L' and a > 1:
            a -= 1
        if a > w:
            print('NO')
            exit()

print('YES')

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

int main(){
  int N;
  cin >> N;
  int a[100];
  int A=0;
  int B=0;
  for(int i =0; i<N; i++){
    cin >>a[i];
  }
  sort(a,a+N,greater<int>());
  for(int i =0; i<N; i++){
    if(i%2==0){
      A+=a[i];
	}else{
      B +=a[i];
    }
  }
cout << A-B <<endl;
  return 0;
}

Measured memory_bytes: 256
num_weight = int(input())

weights = list(map(int, input().split(' ')))

deltas = []
total = sum(weights)

for i in range(1, num_weight):
    s1 = sum(weights[:i])
    s2 = total - s1
    delta = abs(s1 - s2)
    deltas.append(delta)

print(min(deltas))
exit(0)


Measured memory_bytes: 3060
d, n = map(int, input().split())
if d == 0:
    if n == 100:
        print(101)
    else:
        print(n)
elif d == 1:
    if n == 100:
        print(101*100)
    else:
        print(100*n)
else:
    if n == 100:
        print(101*10000)
    else:
        print(10000*n)

Measured memory_bytes: 9132
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> v;
int main()
{
    int a,b,c;

    cin >> a >> b >> c;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(),v.end());
    if(v[0] == 5 && v[1] == 5 && v[2] == 7)
    {
        cout << "YES" << endl;
    }
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let _: i32 = read();
    let mut a: Vec<i32> = read_vec();
    let mut count = 0;
    'outer: loop {
        for element in &mut a {
            if *element % 2 == 0 {
                *element /= 2;
            } else {
                break 'outer;
            }
        }
        count = count + 1;
    }
    println!("{}", count);
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n + 2, 0);
  int cost = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
    cost += abs(a[i] - a[i - 1]);
  }
  cost += abs(a[n]);
  debug(cost);
  for (int i = 1; i < n + 1; i++) {
    int ans = cost;
    ans -= abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
    ans += abs(a[i + 1] - a[i - 1]);
    cout << ans << '\n';
  }
  return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>

void selectionSort(int *A, int N)
{
    int minj, buff;
    int count = 0;
    for(int i = 0; i < N; i++)
    {
        minj = i;
        for(int j = i; j < N; j++)
        {
            if(A[j] < A[minj])
            {
                minj = j;
            }
        }
        if(i != minj){
            buff = A[i];
            A[i] = A[minj];
            A[minj] = buff;
            count++;
        }
        
    }
    for(int k = 0; k < N; k++){
        printf("%d", A[k]);
        if(k != N-1){
            printf(" ");
        }
    }
    printf("\n");
    printf("%d\n",count);
}

int main(void){
    int N, a;
    
    scanf("%d",&N);
    int A[N];
    
    for(int i = 0; i < N;i++)
    {
        scanf("%d",&a);
        A[i] = a;
    }
    selectionSort(A, N);
    return 0;
}



Measured memory_bytes: 1988
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	typedef pair<int,int> P;
	const int N=109,dx[2]={0,1},dy[4]={1,0};
	int mapx[N][N],n,m,dist[N][N];
	int main(){
		n=read<int>(),m=read<int>();
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++){
				char c;cin>>c;
				mapx[i][j]=c=='.';
			}

		dist[1][1]=1;
		for(int i=2;i<=m;i++) dist[1][i]=dist[1][i-1]+(mapx[1][i-1]^mapx[1][i]);
		for(int i=2;i<=n;i++){
			dist[i][1]=dist[i-1][1]+(mapx[i-1][1]^mapx[i][1]);
			for(int j=2;j<=m;j++)
				dist[i][j]=min(dist[i-1][j]+(mapx[i-1][j]^mapx[i][j]),dist[i][j-1]+(mapx[i][j-1]^mapx[i][j]));
		}
		int ans=(dist[n][m]+1)/2;
		if(dist[n][m]&1 && mapx[1][1]==1) ans--;
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen("flip.in","r",stdin);
	freopen("flip.out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 384
N, x = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

B = [min(a, x) for a in A]
for i in range(N - 1):
    su = B[i] + B[i + 1]
    if su > x:
        B[i + 1] -= su - x

print(sum(a - b for a, b in zip(A, B)))

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

int main() {
	int K, S;
	cin >> K >> S;
	int cnt = 0;
	for (int x = 0; x <= K; ++x) {
		for (int y = 0; y <= K; ++y) {
			int z = S - (x + y);
			if (0 <= z && z <= K) ++cnt;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3640
MOD = 10**9 + 7
n, m = [int(item) for item in input().split()]
x = [int(item) for item in input().split()]
y = [int(item) for item in input().split()]

x_total, y_total = 0, 0 
for i in range(1,n):
    x_total += (i * (n-i) * (x[i] - x[i-1])) % MOD
for i in range(1,m):
    y_total += (i * (m-i) * (y[i] - y[i-1])) % MOD
print((x_total * y_total)%MOD)

Measured memory_bytes: 19580
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import defaultdict
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
#import math

def run():
    X, N = map(int, input().split())
    P = list(map(int, sysread().split()))
    exist = [False] * 201
    for p in P:
        exist[p] = True
    resid = 0

    while True:
        if not exist[X - resid]:
            print(X - resid)
            return None
        if not exist[X + resid]:
            print(X+resid)
            return None
        resid += 1


if __name__ == "__main__":
    run()

Measured memory_bytes: 9204
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int N;
  int K;
  vector<int> h;

  cin >> N >> K;
  
  for (int i=0; i < N; i++) {
    int j;
    cin >> j;
    h.push_back(j);
  }
  sort(h.begin(), h.end());

  int res = 1000000000;
  for (int i = K - 1; i < N; i++) {
    int delta_h = h[i] - h[i - K + 1];
    
    //cout << delta_h << endl;
    //cout << h[i - K - 1] << "***" << endl;
    if (delta_h < res) res = delta_h;
  }
  cout << res;
}

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


#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ll long long


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int a, b, k;
    cin >> a >> b >> k;

    int at = 0;
    for ( int i = min(a, b); i >= 1; i-- ) {
    	if ( a % i == 0 and b % i == 0 ) {
    		at++;
    		if ( at == k ) {
    			cout << i << endl;
    			return 0;
    		}
    	}
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
sqN = N**0.5


def F(a, b):
    count = 0
    for i in range(10):
        a = a // 10
        b = b // 10
        count += 1
        if a <= 0 and b <= 0:
            break
    return count


minF = 10
for i in range(1, int(sqN)+1):
    if N % i == 0:
        f = F(i, N / i)
        minF = min(minF, f)

print(minF)


Measured memory_bytes: 3060
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    res = 0
    flag = True
    for c in '753':
        if s.count(c) == 0:
            flag = False
    res =  1 if flag else 0
    for c in '753':
        res += dfs(s+c)
    return res

print(dfs('0'))

Measured memory_bytes: 3060