akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> V(N);
  REP(i, N) cin >> V[i];

  vector<int> C(N);
  REP(i, N) cin >> C[i];

  int ans = 0;
  REP(i, N){
    ans += max(0ll, V[i]-C[i]);
  }

  cout << ans << "\n";

  return 0;
}


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

int main(void){
    int n,ans=0,temp=0 ;
    cin >> n ;
    vector<int> h ;
    for (int i=0; i<n; i++){
        int x ;
        cin >> x ;
        h.push_back(x) ;
    }
    for (int i=0; i<n-1; i++){
        if (h[i+1]<=h[i]){
            temp++ ;
        } else {
            ans=max(ans,temp) ;
            temp=0 ;
        }
    }
    cout << max(ans,temp) << endl ; 
}

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

const int N = 1e5 + 5;
int n;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    vector<int> p(n);
    
    vector<int> pos;
    for (int i = 0; i < n; i++){
        cin >> p[i];
        if(p[i] != i+1){
            pos.push_back(i);
        }
    }
    
    if(pos.size()!=2 && pos.size() !=0 ){
        cout << "NO" << "\n";
    }else{
        cout << "YES" << "\n";
    }
    
    
    
    
    return 0;
}


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

using namespace std;

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

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

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

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

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

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

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<string>> v(h, vector<string>(w));
    rep(y, h) rep(x, w) cin >> v[y][x];
    P p = [&] {
        rep(y, h) rep(x, w) if (v[y][x] == "snuke") return P(y, x);
    }();

    cout << char('A' + p.second) << p.first + 1 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  // n = スイッチ
  // m = 電球
  int n, m;
  cin >> n >> m;
  V<V<int>> s_list;
  V<int> p_list;
  s_list.resize(m);
  p_list.resize(m);

  rep(i, m) {
    int k;
    cin >> k;
    s_list[i].resize(k);
    rep(ki, k) {
      cin >> s_list[i][ki];
    }
  }
  rep(i, m) {
    cin >> p_list[i];
  }

  // n個数のスイッチのon off
  int all_lights_up_count = 0;
  rep(bit, 1 << n){
    V<bool> s_on(s_list.size(), false);

    rep(i, n) {
      if(bit >> i & 1) {
        s_on[i] = true;
      }
    }

    bool all_lights_up = true;
    rep(i, s_list.size()) {
      int switch_on_count = 0;

      rep(j, s_list[i].size()) {
        int s_label = s_list[i][j];
        if(s_on[s_label - 1]) {
          switch_on_count++;
        }
      }

      if(switch_on_count % 2 != p_list[i]) {
        all_lights_up = false;
        break;
      }
    }

    if(all_lights_up) {
      all_lights_up_count++;
    }
  }

  cout << all_lights_up_count << endl;
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r", stdin);
    //freopen("output.txt","w",stdout); 
    int x; cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
    
}   
   

Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))
ans1 = 0
ans2 = 0
ans3 = 0
for i in range(n):
    if a[i] % 4 == 0:
        ans1 += 1
    elif a[i] % 2 == 0:
        ans2 += 1
    else:
        ans3 += 1
if ans1 + 1 == ans3 and ans2 == 0:
    print("Yes")
elif ans1 >= ans3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 20024
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <valarray>

using namespace std;

int main()
{
    int N;
    long long A, B;
    scanf("%d %lld %lld\n", &N, &A, &B);

    vector<int> X; X.reserve(N);
    for (int i = 0; i < N; ++i){
        int Xi;
        scanf("%d\n", &Xi);
        X.emplace_back(Xi);
    }

    long long result = 0;
    for (int i = 1; i < N; ++i){
        result += min((X[i] - X[i - 1]) * A, B);
    }
    printf("%lld\n", result);
}


