akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11

using namespace std;
#define N_MAX 112345
ll k;
struct edge {
  ll to;
  ll cost;
  edge() {}
  edge(ll to_, ll cost_) : to(to_), cost(cost_) {}
};
std::vector<edge> graph[N_MAX];

// O(ElogV)ダイクストラ
ll D[N_MAX];

void Dijkstra(uint32_t s) {
  using P = std::pair<ll, ll>; // cost pos
  std::priority_queue<P, std::vector<P>, std::greater<P>> que;
  std::fill(std::begin(D), std::end(D), INF);

  D[1] = 1;
  que.emplace(1, 1);
  while (!que.empty()) {
    auto p = que.top();
    que.pop();
    const auto &nowpos = p.second;
    const auto &nowcost = p.first;
    if (D[nowpos] < nowcost) {
      continue;
    }
    REP(i, 2) {
      auto cost = nowcost + (i == 0),
           to = (i == 0 ? nowpos + 1 : nowpos * 10) % k;

      if (cost < D[to]) {
        D[to] = cost;
        que.emplace(cost, to);
      }
    }
  }
}

int main() {
  cin >> k;
  Dijkstra(0);
  cout << D[0] << endl;
}


Measured memory_bytes: 4856
import numpy as np

def binstr(n):
    return np.array(list(map(int,list(bin(n)[2:].rjust(40,'0')))))

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

AA = sum([binstr(i) for i in A])
X = 0
ans = 0
for i in range(40):
    if AA[i] > N-AA[i]:   # 0にした方がいい
        ans += AA[i]*(2**(39-i))
    else:                 # 1にした方がいい
        if X+2**(39-i) <= K:    # 1
            ans += (N-AA[i])*(2**(39-i))
            X += 2**(39-i)
        else:                  # 0
            ans += AA[i]*(2**(39-i))

print(ans)

Measured memory_bytes: 74960
/**
*    author:  Dooloper
*    created: 03.05.2020 21:47:14
**/

#include <bits/stdc++.h>

using namespace std;

