akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  map<int, ll> amap;
  int A[N];
  vector<int> arr;
  for(int i=0;i<N;++i) {
    cin>>A[i];
    if(amap[A[i]]==0) arr.push_back(A[i]);
    amap[A[i]]++;
  }
  ll ans = 0;
  for(int i=0;i<arr.size();++i) {
    ans += amap[arr[i]]*(amap[arr[i]]-1)/2;
  }
  ll tmp;
  for(int i=0;i<N;++i) {
    cout<<ans-amap[A[i]]+1<<endl;
  }
}



Measured memory_bytes: 12548
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    ll N ,P; cin >> N >> P;

    if(N == 1){
        cout << P << endl;
        return 0;
    }

    ll ans = 1;
    vector<pair<ll, ll>> v = prime_factorize(P);
    // sort(allr(v));
    for(auto itr = v.begin();itr != v.end();itr++){
        if(itr->second >= N){
            ans *= pow(itr -> fs, (itr -> second) / N);
        }
    }

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

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

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

signed main(){
  int n,m,q;cin>>n>>m>>q;
  vector<int> a(q),b(q),c(q),d(q);
  for(int i=0;i<q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
  vector<int> v(n,1);
  int ans=0;
  while(1){
    int res=0;
    for(int i=0;i<q;i++){
      if(v[b[i]-1]-v[a[i]-1]==c[i])res+=d[i];
    }
    chmax(ans,res);
    int now=n-1;
    while(1){
      if(++v[now]>m){if(!now)break;v[now]=0,now--;}
      else break;
    }
    if(v[0]>m)break;
    for(int i=1;i<n;i++)chmax(v[i],v[i-1]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    val info = (1..n).map { readLine()!!.split(" ").map { it.toInt() }.toTypedArray() }

    for (cx in 0..100) {
        for (cy in 0..100) {

            val (x, y, h) = info.first { it[2] >= 1 }
            val H = Math.abs(x - cx) + Math.abs(y - cy) + h
            val isans = info.all { it[2] == Math.max(H-Math.abs(it[0] - cx) - Math.abs(it[1] - cy), 0)}

            if(isans){
                println("$cx $cy $H")
                break
            }
        }
    }
}

Measured memory_bytes: 37968
ABCD = input()
# ABCD = "3242"

ABCD = list(map(int, list(ABCD)))

from operator import add, sub
import sys


def f(x):
    return "+" if x == add else "-"


# 2^3
# naive
for op1 in [add, sub]:
    for op2 in [add, sub]:
        for op3 in [add, sub]:
            s = op3(op2(op1(ABCD[0], ABCD[1]), ABCD[2]), ABCD[3])
            if s == 7:
                print("{}{}{}{}{}{}{}=7".format(
                    ABCD[0], f(op1), ABCD[1], f(op2), ABCD[2], f(op3), ABCD[3]))
                sys.exit(0)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  int n,m;
  cin>>n>>m;
  vector<P> v;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    v.PB(P(a,b));
  }
  sort(all(v));
  
  priority_queue<int> q;

  int ans=0,j=0;
  FOR(i,1,m+1){
    while(j<n&&v[j].F<=i){
      q.push(v[j].S);
      j++;
    }
    if(q.empty()) continue;
    ans+=q.top();
    q.pop();
  }

  cout<<ans<<endl;


}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n, W;
    cin >> n >> W;
    vector<int> value(n), weight(n);
    for(int i = 0; i < n; i++) cin >> value[i] >> weight[i];
    vector<vector<int>> dp(n + 1, vector<int>(W + 1));
    for(int i = 1; i <= n; i++){
        int v = value[i - 1];
        int w = weight[i - 1];
        for(int j = 1; j <= W; j++){
            if(j < w) dp[i][j] = dp[i - 1][j];
            else{
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v);
            }
        }
    }
    //for(int i = 0 ; i <= n ; i ++) {cout << "\n"; for (int j = 0 ; j <= W ; j++) cout << dp[i][j] << " ";}
    cout << dp[n][W] << "\n";
}


Measured memory_bytes: 6748
function main(input){
  const lines = input.split('\n');
  const NZW = lines.shift().split(' ').map(x => parseInt(x));
  const N = NZW[0];
  const Z = NZW[1];
  const W = NZW[2];
  const A = lines.shift().split(' ').map(x => parseInt(x));

  // 初期を維持、n-1取る、n取る

  var fetch_n_1 = 0;
  if(N>1){fetch_n_1=Math.abs(A[N-1] - A[N-2]);}
  const fetch_n = Math.abs(A[N-1]-W);

  const result = Math.max(fetch_n_1, fetch_n)
  console.log(result);

}

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