Measured memory_bytes: 640
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,j,tmp;
        int[][] A = new int[101][101];
        int[] n = new int[990];
        String[] str = new String[990];
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        str = in.readLine().split(" ");
        for(i=0;i<2;i++){
            n[i]=Integer.parseInt(str[i]);   
        } 
        for(i=0;i<n[0];i++){
            str = in.readLine().split(" ");
            for(j=0;j<n[1];j++){
                tmp = Integer.parseInt(str[j]);
                A[i][j]+=tmp; A[n[0]][j]+=tmp; A[i][n[1]]+=tmp; A[n[0]][n[1]]+=tmp;
            }
        }
        for(i=0;i<=n[0];i++){
            for(j=0;j<=n[1];j++){
                if(j!=0) System.out.print(" ");
                System.out.print(A[i][j]);
            }
            System.out.println();
        }        
        System.out.flush();
    }
}

Measured memory_bytes: 31340
n=int(input())
Rt=[0 for i in range(n)]
for i in range(n):
    Rt[i]=int(input())
maxv=-100000000000000
minv=Rt[0]
for j in range(1,n):
    maxv=max(maxv,Rt[j]-minv)
    minv=min(minv,Rt[j])
print(maxv)


Measured memory_bytes: 13604
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}


void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}


string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}


string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

int main() {
    int n, a, Alice, Bob;
    vector<int> A;
    cin >> n;
    REP(i, n) {
        cin >> a;
        A.pb(a);
    }

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

    if (A.size() % 2) {
        REP(i, A.size()) {
            if (i % 2 == 1) Bob += A[i];
            else Alice += A[i];
        }
    } else {
        REP(i, A.size()) {
            if (i % 2 == 1) Alice += A[i];
            else Bob += A[i];
        }
    }
    cout << Alice - Bob << endl;

    return 0;
}

Measured memory_bytes: 256
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
//#define =1e9 =(int)1e9
const ll mod = 1000000007;
const ll nmax=3000001;
#define int ll
int n, dp[100002][2];
vi g[100002];

void dfs(int nod, int daddy){
    dp[nod][0]=dp[nod][1]=1;
    for(int i: g[nod]){
        if(i!=daddy){
            dfs(i, nod);
            dp[nod][0]*=(dp[i][0]+dp[i][1])%mod;
            dp[nod][0]%=mod;
            dp[nod][1]*=dp[i][0];
            dp[nod][1]%=mod;
        }
    }
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n;
    for(int i=1; i<=n-1; i++){
        int x, y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1, 0);
    cout<<(dp[1][0]+dp[1][1])%mod;
}


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

int a,b;