int cnt[101010];

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n,m,ans = 0;
	cin >> n >> m;
	vector<long long> h(n);
	for(int i = 0; i < n; i++) cin >> h[i];
	for(int i = 0; i < n; i++) cnt[i] = 1;

	int a,b;
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		a--;
		b--;

		if(h[a] >= h[b] && cnt[b] != 0){
			cnt[b] = 0;
		}
		if(h[a] <= h[b] && cnt[a] != 0){
			cnt[a] = 0;
		}
	}
	for(int i = 0; i < n; i++){
		if(cnt[i] == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> ans(m, 0);
    int k, a, cnt = 0;

    for(int i = 0; i < n; i++){
        cin >> k;
        for(int j = 0; j < k; j++){
            cin >> a;
            ans[a - 1] += 1;
        }
    }
    for(int i = 0; i < m; i++){
        if(ans[i] == n) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
aa=[list(map(int, input().split())) for _ in range(h)]
odd=[]
for y in range(h):
    temp=[]
    for x in range(w):
        if aa[y][x]%2==1:
            temp.append((y,x))
    if y%2==0:
        temp.sort()
    else:
        temp.sort(reverse=True)
    odd+=temp
#print(odd)
result=[]
i=0
while i<(len(odd)//2)*2:
    #print("i#",i)
    start=odd[i]
    sx,sy=start[1],start[0]

    goal=odd[i+1]
    gx,gy=goal[1],goal[0]

    #print(sx,sy,gx,gy)

    #先に縦移動
    if sy%2==0:
        if gx<sx:
            flag="yx"
        else:
            flag="xy"
    else:
        if gx<sx:
            flag="xy"
        else:
            flag="yx"
    
    while sx!=gx or sy!=gy:
        #print(result)
        if flag=="xy":
            if sx<gx:
                result.append((sy+1,sx+1,sy+1,sx+1+1))
                sx+=1
            elif sx>gx:
                result.append((sy+1,sx+1,sy+1,sx-1+1))
                sx-=1
            elif sy<gy:
                result.append((sy+1,sx+1,sy+1+1,sx+1))
                sy+=1
            else:
                result.append("error1")
        elif flag=="yx":
            if sy<gy:
                result.append((sy+1,sx+1,sy+1+1,sx+1))
                sy+=1
            elif sx<gx:
                result.append((sy+1,sx+1,sy+1,sx+1+1))
                sx+=1
            elif sx>gx:
                result.append((sy+1,sx+1,sy+1,sx-1+1))
                sx-=1
            else:
                result.append("error2")
    i+=2

print(len(result))
for item in result:
    print(" ".join(map(str,item)))





Measured memory_bytes: 82172
n,m = map(int,input().split())
ks = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
ans = 0

for i in range(2**n):
  light = 0
  for j in range(m):
    cnt = 0
    for k in range(1,ks[j][0]+1):
      if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
        cnt += 1
    if cnt % 2 == p[j]:
      light += 1
  if light == m:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #pragma GCC optimization ("unroll-loops")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
	 ll n,x,t;
	 cin >> n >> x >> t;
	 cout << ((n+x-1)/x)*t;
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying

Measured memory_bytes: 3652
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func gcd(a int64, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a int64, b int64) int64 {
	return a / gcd(a, b) * b
}

func calc(sum int64, c int64, d int64) int64 {
	divC := sum / c
	divD := sum / d
	divCD := sum / lcm(c, d)
	return (sum - divC - divD + divCD)
}

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

	a := int64(nextInt())
	b := int64(nextInt())
	c := int64(nextInt())
	d := int64(nextInt())

	if a == 1 {
		sum := b
		fmt.Println(calc(sum, c, d))
	} else {
		sum1 := a - 1
		cal1 := calc(sum1, c, d)

		sum2 := b
		cal2 := calc(sum2, c, d)
		fmt.Println(cal2 - cal1)
	}
}


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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int> v(n);
	double bb = 0.0;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		bb += (1.0 / (double)a);
	}

	cout << setprecision(16) << (double)((double)1.0 / (double)bb) << endl;
	return 0;
}


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

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

    if( A+B+C != 17 ) cout << "NO" << endl;
    else {
        switch( A ){
        case 5:
            if( B == 5 ^ C == 5 ) cout << "YES" << endl;
            break;
        case 7:
            if( B == 5 ) cout << "YES" << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
'use strict';

function Main(input) {
    const tmp = input.split(' ');
    let A = parseInt(tmp[0], 10);
    let B = parseInt(tmp[1], 10);
    const K = tmp[2];

    for (let i = 0; i < K; i++) {
        if (i % 2 == 0) {
            if (A % 2 == 1) {
                A--;
            }
            B += A / 2;
            A /= 2;
        } else {
            if (B % 2 == 1) {
                B--;
            }
            A += B / 2;
            B /= 2;
        }
    }
    console.log(A, B);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t n; cin>>n;
	int ans=0;
	for(int64_t p=2;p*p<=n;++p){
		if(n%p!=0)continue;
		int64_t z=p;
		while(n%z==0){
			++ans;
			n/=z;
			z*=p;
		}
		while(n%p==0)n/=p;
	}
	if(n!=1)++ans;
	cout<<ans<<"\n"s;
}

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

int main() {
  int i, j, k, N; cin >> N;
  string s, t; cin >> s >> t;
  rep (i, N)
    cout << s.at(i) << t.at(i);
  cout << endl;

  return 0;
}


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

int main() {
  int N,A,x;
  cin>>N;
  cin>>A;
  x=N%500;
  if (x<=A){
   cout<<"Yes"<<endl; 
  }
   else{
   cout<<"No"<<endl; 
  }
}
    


Measured memory_bytes: 256
#include <stdio.h>

int main(void) 
{
    int range, target, cnt;
    int a, b, c;

    scanf("%d %d", &range, &target);
    
    while ((range != 0) || (range != 0)) {
        cnt = 0;
        for (a=range; a>0; a--) {
            for (b=a-1; b>0; b--) {
                for(c=b-1; c>0; c--) {
                    if ((a + b + c) == target) {
                        cnt++;
                    }
                }
            }
        }

        printf("%d\n", cnt);
        scanf("%d %d", &range, &target);
    }
    
    return 0;    
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll findTrailingZeros(ll n)
{
    ll cnt = 0;
    for (ll i = 5; n / i >= 1; i *= 5)
        cnt += n / i;

    return cnt;
}
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t;
	t=1;
	while(t--)
    {
        ll k;
        cin>>k;
        set<ll> s;
        for(int i=1;i<=9;i++)
            s.insert(i);
        ll ans;
        while(k--)
        {
            auto it=s.begin();
            ll p=(*it);
            ll r=p%10;ans=p;
            s.erase(it);
            if(r==0)
            {
                if(s.size()<k)
                s.insert(p*10);
                if(s.size()<k);
                s.insert(p*10+1);
            }
            else if(r==9)
            {
               if(s.size()<k)
                s.insert(p*10+8);
                if(s.size()<k)
                 s.insert(p*10+9);
            }
            else
            {
                if(s.size()<k)
                s.insert(p*10+(r-1));
                if(s.size()<k)
                 s.insert(p*10 + r);
                 if(s.size()<k)
                s.insert(p*10 + (r+1));
            }
        }
        cout<<ans;
    }
}


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

int main() {
  long A, B, K;
  cin >> A >> B >> K;
  if (K >= A) {
    K -= A;
    A = 0;
    B -= K;
    if (B < 0) B = 0;
  } else {
    A -= K;
  }
  cout << A << " " << B << "\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      int n = scanner.nextInt();
      if (n == 0) {
        break;
      }
      List<String> cs = new ArrayList<String>();
      for (int ii = 0; ii < n; ii++) {
        int c1 = scanner.nextInt();
        int m1 = scanner.nextInt();
        int s1 = scanner.nextInt();
        int m2 = scanner.nextInt();
        int s2 = scanner.nextInt();
        int m3 = scanner.nextInt();
        int s3 = scanner.nextInt();
        int m4 = scanner.nextInt();
        int s4 = scanner.nextInt();
        int t = m1 * 60 + s1 + m2 * 60 + s2 + m3 * 60 + s3 + m4 * 60 + s4;
        cs.add(String.format("%05d,%08d", t, c1));
      }
      Collections.sort(cs);
      String[] works = cs.get(0).split(",");
      System.out.println(Integer.parseInt(works[1]));
      works = cs.get(1).split(",");
      System.out.println(Integer.parseInt(works[1]));
      works = cs.get(cs.size() - 2).split(",");
      System.out.println(Integer.parseInt(works[1]));
    }
  }
}

Measured memory_bytes: 74072
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  int ans=0;
  int t=0,r=0;
  for(int i=0;i<n;i++){
    if(r==n){
      ans++;
      continue;
    }
    if(r==i) t+=a[r++];
    while(r<n&&a[r]<=t*2) t+=a[r++];
    if(r==n) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i].first;
        b[i].second = i;
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < n; i++) {
        a[b[i].second].second = i;
    }
    sort(a.begin(), a.end());

    for (int i = 0; i < n; i++) {
        if (a[i].first > b[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }

    int j = 0, cnt = 0;
    do {
        j = a[j].second;
        cnt++;
    } while (j != 0);
    if (cnt != n) {
        cout << "Yes" << endl;
        return 0;
    }

    for (int i = 0; i < n - 1; i++) {
        if (a[i + 1].first <= b[i].first) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;

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

    cout<<(a+b)*h/2<<endl;
}


Measured memory_bytes: 3592
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

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

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);

	return x * y / tmp;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


	int a,b;
	cin >> a >> b;
	string s,t;
	
	for (int i = 0; i < b; i++)
	{
		/* code */
		s.push_back('0'+a);
	}

	for (int i = 0; i < a; i++)
	{
		/* code */
		t.push_back('0'+b);
	}
	//cout << b-'0'<<endl;
	if(s <= t){
		cout << s << endl;
	}else{
		cout << t << endl;
	}

	

	return 0;
}



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }

