akhauriyash/Code-Regression huggingface dataset:
// ctrl+shift+b
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N; vector<ll> A(N); rep(i, N){cin >> A.at(i);}
    sort(A.begin(), A.end());
    cout << A.at(A.size() - 1) - A.at(0) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

// 参考 URL
// http://kmjp.hatenablog.jp/entry/2018/03/11/1100

template <typename T=long long>
vector<T> LISLDS(T N, T A, T B)
{
    vector<T> ret;
    for(long long i = B-1; i >= 0; --i) ret.push_back(i);

    if(A == 1) return ret;

    long long rem = N-B;
    long long p = rem/(A-1), r = rem%(A-1);

    long long b = r, c = A-1-r;

    REP(i, b){
        int size = ret.size();
        REP(j, p+1) ret.push_back(size+p-j);
    }
    REP(i, c){
        int size = ret.size();
        REP(j, p) ret.push_back(size+p-1-j);
    }

    return ret;
}


int main()
{
    long long N, A, B;
    cin >> N >> A >> B;
    
    if(A+B > N+1 or A*B < N) cout << -1 << endl;
    else{
        for(auto v: LISLDS(N, A, B)) cout << v+1 << " ";
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 6384
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		num = nextInt()
		nums = append(nums, num)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := scanNums(n)
	sum := big.NewInt(1)
	border := big.NewInt(1000000000000000000)
	for i := 0; i < n; i++ {
		if a[i] == 0 {
			fmt.Println(0)
			return
		}
	}
	for i := 0; i < n; i++ {
		tmp := big.NewInt(int64(a[i]))
		sum = sum.Mul(sum, tmp)
		if sum.Cmp(border) == 1 {
			fmt.Println(-1)
			return
		}
	}
	if sum.Cmp(border) == 1 {
		fmt.Println(-1)
	}
	if sum.Cmp(border) == 0 || sum.Cmp(border) == -1 {
		fmt.Println(sum)
	}
}


Measured memory_bytes: 7144
#include<iostream>
#include <bits/stdc++.h>
#include<vector>
#include<cstdlib>

using namespace std;

int main(){
  int w,h,n;
  int x,y,a;

  cin>>w>>h>>n;
  int a1[2]={0,0},a2[2]={w,0},a3[2]={0,0},a4[2]={0,h};
  for(int i=0;i<n;i++){
    cin>>x>>y>>a;
    if(a==1){
      if(a1[0]<x)a1[0]=x;
      //cout<<"a1[0] "<<a1[0]<<endl;
    }else if(a==2){
      if(a2[0]>x)a2[0]=x;
      //cout<<"a2[0] "<<a2[0]<<endl;
    }else if(a==3){
      if(a3[1]<y)a3[1]=y;
      //cout<<"a3[1] "<<a3[1]<<endl;
    }else if(a==4){
      if(a4[1]>y)a4[1]=y;
      //cout<<"a4[1] "<<a4[1]<<endl;
    }
  }
  if(a1[0]>=a2[0] || a3[1]>=a4[1])cout<<0<<endl;
  else{
    cout<<(a2[0]-a1[0])*(a4[1]-a3[1])<<endl;
  }

  return 0;
  }


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

void search(vector<int>& memo, const vector<vector<int>> edge, int st, pair<int, int> exception) {
	memo[st] = 1;

	for (int tmp : edge[st]) {
		if ((exception.first == st && exception.second == tmp)
				|| (exception.first == tmp && exception.second == st)) {
			continue;
		}
		if (memo[tmp] == 1) {
			continue;
		}

		search(memo, edge, tmp, exception);
	}

}

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

	int n, m;
	cin >> n >> m;

	vector<pair<int, int>> pass(m);
	rep (i, 0, m)
		cin >> pass[i].first >> pass[i].second;

	vector<vector<int>> edge(n + 1);
	rep (i, 0, m) {
		edge[pass[i].first].push_back(pass[i].second);
		edge[pass[i].second].push_back(pass[i].first);
	}

	int res = 0;
	//	vector<pair<int, int>> memo;
	rep (i, 0, m) {
		vector<int> memo(n + 1, 0);

		// search
		search(memo, edge, 1, pass[i]);

		rep (i, 1, n + 1) {
			if (memo[i] == 0) {
				res++;
				break;
			}
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s;
	cin >> s;
	for (auto ch : s) {
		if (ch == '1') cout << 9;
		else cout << 1;
	}

	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#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);

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

  int N, M; cin >> N >> M;
  string S; cin >> S;
  map<int, set<int>> mem;
  int l = 0, sz = 1;
  while(M--){
	string q; cin >> q;
	if(q[0] == 'L'){
	  if(q[1] == '-'){
		++sz; --l;
	  }
	  else{
		++l; --sz;
	  }
	}
	else{
	  if(q[1] == '-'){
		--sz;
	  }
	  else{
		++sz;
	  }
	}
	mem[sz].insert(l);
  }

  int ans = 0;
  for(auto isi: mem){
	sz = isi.first;
	set<string> s;
	for(int left: isi.second){
	  s.insert(S.substr(left,sz));
	}
	ans += SZ(s);
  }

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

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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B){
    cout << C << endl;
  }else if(A==C){
    cout << B << endl;
  }else{
    cout << A << endl;
  }
}

Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    s = input()
    ans = 700
    if s[0] == 'o':
        ans += 100
    if s[1] == 'o':
        ans += 100
    if s[2] == 'o':
        ans += 100
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
import sys


def main():
    n, m = map(int, input().split())
    g = [[] for i in range(n)]
    lines = sys.stdin.read().splitlines()
    for i in range(m):
        l, r, d = map(int, lines[i].split())
        g[l - 1].append((r - 1, d))
        g[r - 1].append((l - 1, -d))
    dis = [0] * n
    visited = [False] * n
    for i in range(n):
        if visited[i]:
            continue
        stack = list([i])
        visited[i] = True
        while len(stack):
            v = stack[-1]
            stack.pop()
            for u, d in g[v]:
                if not visited[u]:
                    dis[u] = dis[v] + d
                    stack.append(u)
                    visited[u] = True
    for v in range(n):
        for u, d in g[v]:
            if dis[v] + d != dis[u]:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 80576
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());

		int findCount = 0;
		for (int i = 0; i < n; i++) {
			int num = Integer.parseInt(br.readLine());
			if (isPrime(num)) {
				findCount++;
			}
		}
		System.out.println(findCount);
	}

	public static boolean isPrime(int num) {
		if (num < 2) {
			return false;
		} else if (num == 2) {
			return true;
		} else if (num % 2 == 0) {
			return false;
		}

		double sqrtNum = Math.sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2) {
			if (num % i == 0) {
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 30048
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    int n,k;
    cin >> n >> k;
    vector<int> p;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        p.push_back(a);
    }
    sort(p.begin(),p.end());
    ll min = 0;
    for (int i = 0; i < k; i++) min += p[i];
    cout << min << endl;
}