Measured memory_bytes: 11596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
//============================================================================
#define PARENT(x)   pred((succ(x)/2))
#define LEFT(x)     pred((succ(x)*2))
#define RIGHT(x)    pred((succ(x)*2+1))
#define LEFTIDX(x)     ((x)*2)
#define RIGHTIDX(x)    ((x)*2+1)
long Ary[11];
//----------------------------------------------------------------------------
void swaplong(long *x, long *y)
{
    long z;

    z=*x, *x=*y, *y=z;
}
//----------------------------------------------------------------------------
void maxHeapify(long H, long *A, long i)
{
    long l,r,largest;

    l = LEFTIDX(i);
    r = RIGHTIDX(i);
    //i--;
    // ????????????????????????????????§???????????§????????????????????¶
    if (l <= H && A[l] > A[i])
        largest = l;
    else
        largest = i;
    if (r <= H && A[r] > A[largest])
        largest = r;
    if (largest != i){//???// i ???????????????????????§????????´???
        swaplong(&A[i], &A[largest]);// ?????????
        maxHeapify(H, A, largest); // ?????°??????????????????
    }
}
//----------------------------------------------------------------------------
void buildMaxHeap(long H, long *A)
{
    long i;

    for (i=H/2; 0<i; i--)
        maxHeapify(H, A, i);
}
//----------------------------------------------------------------------------
void bintree(FILE *file)
{
    long i,n,*ary; char buffer[20];

    fgets(buffer, sizeof(buffer)-1, file);
    sscanf(buffer, "%ld", &n);
    ary=malloc(n*sizeof(long));
    for (i=0; i<n; i++){
        fscanf(file, "%ld", &ary[i]);
    }
    for (i=0; i<n; i++){
        printf("node %ld: key = %ld, ", succ(i), ary[i]);
        if (i)
            printf("parent key = %ld, ", ary[PARENT(i)]);
        if (LEFT(i)<n)
            printf("left key = %ld, ", ary[LEFT(i)]);
        if (RIGHT(i)<n)
            printf("right key = %ld, ", ary[RIGHT(i)]);
        printf("\n");
    }
    free(ary);
}
//----------------------------------------------------------------------------
void input(FILE *file)
{
    long i,n,*ary; char buffer[20];

    fgets(buffer, sizeof(buffer)-1, file);
    sscanf(buffer, "%ld", &n);
    ary=malloc(succ(n)*sizeof(long));
    for (i=1; i<=n; i++){
        fscanf(file, "%ld", &ary[i]);
    }
    buildMaxHeap(n, ary);
    for (i=1; i<=n; i++)
        printf(" %ld", ary[i]);
    printf("\n");
    free(ary);
}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif

Measured memory_bytes: 4516
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void){
    int N, K;
    cin >> N >> K;
    std::vector<int> A(N, 0);
    rep(i, K){
        int d;
        cin >> d;
        rep(j, d){
            int AA;
            cin >> AA;
            A.at(AA-1)++;
        }
    }
    int ans = 0;
    rep(i, N){
        if(A.at(i) == 0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
###############################################################################

from bisect import bisect_left as binl
from copy import copy, deepcopy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n = intin()
    ablist = intinl(n-1)

    linklist = make_linklist(ablist)
    diameter = calc_tree_diameter(linklist)

    if diameter % 3 == 1:
        print('Second')
    else:
        print('First')


if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int k, n;
  cin >> k >> n;
  if (k % 2 == 0) {
    cout << k / 2;
    for (int i = 1; i < n; i++) cout << " " << k;
    cout << endl;
    return 0;
  }
  vector<int> ans(n, k / 2 + 1);
  for (int i = 0; i < n / 2; i++) {
    if (ans.back() == 1) {
      ans.pop_back();
    } else {
      ans.back()--;
      while (ans.size() < n)
        ans.push_back(k);
    }
  }
  cout << ans[0];
  for (int i = 1; i < ans.size(); i++) cout << " " << ans[i];
  cout << endl;
  return 0;
}


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

int main(){
  string s;
  std::cin >> s;
  int a = 0, b = 0;
  for (int i = 0; i < s.length(); i++) {
    if(s[i] == '1')a++;
    else b++;
  }
  std::cout << s.length() - abs(a - b) << std::endl;
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        var l = Console.ReadLine().Split(" ").Select(e => long.Parse(e)).ToArray();
        long count = 0;
        for (int i = 0; i < l.Length; i++)
        {
            for (int j = i + 1; j < l.Length; j++)
            {
                for (int k = j + 1; k < l.Length; k++)
                {
                    if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i])
                    {
                        continue;
                    }
                    if (l[i] + l[j] <= l[k]) continue;
                    if (l[j] + l[k] <= l[i]) continue;
                    if (l[k] + l[i] <= l[j]) continue;
                    count++;
                }
            }
        }
        Console.WriteLine(count);
    }
}


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

/**
 * @author Yuki
 */
public class Main {

	/*** 利子 */
	private final static double INTEREST = 1.05;
	/*** 切り上げ額 */
	private final static double REVALUATION = 1000;
	/*** 借金 */
	private static int debt = 100000;
	/*** 文字型入力ストリーム（標準入力） */
	private static BufferedReader br;
	/*** 週 */
	private static int weekNum;

