akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll SORT(int n, vector<pair<ll, ll>> &v, int start){
  sort(v.begin()+start, v.end());
  return v[n-1].first;
}

int ans = 0;

int main(void){
  
  ll a,b,c,k;
  cin>>a>>b>>c>>k;

  if(k< a || k==a){
    cout<<k<<endl;
    return 0;
  }else if(k < (a+b) || k==(a+b)){
      cout<<a<<endl;
      return 0;
  }else{
      cout<<a-(k-a-b)<<endl;
    
  }
  return 0;

}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

ll cul(ll k){
    return ((ll)pow(26,k+1)-26)/25;
}

string solve(ll k,ll rem){
    if(k==1){
        return {(char)('a'+rem-1)};
    }
    ll a = cul(k-1)-cul(k-2);
    ll l=1;
    while(true){
        if(rem <= a*l) break;
        l++;
    }
    l--;
    ll r = rem-a*l;
    return (char)('a'+l)+solve(k-1,r);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    // 桁数
    ll k = 1;
    while(true){
        if(n <= cul(k)){
            break;
        }
        k++;
    }
    // k桁のrem番目
    ll rem = n-cul(k-1);
    string ans = solve(k,rem);
    cout << ans << endl;
}

Measured memory_bytes: 4036
#include <iostream>
#include <map>
#include <queue>
#include <algorithm> 
#include <cstring>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define ll long long

int vis[15];
int lst;
int a[105];
int main(int argc, char** argv) {
	int n,m,sm;
	cin>>n>>m;
	sm=m;
	int s,c;
	int fg=0;
	memset(vis,-1,sizeof(vis));
	while(m--)
{
	scanf("%d%d",&s,&c);
	if(vis[s]!=-1&&vis[s]!=c)
	{
		fg=1;
	}
	if(s==1&&c==0&&!fg)
	{
		fg=2;
	}
	vis[s]=c;
}

if(fg==1)
{
	cout<<-1<<endl;
}
else if(fg==2||(n==1&&sm==0))
{
	
	if(n==1)cout<<0;
	else cout<<-1;
}
else rep(i,1,n)
{
	if(i==1&&vis[i]<=0)cout<<1;
	else
	{
		cout<<max(vis[i],0);
	}
}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;


int main()
{
	int n;
	scanf("%d", &n);
	ll a[n  + 5];
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);

	ll dp[n  + 4][n  + 4];
	for (int i = n - 1; i >= 0; i--) {
		for (int j = i; j < n; j++) {
			if (i == j) dp[i][j] = a[i];
			else {
				dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
			}
		}
	}
	printf("%lld\n", dp[0][n - 1]);
	return 0;
}


Measured memory_bytes: 46464
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100001


int main(){
  char s[SIZE];
  int l;

  scanf("%s",s);
  l = strlen(s);

  for(int i=0;i<l;i++){

    if(i<l-2){
      if(s[i]==s[i+2]){
        printf("%d %d\n",i+1,i+3);
        return 0;
      }
    }

    if(i<l-1){
      if(s[i]==s[i+1]){
        printf("%d %d\n",i+1,i+2);
        return 0;
      }
    }
  }
    
  printf("-1 -1\n"); 
  
  return 0;
}


