akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> T(N);
  rep (i, N) cin >> T[i];
  long sum = 0;
  rep (i, N) sum += T[i];
  long M;
  cin >> M;
  rep (i, M) {
    long p, x;
    cin >> p >> x;
    p--;
    cout << sum - T[p] + x << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n; 
  vector<int> in(n);
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  sort(in.rbegin(), in.rend());
  int first = in[0];
  int second = INT_MAX / 2;
  for (int i = 1; i < n; i++) {
    if (abs(second  * 2 - first) >= abs(in[i] * 2 - first)) {
      second = in[i];
    }
  }
  cout << first << " " << second << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/

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

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)

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

//abc b
int main(void)
{
  int n;
  LL sum = 0;
  scanf("%d", &n);
for (size_t i = 1; i <= n; i++) {
  if (i%3 ==0 || i%5==0) {
    continue;
  }
  else{
    sum += i;
  }
}
printf("%lld\n",sum );
}


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

using namespace std;

class Node{
    public:
        int l, r, p;
        int deg, sib, dep, hig;
        string typ;
};
Node nodes[25];

int top(int id,int tp){
    if(nodes[id].p!=-1){
        return top(nodes[id].p,tp+1);
    }
    return tp;
}


int dfs(int id,int dep){
    if(nodes[id].r!=-1||nodes[id].l!=-1){
      int m=0;
      if(nodes[id].r!=-1)
          m = dfs(nodes[id].r,dep+1);
      if(nodes[id].l!=-1)
          m = max(m,dfs(nodes[id].l,dep+1));
      return m;
    }
    return dep;
}