	/*** 初期化 */
	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * メインメソッド<br>
	 * 借金の残高を出力する
	 *
	 */
	public static void main(String[] args) throws IOException {

		weekNum = Integer.parseInt(br.readLine());	// 週を取得

		System.out.println(getTotalDept());	// 借金の残高の出力

	}

	/**
	 * 借金の残高を取得する 利子をかけた週の合計の借金を計算して返す
	 *
	 * @return 借金の残高
	 */
	private static int getTotalDept() {
		double debtTemp = debt / REVALUATION;
		for (; weekNum > 0; weekNum--) {
			debtTemp = Math.ceil(debtTemp * INTEREST); // 切り上げ
		}
		return (int) (debtTemp * REVALUATION);
	}

}

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

constexpr int MAX = 2e6 + 10;
constexpr int MINUS = -1;

int gPQ[MAX];
int gSize = 0;

int GetParent( int i ){
  return ( i - 1 ) / 2;
}

int GetLeft( int i ){
  return i * 2 + 1;
}

int GetRight( int i ){
  return i * 2 + 2;
}

void Increase( int i, int key ){
  assert( key >= gPQ[i] );

  gPQ[i] = key;
  while( i > 0 && gPQ[GetParent( i )] < gPQ[i] ){
    swap( gPQ[i], gPQ[GetParent( i )] );
    i = GetParent( i );
  }
}

void Insert( int key ){
  gPQ[gSize] = MINUS;
  Increase( gSize, key );
  gSize++;
}
  
void MaxHeapify( int i ){
  int l = GetLeft( i );
  int r = GetRight( i );
  int largest = 0;

  if( l < gSize && gPQ[l] > gPQ[i] ){
    largest = l;
  }else{
    largest = i;
  }

  if( r < gSize && gPQ[r] > gPQ[largest] ){
    largest = r;
  }

  if( largest != i ){
    swap( gPQ[largest], gPQ[i] );
    MaxHeapify( largest );
  }
}

int Extract(){
  assert( gSize >= 1 );
  int max = gPQ[0];
  gPQ[0] = gPQ[gSize - 1];
  MaxHeapify( 0 );
  gSize--;

  return max;
}

int main(){
  while( 1 ){
    char cmd[10]; cin >> cmd;
    if( strcmp( cmd, "insert" ) == 0 ){
      int key; cin >> key;
      Insert( key );
    }else if( strcmp( cmd, "extract" ) == 0 ){
      cout << Extract() << endl;
    }else if( strcmp( cmd, "end" ) == 0 ){
      break;
    }else{
      cout << "error" << endl;
    }
  }
}



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

signed main(){

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  int q;
  cin>>q;
  while(q--){
    int com,l,r;
    cin>>com>>l>>r;
    if(com==0){
      cout<< *min_element(a.begin()+l,a.begin()+r) <<endl;
    }
    else{
      cout<< *max_element(a.begin()+l,a.begin()+r) <<endl;
    }
  }

}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    string s;
    cin >> s;
    LL x = 0;
    for (int i = 0; i < s.size(); i++) {
        x += s[i] - '0';
    }
    if (x % 9 == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}


Measured memory_bytes: 3720
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
	int i,x,sum,slen;
	char input[1024],num[2];
	while(1){
		sum=0;
		fgets(input,sizeof input,stdin);
		slen=strlen(input);
		for(i=0;i<slen-1;i++){
			num[0]=input[i];
			sum+=atoi(num);
		}
		if(sum==0){
			break;
		}
		printf("%d\n",sum);
	}
	return 0;
}

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

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

	int AC = 0, WA = 0, TLE = 0, RE = 0;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;

		if (S == "AC")AC++;
		else if (S == "WA") WA++;
		else if (S == "TLE") TLE++;
		else RE++;
	}

	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;
}

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

int grundy[21][21][21][21];

int calc_grundy(int y1, int x1, int y2, int x2, vector<string> const& v) {
    if(y2 <= y1 || x2 <= x1) {
        return grundy[y1][x1][y2][x2] = 0;
    }
    int& r = grundy[y1][x1][y2][x2];
    if(r != -1) {
        return r;
    }
    set<int> s;
    for(int i=y1; i<y2; ++i) {
        for(int j=x1; j<x2; ++j) {
            if(v[i][j] == 'X') {
                continue;
            }
            int g = 0;
            g ^= calc_grundy(y1, x1, i, j, v);
            g ^= calc_grundy(i+1, x1, y2, j, v);
            g ^= calc_grundy(y1, j+1, i, x2, v);
            g ^= calc_grundy(i+1, j+1, y2, x2, v);
            s.insert(g);
        }
    }
    r = 0;
    while(s.count(r) == 1) {
        r++;
    }
    return r;
}

string solve(vector<string> const& v) {
    const int H = v.size();
    const int W = v[0].size();
    return calc_grundy(0, 0, H, W, v) == 0 ? "Second" : "First";
}

