akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if (l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if (r <= H && A[r] > A[largest]) largest = r;

  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int extract() {
  int maxv;
  if (H < 1) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key) {
  if (key < A[i]) return;
  A[i] = key;
  while (i > 1 && A[i / 2] < A[i]) {
    swap(A[i], A[i / 2]);
    i = i / 2;
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

int main() {
  int key;
  char com[10];

  while (1) {
    scanf("%s", com);
    if (com[0] == 'e' && com[1] == 'n') break;
    if(com[0] == 'i') {
      scanf("%d", &key);
      insert(key);
    } else {
      printf("%d\n", extract());
    }
  }

  return 0;
}



Measured memory_bytes: 6600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }


bool kaibun(string s){
  for(int i=0; i<sz(s)/2; i++){
    if(s[i]!=s[sz(s)-1-i]) return false;
  }
  return true;
}


int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int n=sz(s);
  string left="",right="";
  rep(i,n/2) left+=s[i];
  for(int i=n/2+1; i<n; i++) right+=s[i];
  //cout << left << endl;
  //cout << right << endl;
  if(kaibun(s)&&kaibun(left)&&kaibun(right)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

using namespace std;

int main(void) {
  long long n;
  cin >> n;
  //  cout << "n: " << n << endl;
  vector <long long> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    //    cout << "a[" << i << "]: " << a[i] << endl;
  }

  vector <bool> color(8);
  for(int i = 0; i < 8; i++) {
    color[i] = false;
    //    cout << "color[" << i << "]: " << color[i] << endl;
  }
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 8; j++) {
      if(400 * j <= a[i] && a[i] < 400 * (j + 1)) {
	color[j] = true;
	//	cout << "color[" << j << "]: " << color[j] << endl;
      }
    }
  }

  long long c = 0;
  for(int i = 0; i < 8; i++) {
    if(color[i]) {
      c++;
    }
  }
  long long joker = 0;
  for(int i = 0; i < n; i++) {
    if(a[i] >= 3200) {
      joker++;
    }
  }

  long long mx = joker + c;
  long long mn;
  if(c >= 1) {
    mn = c;
  }
  else {
    mn = 1;
  }

  cout << mn << " " << mx << endl;
}

Measured memory_bytes: 256
from collections import deque
h,w = map(int,input().split())
mapa=[]
mapa.append(''.join(['#' for _ in range(w+2)]))
dotn = 0
for i in range(h):
    temp = input()
    dotn+=temp.count('.')
    mapa.append('#'+temp+'#')
mapa.append(''.join(['#' for _ in range(w+2)]))
passed = [[False for _ in range(w+2)] for _ in range(h+2)]

def dircheck(cy,cx):
    if mapa[cy][cx]=='.' and not passed[cy][cx]:
        passed[cy][cx]=True
        return True
    else:
        return False    

q=deque()
q.append((1,1))
step=0
goaled=False
while True:
    newq=deque()
    while len(q)!=0:
        (y,x) = q.pop()
        if (y,x)==(h,w):
            goaled=True
            break
        else:
            for dy,dx in zip((y-1,y+1,y,y),(x,x,x-1,x+1)):
                if dircheck(dy,dx):newq.append((dy,dx))
    q = newq
    step+=1
    if goaled:
        print(dotn-step)        
        break
    if len(newq)==0:
        print(-1)
        break

Measured memory_bytes: 9436
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

template<typename T>
struct Graph{
    vector<T> nodes;
    map<T,vector<pair<T,ll> > > nexts;
    Graph(ll n,T initial){
        nodes.resize(n,initial);
    }
    Graph(ll n){
        nodes.resize(n);
    }
    Graph(vector<T> &a):nodes(a){}
    Graph(){}
    void add_edge(T &s,T &e,ll c){
        this->nexts[s].push_back({e,c});
    }
    map<T,ll> dijkstra(T &s){
        map<T,ll> dist;
        for(T tmp:this->nodes){
            dist[tmp] = inf;
        }
        priority_queue<pair<ll,T>,vector<pair<ll,T> >,greater<pair<ll,T> > > q;
        q.push({0,s});
        dist[s] = 0;
        while(q.empty() == false){
            pair<ll,T> now = q.top();
            q.pop();
            if(now.first > dist[now.second]) continue;
            dist[now.second] = now.first;
            for(pair<T,ll> next:this->nexts[now.second]){
                if(now.first + next.second < dist[next.first]){
                    dist[next.first] = now.first+next.second;
                    q.push({dist[next.first],next.first});
                }
            }
        }
        return dist;
    }
};