Measured memory_bytes: 3644
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll d;
    cin >> d;
    V C(26);
    rep(i, 26) cin >> C[i];
    VV S(d, V(26));
    rep(i, d) { rep(j, 26) cin >> S[i][j]; }
    V prev(26,-1);
    rep3(i,0,d){
        ll reg=-INF;
        ll res=0;
        rep(j,26){
            ll temp=0;
            temp+=S[i][j];
            rep(k,26){
                if(j==k){
                    continue;
                }
                temp-=C[k]*(i-prev[k]);
            }
            if(chmax(reg,temp)){
                res=j+1;
            }
        }
        cout<<res<<endl;
    }
}


Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
using pint = pair<int,int>;
using Graph = vector<vector<pint>>;
const int INF = 1000000000;

int N, M;
Graph G;
vector<int> D;

void solve() {
    map<int, vector<int>> ma;
    for (int v = 0; v < N; ++v) ma[D[v]].push_back(v);

    vector<int> color(N, -1);
    vector<int> res(M, INF);
    for (auto it : ma) {
        int val = it.first;
        auto vs = it.second;
        for (auto v : vs) {
            if (color[v] != -1) continue; // 既に処理済み
            bool exist = false;
            for (auto e : G[v]) {
                int nv = e.first;
                if (D[v] < D[nv]) continue;
                exist = true;
                res[e.second] = val;
                if (color[nv] == -1) {
                    color[v] = 0;
                    color[nv] = 1;
                }
                else color[v] = 1 - color[nv];
                break;
            }
            if (!exist) {
                cout << -1 << endl;
                return;
            }
        }
    }
    for (int i = 0; i < N; ++i) {
        if (color[i] == 0) cout << "W";
        else cout << "B";
    }
    cout << endl;
    for (int i = 0; i < M; ++i) cout << res[i] << endl;
}