int main() {
    int H, W;
    cin >> H >> W;
    for(int i=0; i<21; ++i) {
        for(int j=0; j<21; ++j) {
            for(int k=0; k<21; ++k) {
                for(int l=0; l<21; ++l) {
                    grundy[i][j][k][l] = -1;
                }
            }
        }
    }
    vector<string> v(H);
    for(int i=0; i<H; ++i) {
        cin >> v[i];
    }
    cout << solve(v) << endl;
}


Measured memory_bytes: 3960
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
ll dp[1<<21];

int main(){
    int n;
    cin>>n;
    vector< vector<int> >  a(n,vector<int>(n,false));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    dp[0]=1;
    for(int bit=1;bit<1<<n;bit++){
        int i = __builtin_popcount(bit)-1;
        for(int j=0;j<n;j++){
            if(bit>>j & 1 && a[i][j]){
                dp[bit]+=dp[bit^1<<j];
                dp[bit]%=MOD;
            }
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 19964
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

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

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

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

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

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

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

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

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

fn dfs(v: usize, par: i64, adj: &Vec<Vec<usize>>, vq: &Vec<i64>, count: &mut Vec<i64>) {
  if count[v] >= 0 {
    return;
  }
  count[v] = par + vq[v];
  for &u in &adj[v] {
    dfs(u, count[v], adj, vq, count);
  }
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    q: usize,
    edge: [(usize1, usize1); n-1],
    query: [(usize1, i64); q],
  }
  let mut adj = vec![vec![]; n];
  for &(a, b) in &edge {
    adj[a].push(b);
    adj[b].push(a);
  }
  let mut vq = vec![0i64; n];
  for &(p, x) in &query {
    vq[p] += x;
  }
  let mut count = vec![-1i64; n];
  dfs(0, 0, &adj, &vq, &mut count);
  for &c in &count {
    puts!("{} ", c)
  }
  puts!("\n");
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i=0; i<N ;i++){
    cin >> A.at(i);
  }
  
  sort(A.begin(),A.end());
  
  int x=0;
  
  for(int i=0; i<N-1 ; i++){
    if(A.at(i)==A.at(i+1)){
      cout << "NO" << endl;
      x=1;
      break;
    }
  }
  
  
  
  if(x==0){
    cout << "YES" << endl;
  }
  
  
}



Measured memory_bytes: 4036
import java.util.*

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val n = scanner.nextInt()
	val k = scanner.nextInt()
	val s = scanner.next()

	var init = 0
	var bef = ' '
	s.toCharArray().forEach { c ->
		if (bef==c) init++
		bef = c
	}
	val seps = n-init-1
	var ans = init
	if (k<=seps/2) ans += 2*k
	else ans += seps/2 + k

	println(Math.min(ans, n-1))
}

Measured memory_bytes: 32240
#include<bits/stdc++.h>
using namespace std;
long long n,x,a=0,num=0,f;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(a==0){
			a=x;f=0;num++;
		}
		else if(f==0){
			if(x>a)f=1;
			else if(x<a)f=-1;
			a=x;
		}
		else if(f==1){
			if(x<a){f=0;num++;}
			a=x;
		}
		else if(f==-1){
			if(x>a){f=0;num++;}
			a=x;
		}
	}
	cout<<num<<endl;	
}

Measured memory_bytes: 256
s=[1 if i == 'W' else 0 for i in input()]

a = sum(s)

for i in range(len(s)):
    if s[i] == 0:
        s = s[i:]
        break


ret = 0
k = 0
for i in range(len(s)):
    if s[i] == 0:
        k +=1
        continue
    ret += k
print(ret)

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


//a b c  a b c a-b b-c c-a a-b-c
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    //---------------------Code-------------------------------------
    int n,k;
    cin>>n>>k;
    vector<int> l;
    for (int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        l.push_back(temp);
    }
    sort(l.begin(), l.end());
    int ans=0;
    for(int i=0;i<k;i++)
    {
        ans+=l[i];

    }
    cout<<ans<<endl;

    //--------------------------------------------------------------

}