struct Node{
    ll x;
    Node(ll a): x(a){}
    Node(): x(1){}
    bool operator<(const Node &b)const{
        return this->x < b.x;
    }
};

int main(void){
    string s;
    cin>>s;
    sort(all(s));
    if(s == "abc") cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;
#define MAN 1000000000

//int ai[1000005];
int main(){
    long long n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);
    long long be,cost=0,next,walk;
    scanf("%lld",&be);//获取初始地点
    for(int i=2;i<=n;i++){
        scanf("%lld",&next);
        walk=(next-be)*a;
        if(walk<=b){//如果走花费的体力值更小，那么就选择走
            cost+=walk;
            be=next;
        }
        else{
            cost+=b;//选择飞过去
            be=next;
        }
    }
    printf("%lld\n",cost);
    return 0;
}



Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "First"; }
  string_type do_falsename() const { return "Second"; }
};

bool f(vector<ll> a) {
  bool lose = true;
  for (ll i: a) if (i != 1) lose = false;
  if (lose) return false;
  int c = 0;
  for (ll i: a) if (i % 2 == 0) ++c;
  if (c % 2) return true;
  if (c < int(a.size()) - 1) return false;
  for (ll &i: a) {
    if (i == 1) return false;
    if (i % 2) --i;
  }
  ll g = a[0];
  for (ll i: a) g = __gcd(g, i);
  for (ll &i: a) i /= g;
  return !f(a);
}

void solve(ll N, vector<ll> A) {
  cout << f(A) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> A(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &A[i]);
	}
	solve(N, A);
	return 0;
}


