akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    string s;
    cin >> s;

    int count=0;
    
    int n=s.length();
    for (int i=0;i<=n-1;i++)
    {
        if (s[i]!=s[n-1-i])
        {
            s[i]=s[n-i-1];
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

'''
Author: andyli
Time: 2020-08-02 19:55:48
'''

import os
from io import BytesIO, IOBase
import sys


def main():
    n,d = map(int,input().split())

    ans = 0
    for _ in range(n):
        x,y = map(int,input().split())

        if (x*x + y*y) <= d*d: 
            ans += 1
    
    print(ans)
    return


# region fastio
BUFSIZE = 1048576


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b'\n') + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode('ascii'))
        self.read = lambda: self.buffer.read().decode('ascii')
        self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip('\r\n')

# endregion


if __name__ == '__main__':
    main()


Measured memory_bytes: 77304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    string ans = "Yes";
    int c[3][3];

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
        cin >> c[i][j];
        }
    }
    if(c[0][0]-c[1][0]!=c[0][1]-c[1][1]||c[0][1]-c[1][1]!=c[0][2]-c[1][2]){
        ans = "No";
    }
    if(c[1][0]-c[2][0]!=c[1][1]-c[2][1]||c[1][1]-c[2][1]!=c[1][2]-c[2][2]){
        ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005
typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void initialize(){
  head=tail=0;
}

int isEmpty(){
  if(head==tail)
    return 0;
  else
    return 1;
}

int isFull(){
  if(head==(tail+1)%LEN)
    return 0;
  else;
  return 1;
}

void enqueue(P x){
  if(isFull(x)==0)
   printf("??¨?????????????????????????????????\n");
  Q[tail]=x;
  if(tail+1==LEN)
    tail=0;
    else
      tail++;
}

P dequeue(){
  P x;
  if(isEmpty()==0)
    printf("??¨?????????????????????????????????\n");
  x=Q[head];
  if(head+1==LEN)
    head=0;
  else
    head++;
  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  initialize();
  head=1;
  tail=n+1;
  while(tail!=head){
    if(Q[head].t >q)
{
      elaps+=q;
      Q[head].t-=q;
      enqueue(dequeue());
   }
else
  {
      elaps+=Q[head].t;
      dequeue();
      printf("%s %d\n",Q[head-1].name,elaps);
    }
  }
    return 0;
}

Measured memory_bytes: 10756
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

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

    vector<int> X(M);
    for( int i = 0; i < M; ++i )
        cin >> X[i];

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

    vector<int> dis(M-1);
    for( int i = 0; i < M-1; ++i )
        dis[i] = abs(X[i+1]-X[i]);

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

    int ans = 0;
    for( int i = 0; i < M-N; ++i )
        ans += dis[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
    int n, q;
    cin >> n >> q;
    ll ans = 0;
    map<int, int> mr, mc;
    mr[n] = n-2;
    mc[n] = n-2;
    while(q--) {
        int qt, x;
        cin >> qt >> x;
        if (qt == 2) swap(mr, mc);
        /*if (qt == 1)*/ {
            auto it = mc.lower_bound(x);
            if (it != mc.begin()) {
                it--;
                ans += it->second;
            } else {
                mc[x] = mr.begin()->first - 2;
                ans += mc[x];
            }
        }
        if (qt == 2) swap(mr, mc);
    }
    cout << ll(n-2) * (n - 2) - ans << endl;
}


Measured memory_bytes: 12908
using System;

namespace ARC098_D___Xor_Sum_2_2回目_
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var accumSum = new long[N + 1];
            for (int i = 1; i < N + 1; i++) accumSum[i] = accumSum[i - 1] + A[i - 1];
            var accumXor = new long[N + 1];
            for (int i = 1; i < N + 1; i++) accumXor[i] = accumXor[i - 1] ^ A[i - 1];

            var left = 1; var right = 1;
            long result = 0;
            while (left <= N)
            {
                if (right <= N && accumSum[right] - accumSum[left - 1] == (accumXor[right] ^ accumXor[left - 1]))
                {
                    right++;
                }
                else
                {
                    result += right - left;
                    left++;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 35676
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <string.h>

using namespace std;

int main(void)
{
    while(true) {
        int r,n,y[40],b[41];
        double res=500.0;
        
        memset(y, 0, sizeof(y));
        memset(b, 0, sizeof(b));

        scanf("%d%d", &r, &n);
        if(!r && !n) break;

        for(int i=0; i < n; i++) {
            int xs,xe,t;
            scanf("%d%d%d", &xs, &xe, &t);
            for(int p=xs+20; p < xe + 20; p++)
                y[p] = std::max(y[p], t);
        }

        b[0]  = 0;
        b[40] = 0;

        for(int i=1; i < 40; i++)
            b[i] = std::min(y[i-1], y[i]);

        for(int i=-r+1+20; i < r+20; i++) {
            res = std::min( res, (double)(b[i]+r) - sqrt((double)r*r - abs(-20.0+i)*abs(-20.0+i)) );
//            printf(".%d:%lf:%lf.",i,(double)(b[i]+r), sqrt((double)r*r - abs(-20.0+i)*abs(-20.0+i)));
        }

        printf("%lf\n", res);
    }
        
    return 0;

}

Measured memory_bytes: 1064
#include<iostream>
using namespace std;
int main(){
    while(1){
        int n,x;
        cin>>n>>x;
        if(n==0&&x==0) break;
        int c=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x) c++;
                    
                }
            }
        }
        cout<<c<<endl;
    }
}


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

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    int a[n][m];
    int ans = 0;
    int point = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
            point += a[i][j] * b[j];
        }
        point += c;
        if (point > 0) {
            ans++;
        }
        point = 0;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val n  = in.nextInt
  val r  = List.fill(n)(in.next -> in.nextInt).zipWithIndex

  r.sortWith((x, y) => {
      if (x._1._1 == y._1._1) {
        x._1._2 >= y._1._2
      } else if (x._1._1 <= y._1._1) {
        true
      } else {
        false
      }
    })
    .map(_._2 + 1)
    .foreach(println)
}