Measured memory_bytes: 384
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 510000
using namespace std;
struct node{int y,nex;}a[N];
int nex[N][27],n,inf,id,fir[N],len,dfn[N],las[N],m;
char s[N];
void ins(int x,int y)
{
	a[++len].y=y;a[len].nex=fir[x];fir[x]=len;
}
void dfs(int x)
{
	dfn[x]=++id;
	for(int k=fir[x];k;k=a[k].nex)
	{
		int y=a[k].y;
		dfs(y);
	}
	las[x]=id;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);inf=n+2;
	for(int i=0;i<=26;i++) nex[n][i]=nex[n+1][i]=nex[n+2][i]=inf;
	nex[n][s[n]-'a'+1]=n+1;
	ins(n+2,n+1);
	ins(n+2,n);
	for(int i=n-1;i>=1;i--)
	{
		int c=s[i]-'a'+1;
		nex[i][c]=i+1;
		for(int j=c+1;j<=26;j++) nex[i][j]=nex[nex[i][j-1]][j-1];
		nex[i][0]=nex[nex[i][26]][26];
		for(int j=1;j<c;j++) nex[i][j]=nex[nex[i][0]][j];
		ins(nex[i][0],i);
	}
	dfs(n+2);
	scanf("%d",&m);
	while(m--)
	{
		int l,r;scanf("%d%d",&l,&r);
		r++;
		if(dfn[r]<=dfn[l] && las[r]>=dfn[l]) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 72576
function Main(input) {
   	var inputArray = input.split("\n");
	var N=inputArray[0]*1;
	var InputArray2=inputArray[1].split(" ");
	
	var red=0;
	var green=0;
	var blue=0;
	
	var specific;
	var count=0;
	
	var answer=1;
	
	var Idx;
	
	for(var i=0;i<N;i++){
		count=0;
		Idx=0;
		specific=InputArray2[i]*1;
		if(specific==red){
			count++;
			red++;
			Idx=1
			
		}
		if(specific==green){
			count++;
			if(Idx==0){
				green++;
				Idx=1
			}
		}
		if(specific==blue){
			count++;
			if(Idx==0){
				blue++;
				Idx=1;
			}
		}
		
		//console.log(answer);
		answer=answer*count;
		answer=answer%1000000007;
	}
	
	console.log(answer);
	
}
     
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 16716
N = int(input())
A = list(map(int,input().split()))
A.sort()

cost_min = float('inf')
for i in range(-100,100+1):
   cost = 0
   for j in range(N):
      cost += (i-A[j])**2
   cost_min = min(cost_min,cost)
  
print(cost_min)

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

using namespace std;
typedef long long ll;

int main() {


  string s;

  cin >> s;

  int num = (int)(s.length());

  int win = 0;
  for(int i=0; i<num; i++){
      if(s[i]=='o') win++;
  }
  if( (win+(15-num)) >= 8){
      cout << "YES";
  }else{
      cout << "NO";
  }





  return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())
costlist=[]
exist=0
for i in range(A):
  c, t = map(int, input().split())
  if t<=B:
    costlist.append(c)
    exist=exist+1
if exist==0:
  kotae="TLE"
else:
  kotae=min(costlist)
print(kotae)

Measured memory_bytes: 3060
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int area { get; set; }
    public int id { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        getAns(s);
    }
    public static void print(Stack<P> st)
    {
        var n = st.Count();
        if (n == 0) { Console.WriteLine(0); Console.WriteLine(0); return; }
        var a = new int[n];
        var asum = 0;
        for (int i = 0; i < n; i++)
        {
            var w = st.Pop();
            a[n - 1 - i] = w.area;
            asum += w.area;
        }
        Console.WriteLine(asum);
        Console.Write("{0} ", n);
        for (int i = 0; i < n; i++)
            if (i == n - 1) Console.WriteLine(a[i]);
            else Console.Write("{0} ", a[i]);

    }
    public static void getAns(string s)
    {
        var st1 = new Stack<int>();
        var st2 = new Stack<P>();
        for (int i = 0; i < s.Length; i++)
            if (s[i] == '\\') st1.Push(i);
            else if (s[i] == '/' && st1.Count() > 0)
            {
                var id = st1.Pop();
                var area = i - id;
                while (st2.Count() > 0 && id <= st2.Peek().id)
                {
                    area += st2.Peek().area;
                    st2.Pop();
                }
                st2.Push(new P { id = id, area = area });
            }
        print(st2);
    }
}



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