Measured memory_bytes: 20608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int H = GetInt();
		int W = GetInt();
		string[,] grid = new string[H, W];
		for(int i = 0; i < H; i++)
			for(int j = 0; j < W; j++)
				grid[i, j] = GetString();

		for(int i = 0; i < H; i++)
		{
			for(int j = 0; j < W; j++)
			{
				if(grid[i, j].Equals("snuke"))
				{
					Console.WriteLine($"{(char)(j + (int)'A')}{i + 1}");
					return;
				}
			}
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

int main() {

    int N;
    string S;
    cin >> N;
    cin >> S;
    int cntr = 0, cntb = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') cntr++;
        else cntb++;
    }
    if (cntr > cntb) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


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

int main(){
  string s;cin >>s;
  
  if(s.size()%2)cout << "No" << endl;
  else{
    bool ok = true;
    
    for(int i=0; i<s.size(); i++){
      if(i%2==0 && s[i]!='h'){
        ok = false;
        break;
      }
      if(i%2==1 && s[i]!='i'){
        ok = false;
        break;
      }
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        d: usize, x: usize,
        a_list: [usize; n],
    }
    let ans = (0..n).map(|i| {
        let a = a_list[i];
        let mut count = 1;
        let mut n = 1;
        while n * a + 1 <= d {
            n += 1;
            count += 1;
        }
        count
    }).sum::<usize>() + x;
    println!("{}", ans);
}


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

// in-short-use macros

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010


//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll x;
    cin>>x;
    ll ans=0;
    ans += 1000*(x/500) + 5*((x%500)/5);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
def e_friendships(N, K):
    if K > (N - 1) * (N - 2) // 2:
        return -1

    ans_graph = []
    for i in range(2, N + 1):
        ans_graph.append((1, i))  # スターの構成

    def append_edge(t, lst=[], count=0):  # t回最短距離が2の頂点を消すように辺を追加
        for i in range(2, N):
            for j in range(i + 1, N + 1):
                if count == t:
                    return lst
                lst.append((i, j))
                count += 1
        return lst

    ans_graph += append_edge((N - 1) * (N - 2) // 2 - K)
    ans_graph.insert(0, (len(ans_graph),))
    return '\n'.join([' '.join(map(str, row)) for row in ans_graph])

N, K = [int(i) for i in input().split()]
print(e_friendships(N, K))

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

int main(){
	while(1){
		int n;
		long a=0, b=0;
		
		
		scanf(" %d", &n);
		if(n==0) break;
		for(int i=0; i<n; ++i){
			int x, y;
			scanf(" %d %d", &x, &y);
			
			if(x>y) a+=x+y;
			else if(x<y) b+=x+y;
			else{
				a+=x; b+=y;
			}
		}
	
		printf("%ld %ld\n", a, b); 
	}

	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if (a > b) PRINT(a-1);
    else PRINT(a);
}


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

int main(){int n,m;cin>>n>>m; vector<char> s(n); rep(i,n)cin >> s[i];int sum=0;
           
           for(int i=0;i<n-1;i++){if(s[i]!=s[i+1])sum++;
                                 }
           int count=0; int ans=0;
            for(int i=0;i<m;i++){
             if(count<=sum){ans+=2;count++;}
                    else if(count<=sum+2){ans++; count++;}}
           
           for(int i=0;i<n-1;i++){
             if(s[i]==s[i+1]){
          ans++;}}
           if(ans>=n){ans=n-1;}
           cout << ans << endl;}

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

int main(){
    vector<char> C(6);

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

    int ans = 0;

    if(C[0] == C[5]){
        ans++;
    }
    if(C[1] == C[4]){
        ans++;
    }
    if(C[2] == C[3]){
        ans++;
    }

    if(ans == 3){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
        

    

} 

Measured memory_bytes: 3604
A,B=map(int,input().split())

def solve(n):
    if n % 2 == 0:
        if n//2 %2 == 0:
            return n
        else:
            return n^1
    else:
        if (n+1) // 2 %2 == 0:
            return 0
        else:
            return 1

print(solve(A-1)^solve(B))

Measured memory_bytes: 2940
using System;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] n = Console.ReadLine().Split(' ');
            float d = float.Parse(n[0]);
            float t = float.Parse(n[1]);
            float s = float.Parse(n[2]);
            float inTime = d / s;
            Console.WriteLine(inTime <= t ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 27532
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;

struct SegTree{
	int size;
	vector<llint> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = -inf;
	}
	
	void update(int i, llint val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = max(seg[i*2], seg[i*2+1]);
		}
	}

	llint query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return -inf;
		if(a <= l && r <= b) return seg[k];
		llint lval = query(a, b, k*2, l, (l+r)/2);
		llint rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return max(lval, rval);
	}
	llint query(int a, int b)
	{
		if(a > b) return -inf;
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint n;
llint h[200005], a[200005];
SegTree seg(18);
vector<llint> comp;

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> h[i];
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	for(int i = 1; i <= n; i++) comp.push_back(h[i]);
	sort(comp.begin(), comp.end());
	comp.erase(unique(comp.begin(), comp.end()), comp.end());
	for(int i = 1; i <= n; i++) h[i] = lower_bound(comp.begin(), comp.end(), h[i]) - comp.begin() + 1;
	
	seg.init();
	seg.update(0, 0);
	for(int i = 1; i <= n; i++){
		seg.update(h[i], seg.query(0, h[i]-1)+a[i]);
	}
	cout << seg.query(1, n) << endl;
	return 0;
}

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

char s[200005][11];
char *str[200005];
int a[200005];
bool cmp(const char* s1,const char *s2)
{
	return strcmp(s1,s2)<0;
}

int main ( )
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%s",s[i]);
		str[i]=s[i];
	}
	sort(str,str+n,cmp);
	int max=1;
	memset(a,0,sizeof(a));
	for(int i=0,j=0;i<n-1;i++)
	{
		if(i==j)
		a[j]=1;
		if(strcmp(str[i],str[i+1])==0) 
		{
			a[j]++;
			if(max<a[j])
				 max=a[j];
		}
		else j+=a[j];
		
	}
	if(strcmp(str[n-2],str[n-1])!=0) a[n-1]=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]==max) 
		printf("%s\n",str[i]);
	}
	return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

const int INF = (1<<30) - 1;