Measured memory_bytes: 25776
(let* ((m (read))
       (n (read))
       (lst (sort (loop :repeat n :collect (cons (read) (read))) #'< :key #'car))
       (dp (make-array (expt 10 5) :initial-element most-positive-fixnum)))
  (setf (aref dp 0) 0)
  (loop :for k :in lst
        :do(loop :for j :from 0 :upto m
                 :do(setf (aref dp (+ j (car k)))
                          (min (aref dp (+ j (car k)))
                               (+ (aref dp j) (cdr k))))))
  (princ (reduce #'min (subseq dp m))))

Measured memory_bytes: 66664
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<math.h>
using namespace std;

int main() {
	int A, B;
	char d[20];
	cin >> A >> B;
	int c = 0;
	for (int i = 0; i < A + B + 1; i++) {
		cin >> d[i];
		if (d[i] == '-')c++;
	}
	if (c != 1) {
		cout << "No";
		return 0;
	}
	if (d[A] == '-')cout << "Yes";
	else cout << "No";

}

Measured memory_bytes: 256
// abc133_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll L, R;
    cin >> L >> R;

    if (R - L > 2019){
        print(0);
        return 0;
    }

    ll ans = 2020;
    REPN(i, L, R+1){
        REPN(j, i+1, R+1){
            ans = min(ans, ((ll)i * (ll)j) % 2019 );
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int bill = 1000;
        while(N>bill)
        {
            bill = bill + 1000; 
        }
        System.out.println(bill-N);
    }
}

Measured memory_bytes: 27052
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N, M;
int c[30];
void solve(){
	int ans = 0;
	rep(lol, N){
		int K;
		cin >> K;
		rep(i, K) {
			int A;
			cin >> A;
			c[--A]++;
			if(c[A] == N)
				ans++;
		}
	}
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M;
		solve();
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left

n = int(input())
a = list(map(int,input().split()))
a.sort()

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect_left(a,a[i]+a[j])
        ans += ind-j-1

print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include <iostream>
#include <vector>
using namespace std;


int main()
{
	int n, q;
	cin >> n;

	vector<int> vNumS(n,0);
	for (int i = 0; i < n; i++)
	{
		int num = 0;
		cin >> num;
		vNumS[i] = num;
	}

	cin >> q;
	vector<int> vNumT(q, 0);

	for (int i = 0; i < q; i++)
	{
		int num = 0;
		cin >> num;
		vNumT[i] = num;
	}


	int result = 0;
	for (int i = 0; i < vNumT.size(); i++)
	{
		for (int j = 0; j < vNumS.size(); j++)
		{
			if (vNumT[i] == vNumS[j])
			{
				result += 1;
				break;
			}
		}
	}

	cout << result << endl;
	return 0;
}




Measured memory_bytes: 3136
#include<stdio.h>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#define INF 200000000
using namespace std;
typedef pair<int,int> P;
typedef struct{
	int a,b,c;
}edge;
vector<P> e[3000];
edge e2[100000];
int d[3000];
int max(int a,int b){return a>b?a:b;}
int main(){
	int n,m,k;
	int i,j;
	scanf("%d %d %d",&n,&m,&k);
	for(i=0;i<m;i++){
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		x--;y--;
		edge ed={x,y,z};
		e[x].push_back(P(y,z));
		e[y].push_back(P(x,z));
		e2[i]=ed;
	}
	priority_queue<P> que;
	for(i=0;i<n;i++)d[i]=INF;
	for(i=0;i<k;i++){
		int x;
		scanf("%d",&x);
		d[x-1]=0;
		que.push(P(0,x-1));
	}
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(i=0;i<e[v].size();i++){
			if(d[e[v][i].first]>d[v]+e[v][i].second){
				d[e[v][i].first]=d[v]+e[v][i].second;
				que.push(P(d[e[v][i].first],e[v][i].first));
			}
		}
	}
	int ans=0;
	for(i=0;i<m;i++){
		int x=e2[i].a;
		int y=e2[i].b;
		int z=e2[i].c;
		ans=max(ans,max(d[x],max(d[y],(int)round((double)(d[x]+d[y]+z)/2))));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5204
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
a,b,n=list(map(int,input().split()))
if n<b:
    print(math.floor(a*n/b))
    exit()

print(math.floor(a*(b-1)/b))



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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll n;
    cin >> n;
    cout  << pow(n,2) * 3 << endl;    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n;
  char c;
  map<char,int>m;
  bool tie,ok;
  while(cin>>n){
    char first,second='!';
    if(n==0)break;
    m.clear();
    tie=ok=true;
    
    rep(i,n){
      cin>>c;
      m[c]++;
      
      if(i==0){
	first=c;
      }else{
	if(m[first]<=m[c]&&first!=c){
	  second=first;
	  first=c;
	}else if(m[second]<=m[c]&&m[c]<m[first]&&second!=c){
	  second=c;
	}
      }
      
      if(debug)cout<<first<<": "<<m[first]<<" "<<second<<": "<<m[second]<<endl;
      if(debug)cout<<"テヲツョツ凝」ツつ?"<<n-i-1<<endl;
      
      if(m[c]>n/2&&ok){
	cout<<c<<" "<<i+1<<endl;
	tie=false;
	ok=false;
      }else if(m[first]>(n-i-1)+m[second]&&ok){
	cout<<first<<" "<<i+1<<endl;
	tie=false;
	ok=false;
      }
      
    }
    if(tie)cout<<"TIE"<<endl;
  }

  return 0;
}

Measured memory_bytes: 3028
import numpy as np
import math


def _run(N, As):
    As.sort(reverse=True)
    sum_value = 0
    for i in range(1, N):
        index = math.ceil((i - 1) / 2)
        sum_value += As[index]
    print(sum_value)
    # states = []
    # for i in range(N):
    #     max_value = 0
    #     max_index = 0
    #     for j in range(len(states)):
    #


def _main():
    N = int(input())
    As = list(map(int, input().split()))
    _run(N, As)


if __name__ == "__main__":
    _main()


Measured memory_bytes: 49436
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
int main(){
  ll n,m,k;cin>>n>>m>>k;
  UnionFind tree(n);
  vl a(m),b(m);
  vl fri(n);
  vvl block(n,vl(0));
  rep(i,m){
    cin>>a[i]>>b[i];
    tree.unite(a[i]-1,b[i]-1);
    //fri[a[i]-1]++;
    //fri[b[i]-1]++;
    block[a[i]-1].push_back(b[i]-1);
    block[b[i]-1].push_back(a[i]-1);
  }
  vl c(k),d(k);
  rep(i,k){
    cin>>c[i]>>d[i];
    block[c[i]-1].push_back(d[i]-1);
    block[d[i]-1].push_back(c[i]-1);
  }
  vl ans(n);
  rep(i,n){
    if(tree.root(i)!=i)ans[tree.root(i)]++;
  }
  rep(i,n){
    ll res=0;
    res+=ans[tree.root(i)];
    res-=fri[res];
    for(auto x:block[i]){
      if(tree.root(x)==tree.root(i))res--;
    }
    cout<<res;
    if(i<n-1)cout<<" ";
    if(i==n-1)cout<<endl;
  }
}

      

Measured memory_bytes: 15220
#include <cstdio>
#define MOD 1000000007
long long dp[100005], ans = 1;
int deg[100005], nxt[100005], app[100005], pre[100005];
bool vis[100005];
int main()
{
	// freopen("AGC008-E.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", nxt + i);
		deg[--nxt[i]]++;
	}
	for (int i = 0; i < n; i++)
	{
		if (deg[i] > 2)
		{
			puts("0");
			return 0;
		}
		if (deg[i] != 2 || vis[i])
			continue;
		int u = i;
		do
		{
			if (vis[u])
			{
				puts("0");
				return 0;
			}
			vis[u] = true;
			pre[nxt[u]] = u;
			u = nxt[u];
		}
		while (u != i);
	}
	for (int i = 0; i < n; i++)
	{
		if (deg[i])
			continue;
		int u = i, foot_len = 0, cyc_len = 0;
		while (!vis[u])
		{
			vis[u] = true;
			u = nxt[u];
			foot_len++;
		}
		do
		{
			u = pre[u];
			cyc_len++;
		}
		while (deg[u] == 1);
		if (foot_len < cyc_len)
			ans = ans * 2 % MOD;
		if (foot_len > cyc_len)
		{
			puts("0");
			return 0;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (vis[i])
			continue;
		int u = i, len = 0;
		do
		{
			vis[u] = true;
			u = nxt[u];
			len++;
		}
		while (u != i);
		app[len]++;
	}
	for (int i = 1; i <= n; i++)
	{
		dp[0] = 1;
		for (int j = 1; j <= app[i]; j++)
		{
			dp[j] = dp[j - 1] * ((i & 1 ^ 1) || i == 1 ? 1 : 2) % MOD;
			if (j >= 2)
				(dp[j] += dp[j - 2] * (j - 1) * i) %= MOD;
		}
		ans = ans * dp[app[i]] % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
MOD=10**9+7
def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD
def invmod(a):
  return powmod(a,MOD-2)
def comb_mod(n,r):
  nPr=1
  fact_r=1
  for i in range(r):
    nPr*=n-i
    nPr%=MOD
    fact_r*=r-i
    fact_r%=MOD  
  return (nPr*invmod(fact_r))%MOD

N,K=map(int,input().split())

for i in range(1,K+1):
  term1=comb_mod(N-K+1,i)
  term2=comb_mod(K-1,K-i)
  print(term1*term2%MOD)

Measured memory_bytes: 3316
#include<iostream>
    #include<set>
    using namespace std;
    int main(){
        set<int>s1,s2,s3;
        s1.insert(1);
        s1.insert(3);
        s1.insert(5);
        s1.insert(7);
        s1.insert(8);
        s1.insert(10);
        s1.insert(12);
        s2.insert(4);
        s2.insert(6);
        s2.insert(9);
        s2.insert(11);
        s3.insert(2);
        int x,y;
        cin>>x>>y;
        if(s1.find(x)!=s1.end()&&s1.find(y)!=s1.end()){
            cout<<"Yes"<<endl;
        }
        else
        if(s2.find(x)!=s2.end()&&s2.find(y)!=s2.end()){
            cout<<"Yes"<<endl;
        }
        else
        if(s3.find(x)!=s3.end()&&s3.find(y)!=s3.end()){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
     
    }

Measured memory_bytes: 3568
#include <vector>
#include <set>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int N;
	scanf("%d",&N);
	vector<int>a(N);
	set<int>h;
	int r=2;
	for(int i=0;i<N;i++){
    scanf("%d",&a[i]);
    h.insert(a[i]);
  }
	sort(a.begin(),a.end());
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
		int d=a[j]-a[i];
		int k=2;
		for(;;k++){
      if(h.find(a[i]+d*k)==h.end())break;
    }
		r=max(r,k);
	}
	printf("%d\n",r);
}


Measured memory_bytes: 3120
def solve():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    numbers = [0] * (10 ** 6 + 1)
    for i in a:
        numbers[i] += 1
        if numbers[i] == 1:
            for j in range(2 * i, len(numbers), i):
                numbers[j] += 2
    print(numbers.count(1))








if __name__ == '__main__':
    solve()


Measured memory_bytes: 32380
#include <iostream>

using namespace std;

int main()
{
  int n;
  cin>>n;
  int *a=new int[n];
  int count=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]%2==0&&(a[i]%3!=0&&a[i]%5!=0))
       count++;
  }
  if(count==0)
    cout<<"APPROVED"<<endl;
  else
    cout<<"DENIED"<<endl;
  return 0;
}

       
      


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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if(a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  static const double pi = 3.141592653589793;
  std::cout << std::setprecision(18);
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double a_theta = (h * 60 + m) / 2;
  double b_theta = m * 6;
  double theta = (a_theta - b_theta) / 180 * pi;
  cout << sqrt(a*a + b*b - 2*a*b*cos(theta)) << endl;
}

Measured memory_bytes: 4164
#include <iostream>

using namespace std;

int main()
{
	int h, w;

	cin >> h >> w;

	while (h != 0 && w != 0) {
		for (int i = 1; i <= w; i++) {
			cout << "#";
		}
		cout << endl;
		for (int i = 2; i < h; i++) {
			cout << "#";
			for (int j = 2; j < w; j++) {
				cout << ".";
			}
			cout << "#" << endl;
		}
		for (int i = 1; i <= w; i++) {
			cout << "#";
		}
		cout << endl << endl;

		cin >> h >> w;
	}
	
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int n, x[20], y[20], ans;
int v[10], w[10];
bool used[20];

bool is_parallel(int x, int y, int p, int q){
    return x * q == y * p;
}

void dfs(int cur, int cnt){
    if(cnt == n/2){
        int tmp = 0;
        rep(i, n/2)For(j, i+1, n/2){
            tmp += is_parallel(x[w[i]]-x[v[i]], y[w[i]]-y[v[i]], x[w[j]]-x[v[j]], y[w[j]]-y[v[j]]);
        }
        chmax(ans, tmp);
        return;
    }
    For(i, cur, n)if(!used[i]){
        used[i] = true;
        v[cnt] = i;

        For(j, i+1, n)if(!used[j]){
            used[j] = true;
            w[cnt] = j;
            dfs(i + 1, cnt + 1);
            used[j] = false;
        }

        used[i] = false;
        return;
    }
}

int main(){
    scanf("%d", &n);
    rep(i, n) scanf("%d%d", &x[i], &y[i]);
    dfs(0, 0);
    printf("%d\n", ans);
}


Measured memory_bytes: 3220
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		final Scanner in = new Scanner(System.in);
		final int a = in.nextInt(), b = in.nextInt();
		boolean result = true;
		if ((a + b) > 16 || a > 8 || b > 8) {
			result = false;
		}
		if (result) System.out.println("Yay!");
		else System.out.println(":(");
	}

}

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

d = int(input())
C = tuple(map(int, input().split()))
S = tuple(tuple(map(int, input().split())) for _ in range(d))
ans = 0
L = [0]*26
for i in range(1, d+1):
  t = int(input())
  t -= 1
  L[t] = i
  ans += S[i-1][t]
  for j, (c, l) in enumerate(zip(C, L)):
    ans -= c*(i-l)
  print(ans)

Measured memory_bytes: 9276
#include <bits/stdc++.h>
#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



int main() {


	char c;
	cin >> c;
	if ('A' <= c && c <= 'Z') {
		cout << 'A' << endl;
	}
	else cout << "a" << endl;


}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    string s;
    cin >> s;
    int sz = s.size();
    vector<vector<ll>> dp(4, vector<ll>(sz + 8, 0));
    REP(i,sz+1){
        dp[3][i] = 1;
    }
    REP(i, sz)
    {
        if (s[i] == 'A'){
            dp[0][i + 1] = (dp[0][i] + dp[3][i]) % MOD;
            dp[1][i + 1] = dp[1][i];
            dp[2][i + 1] = dp[2][i];
            dp[3][i + 1] = dp[3][i];
        }
        else if (s[i] == 'B')
        {
            dp[1][i + 1] = (dp[1][i] + dp[0][i]) % MOD;
            dp[0][i + 1] = dp[0][i];
            dp[2][i + 1] = dp[2][i];
            dp[3][i + 1] = dp[3][i];
        }else if (s[i] == 'C')
        {
            dp[2][i + 1] = (dp[2][i] + dp[1][i]) % MOD;
            dp[0][i + 1] = dp[0][i];
            dp[1][i + 1] = dp[1][i];
            dp[3][i + 1] = dp[3][i];
        }else
        {
            dp[0][i + 1] = (3*dp[0][i] % MOD + dp[3][i]) % MOD;
            dp[1][i + 1] = (3*dp[1][i] % MOD + dp[0][i]) % MOD;
            dp[2][i + 1] = (3*dp[2][i] % MOD + dp[1][i]) % MOD;
            dp[3][i + 1] = dp[3][i] * 3 % MOD;
        }
    }
    cout << dp[2][sz] << endl;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    string S;
    cin >> S;
    
    bool flag = false;

    if( S[0] == 'A' )
    {
        int num = 0;
        REP(i, 2, S.size()-1)
        {
            if(S[i]=='C')num++;
        }
        if( num == 1 ) flag = true;
    }

    if( !flag ) cout << "WA" << endl;
    else
    {
        multiset<char> keys;
        REP(i, 1, S.size())
        {
            if( S[i] != 'C' ) keys.insert(S[i]);
        }
        for( multiset<char>::iterator itr = keys.begin(); itr != keys.end(); itr++)
        {
            if( *itr < 'a' )
            {
                cout << "WA" << endl;
                return 0;
            }
        }
        cout << "AC" <<  endl;
    }
}


Measured memory_bytes: 256
let conv = Bytes.map (fun x -> if 'A' <= x && x <= 'Z' 
                                  then Char.chr (Char.code x - Char.code 'A' + Char.code 'a')
                                  else if 'a' <= x && x <= 'z' then Char.chr (Char.code x - Char.code 'a' + Char.code 'A')
                                  else x)

let () =
  Printf.printf "%s\n" (read_line () |> conv)

Measured memory_bytes: 2220
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include<stdio.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a;
    double b;
    ll ans;
    cin>>a>>b;
    b*=100;
    ans=a*b/100;
    printf("%lld",ans);
}


Measured memory_bytes: 3804
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); ++i)
inline void chmax(int &a, int b) {
    if (a < b) a = b;
}