using namespace std;
using ll = long long;

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

    vector<pair<ll, ll>> A(N);
    for (int i = 0; i < N; ++i) {
        ll x, l;
        cin >> x >> l;
        A[i] = make_pair(x + l, x - l);
    }

    sort(A.begin(), A.end(), greater<pair<ll, ll>>());

    int ans = 0;
    ll left = 1e+13;
    for (auto p : A) {
        if(p.first <= left)
        {
            left = p.second;
            ++ans;
        } else {
            left = max(left, p.second);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys

table = [0]*26

letters = 'abcdefghijklmnopqrstuvwxyz'
input_str = sys.stdin.read()

for A in input_str:
    index = 0
    for B in letters:
        if A == B or A == B.upper():
            table[index] += 1
            break
        index += 1

for i in range(len(letters)):
    print('{} : {}'.format(letters[i], table[i]))


Measured memory_bytes: 5564
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail
    int n, k;
    cin >> n >> k;
    int arr[n];
    for(int i = 0;i < n;i++)
    {
        cin >> arr[i];
    }
    bool game[k+1];
    for(int i = 0;i <= k;i++){
        game[i] = false;
    }
    for(int i = 0;i <= k;i++)
    {
        for(int j = 0;j < n;j++)
        {
            if(arr[j] <= i)
            {
                if(game[i - arr[j]] == false)
                    game[i] = true;
            }
        }
    }
    if(game[k])
    {
        cout << "First";
    }
    else
    {
        cout << "Second";
    }
    return 0;
}

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

ll m11, m10, m01, m00, x[200200], y[200200], n, ans;

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

	for(int i=1;i<=n;i++) cin >> x[i] >> y[i];

	m11 = x[1] + y[1];
	m10 = x[1] - y[1];
	m01 = - x[1] + y[1];
	m00 = - x[1] - y[1];

	for(int i=2;i<=n;i++){
		ans = max({ans, m11 - x[i] - y[i], m10 - x[i] + y[i], m01 + x[i] - y[i], m00 + x[i] + y[i]});
		m11 = max(m11, x[i] + y[i]);
		m10 = max(m10, x[i] - y[i]);
		m01 = max(m01, - x[i] + y[i]);
		m00 = max(m00, - x[i] - y[i]);
	}

	cout << ans;
}

Measured memory_bytes: 6780
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr auto mod = 1000000007;
constexpr auto MOD = 998244353;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<double> a(n);
    FOR(i, 0, n)cin >> a[i];

    double k = 0;
    FOR(i, 0, n)k += 1 / a[i];
    printf("%.11f", 1 / k);
}

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

int main(){
  std::string s;
  std::cin >> s;

  int cnt_1 = 0;
  int cnt_0 = 0;
  rep(i,s.size()) {
    if(s[i] == '1')
      ++cnt_1;
    else
      ++cnt_0;
  }

  std::cout << std::min(cnt_0,cnt_1)*2 << '\n';
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int N = R * 100 + G * 10 + B;
		if(N % 4 == 0) System.out.println("YES");
		else System.out.println("NO");
	}


}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
    ll x, y;
    cin >> x >> y;
    if (labs(x - y) <= 1) {
        cout << "Brown" << endl;
    } else {
        cout << "Alice" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
vector<int> vec(3);
for (int i = 0;i < 3;i++) cin >> vec.at(i);

sort(vec.begin(),vec.end());
cout << vec.at(0)+ vec.at(1) << endl;



return 0;
}


Measured memory_bytes: 256
def main():
  n = int(input())
  ans = 0
  SQRT = int(n ** 0.5)
  for m in range(1,SQRT + 1):
    b = int(n/m)
    ans += m * (m + b) * (b + 1 - m)
  ans -= SQRT * (SQRT+1) * (2*SQRT+1) // 6
  print(ans)
main()