Measured memory_bytes: 3656
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char c;
int n,ans;
bool flag[27];
int main()
{
	memset(flag,false,sizeof(flag));
	scanf("%d",&n);
	while(n--)
	{
		c=0;
		while(c<'A'||c>'Z') c=getchar();
		flag[c-'A']=true;
	}
	for(int i=0;i<27;++i) if(flag[i]) ++ans;
	if(ans==3) printf("Three");
	else printf("Four");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
	static int mod = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int arr[] = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		long pre[] = new long[n];
		pre[0] = arr[0];
		for (int i = 1; i < n; i++) {
			pre[i] = arr[i] + pre[i-1];
		}
		long ans = 0l;
		for (int i = 0; i < n - 1; i++) {
			ans = (ans + ((pre[n-1]- pre[i]) % mod) * arr[i]) % mod;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 60796
#include <stdio.h>
int main(void){
  int k,s;
  int x,y;
  int count=0;
  scanf("%d %d",&k,&s);
  for(x=0;x<=k;x++)
    for(y=0;y<=k;y++)
      if(0<=s-x-y && s-x-y<=k) count++;
  printf("%d\n",count);
  return(0);
}

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

bool isNumber(char c) {
	return '0' <= c and c <= '9';
}

int main()
{
	int N; cin >> N;
	vector<vector<pair<bool, string>>> ts(N+1);
	for (int i = 0; i < N+1; ++i) {
		string s; cin >> s;
		vector<pair<bool, string>> tmp;
		tmp.push_back({isNumber(s[0]), s.substr(0, 1)});
		for (int j = 1; j < s.size(); ++j) {
			if (tmp.back().first == isNumber(s[j])) {
				tmp.back().second += s[j];
			} else {
				tmp.push_back({isNumber(s[j]), s.substr(j, 1)});
			}
		}
		ts[i] = tmp;	
	}
	
	for (int i = 1; i < N+1; ++i) {
		//cout << i << endl;
		bool less = true, eq = true;
		for (int j = 0; j < ts[i].size(); ++j) {
			if (j >= ts[0].size()) {
				less = false;
				eq = false;
				break;
			}
			auto t0 = ts[0][j], tj = ts[i][j];
			if (t0.first == tj.first) {
				if (t0.first) {
					if (stoi(t0.second) == stoi(tj.second)) continue;
					less = stoi(t0.second) > stoi(tj.second); 
				} else {
					if (t0.second == tj.second) continue;
					less = t0.second > tj.second;
				}
			} else {
				less = t0.first == 0;			
			}
			eq = false;
			break;
		}
		if (eq and ts[0].size() == ts[i].size()) {
			less = false;
		}		
		if (less) cout << "-" << endl;
		else cout << "+" << endl;
	}
	return 0;
}


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

int main()
{
    int n;
    std::cin >> n;

    std::vector<std::vector<int>> a(n, std::vector<int>(n - 1));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            std::cin >> a[i][j];
            a[i][j]--;
        }
        std::reverse(a[i].begin(), a[i].end());
    }

    std::vector<std::pair<int, int>> p;
    auto check = [&](int player) {
        if (!a[player].size()) {
            return;
        }

        int opponent = a[player].back();

        if (!a[opponent].size()) {
            return;
        }

        if (a[opponent].back() != player) {
            return;
        }

        if (player > opponent) {
            std::swap(player, opponent);
        }

        p.push_back(std::make_pair(player, opponent));
    };

    for (int i = 0; i < n; i++) {
        check(i);
    }

    int day = 0;
    while (p.size()) {
        day++;
        std::sort(p.begin(), p.end());
        p.erase(std::unique(p.begin(), p.end()), p.end());

        std::vector<std::pair<int, int>> past_p;
        swap(past_p, p);
        for (auto elem : past_p) {
            int first = elem.first;
            int second = elem.second;

            a[first].pop_back();
            a[second].pop_back();

            check(first);
            check(second);
        }
    }

    for (auto elem : a) {
        if (elem.size()) {
            puts("-1");
            return 0;
        }
    }

    std::cout << day << std::endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50




int main(){
    LL N,M;
    cin>>N>>M;
    if(abs(N-M)>1){
        cout<<0<<endl;
        return 0;
    }else{
        LL sum=1;
        FOR(i,1,N+1)sum=(sum*i)%MOD;
        FOR(i,1,M+1)sum=(sum*i)%MOD;
        if(abs(N-M)==0)sum=sum*2LL%MOD;
        cout<<sum<<endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  set<ll> cnt;
  for (int i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    if (cnt.count(a) > 0) {
      cnt.erase(a);
    } else {
      cnt.insert(a);
    }
  }

  cout << cnt.size() << '\n';
  return 0;
}

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

using lld = long long int;

const int MAX_N = (int)1e5 + 5;

int n;
lld a[MAX_N];

int main(void){
  // Here your code !
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%lld", &a[i]);

  sort(a, a + n, greater<int>());

  vector<lld> vs = {};

  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i - 1]) {
      vs.push_back(a[i]);
      i++;
    }
    if (vs.size() > 2) break;
  }
  if (vs.size() == 0 || vs.size() == 1) printf("%d\n", 0);
  else printf("%lld\n", vs[0] * vs[1]);

  return 0;
}


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

#define ll long long

//Why does so many people in Vietnam have Nguyễn in their name?

int main(void)
{
	int n; 
	cin >> n;
	
	n = n % 10;
	
	switch(n) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			cout << "hon\n";
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			cout << "pon\n";
			break;
		
		case 3:
			cout << "bon\n";
			break;
	}
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>