int tax(int a, int p){
    return a*(100+p)/100;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, y, s;
    while(cin>>x>>y>>s, x|y|s){
        int ans = 0;
        for(int i=1; i<1000; i++){
            for(int j=1; j<1000; j++){
                if(tax(i, x)+tax(j, x) == s){
                    ans = max(ans, tax(i, y)+tax(j, y));
                }
            }
        }
        cout << ans << endl;
    }
        
    return 0;
}

Measured memory_bytes: 1188
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 1001001001;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

int main() {
    ll N;
    cin >> N;
    vector<ll> num(N);
    rep(i, N)cin >> num[i];
    ll minest = INF;
    ll ans = 0;
    rep(i, N) {
        if (num[i] < minest) {
            ans++;
            minest = num[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;

constexpr int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return x ? mod - x : 0;}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}

  friend ostream& operator << (ostream& os, const mint& m) noexcept {
    return os << m.x;
  }

  friend istream& operator<< (istream& is, mint& m) noexcept {
    return is >> m.x;
  }
};

struct combination {
  vector<mint> fact, ifact;  // 階乗と階乗の逆元
  combination(int n):fact(n+1),ifact(n+1) {  // 階乗と階乗の逆元を n まで求める
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


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

  int x, y;
  cin >> x >> y;

  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  int steps = (x + y) / 3;
  int m = max(x, y) - min(x, y);

  if ((steps - m) % 2 != 0) {
    cout << 0 << endl;
    return 0;
  }

  combination comb(steps + 5);

  cout << comb(steps, (steps - m) / 2 + m) << endl;

  return 0;
}


Measured memory_bytes: 13736
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];

    vector<int> b(n);
    rep(i,n)b[a[i]-1]=i+1;
    rep(i,n)cout<<b[i]<<endl;
}


    

Measured memory_bytes: 4052
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,w=mp()
item=[lmp() for i in range(n)]
dp=[[0]*(w+1) for i in range(n+1)]
for i in range(n):
    for k in range(1,w+1):
        if k<item[i][0]:
            dp[i+1][k]=dp[i][k]
        else:
            dp[i+1][k]=max(dp[i][k],dp[i][k-item[i][0]]+item[i][1])