int main()
{
	//freopen("093D.txt","w",stdout);
	scanf("%d %d",&a,&b);
	a--;b--;
	puts("100 100");
	for(int i=0;i<50;i++)
	{
		for(int j=0;j<100;j++)
		{
			if(i%2&&j%2&&a)
			{
				putchar('.');
				a--;
			}
			else
				putchar('#');
		}
		puts("");
	}
	for(int i=50;i<100;i++)
	{
		for(int j=0;j<100;j++)
		{
			if(i%2&&j%2&&b)
			{
				putchar('#');
				b--;
			}
			else
				putchar('.');
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int a,b;
    in>>a>>b;
    if(a<10&&b<10) cout<<a*b<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  GI2(A, B);
  GI2(C, D);
  GS(S);
  A--;
  B--;
  C--;
  D--;
  bool can_B = 1;
  for (int i = B + 2; i < D; ++i) {
    if (S[i] == '#' && S[i - 1] == '#') {
      can_B = 0;
    }
  }
  if (!can_B) {
    print("No");
    return 0;
  }
  if (C < D) {
    bool can_A = 1;
    for (int i = A + 2; i < C; ++i) {
      if (S[i] == '#' && S[i - 1] == '#') {
        can_A = 0;
      }
    }
    print(can_A ? "Yes" : "No");
  } else {
    bool can_A = 0;
    int now_cnt = 0;
    for (int i = B - 1; i <= D + 1; ++i) {
      if (S[i] == '.') {
        now_cnt++;
      } else {
        now_cnt = 0;
      }
      if (now_cnt > 2) {
        can_A = 1;
      }
    }
    for (int i = A + 2; i < C; ++i) {
      if (S[i] == '#' && S[i - 1] == '#') {
        can_A = 0;
      }
    }
    print(can_A ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	int pole1 = b-a;
	int pole2 = c-b;
	
	if(pole1==pole2){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#define PI 3.141592653589
using namespace std;

int main(){
	while(1){
		int H,W;
		cin >> H >>W;
		
		if(H==0 && W==0)break;
		
		for(int y=0;y<H;y++){
			for(int x=0;x<W;x++){
				if((x+y)%2==0){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
// C - Numbers on a Circle
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	set<pair<int, int>, greater<pair<int, int> > > s;
	for (int i = 0; i < n; i++) s.insert(make_pair(b[i], i));

	long long ans = 0;
	while (!s.empty()) {
		int i = s.begin()->second;
		s.erase(s.begin());
		int d = b[i] - a[i], t = b[(i + 1) % n] + b[(i - 1 + n) % n];
		if (d < t) continue;
		ans += d / t;
		b[i] -= d / t * t;
		if (b[i] > a[i]) s.insert(make_pair(b[i], i));
	}

	for (int i = 0; i < n; i++)
		if (a[i] != b[i]) ans = -1;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 12416
c = 0
while True:
  W = int(input())
  if W == 0:
    break
  c += 1
  N = int(input())

  vl = [0]
  wl = [0]
  for i in range(N):
    [v,w] = list(map(int,input().split(",")))
    vl.append(v)
    wl.append(w)
  dp = [[0 for i in range(W+1)] for j in range(N+1)]
  for i in range(N+1):
    for j in range(W+1):
      if i == 0 or j == 0:
        dp[i][j] = 0
      else:
        if wl[i] <= j:
          dp[i][j] = max(dp[i-1][j-wl[i]] + vl[i], dp[i-1][j])
        else:
          dp[i][j] = dp[i-1][j]
  ls = dp[N].copy()
  ls.reverse()
  max_w = W
  for i in range(1,W+1):
    if ls[i] == dp[N][W]:
      max_w -= 1
    else:
      break

  print("Case "+str(c)+":")
  print(dp[N][W])
  print(max_w)

Measured memory_bytes: 20200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  //freopen("input.txt","r",stdin);
#endif

  int n;
  cin>>n;
  cout<<ceil(n/2.0);
  return 0;
}

Measured memory_bytes: 3764
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a1,b1,c1,d1,a2,b2,c2,d2,A,B;
    cin>>a1>>b1>>c1>>d1>>a2>>b2>>c2>>d2;
    A=a1+b1+c1+d1;
    B=a2+b2+c2+d2;
    if(A>B){
        cout<<A<<endl;
    }
    else{
        cout<<B<<endl;
    }
}



Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main(void){
    int a,b;
    string op;
    
    while(true){
        cin >> a >> op >> b;
        if (op == "?") break;
        else if (op == "+") cout << a + b << endl;
        else if (op == "-") cout << a - b << endl;
        else if (op == "*") cout << a * b << endl;
        else if (op == "/") cout << a / b << endl;
    }
    
    return 0;
}


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

int gcd(int a, int b){
    if(a > b){
        a = a - b;
    }
    else if(a == b){
        return a;
    }
    else{
        b = b - a;
    }
    return  gcd(a,b);
}

int main() {
    long long n,x;
    cin >> n >> x;
    vector<long long> v(n);
    for(int i=0; i<n; i++){
        cin >> v.at(i);
        v.at(i) = abs(x-v.at(i));
    }
    if(n == 1){
        cout << v.at(0) << endl;
        return 0;
    }
    else if(n == 2){
        cout << gcd(v.at(0),v.at(1)) << endl;
        return 0;
    }
    else{
        int gc = gcd(v.at(0),v.at(1));
        for(int i=2; i<n; i++){
            gc = gcd(gc,v.at(i));
        }
        cout << gc << endl;
        return 0;
    }
    
}


Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int a, b, c;
	cin >> a >> b >> c;
	cout << (a*b*c / 2) / max({a,b,c}) << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m = map(int,readline().split())
data = list(map(int,read().split()))

links = [[] for _ in range(n+1)]
it = iter(data)
for a,b in zip(it,it):
    links[a].append(b)
    links[b].append(a)

color = [-1] * (n+1)
color[1] = 0
stack = [1]
while(stack):
    i = stack.pop()
    ci = color[i]
    for j in links[i]:
        if(color[j] == -1):
            color[j] = 1-ci
            stack.append(j)
        else:
            if(color[j]==ci):
                ans = (n*(n-1))//2 - m
                print(ans)
                exit()

n0 = color.count(0)
n1 = color.count(1)
ans = n0*n1 - m
print(ans)

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

#define int long long
#define debug(x) cout<<#x<<" "<<x<<endl;

const int N=1e6+5;
const double eps=1e-9;
const int INF=1e18;

signed main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d){
        puts("Yes");
    }
    else puts("No");
    return 0;
}

//Created Time  :2020/8/29 20:00:20


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
 
 
 
int main() {
    int n;
    scanf("%d",&n);

    int ans = 0;

    rep(i,4){
        if(n%10==2){
            ans++;
        }
        n = n/10;
    }







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

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

int main()
{
    double x1, y1, x2, y2, x3, y3;
    scanf("%lf,%lf %lf,%lf", &x1, &y1, &x2, &y2);
    double ans = 0.0;
    
    while(scanf("%lf,%lf", &x3, &y3) != EOF){
        double a = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1- y2)); 
        double b = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2- y3));
        double c = sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3- y1));
        double z = (a + b + c) / 2;
        ans += sqrt(z * (z - a) * (z - b) * (z - c));
        x2 = x3; y2 = y3;
    }
    
    printf("%.7f\n", ans);
}

Measured memory_bytes: 1084
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	lint N;
	cin >> N;
	int n;
	n = sqrt(N);
	lint m = 100000000000000000;
	for (int ia = 1; ia  <= n; ia++) {
		if (N % ia == 0) {
			m = min(m, ia + N / ia);
		}
	}
	cout << m - 2 << endl;
}



Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    A,B,C,D = map(int,input().split())

    while True:
        C -= B
        if C <= 0:
            res = 'Yes'
            break

        A -= D
        if A <= 0:
            res = 'No'
            break

    print(res)



main()


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

int main(){
	vector<char> v(26);
	v[0]='z';
	for(int i=1; i<26; i++) v[i]='a'+i-1;
	
	//for(auto x:v) cout<<x;
	
	string s;

	ll n; cin>>n;
	do{
		s+=v[n%26];
		n=(n-1)/26;
	} while (n>0);
	reverse(s.begin(),s.end());
	cout << s << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main() {
	vector<int>A(3);
	for (int i = 0; i < 3; i++)cin >> A[i];

	int M = max({A[0],A[1],A[2]});
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		ans += (M - A[i]) / 2; A[i] += 2 * ((M - A[i]) / 2);
	}

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

	if (A[0] == A[1] && A[1] == A[2])cout << ans << endl;
	else if(A[0]==A[1] && A[1]!=A[2])cout << ans + 1 << endl;
	else cout << ans + 2 << endl;

	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const long long int MOD = 1000000007;
const int INF = 1000000000;

int p, q;

int main(){
    cin >> p >> q;
    int pp = p, qq = q;
    while(qq){
        pp %= qq;
        swap(pp,qq);
    }
    q /= pp;
    int ans = 1;
    for(int i = 2;;i++){
        if(i*i > q) break;
        if(q%i == 0){
            ans *= i;
        }
        while(q%i == 0){
            q /= i;
        }
    }
    ans *= q;
    cout << ans << endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    string s;
    cin >> s;
    if(s.back()== 's') s+= 'e';
    s += 's';
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i,n) for (int i = 1; i <= (int)(n); i++)

int main()
{
  int n,T;
  cin >> n >> T;
  
  int t[n];
  rep(i,n) cin >> t[i];
  
  ll ans = 0;
  for(int i = 0; i < n-1; i++)
  { 
    if(t[i+1] - t[i] < T)
    {
      ans += t[i+1] - t[i];
    }else
    {
      ans += T;
    }
  }
  
  ans += T;
  
  cout << ans << endl;
    
}

Measured memory_bytes: 4288
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    rep(i,N){
        string S; cin >> S;
        string A;
        int pos=0;
        while(SZ(S)>pos){
            int cnt=0;
            while(S[pos]!='0'){
                cnt++;
                pos++;
            }
            if(S[pos-1]=='1'){
                if(cnt%5==1) A+='.';
                else if(cnt%5==2) A+=',';
                else if(cnt%5==3) A+='!';
                else if(cnt%5==4) A+='?';
                else A+=' ';
            } else if(S[pos-1]=='2'){
                if(cnt%3==1) A+='a';
                else if(cnt%3==2) A+='b';
                else A+='c';
            } else if(S[pos-1]=='3'){
                if(cnt%3==1) A+='d';
                else if(cnt%3==2) A+='e';
                else A+='f';
            } else if(S[pos-1]=='4'){
                if(cnt%3==1) A+='g';
                else if(cnt%3==2) A+='h';
                else A+='i';
            } else if(S[pos-1]=='5'){
                if(cnt%3==1) A+='j';
                else if(cnt%3==2) A+='k';
                else A+='l';
            } else if(S[pos-1]=='6'){
                if(cnt%3==1) A+='m';
                else if(cnt%3==2) A+='n';
                else A+='o';
            } else if(S[pos-1]=='7'){
                if(cnt%4==1) A+='p';
                else if(cnt%4==2) A+='q';
                else if(cnt%4==3) A+='r';
                else A+='s';
            } else if(S[pos-1]=='8'){
                if(cnt%3==1) A+='t';
                else if(cnt%3==2) A+='u';
                else A+='v';
            } else if(S[pos-1]=='9'){
                if(cnt%4==1) A+='w';
                else if(cnt%4==2) A+='x';
                else if(cnt%4==3) A+='y';
                else A+='z';
            }
            pos++;
        }
        cout << A << endl;
    }
}


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


using namespace std;
long long int n,w,dp[101][100001];
vector<int> weight, val;

long long int knapsack(int i, int cap)
{
    if(i==n || cap<=0) return 0;
    if(dp[i][cap]!=-1) return dp[i][cap];
    if(cap>=weight[i]) dp[i][cap]=max(knapsack(i+1,cap),val[i]+knapsack(i+1,cap-weight[i]));
    else dp[i][cap]=knapsack(i+1,cap);
    return dp[i][cap];
}

int main()
{
    ios::sync_with_stdio(false);
    memset(dp,-1,sizeof dp);
    int x,y;
    cin>>n>>w;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        weight.push_back(x);
        val.push_back(y);
    }
    cout<<knapsack(0,w);
    return 0;
}