using namespace std;

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

  int cnt = 0;

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

    bool flag = true;
    
    for(int j = 2; j*j <= a[i]; j++){
      if(a[i] % j == 0){
	flag = 0;
	break;
      }
    }

    if(flag) cnt++;

  }

  cout << cnt << endl;

  return 0;

}



Measured memory_bytes: 3104
# 深さ優先探索（行きがけ）
import sys
from collections import deque  # 両端の配列アクセスのときは高速、それ以外はlistのままのほうがいい


def main():
    N, Q = map(int, input().split())
    tree = [deque([]) for _ in range(N)]
    value = [0]*N
    flag = [0]*N

    for _ in range(N-1):
        a, b = map(int, input().split())
        if a == b:
            continue
        tree[a-1].append(b-1)
        tree[b-1].append(a-1)
    for _ in range(Q):
        p, x = map(int, input().split())
        value[p-1] += x

    stack = deque()
    stack.append(0)

    def dfs(v):
        now = v
        nowArray = tree[v]
        flag[v] = 1
        l = len(nowArray)

        for _ in range(l):  # 子ノードに値を追加
            w = tree[v].popleft()  # 子ノード
            if v not in tree[w]:
                continue
            value[w] += value[now]
            stack.append(w)

    while stack:
        top = stack.popleft()
        if flag[top] != 1:
            dfs(top)

    print(*value)


if __name__ == '__main__':
    main()


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

int main(){
    int A,B,H,M;
    cin >> A >>B >> H >> M;
    double Va = (double)2*M_PI / (double)(12 * 60);
    double Vb = 2*M_PI / 60;
    int time = H * 60 + M;
    vector<double> posA = {0,(double)A};
    vector<double> posB = {0,(double)B};
    double ra = Va * time;
    double rb = Vb * time;
    posA = {A*cos(ra),A*sin(ra)};
    posB = {B*cos(rb),B*sin(rb)};
    //cout << posA[0] << "," << posA[1] << endl;
    //cout << posB[0] << "," << posB[1] << endl;
    double distance = sqrt(pow(posA[0]-posB[0],2) + pow(posA[1]-posB[1],2));
    cout << fixed << setprecision(10) << distance << endl;
}

Measured memory_bytes: 4160
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    int n,a;
    cin >> n >> a;
    cout << n* n - a << endl;

    return 0;
}


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

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;

void add(vi &bit, int x, int a) {
    for (; x < (int)bit.size(); x += x & -x) {
        bit.at(x) += a;
    }
}