int main(){
    int n, id, r, l;
    int parent;
    cin>>n;
    for(int i=0;i<n;i++){
        nodes[i].p=-1;
        nodes[i].sib=-1;
        nodes[i].dep= -1;
        nodes[i].typ = "";
    }
            
    for(int i=0;i<n;i++){
        bool flag=true;
        cin>>id>>r>>l;
        if(r!=-1){
            nodes[ r].p = id;
            nodes[id].r = r;
            nodes[id].deg = 1;
            flag=false;
        }else{
            nodes[id].r = -1;
        }
        if(l!=-1){
            nodes[ l].p = id;
            nodes[id].l = l;
            nodes[id].deg = 1;
            flag=false;
        }else{
            nodes[id].l = -1;
        }
        if(r!=-1&&l!=-1){
            nodes[ l].sib = r;
            nodes[ r].sib = l;
            nodes[id].deg = 2;
        }
        if(flag)
            nodes[id].typ="leaf";
        else
            nodes[id].typ="internal node";
    }
    for(int i=0;i<n;i++){
        if(nodes[i].p==-1){
            nodes[i].typ = "root";
        }
        nodes[i].hig=dfs(i,0);
        nodes[i].dep=top(i,0);
    }
    for(int i=0;i<n;i++){
        cout<<"node "<<i;
        cout<<": parent = "<<nodes[i].p;
        cout<<", sibling = "<<nodes[i].sib;
        cout<<", degree = "<<nodes[i].deg;
        cout<<", depth = "<<nodes[i].dep;
        cout<<", height = "<<nodes[i].hig;
        cout<<", "<<nodes[i].typ;
        cout<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int M, D;
  cin >> M >> D;
  int ans = 0;
  for(int i=1; i<=M; i++) {
    for(int j=2; j<=D/10; j++) {
      for(int k=2; k<=9; k++) {
        if(j*10+k > D)
          break;
        if(j*k == i)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def inpl(): return [int(i) for i in input().split()]
import sys
N = int(input())

D = inpl()
tt = [0 for _ in range(24)]
tt[0] = 2
for d in D:
    tt[d] += 1
    tt[-d] += 1    

for t in tt:
    if t > 2:
        print(0)
        sys.exit()
if N > 11:
    prev = tt[-1]
    for t in tt:
        if t == 0:
            prev = 0
            continue
        if t == 1:
            if prev == 2:
                print(1)
                break
            prev = 1
        if t == 2:
            if prev == 1 or prev == 2:
                print(1)
                break
            prev = 2
    else:
        print(2)
    sys.exit()
ans = 0
for i in range(2**N):
    stri = format(i, 'b')
    stri = '0'*(N-len(stri)) +stri
    tt = [0 for _ in range(24)]
    tt[0] = 1
    for j in range(N):
        c = 1
        if stri[j] == '0':
             c = -1
        tt[c * D[j]] += 1
    for t in tt:
        if t > 1:
            break
    else:
        ctr = 1
        H = []
        for i in range(48):
            if tt[i%24] == 0:
                ctr += 1
            else:
                H.append(ctr)
                ctr = 1
        H.pop(0)
        ans = max(ans, min(H))
print(ans)

Measured memory_bytes: 3192
from math import ceil
from collections import deque
def main():
    N,D,A = map(int, input().split())
    # 座標X[i]のモンスターはceil(H[i]/A)回攻撃すれば倒せる
    # N=5, D=2
    # 0 1 2 3 4 5 6 7 8 9 10
    # 0 5 0 2 0 0 3 3 0 0 4 (倒すのに必要な回数; 全部0にすれば終了)
    # 0 0 0 0 0 0 3 3 0 0 4 (座標3で5回爆破したあと)
    # 0 0 0 0 0 0 0 0 0 0 1 (座標8で3回爆破したあと)
    # 0 0 0 0 0 0 0 0 0 0 0 (座標10で1回爆破したあと)
    # ->よって5+3+1=9回が最小回数..?

    Monsters = sorted([list(map(int, input().split())) for i in range(N)])
    Monsters = [[x-1, ceil(h / A)] for x, h in Monsters]

    acc_damage = 0
    que = deque([])

    ans = 0
    for x, h in Monsters:
        # 期限切れの蓄積ダメージを削除
        while que and x > que[0][0]:
            limit, damage = que.popleft()
            acc_damage -= damage

        need = max(0, h - acc_damage)
        ans += need
        acc_damage += need

        if need:
            que.append([x + 2 * D, need])

    print(ans)


main()


Measured memory_bytes: 79480
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.length()-1] == b[0] && b[b.length() - 1] == c[0]) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}




Measured memory_bytes: 3636
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e18+100;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

string s;

int main() {	
	cin >> s;
	
	int ans = 0;
	
	int l = 0, r = s.size() - 1, lc = 0, rc = 0;
	while (l <= r) {
		lc = rc = 0;
		while (l < s.size() && s[l] == 'x') l++, lc++;
		if (l > r) break;
		while (r >= 0 && s[r] == 'x') r--, rc++;
		if (s[l] != s[r]) {
			puts("-1");
			return 0;
		}
		
		ans += abs(lc - rc);
		l++;
		r--;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, u[3], mode, tar; long long d, x[30], y[30], ret, seg[33554432], val[14348907]; pair<long long, long long> t[2][14348907];
inline void rec(int pos, long long a, long long b) {
	if (pos == tar) {
		if (b <= 0) t[mode][u[mode]++] = make_pair(a, b);
		return;
	}
	rec(pos + 1, a + x[pos], b + y[pos]);
	rec(pos + 1, a - x[pos], b - y[pos]);
	rec(pos + 1, a, b);
}
inline long long query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return (1LL << 60);
	if (a <= l && r <= b) return seg[k];
	long long lch = query(a, b, 2 * k, l, (l + r) / 2);
	long long rch = query(a, b, 2 * k + 1, (l + r) / 2, r);
	return min(lch, rch);
}
int main() {
	scanf("%d%lld", &n, &d);
	for (int i = 0; i < n; i++) scanf("%lld%lld", &x[i], &y[i]);
	mode = 0; tar = n / 2; rec(0, 0, 0);
	mode = 1; tar = n; rec(n / 2, 0, 0);
	sort(t[1], t[1] + u[1]);
	for (u[2] = 1; u[2] <= u[1]; u[2] <<= 1);
	for (int i = 0; i < u[1]; i++) val[i] = t[1][i].first;
	for (int i = 0; i < u[1]; i++) seg[i + u[2]] = t[1][i].second;
	for (int i = u[2]; i >= 1; i--) seg[i] = min(seg[2 * i], seg[2 * i + 1]);
	for (int i = 0; i < u[0]; i++) {
		int pl = lower_bound(val, val + u[1], -t[0][i].first - d) - val;
		int pr = upper_bound(val, val + u[1], -t[0][i].first + d) - val;
		long long res = query(pl, pr, 1, 0, u[2]);
		ret = max(ret, -t[0][i].second - res);
	}
	printf("%lld\n", ret);
	return 0;
}

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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        cin >> n;

        if (n >= 30) puts("Yes");
        else puts("No");
    }
}


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


int main()
{
	int a, b, c;
	int count = 0;
	cin >> a >> b >> c;

	for (int i = a; i <= b; i++){
		if (c%i == 0){
			count++;
		}
	}

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


Measured memory_bytes: 3100
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include <cassert>
 #include <iomanip>
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double L;
    cin>>L;
    double t = L/3;
    cout<<fixed<<setprecision(12) << t*t*t << endl;
    return 0;
}


Measured memory_bytes: 3804
<?php
$input = STDIN;


while (true) {
    list($m, $f, $r) = explode(' ', trim(fgets($input)));

    if ($m == -1 && $f == -1 && $r == -1) break;

    if ($m == -1 || $f == -1) {
        print "F\n";
        continue;
    }

    $total = 0;
    if ($m != -1) $total += $m;
    if ($f != -1) $total += $f;

    if ($total >= 80) {
        print "A\n";
    } elseif ($total >= 65) {
        print "B\n";
    } elseif ($total >= 50) {
        print "C\n";
    } elseif ($total >= 30) {
        if ($r >= 50) print "C\n";
        else print "D\n";
    } else {
        print "F\n";
    }
}


Measured memory_bytes: 9236
N, K = map(int, input().split())

L = []
for i in range(10**5+1):
    L.append(0)

for n in range(N):
    a, b = map(int, input().split())
    L[a] += b

a = 0
while K > 0:
    a += 1
    K -= L[a]
    
print(a)

Measured memory_bytes: 11784
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define s(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;

int main() {
	int a, b, c,d[100],p=0;
	cin >> a >> b >> c;
	p = a;
	for (int i = 0; i < a; i++) {
		cin >> d[i];
		for (int j = 1;; j++) {
			if (j * d[i] + 1 > b)break;
			p++;
		}
	}
	cout << p+c<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  double v[n];
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v,v+n);
  double sum=v[0];
  for(int i=1;i<n;i++){
    sum=(sum+v[i])/2.0;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> M;
		if (i & 1)if (M & 1)K++;
	}
	cout << K << endl;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int a = kb.nextInt(); // h
		int b = kb.nextInt(); // s
		int c = kb.nextInt(); // h
		int d = kb.nextInt(); // s
		while (true) {
			c -= b;
			if (c <= 0) {
				System.out.println("Yes");
				break;
			}
			a -= d;
			if (a <= 0) {
				System.out.println("No");
				break;
			}
		}
		kb.close();
	}

}