int main() {
    int n; cin >> n;
    vector<vector<int>> h(n, vector<int>(3));
    rep(i, n) cin >> h[i][0] >> h[i][1] >> h[i][2];
    vector<vector<int>> dp(n, vector<int>(3));
    rep(i, 3) dp[0][i] = h[0][i];
    rep(i, n-1) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k) continue;
                chmax(dp[i+1][k], dp[i][j] + h[i+1][k]);
            }
        }
    }
    int ans = 0;
    rep(i, 3) ans = max(ans, dp[n-1][i]);
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int N;
	vector<int>list;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	int sum = 0;

	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			int num = list[i] * list[j];
			sum += num;
		}
	}

	cout << sum << endl;



	
	return 0;
}

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

int main()
{
  int n, h, k = 0, ata = 0, dm = 0;
  cin >> n >> h;
  vector<int> a(n, 0);
  vector<int> b(n, 0);
 
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    cin >> b[i];
  }
 
  sort(a.begin(), a.end());
  int a_max = a.back();
  int a_min = a.front();
 
  sort(b.begin(), b.end());
  int b_max = b.back();
  int b_min = b.front();
 
  for (int i = n - 1; i >= 0; i--)
  {
    if(b[i] > a_max)
    {
      ata++;
      dm += b[i];
      if(dm >= h)
      {
        cout << ata << endl;
        exit(0);
      }
    }
  }
 
  while (dm < h)
  {
    ata++;
    dm += a_max;
  }
 
  cout << ata << endl;

}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    //i について全探索する
    for (int i = 0; i < N; i++)
    {
        //A[i+1] ... A[N] の値を更新する
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}


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