int n, k;

int main() {
	cin >> n >> k;
	
	cout << ce(n - 1, k - 1) << endl;
	
	return 0;
}


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

using namespace std;

int main()
{                        
	int k, n, m, s;
    cin>>n>>m;
 
    vector<vector<int> > bulb(m, vector<int>());
    vector<int> p(m);
 
    for (int i=0;i<m;++i){
        cin>>k;
        while (k--){
            cin>>s;
            s--;
            bulb[i].emplace_back(s);
        }
    }
    for (int i=0;i<m;++i) cin>>p[i];
 
    int ans = 0;
    for (int mask = 0; mask<(1<<n);++mask){
        bool isValid = true;
        for (int i=0;i<m;++i){
 
            int cnt = 0;
            for (auto b : bulb[i]){
                if (mask&(1<<b)) cnt++;
            }
            if (cnt%2 != p[i]){
                isValid = false;
                break;
            }
        }
        if (isValid) ans++;
    }
 
    cout<<ans<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pll         vector< pair<ll ,ll> >
#define vll         vector<ll>
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(v)      v.begin(), v.end()
#define lb          lower_bound  //value not less than(>=)
#define ub          upper_bound  //value greater than(>)
#define bs          binary_search
#define pcont(v)    for(auto it:v) cout<<it<<" ";cout<<endl
#define ret(x)      return cout << x,0;
#define pi          pair<ll,pair<ll,ll> >

ll const MAX = 1e5+5;
using namespace std;

ll dp[MAX][4];
ll a[MAX],b[MAX],c[MAX];
ll n;

ll ff(ll pos, ll last) {
    if(pos==n+1) return 0;
    if(dp[pos][last]!=-1) return dp[pos][last];
    ll ans;
    if(last==1) {
        ans=max(ff(pos+1,2)+b[pos], ff(pos+1,3)+c[pos]);
    }
    if(last==2) {
        ans=max(ff(pos+1,1)+a[pos], ff(pos+1,3)+c[pos]);
    }
    if(last==3) {
        ans=max(ff(pos+1,1)+a[pos], ff(pos+1,2)+b[pos]);
    }
    return dp[pos][last]=ans;
}

ll f(ll start, ll last) {
    rep(i,1,n+1) dp[i][1]=-1,dp[i][2]=-1,dp[i][3]=-1;
    return ff(start, last);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

    cin >> n;
    rep(i,1,n+1) cin >> a[i] >> b[i] >> c[i];
    cout << max(f(2,1)+a[1], max(f(2,2)+b[1], f(2,3)+c[1]));
}


Measured memory_bytes: 10368
n = int(input())
save = [-1]*(n+1)

def aC2(a):
    if(save[a]!=-1):
        return save[a]
    ans = 1
    for i in range(a-1,a+1):
        ans *= i
    ans //=2
    save[a] = ans
    return ans

dic = {}
for i in range(n):
    s = list(input())
    s.sort()
    s = ''.join(s)
    if(dic.get(s) is None):
        dic[s] = 1
    else:
        dic[s] += 1

ans = 0
for x in dic.values():
    if(x==0 or x==1):
        continue
    ans += aC2(x)

print(ans)



    

Measured memory_bytes: 18704
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
#define debug(x) cout<<x;
    
int a[200005];
    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int k,n;
    cin>>k>>n;

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

    int ans=0,maxn=0;
    for (int i=0;i<n-1;i++)
    {
        ans+=a[i+1]-a[i];
        maxn=max(maxn,a[i+1]-a[i]);
    }
    ans+=a[0]+k-a[n-1];
    maxn=max(maxn,a[0]+k-a[n-1]);

    cout<<ans-maxn<<'\n';
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < S.length(); i++)
    {
        if(S[i] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int moda = a % b;
    int x = moda + moda;
    while(x % b != moda){
        if (x % b == c){
            cout << "YES" << endl;
            return 0;
        }
        x += moda;
        // cout << x << endl;
    }
    cout << "NO" << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n;
vector<LL> d,init_d;
vector<LL> ind,width;
vector<pair<int,int>> ans;
vector<vector<int>> tree;

LL dfs(int pos,LL cum){
  LL ret = cum;
  REP(i,tree[pos].size())
    ret += dfs(tree[pos][i],cum+1);
  return ret;
}

int main(){
  cin>>n;
  LL tmp;
  REP(i,n){
    cin>>tmp;
    d.push_back(tmp);
    init_d.push_back(tmp);
  }
  sort(d.begin(),d.end());
  ind.resize(n);
  REP(i,n){
    int min_ind = distance(d.begin(),lower_bound(d.begin(),d.end(),init_d[i]));
    ind[min_ind] = i+1;
  }
  REP(i,n){
    width.push_back(1);
  }
  tree.resize(n);
  REP(i,n-1){
    LL s = d[n-1-i] - (n - 2*width[n-1-i]);
    //cerr<<s<<endl;
    int min_ind2 = distance(d.begin(),lower_bound(d.begin(),d.end(),s));
    if(d[min_ind2] != s || s > d[n-1-i]){
      cout<<-1<<endl;
      return 0;
     }
    ans.push_back(make_pair(min_ind2,n-1-i));
    tree[min_ind2].push_back(n-1-i);
    //tree[n-1-i].push_back(min_ind2);
    width[min_ind2] += width[n-1-i];
  }
  
  if(d[0] != dfs(0,0)){
    cout<<-1<<endl;
    return 0;
  }
  
  REP(i,ans.size())
    cout<<ind[ans[i].first]<<" "<<ind[ans[i].second]<<endl;
  return 0;
}


Measured memory_bytes: 14700
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

n = int(input())
edge = []
for i in range(n-1):
    edge.append(list(map(int,input().split())))

c_arr = sorted(list(map(int,input().split())))

m = sum(c_arr) - max(c_arr)
ans = [0]*(n + 1)
a,b = edge.pop()
ans[a] = c_arr.pop()
ans[b] = c_arr.pop()
uf = UnionFind(n)
uf.union(a,b)
while edge:
    for i in range(len(edge)):
        if uf.same_check(a,edge[i][0]):
            if not uf.same_check(a,edge[i][1]):
                ans[edge[i][1]] = c_arr.pop()
                uf.union(edge[i][0],edge[i][1])
                edge.pop(i)
                break
        elif uf.same_check(a,edge[i][1]):
            ans[edge[i][0]] = c_arr.pop()
            uf.union(edge[i][0],edge[i][1])
            edge.pop(i)
            break
print(m)
print(*ans[1:])        


Measured memory_bytes: 51800
def prime(N):
    p=set(range(2,N+1))
    for i in range(int(N**.5)+1):
        if i in p:
            p-=set(range(i*2,N+1,i))
    return p
N=2*10**5
p=prime(N)
X=int(input())
for i in range(X,N+1):
    if i in p:
        print(i)
        break

Measured memory_bytes: 27620
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
while (true) {
   if (arr[0] == "0 0") break;
   var nm = arr.shift().split(" ").map(Number);
   var m = nm[1];
   var a = arr.shift().split(" ").map(Number);
   a.sort(function(a, b) {
      return b - a;
   });
   var max = 0;
   for (var i = 0; i < a.length - 1; i++) {
      for (var j = i + 1; j < a.length; j++) {
         if (a[i] + a[j] <= m) {
            max = Math.max(max, a[i] + a[j]);
            continue;
         }
      }
   }
   if (max == 0) max = "NONE";
   console.log(max);
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int L = A + B;
  int R = C + D;
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L < R) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;
  ll a[n];
  REP(i, n) cin >> a[i];
  ll ans = 1, now = 0, flag = 0;
  REP(i, n){
    if(a[now] == 2){
      flag = 1;
      break;
    }
    now = a[now] - 1;
    ans++;
  }
  if(flag) cout << ans << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		long n =scn.nextLong();
		 PriorityQueue<Long> pq =new PriorityQueue<>();
		   long i=0;
		   for(i=0;i<9;i++){
			   pq.add(i+1);
		   }
		   i=0;
		   while(i<n-1 && pq.size()>0){
			   long val =pq.remove();
			         if(val%10!=0){
				   pq.add(val*10+(val%10-1));
			         }
			         if(val%10!=9){
			   long val1=val*10+(val%10+1);
			   pq.add(val1);
			   }
			         
			   long val2=val*10+(val%10);
			 
			   pq.add(val2);
			   i++;
			  
			   
		   }
//         while(pq.size()>1){
//        	 pq.remove();
//         }
         System.out.println(pq.remove());
	}

}