Measured memory_bytes: 27076
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())

answer = 0
for _ in range(N):
    x,u = input().split()
    if u == "JPY":
        money = int(x) 
    else:
        money = float(x)*380000
    answer += money
print(answer)



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

inline bool check(int n)
{
	for (int i = 2; i*i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}

int main()
{
	int n[1000000] = {};
	int x;
	bool f;
	
	for (int i = 2; i <= 1000000; i++)
	{
		f = check(i);
		if (f == true) n[i] = n[i - 1] + 1;
		else n[i] = n[i - 1];
	}

	while (cin >> x)
		cout << n[x] << endl;
	return 0;
}


Measured memory_bytes: 6912
use std::io::stdin;

fn main() {
    let v = get_param();
    println!("{}", solve(v[0], v[1], v[2]));
}

fn get_param() -> Vec<u32> {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

fn solve(n: u32, a: u32, b: u32) -> u32 {
    (1..n + 1).filter(|&n| between(digits_sum(n), a, b)).sum()
}

fn digits_sum(x: u32) -> u32 {
    x.to_string()
        .chars()
        .fold(0, |acc, c| acc + c.to_digit(10).unwrap())
}

fn between(x: u32, a: u32, b: u32) -> bool {
    a <= x && x <= b
}


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

using ll = long long;

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

    ll n,a,b,c,d,e;cin>>n>>a>>b>>c>>d>>e;

    ll s=min(min(min(min(a,b),c),d),e);

    ll ans=(n-1)/s+5;

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3604
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    // can't continue when all the number is odd
    // So, best strategy is for a one manipulation, divide only one item by 2 and multiple other by 3.
    // Hence, the answer is the sum of 'how many times ai is dividable by 2'


    // O(Nlog(max(ai)))
    val answer = a.map {
        timesDividableBy2(it)
    }.sum()
    println(answer)
}

// O(log_(divider)N)
fun timesDividableBy2(num: Long) : Int {
    var tmp = num
    var count = 0

    while (tmp.mod(2) == 0L) {
        tmp = tmp / 2 + tmp % 2
        count++
    }
    return count
}


Measured memory_bytes: 40096
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  char S[3];
  cin >> S;

  char c = S[0];
  string ans;
  if (c == S[1] && c == S[2]) ans = "No";
  else ans = "Yes";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int a = in.nextInt();
        int b = in.nextInt();
        if (a > b) {
            int t = a;
            a = b;
            b = t;
        }
        if (a == 1 && b == 2) {
            out.println(3);
        } else if (a == 2) {
            out.println(1);
        } else {
            out.println(2);
        }
    }

    public static void main(String[]$) {
        try {
            new Main().solve();
            out.flush();
        } catch (Throwable t) {
            out.flush();
            t.printStackTrace();
        }
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 20820
//A - 居合を終え、青い絵を覆う
#include <bits/stdc++.h>
using namespace std;

int main(void){
    char s;
    cin >> s;
    if(s == 'a' ||s == 'i' ||s == 'u' ||s == 'e' ||s == 'o')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
counter = 0
flag = 1

while(flag):
  flag = 0
  for i in range(N):
    if a[i] % 2 == 0:
      counter = counter + 1
      a[i] = a[i] / 2
      flag = 1
      
print(counter)

Measured memory_bytes: 4148
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main()
{
    int t;
    
    // scanf("%d",&t);
    
    t=1;
    
    while(t--)
    {
        int n;
        
        scanf("%d",&n);
        
        long long mod=1e9+7,ans=1;
        
        for(int i=1;i<=n;i++)
            ans=(ans*i)%mod;
        
        printf("%lld",ans);
    }

    return 0;
}

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

int main(){
	int n,r,card[51];
	while(cin>>n>>r, n&&r){
		for(int i=1;i<=n;i++) card[i]=n+1-i;

		int p,c;
		for(int i=0;i<r;i++){
			cin>>p>>c;
			int head=1;
			for(int j=0;j<c;j++){
				int now=p+j;
				while(head<now){
					swap(card[now],card[now-1]);
					now--;
				}
				head++;
				//for(int k=1;k<=n;k++)cout<<card[k]<<":";
				//cout<<endl;
			}
		}
		cout<<card[1]<<endl;
	}

	return 0;
}



Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			while(sc.hasNext()) {
				int N=sc.nextInt();
				int M=sc.nextInt();
				int P=sc.nextInt();
				if(N==0) break;
				int cost=0;
				int sum=0;
				for(int i=1; i<=N; i++) {
					int gold=sc.nextInt();
					if(i==M) {
						cost=gold;
					}
					sum+=gold;
				}
				int ans=(cost==0)? 0:(sum*100*(100-P)/100)/cost;
				System.out.println(ans);

			}
		}
	}
} 


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