print(dp[-1][-1])

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int H[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>H[i];
	sort(H,H+N);
	ll sum=0;
	FOR(i,N-K) sum+=H[i];
	cout<<sum<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024
/* 
 * Project: AtCoder Beginners Contest 140 B - Buffet
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/23
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
#include <vector>
using namespace std;

uint16_t n;
vector<uint32_t> a, b, c;

void solve() {

    uint32_t sum = 0;
    uint32_t last = 21;
    for (int i=0;i<n;i++) {
        sum += b[a[i]-1];
        if (a[i] - last == 1) {
            sum += c[last-1];
        }
        last = a[i];
    }
    printf("%d\n",sum);

}

int main() {

    scanf("%hd", &n);
    uint32_t tmp = 0;
    for (int i=0;i<n;i++) {
        scanf("%d", &tmp);
        a.push_back(tmp);
    }
    for (int i=0;i<n;i++) {
        scanf("%d", &tmp);
        b.push_back(tmp);
    }
    for (int i=0;i<n-1;i++) {
        scanf("%d", &tmp);
        c.push_back(tmp);
    }

    solve();

}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[10010],y[10010];
string s,str;
int main(){
  double d;
  cin>>d;
  cout<<d*6.2831853;
  return 0;
}

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

using namespace std;


int32_t main(){

    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    int m,d;
    cin>>m>>d;
    int ans = 0;
    for(int i=1; i<=m;i++){
        for(int j = 11; j<=d; j++){
            int t = j;
            int d1 = t%10;
            int d2 = t/10%10;

            if(d1>=2&&d2>=2&&d1*d2==i)ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    jsc2019qual_a()
}

fun jsc2019qual_a() {
    val (month, day) = readLine()!!.split(" ").map { it.toInt() }

    var sum = 0
    for (m in 1..month) {
        for (d in 1..day) {
            val d1 = d % 10
            val d10 = d / 10
            if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) sum++
        }
    }

    println(sum)
}


Measured memory_bytes: 36128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String s = scan.next();

		char[] a = s.toCharArray();
		int total = 0;

		for(int i=0;i<a.length;i++) {
			total += Character.getNumericValue(a[i]);
		}

		if(total%9==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 40896
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n,m = invr()
    q = 1 << n
    w = [10 ** 18] * q
    w[0] = 0
    for i in range(m):
        a,b = invr()
        qw = 0
        for j in map(int,input().split()):
            qw = qw + (1 << (j - 1))
        for j in range(q - 1,-1,-1):
            w[j|qw] = min(w[j] + a,w[j | qw])
    print(-1 if w[-1] == 10 ** 18 else w[-1])
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1],1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)

def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))

def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

#-----------------------------------------------------------------------#
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 74488
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, x;
  cin >> a >> b >> x;
  cout << fixed << setprecision(20);
  if(x < a*b*a/2.0) {
    double c = (double)x/a*2/b;
    cout << 90 - atan(c/b)*180/M_PI << "\n";
  } else {
    double c = 2*b-(double)x/a*2/a;
    cout << 90 - atan(a/c)*180/M_PI << "\n";
  }
  return 0;
}


Measured memory_bytes: 4076
import numpy as np
s = list(input())
x, y = map(int, input().split())

X = [0]
Y = [0]

X_append = X.append
Y_append = Y.append

flag = True
tmp = 0
for i in s:
    if i == 'F':
        tmp += 1
    else:
        if flag:
            X_append(tmp)
        else:
            Y_append(tmp)
        tmp = 0
        flag = not flag

if flag:
    X_append(tmp)
else:
    Y_append(tmp)

# print (X)
# print (Y)

x -= X[1]
X[1] = 0

x = abs(x)
y = abs(y)

total_X = sum(X)
total_Y = sum(Y)

lst_X = np.zeros(total_X + 1, dtype = np.int32)
lst_X[0] = 1
for i in X:
    if i == 0:
        continue
    # print (lst_X)
    # print (lst_X[i:])
    # print (lst_X[:-i])
    # print (np.maximum(lst_X[i:], lst_X[:-i]))

    lst_X[i:] = np.maximum(lst_X[i:], lst_X[:-i])

# print (lst_X)

lst_Y = np.zeros(total_Y + 1)
lst_Y[0] = 1
for i in Y:
    if i == 0:
        continue
    lst_Y[i:] = np.maximum(lst_Y[i:], lst_Y[:-i])

if x > total_X or y > total_Y:
    print ('No')
    exit()

if (total_X - x) % 2 == (total_Y - y) % 2 == 0 and int(lst_X[(total_X - x) // 2]) == 1 and int(lst_Y[(total_Y - y) // 2]) == 1:
    print ('Yes')
else:
    print ('No')

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

using namespace std;

int main(){
    int ans = 0;
    int N;
    int a[101];
    cin >> N;
    //cout << N << endl;
    for(int i=0; i < N; i++){
        cin >> a[i];
    }
    a[N] = 0;
    // sort(a, a+N);
    // for(int i=0; i < N; i++){
    //     cout << a[i] << " ";
    // }
    int lem_ai=1;
    int p_slime=0;
    for(int i=0; i < N+1; i++){
        if (a[i] == p_slime){
            lem_ai++;
        }
        else {
            ans += (lem_ai / 2);
            p_slime = a[i];
            lem_ai = 1;
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

long long n,A[200000],B[200000],i;

int main()
{
    cin>>n;
    for (i=1;i<n;i++)
    {
        cin>>A[i];
        B[A[i]]++;
    }
    for (i=1;i<=n;i++)
    {
        cout<<B[i]<<'\n';
    }
    return 0;
}

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

int main() {
    string n;
    cin >> n;
    if(n[0] == '9' || n[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
N = [input() for _ in range(n)]
M = [input() for _ in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        N_ = []
        for k in range(m):
            N_.append(N[i+k][j:j+m])
        if N_ == M:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair
#define MOD 2019

using namespace std;

int main(){

    vector<ll> vec(1000);
    vec[1] = 1;
    for(int i=2;i<1000;i++){
        vec[i] = vec[i-1] + i;
    }

    int a,b;
    cin >> a >> b;

    int tmp = b-a;

    cout << vec[tmp] - b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void)
{
	long long  a, b;

	std::cin >> a >> b;

	if ((a * b) % 2 == 0) {
		std::cout << "Even" << std::endl;
	}
	else {
		std::cout << "Odd" << std::endl;
	}
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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

int main(){
    int n; cin >> n;
    vector<queue<int>> com(n);
    for(int i=0; i<n; i++){
        for(int j=0; j<n-1; j++){
            int a; cin >> a;
            a--;
            com[i].push(a);
        }
    }

    int ans=0;
    while(1){
        ans++;
        vi fight;
        for(int i=0; i<n; i++){
            if(com[i].empty()) continue;
            int player=com[i].front();
            if(com[player].front() == i){
                fight.push_back(i);
            }
        }
        for(int i=0; i<(int)fight.size(); i++){
            com[fight[i]].pop();
        }
        if(fight.empty()){
            ans=-1;
            break;
        } 
        bool fin=true;
        for(int i=0; i<n; i++){
            if(!com[i].empty()) fin=false;
        }
        if(fin) break;
    }

    cout << ans << endl;
    /*
    int n; cin >> n;
    vi x(n), y(n);
    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i];
    }
    */
    
    return 0;
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

string s;

int main(){
  cin >> s;
  int st=INF,g;
  REP(i,s.size()){
    if(s[i]=='A'){
      st = min(i,st);
    }
    if(s[i]=='Z'){
      g = i;
    }
  }
  printf("%d\n",g-st+1);
}


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

namespace ITP1_3_C_Swapping_Two_Numbers
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nums = null;
            do
            {
                if ( nums != null )
                    Console.WriteLine( nums.Select( int.Parse ).OrderBy( n => n ).Select( n => n.ToString() ).Aggregate( (acc, s) => acc + " " + s ) );
                nums = Console.ReadLine().Split( ' ' );
            } while ( nums[ 0 ] != "0" || nums[ 1 ] != "0" );
        }
    }
}