Measured memory_bytes: 9436
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
#define int long long
using ll = long long;
using P = pair<int, int>;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> p, m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 0) {
            m.push_back(a[i]);
        } else {
            p.push_back(a[i]);
        }
    }
    int P = p.size();
    int M = m.size();
    bool ok = false;
    if (P > 0) {
        if (n == k) {
            ok = (M % 2 == 0);
        } else {
            ok = true;
        }
    } else {
        ok = (k % 2 == 0);
    }
    mint ans = 1;
    if (!ok) {
        sort(ALL(a), [](int x, int y) { return abs(x) < abs(y); });

        for (int i = 0; i < k; i++) {
            ans *= a[i];
        }
    } else {
        sort(ALL(p));
        sort(ALL(m));
        reverse(ALL(m));
        if (k % 2 == 1) {
            ans *= p.back();
            p.pop_back();
        }
        vector<int> s;
        while (p.size() >= 2) {
            ll x = p.back();
            p.pop_back();
            x *= p.back();
            p.pop_back();
            s.push_back(x);
        }
        while (m.size() >= 2) {
            ll x = m.back();
            m.pop_back();
            x *= m.back();
            m.pop_back();
            s.push_back(x);
        }
        sort(ALL(s));
        reverse(ALL(s));
        for (int i = 0; i < k / 2; i++) {
            ans *= s[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8164
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll ans[Max];
ll n,Q;
void solve(){
	 cin>>n>>Q;
	 vector<VI> tr(n+1);
	 rep(i,0,n-1){
	 	int x,y;
	 	cin>>x>>y;
	 	tr[x].pb(y);
	 	tr[y].pb(x);
	 }
//	 queue<PII> q;
//	 q.push({1,0});
////	 vector<int> dep(n+1,0);
////	 dep[1] = 0;
////	 int d=1;
//	 while(!q.empty()){
//	 	int m = q.size();
//	 	for(int k=0;k<m;k++){
//	 		PII p = q.front();
//	 		q.pop();
//	 		for(int i=0;i<tr[p.fi].size();i++){
//	 			if(tr[p.first][i]==p.second)tr[p.first][i] = 0;
//	 			else{
//	 				q.push({tr[p.first][i],p.first});
////	 				dep[tr[p.first][i]] = d;
//				 }
//			 } 
//		 }
////		 d++;
//	 }
	 map<int,int> bon;
	 rep(i,0,Q){
	 	int x,j;
	 	cin>>j>>x;
	 	bon[j]+=x;
	 }
	 queue<int> q;
	 q.push(1);
	 VI vis(n+1,0);
	 vis[1] = 1;
	 while(!q.empty()){
	 	int m = q.size();
		 for(int i=0;i<m;i++){
		 	int u = q.front();
		 	q.pop();
		 	ans[u]+=bon[u];
		 	for(int j=0;j<tr[u].size();j++){
		 		if(!vis[tr[u][j]]){
		 			bon[tr[u][j]]+=bon[u];
		 			vis[tr[u][j]] = 1;
		 			q.push(tr[u][j]);
				 }
			 }
		 } 
	 } 
	 rep(i,1,n+1){
	 	cout<<ans[i]<<" ";
	 }
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 26484
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,j,k,n,a,b,c;
	vector <vector<int> > v;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b>>c;
		vector <int> temp;
		temp.push_back(a);
		temp.push_back(b);
		temp.push_back(c);
		v.push_back(temp);

	}
	int aa[n],ab[n],ac[n];
	aa[0]=v[0][0],ab[0]=v[0][1],ac[0]=v[0][2];
	for(i=1;i<n;i++){
		aa[i]=v[i][0]+max(ab[i-1],ac[i-1]);
		ab[i]=v[i][1]+max(aa[i-1],ac[i-1]);
		ac[i]=v[i][2]+max(aa[i-1],ab[i-1]);
	}
	j=max(aa[n-1],ab[n-1]);
	cout<< max(j,ac[n-1])<<endl;
	return 0;
}


Measured memory_bytes: 7600
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int e[105][105];
int main()
{
    int n;
    int k,m,p;
    memset(e,0,sizeof(e));
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&k);
        scanf("%d",&m);
        for(int j=1;j<=m;j++)
        {
            scanf("%d",&p);
            e[k][p] = 1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(j != n)
                printf("%d ",e[i][j]);
            else
                printf("%d",e[i][j]);
        }

        printf("\n");
    }
    return 0;

}

Measured memory_bytes: 3248
#include<iostream>
#include<math.h>

int main(){

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

    float mean;
    mean = 0;
    for (int i = 0; i < n; ++i)
        mean += a[i];
    mean = round( mean / n); 

    int cost = 0;
    for (int i = 0; i < n; ++i)
        cost += (a[i] - mean) * (a[i] - mean);
            
    std::cout << cost << std::endl;

    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    System.out.println(str.equals("AAA") || str.equals("BBB")?"No":"Yes");
  }
}

Measured memory_bytes: 20944
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  print(s.substr(0, 3));
}


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