using namespace std;

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

	int w;
	cin >> w;
	int a, b;
	cin >> a >> b;
	if ((b <= a + w && b >= a) || (a <= b + w && a >= b)) {
		cout << "0\n";
		return 0;
	}
	cout << min(abs(b - a - w), abs(a - b - w)) << '\n';

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,n,a,b,dp[10001];
int main()
{
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	scanf("%d%d",&h,&n);
	while(n--)
	{
		scanf("%d%d",&a,&b);
		for(int i=1;i<=h;i++)dp[i]=min(dp[max(i-a,0)]+b,dp[i]);
	}
	printf("%d",dp[h]);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

rinds, ginds, binds = [], [], []

for i in range(n):
    if s[i] == 'R': rinds.append(i)
    elif s[i] == 'G': ginds.append(i)
    else: binds.append(i)


rlen, glen, blen = len(rinds), len(ginds), len(binds)

def binsearch_same(binds, blen, dist, i):
    lo, hi = 0, blen-1
    while lo<=hi:
        mid = lo + (hi-lo)//2
        d = binds[mid] - i
        if dist == d:
            return True
        elif d < dist:
            lo = mid + 1
        else:
            hi = mid - 1
    return False

ans = 0

for i in rinds:
    for j in ginds:
        dist = abs(i-j)
        i_ = min(i, j)
        j_ = max(i, j)
        ans += blen
        # i' < j' < k

        if binsearch_same(binds, blen, dist, j_):
            ans -= 1
        # i'< k < j' 
        if dist%2==0 and binsearch_same(binds, blen, dist//2, i_):
            ans -= 1
        # # k < i' < j'
        if binsearch_same(binds, blen, -dist, i_):
            ans -= 1

print(ans)






Measured memory_bytes: 72644
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<ll> v(n);
    REP(i,n) cin >> v[i];

    auto it = max_element(ALL(v));
    int mx = *it;
    int mxi = distance(v.begin(),it);
    it = min_element(ALL(v));
    int mn = *it;
    int mni = distance(v.begin(),it);


    vector<pair<int,int>> p;
    
    if (mx < 0 || (abs(mx) < abs(mn))) {
        for (auto i = n-1; i >= 0 ; i--) {
            p.emplace_back(make_pair(mni+1,i+1));
        }
        for (auto i = n-1; i > 0 ; i--) {
            p.emplace_back(make_pair(i+1,i));
        }
    } else {
        for (auto i = 0; i < n ; i++) {
            p.emplace_back(make_pair(mxi+1,i+1));
        }
        for (auto i = 0; i < n-1 ; i++) {
            p.emplace_back(make_pair(i+1,i+2));
        }
    }

    cout << p.size() << endl;
    for(auto x:p) {
        cout << x.first << " " << x.second << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,0,n-1)cin >> x[i];

    int ans = INF;
    rep(i,1,100){
        int tans = 0;
        rep(j,0,n-1)tans += (x[j]-i)*(x[j]-i);
        ans = min(ans,tans);
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
n,k = map(int, input().split())

snack = [0 for _ in range(n)]

for i in range(k):
    d = int(input())
    line = [int(s) - 1 for s in input().split()]
    
    for a in range(d):
        snack[line[a]] += 1

print(snack.count(0))


Measured memory_bytes: 9168
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, C = lr()
XV = np.array([lr() for _ in range(N)])
right = XV[:, 1]
r_pos = XV[:, 0]
rcum = right.cumsum() - r_pos
r_max_cum = np.maximum.accumulate(rcum)
left = right[::-1]
l_pos = (C - r_pos)[::-1]
lcum = left.cumsum() - l_pos
l_max_cum = np.maximum.accumulate(lcum)

answer = max(0, r_max_cum[-1], l_max_cum[-1])
# i個目で折り返す
for i in range(N-1):
    temp = rcum[i] - r_pos[i]  # 帰りの距離を引く
    temp += l_max_cum[N-2-i]
    if temp > answer:
        answer = temp

for i in range(N-1):
    temp = lcum[i] - l_pos[i]  # 帰りの距離を引く
    temp += r_max_cum[N-2-i]
    if temp > answer:
        answer = temp

print(answer)


Measured memory_bytes: 37876
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
ll lucas(ll n){
    if(n == 0)return 2;
    else if(n == 1)return 1;
    else return lucas(n-1)+lucas(n-2);
}

int main(){
    ll n;
    cin >> n;
    vector<ll>data(n+1);
    data[0] = 2;
    data[1] = 1;
    for(ll i = 2;i <= n;i++){
        data[i] = data[i-1] + data[i-2];
    }
    cout << data[n] << endl;
    return 0;
}

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

using namespace std;

struct Restaurant {
    string city;
    int score;
    int index;
    friend istream& operator>>(istream& in, Restaurant& r) {
        in >> r.city >> r.score;
        return in;
    }
    bool operator<(const Restaurant& o) const {
        if (city == o.city) {
            return score > o.score;
        }
        return city < o.city;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<Restaurant> rests(n);
    for (int i = 0; i < n; ++i) {
        cin >> rests[i];
        rests[i].index = i +1;
    }
    sort(rests.begin(), rests.end());
    for (auto& rest : rests) {
        cout << rest.index << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
input = gets.split
n = input[0].to_i
k = input[1].to_i
arr = gets.split
total = 0

if k >= n
  print 0
else
  arr = arr.sort{|a, b| a.to_i <=> b.to_i }
  size = n - k
  for i in 0...size
    total += arr[i].to_i
  end
  print total
end

Measured memory_bytes: 18304
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a=INT()
    b=INT()
    c=INT()
    d=INT()
    e=INT()
    f=INT()
    if e-a<=f:
        print('Yay!')
    else:
        print(':(')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    static long INF = (1L<<60);
    static int n;
    static long[] dat;

    static void update(int x, int y) {
        int tmp = x+n-1;
        dat[tmp] = y;
        while (tmp>0) {
            tmp=(tmp-1)/2;
            dat[tmp] = Math.min(dat[tmp*2+1], dat[tmp*2+2]);
        }
    }

    static long query(int a, int b, int k, int l, int r) {
        if (b<=l || r<=a) return INF;
        if (a<=l && r<=b) return dat[k];
        else {
            long lv = query(a, b, 2*k+1, l, (l+r)/2);
            long rv = query(a, b, 2*k+2, (l+r)/2, r);
            return Math.min(lv, rv);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        n = 1;
        while(n<2*N) n*=2;
        dat = new long[2*n-1];
        Arrays.fill(dat, INF);
        int x = sc.nextInt();
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = sc.nextInt();
        }
        for (int i=0;i<N;i++) {
            update(i, a[i]);
            update(i+N, a[i]);
        }

        long min = INF;
        for (int i=0;i<N;i++) { // magic cnt
            long tmp = 0L;
            for (int j=0;j<N;j++) {
                tmp+=query(N+j-i, N+j+1, 0, 0, n);
            }
            min = Math.min(min, tmp+(long)x*i);
        }
        // System.out.println(Arrays.toString(dat));
        System.out.println(min);
    }
}

Measured memory_bytes: 27592
n = int(input())

d = 2
ans = 0

while d * d <= n:
    if n % d != 0:
        d += 1
        continue

    z = d
    while n % z == 0:
        n //= z
        z *= d
        ans += 1

    while n % d == 0:
        n //= d

if n != 1:
    ans += 1

print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double res = -1;
    int ressugar = 0;
    int reswater = 0;
    int index = 0;
    for (int na = 0; na < 31; na++)
    {
        for (int nb = 0; nb < 31; nb++)
        {
            for (int nc = 0; nc < 101; nc++)
            {
                for (int nd = 0; nd < 101; nd++)
                {
                    if (na == 0 & nb == 0 & nc == 0 & nd == 0)
                        continue;
                    if (a * 100 * na + b * 100 * nb + c * nc + d * nd > f)
                    {
                        continue;
                    }
                    if (c * nc + d * nd > (a * na + b * nb) * e)
                    {
                        continue;
                    }
                    int sugar = c * nc + d * nd;
                    int water = a * 100 * na + b * 100 * nb;
                    if (0 == water)
                        continue;
                    double conc_inv = (double)sugar / (double)water;
                    res = max(res, conc_inv);
                    if (res == conc_inv)
                    {
                        ressugar = sugar;
                        reswater = water;
                    }
                }
            }
        }
    }
    cout << ressugar + reswater << " " << ressugar << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N;
    cin >> N;
    double X = (double)N / 1.08;
    int l = 1.08 * floor(X);
    int u = 1.08 * ceil(X);
    if (l == N) {
        print(floor(X));
    } else if (u == N) {
        print(ceil(X));
    } else {
        print(":(");
    }
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
<?php
while(fscanf(STDIN,"%d %d",$a,$b)){
    $gcd = $a>$b ? gcd($a,$b) : gcd($b,$a);
    echo $gcd . " " . $a*$b/$gcd . "\n";
}
function gcd($a,$b){
    if($b==0)return $a;
    return gcd($b,$a%$b);
}
?>

Measured memory_bytes: 6608
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		HashMap<String, Integer> map = new HashMap<String, Integer>();

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			map.clear();
			while (n-- != 0) {
				String name = sc.next();
				int cost = sc.nextInt();
				map.put(name,  cost);
			}
			m = sc.nextInt();
			String alc[] = new String[m];
			int num[] = new int[m];
			String list[][] = new String[m][110];
			for (int i = 0; i < m; i++) {
				alc[i] = sc.next();
				num[i] = sc.nextInt();
				for (int j = 0; j < num[i]; j++) {
					list[i][j] = sc.next();
				}
			}

			boolean flag = true;
			while (flag) {
				flag = false;
				for (int i = 0; i < m; i++) {
					int sum = 0;
					for (int j = 0; j < num[i]; j++) {
						if (map.containsKey(list[i][j])) {
							sum += map.get(list[i][j]);
						}
					}
					if (map.get(alc[i]) == null || sum < map.get(alc[i])) {
						map.put(alc[i], sum);
						flag = true;
					}
				}
			}

			System.out.println(map.get(sc.next()));
		}
	}
}

Measured memory_bytes: 24872
#include <bits/stdc++.h>
#define ll long long int  

using namespace std;

void solve(){

	ll n;
	cin>>n;

	
	ll sum = 0;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			for(ll k=1;k<=n;k++){
				ll g1 = __gcd(i,j);
				sum += __gcd(g1, k);
			}
		}
	}
	cout<<sum<<endl;
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}

}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(auto & b : a) cin>>b;
    ll sum = accumulate(a.begin(),a.end(),0ll);
    vector<ll> ans(n);
    ans[0] = sum;
    for(int i=0;i<n;++i){
        if(i%2)ans[0] -= 2*a[i];
    }
    for(int i=1;i<n;++i){
        ans[i] = 2*a[i-1] - ans[i-1];
    }
    for(int i=0;i<n;++i) {cout << ans[i];if(i!=n-1)cout<<" ";}
    cout << endl;
    return 0;
}