Measured memory_bytes: 6572
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)

//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	int n,k;
	string s;
	cin >> n >> k >> s;
	s[k-1] =s[k-1] - 'A' + 'a'; 
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

//階乗,二項係数
//*
ll fact[100010];
ll invfact[100010];
void makefact(int n,ll m){
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%m;
	invfact[n]=invp(fact[n],m);
	for(int i=n;i>0;i--)invfact[i-1]=invfact[i]*i%m;
}
ll choose(int n,int r,int m){return n<0||r<0||n-r<0?0:fact[n]*invfact[r]%m*invfact[n-r]%m;}
//*/

ll f(ll n,ll m){
	ll s=0;
	rep(i,0,m+1)s=(s+choose(m,i,MOD)*pom(i,n,MOD)*((m-i)%2==0?1:-1))%MOD;
	s=s*invfact[m]%MOD;
	return (s+MOD)%MOD;
}

int main(){
	makefact(2000,MOD);
	int n,m;
	scanf("%d%d",&n,&m);
	ll s=0;
	rep(i,0,m+1)s=(s+f(n,i))%MOD;
	printf("%lld\n",s);
}


Measured memory_bytes: 2112
while(1) :
    x = input().split()
    n = int(x[0])
    m = int(x[1])
    if (n == 0 and m == 0): break
    a = input().split()
    mx = -1
    for i in range(n-1):
        for j in range(i+1,n):
            tmp = int(a[i]) + int(a[j])
            if tmp > mx and tmp <= m: mx = tmp
    if mx == -1: print("NONE")
    else: print(mx)



Measured memory_bytes: 5624
tables =list(map(int,input().split()))
for i in range(2,0,-1):
    k = 0
    while k < i:
        if tables[k] > tables[k+1]:
            tables[k],tables[k+1] = tables[k+1],tables[k]
        k+=1

print(tables[0],tables[1],tables[2])


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

using namespace std;
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;

vector<int>result;
int N;
Graph G;

void dfs(int v, int c)
{
    result[v] = c;
    for(auto nx: G[v])
    {
        if(result[nx.first] != -1)
        {
            continue;
        }
        if(nx.second % 2 == 0)
        {
            dfs(nx.first, c);
        }
        if(nx.second % 2 == 1)
        {
            dfs(nx.first, 1-c);
        }
    }
}