Measured memory_bytes: 79232
n, y = map(int, input().split())


for i in range(n + 1):
    for j in range(n - i + 1):
        k = n - (i + j)
        money = 10000 * i + 5000 * j + 1000 * k
        if money == y:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    int N, M;
    int K[31];
    int A[31];

    int count[31] = {0};

    int answer=0;
    cin>>N>>M;

    for(int i=0; i<N; i++){
        cin>>K[i];
        for(int j=0; j<K[i]; j++){
            cin>>A[j];
            count[A[j]]++;
        }
    }

    for(int i=1; i<=M; i++){
        if(count[i]==N) {
            answer++;
        }
    }

    cout<<answer<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
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; }



int main() {
    int n,k,q;
    cin >> n >> k >> q;
    vector<int>a(q);
    rep(i,q) cin >> a[i];
    map<int,int> mp;
    rep(i,n) {
        mp[i] = 0;
    }
    rep(i,q) {
        mp[a[i]-1]++;
    }
    rep(i,n) {
        mp[i] -= q;
    }
    rep(i,n) {
        if(mp[i]+k>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_LONG_MAX;
const double EPS=0.00001;
int main(){
    LL aa[4];
    REP(i,4)cin>>aa[i];
    LL N;
    cin>>N;
    LL a[4];
    a[0]=aa[0]*8L;
    a[1]=aa[1]*4L;
    a[2]=aa[2]*2L;
    a[3]=aa[3];
    vector<PLL>pi;
    REP(i,4){
        pi.PB(MP(a[i],i));
    }
    SORT(pi);
    double d[]={0.25,0.5,1.0,2.0};
    double res=0.0;
    LL sum=0;
    int cnt=0;
    while(N-res>EPS){
        LL p=pi[cnt].first;
        //cout<<"!"<<p<<endl;
        if(N-res<d[pi[cnt].second]){
            cnt++;continue;
        }
        LL tmp=(N-res)/d[pi[cnt].second];
        res+=tmp*d[pi[cnt].second];
        sum+=tmp*aa[pi[cnt].second];
        cnt++;
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;

vector<int> bfs(vector<vector<int>> edges) {
  int n = edges.size()-1, ptr=0, zeros=n-1;
  vector<bool> marked(n+1, false);
  vector<int> q, path, sign(n+1, -1);
  marked[1] = true;
  q.push_back(1);
  path.push_back(0);
  while(ptr < q.size()) {
    int v = q[ptr], len = path[ptr];
    for (auto e: edges[v]) {
      if (!marked[e]) {
        marked[e] = true;
        q.push_back(e);
        path.push_back(len+1);
        sign[e] = v;
        zeros--;
      }
    }
    ptr++;
  }
  if (zeros) sign.resize(1);
  return sign;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, a, b;
  cin>>n>>m;
  vector<vector<int>> edges(n+1, vector<int> (0));
  for (int i=0; i<m; i++) {
    cin>>a>>b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  vector<int> sign = bfs(edges);
  if (sign.size() == 1) cout<<"No\n";
  else {
    cout<<"Yes\n";
    for (int i=2; i<=n; i++) {
      cout<<sign[i]<<'\n';
    }
  }
}

Measured memory_bytes: 16672
import math

n,m = map(int, input().split())
n_p = 0
if 2 <= n:
    n_p = math.factorial(n) // (2*(math.factorial(n-2)))

m_p = 0
if 2 <= m:
    m_p = math.factorial(m) // (2*(math.factorial(m-2)))

print(n_p + m_p)


Measured memory_bytes: 3060
import sys
#input = sys.stdin.buffer.readline

def main():
    N = str(input())
    K = int(input())
    
    l = len(N)
    dpa = [[0 for _ in range(K+1)] for _ in range(l)]
    dpb = [[0 for _ in range(K+1)] for _ in range(l)]
    
    dpa[0][0],dpa[0][1],dpb[0][1] = 1,int(N[0])-1,1
    for i in range(1,l):
        dpa[i][0] = 1
        num = int(N[i])
        if num == 0:
            for j in range(K):
                j += 1
                dpa[i][j] = dpa[i-1][j-1]*9 + dpa[i-1][j]
                dpb[i][j] = dpb[i-1][j]
        else:
            for j in range(K):
                j += 1
                dpa[i][j] = dpa[i-1][j-1]*9 + dpa[i-1][j] + dpb[i-1][j-1]*(num-1) + dpb[i-1][j]
                dpb[i][j] = dpb[i-1][j-1]

    print(dpa[l-1][K]+dpb[l-1][K])

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[110][100100];

int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  clr(dp,0);
  dp[0][0] = 1;
  rep(i,1,v.sz+1){
    rep(j,0,100050){
      if(dp[i-1][j]!=0){
        dp[i][j] = 1;
        dp[i][j+v[i-1]] = 1;
      }
    }
  }
  ll mx = 0;
  rep(i,0,100050){
    if(i%10==0)continue;
    if(dp[n][i]==1){
      mx = max(mx,i);
    }
  }
  cout << mx << endl;
  return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    int n = size(s);
    ll ans = 0;
    REP(i, 1 << (n-1)){
        ll sum = 0;
        REP(j, n){
            if(j > 0 && ((i >> (j-1)) & 1)){
                ans += sum;
                sum = s[j] - '0';
            }else{
                sum = sum * 10 + (s[j] - '0');
            }
        }
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
  input! {
    x:usize, y:usize
  }

  let mut ans = "No";

  for i in 0..=x {
    let j = x - i;
    if i*2 + j*4 == y {ans = "Yes"}
  }

  println!("{}", ans);

  //println!("Hello, AtCoder!");
}


Measured memory_bytes: 2124
/*  ex7_3
    Y_Aizaki  */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int row, col;
    // 行数、列数
    char **matrix;
    // マス目入力を受け取る配列（動的）

    scanf("%d%d", &row, &col);

    // マス目入力を受け取る配列（動的）
    matrix = (char**)calloc(row, sizeof(char*));
    if (matrix == NULL){
        exit(1);
    }
    for (int i = 0; i < row; i++){
        matrix[i] = (char*)calloc(col, sizeof(char));
        if (matrix[i] == NULL){
            exit(1);
        }
    }

    int answer[row][col];
    // VLA
    // matrixの要素を標準出力するか、判断する

    // answerの初期化
    for (int i = 0; i < row; i++){
        for (int j = 0; j < col; j++){
            answer[i][j] = 0;
        }
    }

    for (int i = 0; i < row; i++){
        for (int j = 0; j < col; j++){
            // matrixに'.','#'を入力するループ
            scanf(" %c", &matrix[i][j]);
        }
    }

    for (int i = 0; i < row; i++){
        // 列ごとに見るループ

        for (int j = 0; j < col; j++){
            if (matrix[i][j] == '#'){
                break;
            }

            if (j == col-1){
                for (int x = 0; x < col; x++){
                    answer[i][x] = 1;
                }
            }
        }
    }

    for (int j = 0; j < col; j++){
        // 行ごとに見るループ

        for (int i = 0; i < row; i++){
            if (matrix[i][j] == '#'){
                break;
            }
            if (i == row-1){
                for (int x = 0; x < row; x++){
                    answer[x][j] = 1;
                }
            }
        } 
    }

    for (int i = 0; i < row; i++){
        int newline = 0;
        // 改行判定

        for (int j = 0; j < col; j++){
            // 出力するループ

            if (answer[i][j] == 0){
                printf("%c", matrix[i][j]);
                newline = 1;
            }

            if (j == col-1 && newline == 1){
                putchar('\n');
            }   
        }
    }

    for (int i = 0; i < row; i++){
        free(matrix[i]);
    }
    free(matrix);
    
    return 0;
}

Measured memory_bytes: 1668
n = int(input())
a = list(map(int,input().split()))

b = []
c = 0
d = 0

for i in range (n):
    if a[i] % 2 == 0:
        b.append(a[i])
        c=c+1

for j in range (c):
    if b[j]%3 == 0 or b[j]%5 == 0:
        d = d
    else:
        d = d+1

if d == 0:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] v = new int[n];
		int[] c = new int[n];
		int x = 0;
		int y = 0;

		for (int i = 0; i < v.length; i++) {
			v[i] = sc.nextInt();
		}

		for (int i = 0; i < c.length; i++) {
			c[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			if (v[i] > c[i]) {
				x += v[i];
				y += c[i];
			}
		}

		System.out.println(x - y);

	}

}


Measured memory_bytes: 22740
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>


auto is_prime(int )->bool;

int main() {

	
	int x{}, c{0};
	std::cin >> x;

	for (int i{ 0 }; i < x; i++) {
		int tmp{ 0 };
		std::cin >> tmp;
		if ( is_prime(tmp) ) c++;
		//std::cout << i << "\n";
	}

	std::cout << (c == 0 ? -1 : c) << "\n";
//	std::cout << "end" << "\n";
//	std::cin >> x;

}

auto is_prime(int x)->bool {
	if (x <= 1)		return false;
	if (x == 2)		return true;
	if (x % 2 == 0) return false;

	auto sq_x = std::sqrt(x);
	for (int i{ 3 }; i <= sq_x;i+=2) {
		if (x%i == 0)return false;
	}
	return true;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    vector<int> A(N+2, 0);
    rep(i, 1, N+1) cin >> A[i];

    vector<int> diff(N+2, 0);
    rep(i, 1, N+1) diff[i] = abs(A[i+1]-A[i-1]) - (abs(A[i+1]-A[i]) + abs(A[i]-A[i-1]));

    int sum = 0;
    rep(i, 1, N+2) sum += abs(A[i]-A[i-1]);

    rep(i, 1, N+1) cout << sum + diff[i] << "\n";
}

Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int int64_t
#define watch(x) cout << (#x) << " is " << (x) << endl

const int32_t MAX=1e9+7;
typedef vector<int> vi;
typedef vector<int64_t> vll;

int32_t main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;

    //Problem code start

    int n;
    cin >> n;
    vi h(n+1);
    for(int i=1;i<n+1;i++) cin >> h[i];
    vi f(n+1);
    f[n]=0;
    for(int i=n-1;i>0;i--){
        int first=MAX,second=MAX;
        if(i+1<=n){
            first=abs(h[i]-h[i+1])+f[i+1];
        }
        if(i+2<=n){
            second=abs(h[i]-h[i+2])+f[i+2];
        }
        f[i]=min(first, second);
    }
    cout << f[1];
    return 0;
}

Measured memory_bytes: 4740
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

use std::collections::LinkedList;

fn main() {
    let mut a = get!(String).chars().collect::<LinkedList<char>>();
    let mut b = get!(String).chars().collect::<LinkedList<char>>();
    let mut c = get!(String).chars().collect::<LinkedList<char>>();

    let mut t = 'a';
    loop {
        let mut s = match t {
            'a' => &mut a,
            'b' => &mut b,
            'c' => &mut c,
            _ => panic!("")
        };
        match s.front() {
            None => {
                println!("{}", t.to_string().to_uppercase());
                return;
            }
            Some(nt) => {
                t = *nt;
            }
        }
        s.pop_front();
    }
}

Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhijeetkns
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFerrisWheel solver = new AFerrisWheel();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFerrisWheel {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a >= 13) out.println(b);
            else if (a >= 6 && a <= 12) out.println(b / 2);
            else {
                out.println(0);
            }
        }

    }
}