Measured memory_bytes: 2944
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0, count = 0;
	char ac,uc[100000];
	cin >>uc[0]>>uc[1]>>uc[2] ;
	if (uc[0]==uc[2]) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl; }
	
	
		return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        while(true)
        {
            
            int n = sc.nextInt();
            if(n == 0)break;
            int[] s = new int[n];
            for (int i = 0; i < n; i++) {
                s[i] = sc.nextInt();
            }
            double average = 0;

            for (int i = 0; i < n; i++) {
                average += s[i]; 
            }
            average /= n;
            double alpha2 = 0;
            for (int i = 0; i < n; i++) {
                alpha2 += (s[i] -average) * (s[i] -average);
            }
            alpha2 /= n;
            System.out.println(Math.sqrt(alpha2) );
        }
        sc.close();

    }
    
    public static void printary(int[] a)
    {
        for ( int i = 0; i < a.length; i++) {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 31708
#include <cmath>
#include <iostream>
#include <vector>
#include <tuple>

using lli=long long;
int main(){
  int N;
  std::cin >> N;

  std::vector<std::tuple<lli, lli>> pos_arr(N);
  for(int i = 0; i < N; i++) std::cin >> std::get<0>(pos_arr[i]) >> std::get<1>(pos_arr[i]);

  int par = (std::abs(std::get<0>(pos_arr[0]))+std::abs(std::get<1>(pos_arr[0])))%2;
  for(int i = 1; i < N; i++){
    if(par != (std::abs(std::get<0>(pos_arr[i]))+std::abs(std::get<1>(pos_arr[i])))%2){
      std::cout << "-1" << std::endl;
      return 0;
    }
  }

  if(par==0) std::cout << "40\n1 ";
  else std::cout << "39\n";
  std::vector<lli> d_arr(39);
  for(int i = 0; i < 39; i++){
    d_arr[i] = 1ll << (38-i);
    std::cout << d_arr[i] << (i==39-1?"\n":" ");
  }


  for(int i = 0; i < N; i++){
    lli x,y;
    std::tie(x,y) = pos_arr[i];
    lli cx=0, cy=0;
    if(par==0){
      cx++;
      std::cout << "R";
    }
    for(int j = 0; j < 39; j++){
      lli dx=x-cx, dy=y-cy;
      if(std::abs(dx)>std::abs(dy)){
        if(dx<0){
          cx -= d_arr[j];
          std::cout << "L";
        }else{
          cx += d_arr[j];
          std::cout << "R";
        }
      }else{
        if(dy<0){
          cy -= d_arr[j];
          std::cout << "D";
        }else{
          cy += d_arr[j];
          std::cout << "U";
        }
      }
    }
    std::cout << "\n";
  }

  return 0;
}



Measured memory_bytes: 256
s=gets.strip.split('')

s_chars = {}
(s).each_with_index do |c, i|
  s_chars[c] ||= [] if s_chars[c].nil?
  s_chars[c] << i
end

valid_chars = s_chars.keys.select {|k| s_chars[k].length > 1 }

#p s
#p s_chars
#p valid_chars

valid_chars.each do |k|
  (s_chars[k].length-1).times do |i|
    if s_chars[k][i+1] - s_chars[k][i]<=2
      puts [s_chars[k][i]+1, s_chars[k][i+1]+1].join(' ')
      exit
    end
  end
end

puts '-1 -1'



Measured memory_bytes: 8188
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, q;
  cin >> n >> q;
  queue<int> que[n];
  REP(i, q) {
    int num, t;
    cin >> num >> t;
    if (num == 0) {
      int x;
      cin >> x;
      que[t].push(x);
    } else if (num == 1) {
      if (que[t].size()) {
        cout << que[t].front() << endl;
      }
    } else {
      if (que[t].size()) {
        que[t].pop();
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4268
#include <bits/stdc++.h>
    #define fastcin ios_base::sync_with_stdio(0);cin.tie(0)
    #define ll long long
    #define pb push_back
    #define F first
    #define S second
    #define pii pair<int,int>
    #define pli pair<long long , int>
    #define pil pair<int,long long>
    #define pll pair<long long,long long>
    #define vi vector<int>
    #define vl vector<long long>
    #define vb vector<bool>
    #define all(c) c.begin(),c.end()
    #define i(a,b) for( int i = a ; i < b ; ++i)
    #define j(a,b) for( int j = a ; j < b ; ++j)
	#define k(a,b) for( int k = a ; k < b ; ++k)			
    #define ri(a,b) for( int i = a ; i >= b ; --i)
    #define rj(a,b) for( int j = a ; j >= b ; --j)
    #define prod(a,b) (((ll)a)*((ll)b))
	#define ar cout << arr[i] << endl

using namespace std;

int solve(){
	int n;
	cin >> n;
	vector<double>arr(n);
	i(0,n) cin >> arr[i];
	double ans = 0;
	i(0,n) ans += (1/arr[i]);
	ans = 1/ans;
	cout << fixed;
	cout << setprecision(14) << ans << endl;
	return 0 ;
}

int main(){
	fastcin;
	int q=1;
	//cin >> q;
	while(q--){
		solve();
	}		
	return 0;
}

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

using namespace std;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int N) : par(N) {
        for(int n=0; n<N; n++) {
            par[n] = n;
        }
    }
    
    int root(int x) {
        if(par[x]==x) return x;
        
        return par[x] = root(par[x]);
    }
    
    bool is_same(int x, int y) {
        int rx=root(x);
        int ry=root(y);
        
        return rx==ry;
    }
    
    void unite(int x, int y) {
        // cout << "the root of " << x << " is ";
        int rx=root(x);
        // cout << rx << endl;
        // cout << "the root of " << y << " is ";
        int ry=root(y);
        // cout << ry << endl;
        if(rx==ry) return ;
        par[rx] = ry;

        // for(int n=0; n<par.size(); n++) {
            // cout << par[n] << " ";
        // }
        // cout << endl;
    }
    
    int group_num() {
        int count=0;
        for(int n=0; n<par.size(); n++) {
            if(par[n]==n) {
                count++;
            }
        }
        return count;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<pair<int, int> > E(M);
    for(int m=0; m<M; m++) {
        int a, b;
        cin >> a >> b;
        E[m] = make_pair(a, b);
    }
    
    
    // cout << "calculate the answer..." << endl;
    
    int count=0;
    for(int out=0; out<M; out++) {
        UnionFind tree(N);
        // cout << "making UnionFind Tree done. " << endl;
        for(int m=0; m<M; m++) {
            if(out==m) continue;
            
            // cout << "unite " << E[m].first-1 << " and " << E[m].second-1 << endl;
            tree.unite(E[m].first-1, E[m].second-1);
        }
        if(tree.group_num()>1) {
            count++;
        }
    }
    
    cout << count << endl;
    


    return 0;
    
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 25
struct node{
	int parent, left, right;
};

node T[MAX];
int D[MAX], H[MAX];

void setDepth(const int t, const int d){
	if (t == -1) return;
	D[t] = d;
	setDepth(T[t].right, d + 1);
	setDepth(T[t].left, d + 1);
}

int setHeight(const int t){
	int h1 = 0, h2 = 0;
	if (T[t].right != -1){
		h1 = setHeight(T[t].right) + 1;
	}
	if (T[t].left != -1){
		h2 = setHeight(T[t].left) + 1;
	}
	return H[t] = (h1 > h2 ? h1 : h2);
}

void output(const int t){
	int deg = 0;
	if (T[t].right != -1) deg++;
	if (T[t].left != -1) deg++;
	int sib = -1;
	int p = T[t].parent;
	if (p != -1){
		if (T[p].right != t) sib = T[p].right;
		else sib = T[p].left;
	}
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
				t, p, sib, deg, D[t], H[t]);
	if (p == -1) printf("root\n");
	else if (H[t] == 0) printf("leaf\n");
	else printf("internal node\n");
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i< n; i++) {
		T[i].left = -1;
		T[i].right = -1;
		T[i].parent = -1;
	}
	for (int i = 0; i < n; i++){
		int t, l, r;
		scanf("%d %d %d", &t, &l, &r);
		T[t].left = l;
		T[t].right = r;
		if (l != -1) T[l].parent = t;
		if (r != -1) T[r].parent = t;
	}
	int root = 0;
	for (int i = 0; i < n; i++){
		if (T[i].parent == -1) {
		    root = i;
		    break;
		}
	}
	setDepth(root, 0);
	setHeight(root);

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



Measured memory_bytes: 2736
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, M;
  cin >> N >> M;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<vector<int64_t>> neighbours(N + 1, vector<int64_t>());
  for (int64_t i = 0; i < M; ++i) {
    int64_t a, b;
    cin >> a >> b;
    neighbours[a].emplace_back(b);
    neighbours[b].emplace_back(a);
  }
  vector<bool> visited(N + 1, false);
  queue<Pair> q;
  visited[1] = true;
  q.emplace(1, 0);
  while (!q.empty()) {
    const int64_t target = q.front().first;
    const int64_t count = q.front().second;
    q.pop();
    for (const auto &next : neighbours[target]) {
      if (!visited[next] && count + 1 <= 2) {
        visited[next] = true;
        q.emplace(next, count + 1);
      }
    }
  }
  if (visited[N]) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 17424
import fractions
import collections
N, K = map(int, input().split())
G = [set() for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)

q = collections.deque()
q.append((0))
ans = K
mod = 10**9+7
r = [True]*N
r[0] = False
while(q):
    x = q.popleft()
    tmp = K - 1
    if x > 0:
        tmp -= 1
    for y in G[x]:
        if r[y]:
            r[y] = False
            q.append(y)
            ans *= tmp
            tmp -= 1
            ans %= mod
print(ans)


Measured memory_bytes: 103708
n = int(input())
dp = [[0] * 3 for i in range(n+1)]
for i in range(1,n+1):
  a,b,c = map(int,input().split())
  dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a
  dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b
  dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[-1]))

Measured memory_bytes: 60012
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

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

    if (n >= 10) {
        cout << r << endl;
    } else {
        cout << r + 100*(10-n) << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;long long a,b,c[200005],n,d,ans,x[200005],y[200005],l,k;struct node{long long x,y;}w[200005];inline bool cmp(node x,node y){return x.x<y.x;}int main(){scanf("%lld%lld%lld",&n,&d,&a);d*=2;for(int i=1;i<=n;++i){scanf("%lld%lld",&w[i].x,&w[i].y);w[i].y=(w[i].y+a-1)/a;}sort(w+1,w+n+1,cmp);l=1;for(int i=1;i<=n;++i){while(l<i&&w[i].x-w[l].x>d)k-=c[l++];c[i]=w[i].y-k;if(c[i]<0)c[i]=0;ans+=c[i];k+=c[i];}printf("%lld",ans);}


Measured memory_bytes: 5888
#include <stdio.h>

int main(void){

	int i, j;
	int seki;
	
	for(i = 1; i <= 9; i++){
		for(j = 1; j <= 9; j++){
			seki = i * j;
			printf("%dx%d=%d\n", i, j, seki);
		}
	}
	
	return 0;
}

Measured memory_bytes: 524