int qry(const vi &bit, int x) {
    int r = 0;
    for (; x; x -= x & -x) {
        r += bit.at(x);
    }
    return r;
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    s = '#' + s;

    vvi bit(26, vi(n + 1));
    for (int i = 1; i <= n; i++) {
        add(bit.at(s.at(i) - 'a'), i, 1);
    }

    int q;
    cin >> q;

    while (q--) {
        int op;
        cin >> op;

        if (op == 1) {
            int x;
            char c;
            cin >> x >> c;

            add(bit.at(s.at(x) - 'a'), x, -1);
            s[x] = c;
            add(bit.at(s.at(x) - 'a'), x, 1);
        } else {
            int l, r;
            cin >> l >> r;

            int ans = 0;
            for (int i = 0; i < 26; i++) {
                ans += qry(bit.at(i), r) - qry(bit.at(i), l - 1) > 0;
            }

            cout << ans << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 56744
main(){
	int t[9] = {6,7,8,36,56,77,96,98,99};
	int a[9] = {14,9,4,34,42,59,83,73,71};
	int c,i;
	while(~scanf("%d",&c)){
		for(i=0;i<9;i++){
			if(c == t[i]){
				printf("%d\n",a[i]);
				break;
			}
		}
	}
	for(i=0;i<5000000;i++){
		t[i%9] = i;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
#include <vector>
#include <numeric>

using namespace std;

vector<pair<long long int, long long int>> getPrimeElements(long long int num) {

	long long int firstnum = num;

	vector<pair<long long int, long long int>> result;
	pair<long long int, long long int> wk;

	if (num % 2 == 0) {
		wk.first = 2;
		wk.second = 0;
		while (num % 2 == 0) {
			wk.second++;
			num /= 2;
		}

		result.push_back(wk);
	}

	long long int waru = 3;

	while (true) {

		if (num % waru == 0) {
			wk.first = waru;
			wk.second = 0;
			while (num % waru == 0) {
				wk.second++;
				num /= waru;
			}

			result.push_back(wk);
		}
		waru += 2;

		if (waru * waru > num) break;

	}

	if (num != 1) {
		wk.first = num;
		wk.second = 1;
		result.push_back(wk);

	}

	return result;
}


int getKeta(int num) {

	if (num == 0)return 1;

	int res = 0;

	while (num > 0) {
		num /= 10;
		res++;
	}

	return res;
}

vector<int> bunkai(int num) {

	string str = to_string(num);
	vector<int> res;

	for (int i = 0; i < str.size(); i++) {
		int a = str[i] - '0';
		res.push_back(a);
	}

	return res;

}


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

	string head, last;
	cin >> head;
	cin >> last;

	int ans = n;

	for (int i = 0; i <= head.size(); i++) {
		if (head.substr(i, n - i) == last.substr(0, n - i)) {
			ans += i;
			break;
		}
	}

	cout << ans << endl;


	return 0;

}




Measured memory_bytes: 256
from collections import defaultdict

d1=defaultdict(lambda:'AA')
d2=defaultdict(lambda:'AA')
S=input()
T=input()
flag =True
for i in range(len(S)):
	if d1[S[i]]!='AA':
		if d1[S[i]] != T[i]:
			flag = False
			break
	if d2[T[i]]!='AA':
		if d2[T[i]]!=S[i]:
			flag =False
			break
	d1[S[i]]=T[i]
	d2[T[i]]=S[i]
if flag:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  vector<string> S(n);
  for(int i=0;i<n;i++){
    cin >> S.at(i) ;
  }
  ll m=0,a=0,r=0,c=0,h=0;
  for(int i=0;i<n;i++){
    if(S.at(i).at(0)=='M') m++;
    else if(S.at(i).at(0)=='A') a++;
    else if(S.at(i).at(0)=='R') r++;
    else if(S.at(i).at(0)=='C') c++;
    else if(S.at(i).at(0)=='H') h++;
  }
  ll ans = 0;
  ans += m*a*r+m*r*c+m*a*c+m*h*a+m*h*r+m*h*c;
  ans += a*r*c+a*r*h+r*c*h+a*c*h;
  cout << ans <<endl;
}
  
  
            

Measured memory_bytes: 6144
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include<cstdio>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
using namespace std;

signed main() {
	int a, b; cin >> a >> b;
	if (a > b) {
		puts("a > b");
	}
	else if (a < b) {
		puts("a < b");
	}
	else {
		puts("a == b");
	}
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if (s.size() % 2 == 1){
        printf("No");
        return 0;
    }
    for (int i = 0; i < s.size(); i+=2){
        if (s[i] !='h' || s[i+1] != 'i' ){
            printf("No");
            return 0;
        }

    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		
		if(x < a) {
			System.out.println("0");
		}else {
			System.out.println("10");
		}
	}

}


Measured memory_bytes: 22612
#include <cstring>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    string s; cin >> s;
    int bit[26][n+2];
    memset(bit, 0, sizeof bit);
    for (int i = 0; i < n; i++)
        for (int j = i+1; j <= n; j += j&-j) bit[s[i]-'a'][j]++;

    int q; cin >> q;
    while (q--) {
        int x; cin >> x;
        if (x == 1) {
            int y; char z; cin >> y >> z;
            if (s[y-1] != z) {
                char oz = s[y-1];
                s[y-1] = z;
                for (int j = y; j <= n; j += j&-j) bit[z-'a'][j]++;
                for (int j = y; j <= n; j += j&-j) bit[oz-'a'][j]--;
            }
        } else {
            int y, z; cin >> y >> z;
            int ret = 0;
            for (int i = 0; i < 26; i++) {
                int sum = 0;
                for (int j = z; j > 0; j -= j&-j) sum += bit[i][j];
                for (int j = y-1; j > 0; j -= j&-j) sum -= bit[i][j];
                if (sum > 0) ret++;
            }
            cout << ret << endl;
        }
    }
}


Measured memory_bytes: 51716
a = int(input())
b = list(map(int,input().split()))
print(" ".join(list(map(str,b))))
for i in range(1,a):
    v = b[i]
    j = i -1
    while j >=0 and b[j] > v:
        b[j+1] = b[j]
        j -= 1
        b[j+1] = v
    print(" ".join(list(map(str,b))))



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = list()
C = list()
for i in range(Q):
  b, c = map(int, input().split())
  B.append(b)
  C.append(c)

A_sum = sum(A)
num_count = [0] * (10 ** 5)

for a in A:
  num_count[a-1] += 1
for i in range(Q):
  if num_count[B[i]-1] != 0:
    A_sum += (C[i] - B[i]) * num_count[B[i]-1]
    print(A_sum)
    num_count[C[i]-1] += num_count[B[i]-1]
    num_count[B[i]-1] = 0
  else:
    print(A_sum)

Measured memory_bytes: 92720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

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

int main(){
    long int A,B;
    cin >> A >> B;
    
    long int GCD = gcd(A, B);
    long int g = GCD;
    long int ans = 1;
    for(long int i = 2; i * i <= g; ++i) {
        if(GCD % i == 0){
            ans++;
        while(GCD % i == 0) GCD /= i;
        }
    }
    if(GCD != 1) ans++;
    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int x[3], y[3];
  rep(i, 3) {
    in(x[i]); in(y[i]);
  }
  double a = sqrt((x[0] - x[1]) * (x[0] - x[1]) + (y[0] - y[1]) * (y[0] - y[1])),
         b = sqrt((x[1] - x[2]) * (x[1] - x[2]) + (y[1] - y[2]) * (y[1] - y[2])),
         c = sqrt((x[2] - x[0]) * (x[2] - x[0]) + (y[2] - y[0]) * (y[2] - y[0]));
  double max_abc = max(a, max(b, c));
  double S = sqrt((a+b+c)/2.0 * (-a+b+c)/2.0 * (a-b+c)/2.0 * (a+b-c)/2.0);
  double r = 2.0 * S / (a + b + c);
  double start = 0, end = max_abc;
  rep(i, 1e5) {
    double x = start + (end - start) / 2.0;
    if ((1 - x / r) * max_abc >= 2.0 * x)
      start = x;
    else
      end = x;
  }
  printf("%.12f\n", start);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n, m, x;
  int a[101];
  scanf("%d %d %d", &n, &m, &x);
  int cnt = 0;
  rep(i, 0, m) {
    scanf("%d", &a[i]);
    if (a[i] > x) cnt++;
  }
  printf("%d\n", min(cnt, m - cnt));


  return 0;
}


Measured memory_bytes: 128
## coding: UTF-8


H,W,K = map(int,input().split())
x1, y1, x2, y2 = map(int,input().split())
x1-=1
y1-=1
x2-=1
y2-=1
#1-index to 0-index


c = []
for i in range(H):
    c.append(input())

fresh = [True] * (H*W)
count = [-1] * (H*W)

queue = [x1*W+y1] #now <- start
count[x1*W+y1] = 0 #start -> step = 0
fresh[x1*W+y1] = False
n = [] #next
for i in range(H):
    for j in range(W):
        if(c[i][j] == '@'):
            fresh[i*W+j] = False

#print(fresh)
#print(count)
#print(queue)

step = 1
status = True
while status:
    if(len(queue) > 0):
        pivot = queue.pop()
        #右へ移動
        #if(pivot%W != W-1):#and fresh[pivot+1]):
        for g in range(1, K+1):
            if((pivot+g)%W != 0 and fresh[pivot+g]):
                n.append(pivot+g)
                count[pivot+g] = step
                #fresh[pivot+g] = False false後回し
            else:
                break
        #左へ移動
        #if(pivot%W != 0): #and fresh[pivot-1]):
        for g in range(1, K+1):
            if((pivot-g)%W != W-1 and fresh[pivot-g]):
                n.append(pivot-g)
                count[pivot-g] = step
                #fresh[pivot-g] = False false後回し 
            else:
                break   
        #下へ移動
        #if( int(pivot/W)<(H-1) and fresh[pivot+W]):
        for g in range(1, K+1):
            if( (pivot+g*W)//W < H and fresh[pivot+g*W]):
                n.append(pivot+g*W)
                count[pivot+g*W] = step
                #fresh[pivot+g * W] = False false後回し
            else:
                break    
        #上へ移動
        #if( int(pivot/W)>0 and fresh[pivot-W] ):
        for g in range(1, K+1):
            if( (pivot-g*W)>= 0 and fresh[pivot-g*W] ):
                n.append(pivot-g*W)
                count[pivot-g*W] = step
                #fresh[pivot-g*W] = False
            else:
                break
    elif(len(n)>0): 
        n = sorted(n)
        last = -1
        l = []
        for i in range(len(n)):
            if last != n[i]:
                l.append(n[i])
                last = n[i]
        for e in l:
            fresh[e] = False
        queue = l
        n = []
        #print('step{}end, queue:{}, n:{}, fresh:{}, count:{}'.format(step, queue, n, fresh, count))
        step += 1
    else:
        status = False            


print(count[x2*W+y2])

Measured memory_bytes: 110260
N = int(input())
A,B = map(int,input().split())
plist = [int(_) for _ in input().split()]


a,b,c = 0,0,0
list = []
for p in plist:
    if p <= A:
        a += 1
    elif A+1 <= p <= B:
        b += 1
    elif B+1 <= p:
        c += 1

list.append(a)
list.append(b)
list.append(c)

print(min(list))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;
typedef long long ll;

vector<ll> a;
ll dp[3001][3001][2];

ll calc(ll left, ll right, int hand){
    if(left == right){
        return 0;
    }
    if(dp[left][right][hand] != -1){
        return dp[left][right][hand];
    }

    if(hand == 0){
        dp[left][right][hand] = max(
            calc(left, right - 1, 1) + a.at(right -1),
            calc(left + 1, right, 1) + a.at(left)
        );
    }else{
        dp[left][right][hand] = min(
            calc(left, right - 1, 0) - a.at(right -1),
            calc(left + 1, right, 0) - a.at(left)
        );
    }
    return dp[left][right][hand];
}

int main(){
    ll n;
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }
    memset(dp, -1, sizeof(dp[0][0][0]) * 3001 * 3001 * 2);
    cout << calc(0, n, 0) << endl;
    return 0;
}


Measured memory_bytes: 141184