Measured memory_bytes: 21844
from collections import Counter


def solve(string):
    n, *aqbc = map(int, string.split())
    a, _, bc = aqbc[:n], aqbc[n], aqbc[n + 1:]
    s = sum(a)
    t = Counter(a)
    ans = []
    for b, c in zip(*[iter(bc)] * 2):
        if b not in t.keys():
            ans.append(s)
            continue
        if c in t.keys():
            t[c] += t[b]
        else:
            t[c] = t[b]
        s += (c - b) * t[b]
        del t[b]
        ans.append(s)
    return "\n".join(map(str, ans))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 44092
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  map<ll,ll> ma;
  ll sum = 0;
  rep(i,0,n){
    ll a;
    cin>>a;
    ma[a]++;
    sum += a;
  }
  ll q;
  cin>>q;
  rep(i,0,q){
    ll a,b;
    cin>>a>>b;
    ll a1 = ma[a];
    sum -= a*a1;
    sum += b*a1;
    ma[a] = 0;
    ma[b] += a1;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 9540
#include <iostream>

using namespace std;

int main(){
    int a,b;
    cin >>a >>b;
    if (a>=13){
        cout << b<<endl;
    }
    if(a<13 && a>=6){
        cout << b/2 <<endl;

    }
    if (a<6){
        cout << 0;
    }


    return 0;
}


Measured memory_bytes: 256