int main(){
    
    string s,t;
    cin >> s >> t;
    int ans = (int)t.size();
    int compans = (int)t.size();
    for(int i=0; i<=((int)s.size()-(int)t.size()); i++){
        for(int j=0; j<(int)t.size(); j++){
            if(t[j] == s[j+i]){
                compans -= 1;
            }
        }
        if(compans < ans ){
            ans = compans;
            
        }
        compans = (int)t.size();
    }
    cout << ans << endl;
}

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

int main() {
    while (1) {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0)
            break;

        rep(i, h) {
            rep(j, w) {
                if (i == 0 || j == 0 || i == h - 1 || j == w - 1)
                    cout << "#";
                else
                    cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

ll A[200010];
ll n,k;

ll f(double d){
  ll sum=0;
  for(int i=0;i<n;i++){
    sum+=ceil(A[i]/d);
  }
  return sum;
}

int main(){
  cin>>n>>k;
  rep(i,n) cin>>A[i];
  
  double a=0,b=2000000010,c;
  int t=100;
  while(t--) {
    c=(a+b)/2;
    if(f(c)<=n+k) b=c;
    if(f(c)>n+k) a=c;
  }
  
  ll ans=ceil(c);
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll x, y;
    cin>>x>>y;
    string ans = "No";
    for(ll i=0;i<=x;++i){
        ll a = i;
        ll b = x-i;
        if(a * 2 + b * 4 == y){
            ans = "Yes";
        }
    }
    cout<<ans<<endl;
}

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

int main(){
    while(true){
        int n, m;
        cin >> n >> m;

        if(n==0 && m==0)
            break;

        int a[1001];
        for(int i=0;i<n;i++)
            cin >> a[i];

        int dp = 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<i;j++){
                if(a[i]+a[j] <= m)
                    dp = max(dp, a[i]+a[j]);
            }
        }

        if(dp)
            cout << dp << endl;
        else
            cout << "NONE" << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
a, b, c = map(int, input().split())
flag = 1

if c - a - b <= 0:
    flag = 0
else:
    L = 4 * a * b
    R = (c - a - b) ** 2
    if L >= R:
        flag = 0

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
l = input()

a3 = [1]
a2 = [1]

for i in range(len(l)+5):
    a3.append((a3[-1]*3)%(10**9+7))
    a2.append((a2[-1]*2)%(10**9+7))

ans = 0
a = 0
for i in range(len(l)):
    if l[i]=='1':
        ans += (a3[len(l)-i-1]*a2[a])
        a+=1
    if i==len(l)-1:
        ans += a2[a]
    ans %= 10**9+7

print(ans)


Measured memory_bytes: 51952
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: usize = s.next().unwrap().parse().unwrap();
	let mut sushi = Vec::with_capacity(n);
	for _ in 0..n {
		let t: u32 = s.next().unwrap().parse().unwrap();
		let d: i64 = s.next().unwrap().parse().unwrap();
		sushi.push((d, t - 1));
	}
	sushi.sort_by_key(|a| std::cmp::Reverse(a.0));
	let mut found = vec![false; n];
	let mut a = vec![];
	let mut b = vec![];
	for &(d, t) in sushi.iter() {
		if found[t as usize] {
			a.push(d);
		} else {
			b.push(d);
			found[t as usize] = true;
		}
	}
	let mut ai = std::cmp::min(k, a.len());
	let mut bi = k - ai;
	let mut cur = a[..ai].iter().sum::<i64>() + b[..bi].iter().sum::<i64>();
	let mut ans = cur + (bi as i64).pow(2);
	while bi < b.len() && bi < k {
		cur += b[bi] - a[ai - 1];
		bi += 1;
		ai -= 1;
		if ans < cur + (bi as i64).pow(2) {
			ans = cur + (bi as i64).pow(2);
		}
	}
	println!("{}", ans);
}


Measured memory_bytes: 6672
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin>>s;
	bool flag=true;
	REP(i,3){
		if(s[i]==s[i+1]) flag=false;
	}
	if(flag) cout<<"Good"<<endl;
	else cout<<"Bad"<<endl;
	}


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


int main() {
    int n;
    cin >> n;
    vector<ll> strat(n);
    ll bsum = 0LL;
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        strat[i] = a+b;
        bsum -= b;
    }
    sort(strat.rbegin(), strat.rend());
    ll ans = bsum;
    for(int i = 0; i < n; i++){
        if(i&1) continue;
        ans += strat[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
#define all(v) v.begin(),v.end()
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(pair<int,int> &a,pair<int,int> &b)
{
	if(a.first!=b.first)
	   return a.first<b.first;
	else
		return a.second>b.second;
}
void printQ(deque<int> q)
{
	for(int i=0;i<q.size();i++)
	{
		cout<<q[i]<<" ";
	}
	cout<<endl;
}
struct p{
	int x;
	int y;
};
int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;cin>>n;
	string s;cin>>s;
	for(int i=0;i<s.size();i++)
	{
		s[i]=('A'+(s[i]-'A'+n)%(('Z'-'A'+1)));
	}
	cout<<s<<endl;
	return 0;
}














Measured memory_bytes: 256
# ABC 079
N=input()
A,B,C,D =int(N[0]),int(N[1]),int(N[2]),int(N[3])
def f_add(a,b):
    return a+b
def f_minus(a,b):
    return a-b
def jug_f(f):
    if f ==f_add:
        return '+'
    else:
        return '-'
ans =''
for f1 in [f_add,f_minus]:
    for f2 in [f_add,f_minus]:
        for f3 in [f_add,f_minus]:
            if f3(f2(f1(A,B),C),D)==7:
                ans +=str(A)+jug_f(f1)+str(B)+jug_f(f2)+str(C)+jug_f(f3)+str(D)+"=7"
                print(ans)
                exit()



Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc =  new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] val = new int[N][2];
        for(int i = 0; i < N; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            val[i][0] = a;
            val[i][1] = b;
        }
        Arrays.sort(val, (a, b) -> Integer.compare(a[0], b[0]));
        long ans = 0;
        for(int i = 0; M > 0; i++){
            long a = val[i][0];
            long b = val[i][1];
            if(val[i][1] < M){
                ans += a * b;
                M -= b;
            }else{
                ans += a * M;
                M = 0;
            }
        }
        System.out.println(ans);
    }
}

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

n, m = map(int, input().split())
l = 1
r = n
for _ in range(m):
    a, b = map(int, input().split())
    l = max(l, a)
    r = min(r, b)
ans = r - l + 1
if (ans < 0):
    ans = 0
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j;
  int n,k;
  cin>>n>>k;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  int ans=0;
  rep(i,k)ans+=a[n-1-i];
  cout<<ans<<endl;
 
}


Measured memory_bytes: 256