Measured memory_bytes: 32084
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin>>n;
  int i;
  ll a[n];
  for(i=0;i<n;i++){
  	cin>>a[i];
  }
  
  
  int count=0;
  int j,k;
  for(i=0;i<n;i++){
  	for(j=i+1;j<n;j++){
	  if(a[i]!=a[j]){
	    for(k=j+1;k<n;k++){
	    	if(a[k]!=a[j]&&a[k]!=a[i]){
	    		if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]){
	    			count++;
				}
			}
		}
			
	   }  		
	  
	  }
  }
  
  
  cout<<count<<endl;
  
  return 0;
}

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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

typedef long long int ll;

ll INF = 1000000000000000000;
ll MOD = 1e9+7;

int main(){
    ll N;cin >> N;
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }
    vector<ll> ans;
    while(N != 0){
        int r = N % 2;
        if(r < 0)r += 2;
        N = (N - r) / (-2);
        ans.push_back(r);
    }
    int n = ans.size();
    for(int i = n-1;i >= 0;i--){
        cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

template <int MOD = 1000000007>
struct Mint{
    int x;

    Mint() : x(0) {}
    Mint(int t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(int n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }

    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }

    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        int t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main(){
    int n,k;
    cin >> n >> k;
    vector<int> v;
    for(int i = 1; i * i <= n; i++){
        v.emplace_back(i);
        if(i != n / i) v.emplace_back(n / i);
    }
    sort(ALL(v));
    int m = v.size();
    int cnt[m];
    for(int i = 1; i < m; i++){
        cnt[i] = v[i] - v[i - 1];
    }
    cnt[0] = 1;
    Mint<> dp[k + 1][m];
    dp[0][0] = 1;
    for(int i = 0; i < k; i++){
        Mint<> sum[m + 1];
        for(int j = 0; j < m; j++){
            sum[j + 1] = sum[j] + dp[i][j];
        }
        for(int j = 0; j < m; j++){
            dp[i + 1][j] += sum[m - j] * cnt[j];
        }
    }
    Mint<> ans = 0;
    for(int i = 0; i < m; i++){
        ans += dp[k][i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 26108
#include <iostream>
#include <cstring>
#include <cmath> 
#include <algorithm>

using namespace std;

const int maxn=1e5+10;
int n;
int a[maxn],f[maxn];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	f[2]=abs(a[1]-a[2]);
	for(int i=3;i<=n;i++)
	{
		f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
	} 
	cout<<f[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
"""
[a,b]=list(map(float,input().split()))
import math
a=int(a)
b=int(b*100)
ans=a*b
ans=ans/100
ans=math.floor(ans)
print(ans)
"""
[a,b]=list(input().split())
a=int(a)
b12=list(b.split('.'))
bkai=int(int(b12[0])*100+int(b12[1]))
ans=a*bkai
ans=ans//100
print(ans)

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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

ll mini(ll a,ll b){	return a<b?a:b;}
ll maxi(ll a,ll b){	return a>b?a:b;}
ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

    string s,t;
    cin>>s>>t;

    int a = s.length();
    int b = t.length();

    vector<int> dp[a+1];
    for(int i=0;i<=a;++i)    dp[i].resize(b+1,0);
    vector<int> dptrack[a+1];
    for(int i=0;i<=a;++i)    dptrack[i].resize(b+1,10);


    for(int i=1;i<=a;++i){
        for(int j=1;j<=b;++j){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
                dptrack[i][j] = 0;                
            }
            else if(dp[i-1][j] > dp[i][j-1]){
                dp[i][j] = dp[i-1][j];
                dptrack[i][j] = 1;
            }
            else{
                dp[i][j] = dp[i][j-1];
                dptrack[i][j] = 2;
            }
        }
    }

    vector<char> ans;

    ll x=a,y=b;

    while(dptrack[a][b] != 10){
        if(dptrack[a][b] == 0){
            ans.push_back(s[a-1]);
            a--;
            b--;
        }
        else if(dptrack[a][b] == 1) a--;
        else  b--;
    }

    if(ans.size()){
        while(ans.size()){
            cout<<ans.back();
            ans.pop_back();
        }
    }
    
    cout<<'\n';

    return 0;
}

Measured memory_bytes: 74216
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>

std::string S;
int N, K;
 
int main(int argc, char **argv) {
    std::cin >> N;
    std::cin >> S;
    std::cin >> K;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] != S[K-1]) {
            S[i] = '*';
        }
    }
    std::cout << S << std::endl;

    return 0;
}

Measured memory_bytes: 256
function main(input) {
    var args = input.trim().split("\n");
    var info = args[0].split(" ").map((v) => parseInt(v));
    var N = info[0];
    var M = info[1];
    var jobs = args.filter((v, i) => i !== 0).map((v) => {
        return v.split(" ").map(v2 => parseInt(v2));
    });

    jobs.sort((a, b) => {
        return a[0] - b[0];
    });


    var pq = new PriorityQueue();
    var result = 0;
    var j = 0;
    for(var i = 1; M >= i; i++) {
        while(!!jobs[j] && jobs[j][0] <= i) {
            pq.push(-jobs[j][1]);
            j++;
        }

        if(pq.size()) result += -pq.pop();
    }

    console.log(result);
}

function PriorityQueue(){
    this.heap = [];
}
PriorityQueue.prototype = {
    push : function(x){
        var h = this.heap, i = h.length++, j;
        while(i){
            j = i-1 >> 1;
            if(h[j] <= x)break;
            h[i] = h[j];
            i = j;
        }
        h[i] = x;
    },
    pop : function(){
        var h = this.heap, r = h[0], x = h.pop();
        var i = 0, k = h.length >> 1, j;
        while (i < k) {
            j = (i << 1) + 1;
            if(h[j+1] < h[j])++j;
            if(x <= h[j])break;
            h[i] = h[j];
            i = j;
        }
        if(h.length)h[i] = x;
        return r;
    },
    size : function(){return this.heap.length;},
    top : function(){return this.heap[0];},
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  set<string> d;
  int n;
  cin >> n;
  
  char last;
  string s;
  for(int i=0; i<n; i++) {
  	cin >> s;
    if(i > 0) {
      if(d.count(s) || s[0] != last) {
        cout << "No" << endl;
        return 0;
      }
    }
    d.insert(s);
    last = *(s.end()-1);
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin

num_swap = 0


def merge(a, left, mid, right):
    global num_swap
    L = a[left:mid]
    R = a[mid:right]
    L.append(10**9+1)
    R.append(10**9+1)
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            a[k] = L[i]
            i += 1
        else:
            a[k] = R[j]
            j += 1
        num_swap += 1


def merge_sort(a, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        merge_sort(a, left, mid)
        merge_sort(a, mid, right)
        merge(a, left, mid, right)


stdin.readline()
s = [int(s) for s in stdin.readline().split()]
merge_sort(s, 0, len(s))
print(*s)
print(num_swap)

Measured memory_bytes: 49584
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[1050] = {}, f[100010] , counto = 0, counto1 = 0;
double syo = 0, su = 0;
char mado[105];
string rik;
bool mazi[110], gi[110];
pair<int, int>n[110];
vector<int> r;
int main() 
{
	cin >> e[0]>>e[1]>>e[2]>>d;
	counto = max(e[0], max(e[1], e[2]));
	counto1 = counto;
	//cout << counto << endl;
	for (int i = 0; i < d; i++) {
		counto = counto * 2;
		//cout << counto << endl;
		//cout << e[0] << e[1] << e[2] << endl;
	}
	for (int i = 0; i < 3; i++) {
		if (e[i] == counto1) {
			a += counto;
			counto1 = 111111111;
		}
		else { a += e[i]; }
	}
	cout << a << endl;
	return 0;
}

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

int main(){
    int a,b,c,ans=1;
    cin >>  a >> b >> c;
    if(a==b){
        if(b==c){
            cout << 1 << endl;
        }
        else {
            cout << 2 << endl;
        }
    }
    else{
        if(a==c){
            cout << 2 << endl;
        }
        else if(b==c){
            cout << 2 << endl;
        }
        else{
            cout << 3 << endl;
        }
    }
    return 0;
}

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

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector <ll> p(a);
  vector <ll> q(b);
  vector <ll> r(c);
  rep(i, a) cin >> p.at(i);
  rep(i, b) cin >> q.at(i);
  rep(i, c) cin >> r.at(i);
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  ll res = 0;
  rep(i, x) r.push_back(p.at(a-1-i));
  rep(i, y) r.push_back(q.at(b-1-i));
  sort(r.begin(), r.end());
  rep(i, x+y) res += r.at(r.size()-1-i);
  cout << res << endl;
}

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

struct Node {
    int idx;
    int parent = -1;
};

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

    std::vector<std::vector<int>> links(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        std::cin >> a >> b;
        a--;
        b--;
        links[a].emplace_back(b);
        links[b].emplace_back(a);
    }

    std::vector<Node> nodes(N);
    for (int i = 0; i < N; i++) {
        nodes[i].idx = i;
    }

    std::queue<Node> que;
    que.push(nodes[0]);

    while (!que.empty()) {
        auto q = que.front();
        que.pop();
        for (auto && link : links[q.idx]) {
            if (nodes[link].parent == -1) {
                nodes[link].parent = q.idx;
                que.push(nodes[link]);
            }
        }
    }

    std::cout << "Yes" << std::endl;
    for (int i = 1; i < N; i++) {
        std::cout << nodes[i].parent + 1 << std::endl;
    }
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1
#define j0 gray_cat_j0

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 16;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 205;

const int LIM = 62;

int g[MAXN][LIM];

set<ll> bb;

int gg[LIM][LIM];
int m;

ll val[MAXN];

char s[MAXN];

int get_bit_ind(ll v) {
	for(int i = LIM - 1; i >= 0; i--) {
		if (v & (1ll << i)) {
			return i;
		}
	}
	assert(false);
	return -1;
}

bool is_lnz(int ind) {
	FA(it, bb) {
		ll cur = -(*it);
		int pos = get_bit_ind(cur);
		if (val[ind] & (1ll << pos)) {
			val[ind] ^= cur;
		}
	}
	if (val[ind]) {
		return true;
	}
	return false;
}

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%lld", &val[i]);
	}
	scanf("%s", &s[0]);
	bb.clear();
	for(int i = n - 1; i >= 0; i--) {
		if (is_lnz(i)) {
			if (s[i] == '1') {
				printf("1\n");
				return;
			} else {
				bb.insert(-val[i]);
			}
		}
	}
	printf("0\n");
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 3572
#include<iostream>
#include<string>
using namespace std;
char T[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; int t[999], n, i, j;
int main() {
	string S, U;
	while (true) {
		U = "";
		cin >> n;
		if (n == 0) { break; }
		for (i = 0; i < n; i++) { cin >> t[i]; }
		cin >> S;
		for (i = 0; i < S.size(); i++) {
			for (j = 0; j < 52; j++) {
				if (S[i] == T[j]) {
					U += T[(j - t[i%n] + 52) % 52];
				}
			}
		}
		cout << U << endl;
	}
}

Measured memory_bytes: 1200
#include<iostream>
#define ll long long
using namespace std;

int main(){
  ll L,R; cin >> L >> R;
  ll ans = 2018;
  for(ll i=L;i<=R;i++)
  {
    for(ll k=i+1;k<=R;k++)
    {
      if(ans==0) break;
      ans=min(ans,(i*k)%2019);
    }
    if(ans==0) break;
  }
  cout<<ans;
}
      
  


Measured memory_bytes: 256
H, W, K = map(int, input().split())
c = [input().rstrip() for _ in range(H)]
ans = 0
for biti in range(1 << H):
    for bitj in range(1 << W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if c[i][j] == '#' and not (biti >> i & 1) and not (bitj >> j & 1):
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Measured memory_bytes: 68340
#include <stdio.h>

int main() {
    int n;
    scanf("%d",&n);
    n %= 10;
    printf((n == 2 || n == 4 || n == 5 || n == 7 || n == 9)? "hon\n" : (n == 0 || n== 1 || n == 6 || n == 8)? "pon\n" : "bon\n");
    return 0;
}


Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();
    int ans = 0;
    ans = (n / x) + 1;
    if (n % x == 0)
      ans--;
    System.out.println(ans * t);
    sc.close();
  }
}

Measured memory_bytes: 35764
def resolve():
    n, m = map(int, input().split())
    co = 0
    pe = 0
    P = [0] * n
    for _ in range(m):
        p, s = input().split()
        ind = int(p)-1
        if P[ind] != -1: #既に正解
            if s == "WA":
                P[ind] += 1
            else:
                pe += P[ind]
                P[ind] = -1
                co += 1
    print(co, pe)
resolve()

Measured memory_bytes: 9604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll n;
ll k;
struct data{
    ll to;ll col;
    ll flag;
};
vector<data> v[100001];

void hoge(ll x,ll y,ll z){
    if(y==0){
        ll color=1;
        if(v[x].size()>0){
            rep(i,0,v[x].size()-1){
                if(v[x][i].col==0){
                    v[x][i].col=color;
                    hoge(v[x][i].to,color,x);
                    color++;
                }
            }
        }
    }else{
        ll color=1;
        if(v[x].size()>0){
            rep(i,0,v[x].size()-1){
                if(v[x][i].to==z){
                    continue;
                }
                if(color==y){
                    color++;
                }
                v[x][i].col=color;
                hoge(v[x][i].to,color,x);
                color++;
            }
        }
    }
}

int main(){
    cin>>n;
    ll a,b;
    rep(i,0,n-2){
        cin>>a>>b;
        data d;
        d.col=0;
        d.flag=i;
        d.to=a;
        v[b].pb(d);
        d.to=b;
        v[a].pb(d);
    }
    k=-1;
    ll flag=0;
    rep(i,1,n){
        if(k<(ll)v[i].size()){
            flag=i;
            k=v[i].size();
        }
    }
    hoge(flag,0,0);
    ll ans[n-1];
    rep(i,1,n){
        rep(j,0,v[i].size()-1){
            //cout<<i<<' '<<v[i][j].to<<' '<<v[i][j].col<<endl;
            if(v[i][j].col!=0){
                ans[v[i][j].flag]=v[i][j].col;
            }
        }
    }
    cout<<k<<endl;
    rep(i,0,n-2){
        cout<<ans[i]<<endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 12032