int main()
{
    cin >> N;
    G.resize(N);
    for(int i = 0; i < N-1; i++)
    {
        int u,v,w;
        cin >> u >> v >> w;
        u--;
        v--;
        G[u].push_back(Edge(v,w));
        G[v].push_back(Edge(u,w));
    }
    result.assign(N,-1);
    dfs(0,0);
    for(auto x: result)
    {
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
vector<int> G[100000]; bool used[100000];
int col[100000][2] = {};
int main() {
	int n, m; cin >> n >> m;
	rep(i, m) {
		int u, v; cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int cnt = n; int c1 = 0; int c2 = 0;
	fill(used, used + n, false);
	rep(i, n) {
		if (used[i])continue;
		if (G[i].empty())cnt--;
		else {
			col[i][0] = 1;
			queue<P> q; q.push({ i,0 });
			while (!q.empty()) {
				P nex = q.front(); q.pop();
				used[nex.first] = true;
				int len = G[nex.first].size();
				rep(j, len) {
					int v = G[nex.first][j];
					if (col[v][1 - nex.second])continue;
					col[v][1 - nex.second] = 1;
					q.push({ v,1 - nex.second });
				}
			}
			if (col[i][1])c1++;
			else c2++;
		}
	}
	ll out = (ll)n*n - (ll)cnt*cnt;
	out += (ll)c1*c1 + (ll)2*c2*c2 + (ll)2 * c1*c2;
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 8320
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi p(n), inp(n+1);
    rep(i, n) {
        cin >> p[i];
        inp[p[i]] = i+1;
    }
    set<int> se;
    se.insert(0);
    se.insert(n+1);
    se.insert(inp[n]);
    ll ans = 0;
    for(int i = n-1; i > 0; i--) {
        auto itr = se.lower_bound(inp[i]);
        if(*itr != n+1) {
            ans += ll(*next(itr)-*itr)*(inp[i]-*prev(itr))*i;
        }
        itr = prev(itr);
        if(*itr != 0) {
            ans += ll(*next(itr)-inp[i])*(*itr-*prev(itr))*i;
        }
        se.insert(inp[i]);
    }
    cout << ans << endl;
    
}

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

int main(){
  char C[20];
  rep(i,19){
    cin>>C[i];
    if(C[i]==',') C[i]=' ';
    cout<<C[i];
  }
}

Measured memory_bytes: 3572
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<bool> n(10, true);
  rep(i, K) {
    int tmp;
    cin >> tmp;
    n[tmp] = false;
  }
  int ans=N;
  while(true) {
    int tmp=ans;
    bool flag = true;
    while(tmp) {
      if(!n[tmp%10]) {
        flag = false;
        break;
      }
      tmp/=10;
    }
    if(flag)
      break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(a>0 && c>0){
    c=c-b;
    if(c<=0){
      cout << "Yes";
      break;
    }
    a=a-d;
    if(a<=0){
      cout << "No";
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000003
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int n,m;
vector<vector<int>> g; 
vector<int> color;
bool dfs(int v, int c){
    color[v]=c;
    for(int i:g[v]){
        if(color[i]==color[v])return false;
        if(color[i]==0 and !dfs(i,-c))return false;
    }
    return true;
}

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>m;
    g.resize(n);
    color.resize(n);
    rep(i,m){
        int a,b; cin>>a>>b; a--; b--;
        g[a].push_back(b); g[b].push_back(a);
    }

    if(dfs(0,1)){
        int b=0; rep(i,n)if(color[i]==1)b++;
        cout<<b*(n-b)-m<<endl;
    }else{
        cout<<n*(n-1)/2-m<<endl;
    }

}

Measured memory_bytes: 7424
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int n,m,maxn;
	cin >> n >> m;
	for(int i=m-n+1;i<m+n-1;i++)
	{
		printf("%d ",i);
	}
	cout << m+n-1;
}

Measured memory_bytes: 256
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    T, A = MAP()
    H = LIST()

    ans = 1
    for i in range(N-1):
        if abs(A - (T - 0.006 * H[i+1])) < abs(A - (T - 0.006 * H[ans-1])):
            ans = i + 2

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384