int main() {
    cin >> N >> M;
    D.resize(N);
    for (int i = 0; i < N; ++i) cin >> D[i];
    G.assign(N, vector<pint>());
    for (int i = 0; i < M; ++i) {
        int u, v; cin >> u >> v; --u, --v;
        G[u].emplace_back(v, i);
        G[v].emplace_back(u, i);
    }
    solve();
}
    


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

namespace Contest
{
    

    class Program
    {

        static void Main(string[] args)
        {

            var input = Console.ReadLine().Split();
            var x = int.Parse(input[0]);
            var n = int.Parse(input[1]);
            input = Console.ReadLine().Split();
            
            if(n == 0)
            {
                Console.WriteLine(x);
                return;
            }

            var nums = input.Select(x => int.Parse(x)).ToList() ;

            int[] ans = { x, x };
            while (true)
            {
                if(!(nums.Contains(ans[0])))
                {
                    Console.WriteLine(ans[0]);
                    return;
                }

                if (!(nums.Contains(ans[1])))
                {
                    Console.WriteLine(ans[1]);
                    return;
                }

                ans[0]--;
                ans[1]++;
                

            }

        }
    }
}




Measured memory_bytes: 28260
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int a, b;
int counto;
int ans;
char aa[5];
int main() {
	for (int i = 0; i < 4; i++) {
		cin >> aa[i];
	}
	if (aa[0] == aa[1] && aa[1] == aa[2]) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = i + 1; j < 4; j++) {
			if (aa[i] == aa[j]) {
				aa[i] = ' ';
				aa[j] = ' ';
				break;
			}
		}
	}
	for (int i = 0; i < 4; i++) {
		if (aa[i] != ' ') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

struct UnionFind {
	vector<int> par;
	UnionFind(int x) : par(x, -1) {}
	void init(int x) { par.assign(x, -1); }
	int root(int x) {
		if (par[x] <= -1) return x;
		else return root(par[x]);
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};
int main()
{
	int N, M;
	cin >> N >> M;
	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		uf.merge(a, b);
	}
	set<int> st;
	for (int i = 0; i < N; i++) {
		st.insert(uf.root(i));
	}
	cout << st.size() - 1 << endl;
}

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

typedef long long ll;
using namespace std;

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

    if (n % 2 != 0) {
        cout << "No";
        return 0;
    }
    for (int i = 0; i < n / 2; ++i) {
        if (s[i] != s[n / 2 + i]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
s = list(input())

year = int(''.join(s[:4]))
month = int(''.join(s[5:7]))
day = int(''.join(s[8:10]))

#print(month)

if year < 2019 or (year == 2019 and month <= 4):
    print('Heisei')

else:
    print('TBD')


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

using namespace std;

int main(){
    long long int  N,H,ans=0;
    cin >> N >> H;
    vector<int> a(N),b(N);
    for(int i=0;i<N;i++){
        cin >> a[i] >> b[i];
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    for(int i=N-1;0<=i;i--){
        if(b[i]>a[N-1]){
            H -= b[i];
            ans++;
            if(H<=0){
                cout << N-i << endl;
                return 0;
            }
        }
    }

    ans += (H+a[N-1]-1)/a[N-1];

    cout << ans << endl;
}

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

int main(){
  int n;
  string s,t;
  cin>>n>>s>>t;

  int flg=n;
  for(int i=0; i<n; i++){
    if(s.substr(i, n-i)==t.substr(0,n-i)){
      flg=i;
      break;
    }
  }

  cout<<n+flg<<endl;
}


Measured memory_bytes: 256
//B - Shift only
//https://atcoder.jp/contests/abc081/tasks/abc081_b

#include <cstdio>

int main()
{
  int N, n;
  int c = 0;
  bool tf;
  scanf("%d", &N);
  int num[N];

  for (int i = 0; i < N; i++)
  {
    scanf("%d", &num[i]);
  }
  for (int k = 0; k < 30; k++)
  {
    for (int j = 0; j < N; j++)
    {
      if (num[j] % 2 == 0)
      {
        tf = true;
        num[j] /= 2;
      }
      else
      {
        tf = false;
        break;
      }
    }
    if (tf == true)
    {
      c++;
    }
    else
    {
      break;
    }
  }
  printf("%d\n", c);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

typedef pair<int, int> P;

int main(int argc, char const *argv[]) {
    int h, w, d, q;
    cin >> h >> w >> d;
    vector<vector<int>> a(h, vector<int>(w, 0));
    REP(i,h) REP(j,w) cin >> a[i][j];
    cin >> q;
    vector<int> l(q);
    vector<int> r(q);
    REP(i,q) {
        cin >> l[i];
        cin >> r[i];
    }
    vector<P> p(h*w+1);
    REP(i,h) REP(j,w) p[a[i][j]] = {i, j};
    vector<ll> sumP(h*w+1);
    sumP[0] = 0;
    for (int i = 1; i <= d; ++i) {
        sumP[i] = 0;
        for (int j = i; j <= h*w-d; j+=d) {
            sumP[j+d] = sumP[j]+abs(p[j+d].first-p[j].first)+abs(p[j+d].second-p[j].second);
        }
    }

    REP(i,q) {
        cout << sumP[r[i]]-sumP[l[i]] << std::endl;
    }
    //REP(i,h*w+1) cout << sumP[i] << std::endl;
    return 0;
}

Measured memory_bytes: 3712
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    num = a[i]

    if num % 2 == 1:
        continue
    else:
        if num % 3 == 0 or num % 5 == 0:
            continue
        else:
            print('DENIED')
            exit()

print('APPROVED')



Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
#define F(i,x,n) for(int i=x;i<=n;++i)
#define F_(i,x,n) for(int i=x;i>=n;--i)
using namespace std;
inline void read(int &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
/**/
const int N=1e+5;
int n,a[N],sum,ans;
/**/
int main()
{
    // freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
    read(n);
    for(int i=1;i<=n;i++) read(a[i]),sum+=a[i];
    for(int i=1;i<=n;i++)
    {
        ans+=a[i]*(sum-a[i]);
    }
    cout<<ans/2;
}

Measured memory_bytes: 256
from fractions import gcd


def invmod(j):
    return pow(j, MOD - 2, MOD)


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

MOD = 10 ** 9 + 7


l = 1
ans = 0
for i in range(N):
    g = gcd(l, A[i])
    multip = A[i] * invmod(g) % MOD
    l *= multip
    ans *= multip
    ans += l * invmod(A[i]) % MOD
    ans %= MOD

print(ans % MOD)



Measured memory_bytes: 6200
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int n,m;
    int tar[105];
    int han[105];
    int tarsum,hansum,xxsa,x,y,wa;
    while(1==1)
    {
        n=10000;
        m=10000;
        REP(i,105)
        {
            tar[i]=10000;
            han[i]=20000;
        }
        tarsum=0;
        hansum=0;
        xxsa=0;
        x=10000;
        y=20000;
        wa=10000;
        scanf("%d %d\n",&n,&m);
        if(n==0&&m==0)return 0;
        REP(i,n)
        {
            scanf("%d\n",&tar[i]);
            tarsum+=tar[i];
        }
        REP(i,m)
        {
            scanf("%d\n",&han[i]);
            hansum+=han[i];
        }
        xxsa=tarsum-hansum;
        REP(i,n)
        {
            REP(j,m)
            {
                if((tar[i]-han[j])*2==xxsa)
                {
                    if(tar[i]+han[j]<wa)
                    {
                        x=tar[i];
                        y=han[j];
                        wa=x+y;
                    }
                }
            }
        }
        if(wa==10000)
        {
            printf("-1\n");
        }
        else printf("%d %d\n",x,y);
    }
    return 0;
}


Measured memory_bytes: 3232
import string
def func(a):
    a = a[::-1]
    return a[::-1]
s=input()
s = func(s)
ans=10**9+1
for value in set(s):
    enumerater_value=value+s+value
    var2=0
    var=0
    for i,key in enumerate(enumerater_value):
        if key==value:
            if var2<i-var-1: 
                var2=i-var-1
            var=i
    if ans>var2: 
        ans=var2
print(ans)

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

int main()
{

	int A_yen;
	int B_yen;
	int C_yen;   // 2 C_yen で  Aピザ1枚  Bピザ1枚  (ABセット)
	int X;
	int Y;
	
	int price = 2147483647;

	cin >> A_yen >> B_yen >> C_yen >> X >> Y;
	
	
	// ABセットをiセット買うときを考える
	for (int i = 0; i <= 100000; i++) {

		price = min(price, 2 * C_yen * i + A_yen * max(0, X - i) + B_yen * max(0, Y - i) );		

	}
		
	cout << price <<  endl;

	return 0;
}

Measured memory_bytes: 256
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let s = stdin.lock().lines().next().unwrap().unwrap();
    let ans = match s.as_str() {
        "Sunny" => "Cloudy",
        "Cloudy" => "Rainy",
        "Rainy" => "Sunny",
        _ => panic!(),
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
t, x, y = 0, 0, 0
ans = "Yes"
n = int(input())
for _ in range(n):
    ti, xi, yi = map(int, input().split())
    d = ti - t - abs(xi - x) - abs(yi - y)
    if d < 0 or d % 2 == 1:
        ans = "No"
    t, x , y = ti, xi, yi
print(ans)

Measured memory_bytes: 46440
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
    unsigned short *A,*B;
    
    int C[VMAX+1];
    int n,i,j;
    scanf("%d",&n);
    
    A=malloc(sizeof(short)*n+1);
    B=malloc(sizeof(short)*n+1);
    
    for(i=0;i<=VMAX;i++) C[i] = 0;
    
    for(i=0;i<n;i++){
        scanf("%hu",&A[i+1]);
        C[A[i+1]]++;
    }
    
    for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
    
    for(j=1;j<=n;j++){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
    for(i=1;i<=n;i++){
        if(i>1) printf(" ");
        printf("%d",B[i]);
        }
        printf("\n");
        return 0;
}


Measured memory_bytes: 9624
#include <iostream>
#include <string>
 
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
 
int mainC()
{
	string str;
	cin >> str;
	int n = stoi(str);
	map<string, long long> strMap;
	for (int i = 0; i < n; ++i)
	{
		cin >> str;
		sort(str.begin(), str.end());
		strMap[str]++;
	}
 
	long long m = 0;
	for (const auto& x : strMap)
	{
		auto k = x.second;
		if(k > 1)
			m += (k - 1) * k;
	}
	m /= 2;
	cout << m << endl;
	return 0;
 
}
 
int main()
{
	return mainC();
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <stdlib.h>

#define MOD 1000000007

int main(void) {
	int n;
	scanf("%d", &n);

	long long int arr[300000];
	for (int i = 0; i < n; i++)
		scanf("%lld", &arr[i]);

	long long int sum = 0;
	for (int i = 0; i < 60; i++) {
		long long int a = 0, b = 0;
		for (int j = 0; j < n; j++)
			if (arr[j] & 1ll<<i) a++;
			else b++;

		a = (a*b) % MOD;
		b = (1ll << i) % MOD;
		sum += (a*b) % MOD;
		sum %= MOD;
	}

	printf("%lld\n", sum);
}


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

const int DIM = 100005;
const int MOD = 1000000007;

int cnt[30];
char str[DIM];

int main(void) {
	int n; cin >> n >> (str + 1);
	for (int i = 1; i <= n; ++i) {
		++cnt[str[i] - 'a']; }
	int ans = 1; 
	for (int i = 0; i < 26; ++i) {
		ans = 1LL * ans * (cnt[i] + 1) % MOD; }
	cout << (ans - 1 + MOD) % MOD;
	
	return 0; }


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    total = 0
    for i in range(1, N + 1):
        keta4, mod = divmod(i, 10000)
        keta3, mod = divmod(mod, 1000)
        keta2, mod = divmod(mod, 100)
        keta1, mod = divmod(mod, 10)
        ketasum = keta4 + keta3 + keta2 + keta1 + mod
        if ketasum >= A and ketasum <= B:
            total = total + i
    return total


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(N, A, B))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/* it was worth becoming a chemist */
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 2e6 + 5;

ll a, b, c;

void f() {
	ll x = b / 2 + c / 2;
	ll y = a / 2 + c / 2;
	ll z = b / 2 + a / 2;
	a = x;
	b = y;
	c = z;
}


int main() {	
    #ifndef ONLINE_JUDGE
	//~ freopen(NAME".in", "r", stdin);
    // freopen(NAME".out", "w", stdout);
    #endif
	
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << setprecision(9) << fixed;
    
    cin >> a >> b >> c;
    int ct = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		ct++;
		if (ct >= MAXN) {
			cout << -1;
			return 0;
		}
		f();
		//~ cout << a << ' ' << b << ' ' << c << '\n';
	}
	//~ if (ct > 0) ct++;
	cout << ct;
	return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    int q; cin >> q;

    bool norm = true;
    string rf = "";
    
    for(int i = 0; i < q; i++){
        int n; cin >> n;
        if(n == 1) {
            norm = !norm;
            continue;
        }

        int f; char c; cin >> f >> c;
        if(!norm) f = 3 - f;
        
        if(f == 1) rf = rf + c;
        else s = s + c;
    }

    reverse(rf.begin(), rf.end());
    string ans = rf + s;
    if(!norm) reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1764
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
   ll n,k;
   cin>>n>>k;
   vector<ll>a(n+1);
  vector<ll>b(0);
   rep(i,n){
       ll aa;cin>>aa;
       a[i+1]=a[i]+aa;
   }
   rep(i,n){
       REP(j,i+1,n+1)b.pb(a[j]-a[i]);
   }
   vector<int>used(b.size());
   ll cnt=0;
   ll ans=0;
   for(int i=60;i>=0;i--){
       ll cn=0;
       rep(j,b.size()){
           if(used[j]==cnt){
               if((1LL<<i)&b[j])cn++;
           }
       }
       if(cn>=k){
           ans+=(1LL<<i);
           rep(j,b.size()){
               if(used[j]==cnt){
                   if((1LL<<i)&b[j]){
                       used[j]++;
                   }
               }
           }
           cnt++;
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 6516
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    rep(rr, N+1){
        if(N < rr*R) continue;
        rep(gg, N+1){
            if(N < rr*R + gg*G) continue;
            int tmp = N - R*rr - G*gg;
            if(tmp < 0) continue;
            if(tmp%B == 0) ans++;

        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    int ans = 0;
    rep(i, n)
    {
        ans += min(2 * v[i], abs(v[i] - k) * 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N,ans;
const int GATYA=10000;
int k[GATYA];
bool ok;
int main(){

	while(cin>>N,N){
	ans=N;
	ok=false;
	for(int i=0;i<N;i++){
		cin>>k[i];
		if(k[i]>=2)ok=true;
		if(k[i]==0)ans--;
	}	
	if(ok)cout<<ans+1<<endl;
	else cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    ll N,A,B;
    cin >> N >> A >> B;
    
    ll sum = (N / (A+B)) * A;
    N %= (A+B);
    if(N <= A){
        sum += N;
    }else{
        sum += A;
    }
    cout << sum << endl;
}



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


class Program
{
    static void Main(string[] args)
    {
        int[,] A = new int[3,3];
        for(int i=0; i<3; i++){
            string[] Astr = Console.ReadLine().Split(' ');
            for(int j=0; j<3; j++){
                A[i,j] = int.Parse(Astr[j]);
            }
        }
        int N = int.Parse(Console.ReadLine());
        int[] b = new int[N];
        for(int i=0; i<N; i++){
            b[i] = int.Parse(Console.ReadLine());
        }

        bool[,] Aexist = new bool[3,3];
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                Aexist[i,j] = b.Contains(A[i,j]);
            }
        }

        if(Aexist[0,0]&&Aexist[0,1]&&Aexist[0,2] ||
        Aexist[1,0]&&Aexist[1,1]&&Aexist[1,2] ||
        Aexist[2,0]&&Aexist[2,1]&&Aexist[2,2] ||
        Aexist[0,0]&&Aexist[1,0]&&Aexist[2,0] ||
        Aexist[0,1]&&Aexist[1,1]&&Aexist[2,1] ||
        Aexist[0,2]&&Aexist[1,2]&&Aexist[2,2] ||
        Aexist[0,0]&&Aexist[1,1]&&Aexist[2,2] ||
        Aexist[2,0]&&Aexist[1,1]&&Aexist[0,2]){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s;
int w, u, t;
cin >> s >> w;
u = s.size () ;
t = u/w;
if ( u % w != 0 ) {
t++;
}
for (int i = 0; i < t ; i++) {
cout << s.at ( w * i );
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
typedef long long ll;

int main(){
    int n, W; cin >> n >> W;
    vector<int> w(n+1), v(n+1);
    for(int i = 0; i < n; ++i) cin >> w[i] >> v[i];
    
    vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));

    for(int i = 0; i < n; ++i){
        for(int sum = 0; sum <= W; ++sum){
            if(sum >= w[i])
                dp[i+1][sum] = max(dp[i][sum],dp[i][sum-w[i]]+v[i]);
            else
                dp[i+1][sum] = max(dp[i+1][sum],dp[i][sum]);
        }
    }

    cout << dp[n][W] << endl;

    return 0;
}


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

// macros
#define overload_rep(va_0, va_1, va_2, va_3, name, ...) name
#define rep_0_(i, n) for(int i = 0; i < (n); ++i)
#define rep_1_(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep_2_(i, x, y, z) for(int i = (x); i >= (y); --i)
#define rep(...) overload_rep(__VA_ARGS__, rep_2_, rep_1_, rep_0_)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations

// solve
int main(){

    int N;
    string S;
    cin >> N >> S;

    if(N % 2 == 1){
        cout << "No\n";
        return 0;
    }    

    string T = S.substr(0, N / 2);
    if(T + T == S){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;

}


Measured memory_bytes: 256
import collections
n = int(input())
t = 1
for i in range(1,n+1):
    t *= i
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(t))
ans = 1
for _, v in c.items():
    ans *= (v + 1)
print(ans%(10**9+7))

Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,q;
  int64_t e=0;
  cin >> n;
  vector<int>a(n);
  for (int i=0;i<n;i++) {
    cin >> a.at(i); 
  }
  cin >> q;
  vector<int>b(q);
  vector<int>c(q);
  for (int i=0;i<q;i++) {
    cin >> b.at(i) >> c.at(i); 
  }
  vector<int>d(100000);
  for (int i=0;i<n;i++) {
    d.at(a.at(i)-1)++;
  }
  for (int i=0;i<100000;i++) {
    e+=d.at(i)*(i+1); 
  }
  for (int i=0;i<q;i++) {
    e+=((c.at(i)-b.at(i))*(d.at(b.at(i)-1)));
    d.at(c.at(i)-1)+=d.at(b.at(i)-1);
    d.at(b.at(i)-1)=0;   
    cout << e << endl;
  }
}

Measured memory_bytes: 4820
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long 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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
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 push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e9;

struct edge{int to,cost;};
typedef pair<int,int> P;//firstは最短距離,secondは頂点番号


int main(){
	long n;
	while(cin>>n){
		if(n==0)break;
		long cnt=0;
		while(n!=1){
			if(n%2==0)n/=2;
			else n=n*3+1;
			cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int a;
    set<int> st;
    rep(i, 0, 3){
        cin >> a;
        st.insert(a);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main() {
    string s;
    while(getline(cin, s), s != "."){
	stack<int> stk;
	string ans = "yes";
	rep(i, s.size()){
	    if(s[i] == '(') stk.push(0);
	    else if(s[i] == ')'){
		if(stk.empty() || stk.top() != 0) ans = "no";
		else stk.pop();
	    }
	    if(s[i] == '[') stk.push(1);
	    else if(s[i] == ']'){
		if(stk.empty() || stk.top() != 1) ans = "no";
		else stk.pop();
	    }
	}
	if(!stk.empty()) ans = "no";
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using Graph=mat;

Graph G;
vec c;

void dfs(int x,int par){
    c[x]+=c[par];
    for(int next_x:G[x]){
        if(next_x==par)continue;

        dfs(next_x,x);
    }
}
int main(){
    int N,Q;cin>>N>>Q;
    c.resize(200010,0);
    G.resize(200010);
    for(int i=0;i<N-1;++i){
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i=0;i<Q;i++){
        int p,x;cin>>p>>x;
        c[p]+=x;
    }

    dfs(1,0);
    for(int i=1;i<=N;i++)
        cout<<c[i]<<" ";
    
    return 0;
}

Measured memory_bytes: 23424
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int A, B;
    cin >> A >> B;
    bool is_end = false;
    for(int i = 1; i <= 1009; i++){ //税抜き価格が1009円の時に、10％税率でB=100.9となり、小数点切り捨てで100となる。
        int ans_A = i * 0.08;
        int ans_B = i * 0.1;
        if(ans_A == A && ans_B == B){
            cout << i << endl;
            is_end = true;
            break;
        }
    }
    if(!is_end){
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ans=0;
    int n;scanf("%d",&n);
    int mn=n;
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        mn=min(mn,x);
        if(mn>=x) ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
const main = (input) => {
  const [a, ...b] = input.trim().split('\n')
  const [n, m, x] = a.split(' ').map(Number)

  let ans = Infinity

  const r = (idx, arr, sum) => {
    if (arr.every(v => v >= x)) {
      ans = Math.min(sum, ans)
      return null
    }
    if (idx > n-1) return null

    const [price, ...study] = b[idx].split(' ').map(Number)

    const newSum = sum + price
    const newArr = arr.map((v, i) => v + study[i])

    r(idx+1, newArr, newSum)
    r(idx+1, arr, sum)
  }

  r(0, new Array(m).fill(0), 0)

  return console.log(ans === Infinity ? -1 : ans)
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

const int E = 100;

int N;
int X[50], Y[50];

double f(double x, double y) {
  double ret = 0;
  rep(i, N) {
    auto dx = X[i] - x, dy = Y[i] - y;
    ret = max(ret, dx * dx + dy * dy);
  }
  return ret;
}

double fx(double x) {
  double y1 = 0, y2 = 1000;
  rep(_, E) {
    auto y3 = (y1 + y1 + y2) / 3, y4 = (y1 + y2 + y2) / 3;
    if (f(x, y3) < f(x, y4))
      y2 = y4;
    else
      y1 = y3;
  }
  return f(x, (y1 + y2) / 2);
}

int main() {
  cin >> N;
  rep(i, N) cin >> X[i] >> Y[i];
  double x1 = 0, x2 = 1000;
  rep(_, E) {
    auto x3 = (x1 + x1 + x2) / 3, x4 = (x1 + x2 + x2) / 3;
    if (fx(x3) < fx(x4))
      x2 = x4;
    else
      x1 = x3;
  }
  printf("%.15f\n", sqrt(fx((x1 + x2) / 2)));
  return 0;
}


Measured memory_bytes: 256