int main() {
  int N;
  cin >> N;
  ll sum = 1;
  vector<ll> vec(N);
  rep(i, N){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  if(vec.at(0) == 0){
    cout << 0 << endl;
    return 0;
  }else{
    rep(i, N){
      if(sum >= (1000000000000000000 / vec.at(i)) + 1){
        cout << -1 << endl;
        return 0;
      }else{
        sum = sum * vec.at(i);
      }
   }
   cout << sum << endl;
  }
}

Measured memory_bytes: 3992
#include <iostream>
#include <limits>
using namespace std;
using ll = long long;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define out(v) cout<<v<<"\n"
const ll INF = numeric_limits<ll>::max();

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

  int F[N][10];
  rep(i, N) rep(j, 5)
      cin >> F[i][2*j] >> F[i][2*j+1];
  int P[N][11];
  rep(i, N) rep(j, 11)
    cin >> P[i][j];

  ll ans = -INF;
  rep(bit, 1, 1 << 10) {
    ll tmp = 0;
    rep(i, N) {
      int count = 0;
      rep(j, 10) {
        if (bit & (1 << j) && F[i][j])
          ++count;
      }
      tmp += P[i][count];
    }
    ans = max(ans, tmp);
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    n, T = map(int, input().split())
    arrys = [tuple(map(int, input().split())) for _ in range(n)]
    ans = float('inf')
    for arry in arrys:
        c, t = arry
        if t <= T:
            ans = min(ans, c)
    if ans == float('inf'):
        print('TLE')
    else:
        print(ans)
    
if __name__ == '__main__':
    main()

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let w = v[0];
    let a = v[1];
    let b = v[2];

    if b > a + w {
        println!("{}", b - a - w);
    } else if a > b + w {
        println!("{}", a - b - w);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int go(int x, int y, int z){
    int ans = 0;
    while(1){
        if(x == z){
            ans = 1;
            break;
        }
        if(x == y){
            break;
        }
        x -= 1;
    }
    return ans;
}

int main(void)
{
    int x, y, z;
    int ans = 0;
    char order[30];
    
    fgets(order, 29, stdin);
    sscanf(order, "%d %d %d", &x, &y, &z);
    
    if(x > y){
        ans = go(x, y, z);
    }else{
        ans = go(y, x, z);
    }
    
    if(ans == 0){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}
template <class T> T permutation(ll n, ll k) { T f(1); for (ll i=0; i<k; ++i, --n) f *= n; return f; }
template <class T> T factorial(ll n) { return permutation<T>(n,n); }
template <class T> T binomial(ll n, ll k) { return permutation<T>(n,k) / factorial<T>(k); }

map<ll,int> factorize(ll n) {
    map<ll,int> p;
    for (ll i=2; i*i <= n; ++i) {
        while (n % i == 0) {
            n /= i;
            p[i]++;
        }
    }
    if (n != 1)
        p[n]++;
    return p;
}

int main() {
    fastio;
    ll ans=0;
    ll a,b;
    cin >> a >> b;
    ll g = gcd(a,b);

    auto p = factorize(g);
    ans = p.size()+1;
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)

#define huge 1000000007
typedef long long ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	ll a[200] = {};
	ll b[200] = {};
	ll v[3] = {};
	//ll *a, *b, *x;
	string S,T,U;
	ll count = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;
	

	//char p;
	cin >> S >> T;
	//cin >> S;
	
	rep(j, 0, S.length()) {

		if (S[j] != T[j]) {
			temp = S[j];
			rep(i, 0, S.length()) {
				

			
				if (temp == S[i]) {
					S[i] = T[j];
					sum++;
				}
				else if(T[j] == S[i]) {
					S[i] = temp;
					sum++;
				}

				if (sum > 0 && i < j) {
					break;
				}
				else {
					sum = 0;
				}

				
			}

		}

		if ((S == T) || sum >0)
			break;

		//cout << S << "," << T << endl;
	}

	//cout << S << "," << T << endl;

	//a = (ll *)malloc(M * sizeof(ll));
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(N+1);
	//vector<bool> flag(N);
	
	//count--;
	//	cout << X << endl;
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(v.begin(), v.end());
	
	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/


	if (S == T) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	


	return 0;

}

ll gcd(ll a, ll b) {
	ll c;
	c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}

	return b;
}

Measured memory_bytes: 776
#include <stdio.h>

int main(void){
        int x,y;
        char OP;        
        scanf("%d %c %d",&x,&OP,&y);
        if (OP == '+') {
                        printf("%d\n",x + y);
        }else{
                        printf("%d\n",x - y);
        }
        return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {
    public static void main (String args[]) {
	Scanner scan = new Scanner(System.in);
	int N = scan.nextInt(); // the number of data set
	int a, b, c; // length

	for(int i=0; i<N; i++) {
	    a = scan.nextInt();
	    b = scan.nextInt();
	    c = scan.nextInt();

	    a = a*a; b = b*b; c = c*c;

	    if ((a == b+c) || (b == c+a) || (c == a+b)) {
		System.out.println("YES");
	    }
	    else {
		System.out.println("NO");
	    }
	    
	}
    }
}

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

typedef long long ll;
using namespace std;

int r,c;
int s[11][10001];
bool a[11];

int cnt(){
	int ret = 0;
	for (int i = 0;i < c;i++){
		int x[2] = {0,0};
		for (int j = 0;j < r;j++){
			if(a[j]){
				x[(s[j][i]+1)%2]++;
			}else x[s[j][i]]++;
		}
		ret += max(x[0],x[1]);
	}
	return ret;
}

int dfs(int n){
	if(n == r-1){
		return cnt();
	}
	int ret = -1;
	a[n+1] = true;
	ret = dfs(n+1);
	a[n+1] = false;
	ret = max(ret,dfs(n+1));

	return ret;
}

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

	while(true){
		cin >> r >> c;
		if(r == 0) break;
		for (int i = 0;i < r;i++){
			for (int j = 0;j < c;j++){
				cin >> s[i][j];
			}
		}
		cout << dfs(-1) << endl;
	}

	return 0;

}



Measured memory_bytes: 3508
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

import sys
sys.setrecursionlimit(4100000)
rl = sys.stdin.readline
mod = 10**9+7

N = Int()
A = IntList()

tmp = 0

for i in range(N+1):
    tmp += A[i]*2**(N-i)
    
if tmp > 2**N:
    print(-1)
    sys.exit()
    
if N==0:
  print(1)
  sys.exit()


B = A[::-1]
ans = 1
par = 1
C = []
MAXpar = B[0]

for i in range(N):
    leaf = B[i]
    if len(C)>=1:
        MINP = C[-1][0]
        MAXP = C[-1][1]
        C.append([(MINP+leaf+1)//2,MAXP+leaf])
    else:
        C.append([(leaf+1)//2,leaf])
        

D = C[::-1]
#print(D)
for i in range(1,N):
    minp,maxp = D[i]
    
    ans += A[i]+min(maxp,2*par-A[i])
    #print(A[i],min(maxp,2*par-A[i]))
    par = min(maxp,2*par-A[i])
    
ans += A[-1]
print(ans)
    

Measured memory_bytes: 96052
from math import ceil
import heapq

N, M = map(int, input().split())
A = [-int(a) for a in input().split()]
heapq.heapify(A)

for _ in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A, ceil(a / 2))

print(-sum(A))


Measured memory_bytes: 14380
using System;
using System.Collections.Generic;

class Program
{
  static void Main()
  {
    string[] HW = Console.ReadLine().Split(' ');
    int H = int.Parse(HW[0]);
    int W = int.Parse(HW[1]);
    
    int[,] L = new int[H+1, W+2];
    int[,] R = new int[H+1, W+2];
    int[,] D = new int[H+2, W+1];
    int[,] U = new int[H+2, W+1];
    string[] S = new string[H+1];

    // D, Uの初期化
    for (int j = 1; j <= W; j++)
    {
      D[0, j] = 0;
      U[H+1, j] = 0;
    }
    
    // L, D, R
    for (int i = 1; i <= H; i++)
    {
      S[i] = Console.ReadLine();
      
      //L, D
      L[i, 0] = 0;
      for (int j = 1; j <= W; j++)
      {
        string s = S[i].Substring(j-1, 1);
        if (s == "#")
        {
          L[i, j] = 0;
          D[i, j] = 0;
        }
        else
        {
          L[i, j] = L[i, j-1] + 1;
          D[i, j] = D[i-1, j] + 1;
        }
      }
      
      //R
      R[i, W + 1] = 0;
      for (int j = W; j >= 1; j--)
      {
        string s = S[i].Substring(j-1, 1);
        if (s == "#")
          R[i, j] = 0;
        else
          R[i, j] = R[i, j+1] + 1;
      }
    }
    
    // U, Max
    int max = 0;
    for (int i = H; i >= 1; i--)
    {
      for (int j = 1; j <= W; j++)
      {
        string s = S[i].Substring(j-1, 1);
        if(s != "#")
          U[i, j] = U[i+1,j] + 1;
        else
           U[i, j] = 0;
         int light = L[i,j] + R[i,j] +D[i,j] + U[i,j] - 3;
         max = Math.Max(max, light);
      }
    }
    Console.WriteLine(max);
  }
}

Measured memory_bytes: 92716
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int min = 50000;
  for(int i = 0;i<N;i++){
    int a = sc.nextInt();
    int count = 0;
    while(a%2 == 0){
      count++;
      a /= 2;
    }
    min = Math.min(min,count);
  }
  System.out.println(min);
}}

Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a, b, c, k;
int main() {
	scanf("%d%d%d", &a, &b, &c);
	scanf("%d", &k);
	if(a > b)swap(a, b);
	if(a > c)swap(a, c);
	if(b > c)swap(b, c);
	for(int i = 1; i <= k; i++)c *= 2;
	printf("%d\n", a + b + c);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	char S[5];
	scanf("%s", S);
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) printf("Bad\n");
	else printf("Good\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
template <class X> void print(X x) { cout << x << endl; }
#define in(A, n)                                                                                                       \
    rep(i, n) {                                                                                                        \
        cin >> f;                                                                                                      \
        A.push_back(f);                                                                                                \
    }

void print(vl x) {
    for(ll i : x) {
        cout << i << " ";
    }
    cout << endl;
}
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v, m;
ll codeforces = 1;
string S, T;
vl A, B;
#include <cstdint>
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if(a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if(a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while(exp) {
            if(exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
void input() { cin >> n; }
void solve() {
    vector<mint> kaijo;
    kaijo.pb(1);
    rep(i, n) { kaijo.pb(kaijo.back() * (i + 1)); }
    mint ans = 0;
    rep(i, n) {
        a = i + 1;
        if(a * 3 > n)
            break;
        b = n - a * 3;
        b += a - 1;
        ans += kaijo[b] / (kaijo[b - (a - 1)] * kaijo[a - 1]);
    }

    print(ans.a);
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    while(codeforces--) {
        solve();
    }
}

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

int main() {
  int n;
  cin>>n;
  map<ll,ll> ma;
  ll vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
    ma[vec[i]]++;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(ma[vec[i]]%2==1){
      ans++;
      ma[vec[i]]=0;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7296
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		Map<Integer, Integer> temp = new TreeMap<Integer, Integer>();
		Map<Integer, Integer> result = new TreeMap<Integer, Integer>();
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			String str;
			while( !(str = stdIn.nextLine()).equals("") ){
				String[] s = str.split(",");
				int[] n = new int[2];
				n[0] = Integer.parseInt(s[0]); n[1] = Integer.parseInt(s[1]);
				temp.put(n[0], ( temp.get(n[0]) == null ) ? 1 : temp.get(n[0])+1);
			}
			
			while( stdIn.hasNext() ){
				String str2 = stdIn.next();
				String[] s = str2.split(",");
				int[] n = new int[2];
				n[0] = Integer.parseInt(s[0]); n[1] = Integer.parseInt(s[1]);
				if( temp.get(n[0]) != null ){
					result.put(n[0], ( result.get(n[0]) == null ) ? temp.get(n[0])+1 :result.get(n[0])+1);
				}
			}
			for(Map.Entry<Integer, Integer> entry : result.entrySet()){
				System.out.println(entry.getKey() + " " + entry.getValue());
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
#!/usr/bin/env python
# coding: utf-8

# In[10]:


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


# In[17]:


if (B-A)%2 == 0:
    ans = (B-A)//2
else:
    ans = min(A-1, N-B) + 1 + (B-A-1)//2
print(ans)


# In[ ]:






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

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
const int N=2000+5,D=1e9+7;
s64 mi(s64 x,int y=D-2)
{
	s64 ans=1;
	while(y)
	{
		if(y&1)ans=ans*x%D;
		x=x*x%D;y>>=1;
	}
	return ans;
}
s64 dp[2][N],jie[N*N],niv_jie[N*N];
void init_jie(int n)
{
	jie[0]=1;
	rep(i,1,n)jie[i]=jie[i-1]*i%D;
	niv_jie[n]=mi(jie[n]);
	per(i,n,1)niv_jie[i-1]=niv_jie[i]*i%D;
}
s64 C(int n,int m)
{
	assert(n<N*N);
	return jie[n]*niv_jie[m]%D*niv_jie[n-m]%D;
}

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);
#endif
	int n,k;
	cin>>n>>k;
	if(k==1)
	{
		puts("1");
		exit(0);
	}
	init_jie(n*k);
	bool d=1;
	dp[d][0]=1;
	per(i,n*2,1)
	{
		memset(dp[d^1],0,sizeof(dp[d^1]));
	rep(j,0,min(2*n-i,i))
	if(dp[d][j])
	{
//		cerr<<i<<" "<<j<<" "<<dp[d][j]<<endl;
		int l=(n*2-i-j)/2,r=n*2-i-l;
//		if(j+1<=i-1)cerr<<i<<" "<<j<<r*(k-1)+l+k-2<<" "<<k-2<<endl;
		(dp[d^1][j+1]+=dp[d][j]*C(r*(k-1)+l+k-2,k-2))%=D;
		if(j)(dp[d^1][j-1]+=dp[d][j])%=D;
	}
		d^=1;
	}
	cout<<(dp[d][0]*jie[n]%D+D)%D;
}

Measured memory_bytes: 62976
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> n;
  ll ans = 0;
  clr(d,0);
  lep(i,1,n){
    cin >> d[i];
    ans += abs(d[i-1] - d[i]);//+ abs(d[i] - d[i+1]);
  }
  ans += abs(d[n] - d[n+1]);
  //print(ans);
  lep(i,1,n){
    print(ans - abs(d[i-1] - d[i]) - abs(d[i] - d[i+1]) + abs(d[i-1] - d[i+1]));
  }
  return 0;
}

Measured memory_bytes: 2816
from collections import deque
import sys
input=sys.stdin.readline
inf=float("inf")


def BFS():
    D=[[inf for _ in range(w)] for _ in range(h)]
    queue=deque()
    queue.append([Cx-1,Cy-1,0])
    D[Cx-1][Cy-1]=0

    while len(queue)>0:
        x,y,cnt=queue.popleft()
        for i,j in [[1,0],[0,1],[-1,0],[0,-1]]:
            X,Y=x+i,y+j
            if 0<=X<h and 0<=Y<w:
                if S[X][Y]=="." and D[X][Y]>cnt:
                    D[X][Y]=cnt
                    queue.appendleft([X,Y,cnt])

        for X in range(max(0,x-2),min(h,x+3)):
            for Y in range(max(0,y-2),min(w,y+3)):
                if S[X][Y]=="." and D[X][Y]>cnt+1:
                    D[X][Y]=cnt+1
                    queue.append([X,Y,cnt+1])

    return D[Dx-1][Dy-1]


h,w=map(int,input().split())
Cx,Cy=map(int,input().split())
Dx,Dy=map(int,input().split())
S=[list(input()) for _ in range(h)]

D=BFS()
print(D if D!=inf else -1)

Measured memory_bytes: 164548
#include<iostream>
#include<algorithm>
#include<utility>
#include<cmath>
#include<string>

using namespace std;

char map[101][101];
int a,b;

void dfs(int x,int y,char hoge){
    if(x>=a||x<0){
        return;
    }
    else if(y>=b||y<0){
        return;
    }
    
    if(map[x][y]== hoge){
        map[x][y]='x';
    }
    else{
        return;
    }
    
    dfs(x+1,y,hoge);
    dfs(x-1,y,hoge);
    dfs(x,y+1,hoge);
    dfs(x,y-1,hoge);
}

int main(){
    
    int ans = 0;
    
    while(cin>>a>>b){
        if(a==0&&b==0){
            return 0;
        }
        ans=0;
        
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                cin >> map[i][j];
            }
        }
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                if(map[i][j]!='x'){
                    dfs(i,j,map[i][j]);
                    ans+=1;
                }
            }
        }
        
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        long a = sc.nextLong();
        long v = sc.nextLong();
        long b = sc.nextLong();
        long w = sc.nextLong();
        long t = sc.nextLong();

        if (a == b) {
            System.out.println("YES");
            return;
        }

        if (v <= w) {
            System.out.println("NO");
            return;
        }

        double diff = (double)Math.abs(a - b);
        if (Math.ceil(diff / (v - w)) <= t)
            System.out.println("YES");
        else
            System.out.println("NO");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

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

int main() {
  int X, Y;
  scanf("%d %d", &X, &Y);
  int A = 0;
  int B = 0;

  if(Y == 2*X || Y == 4*X){
    cout << "Yes";
    return 0;
  }
  else{
    for(int i = 0; i < X; i++){
      for(int j = 0; j < X; j++){
      	if(i + j == X){
        	if(2*i + 4 * j == Y){
          		cout << "Yes";
          		return 0;
            }
        }
      }
    }
  }         
  cout << "No";
}

Measured memory_bytes: 3756