akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;

typedef pair<ll,int>pa;

queue<pa>q;
map<ll,int>mp;


bool check(int x)
{
     int three=0,five=0,seven=0;

     while(x){
        if(x%10==3) three++;
        if(x%10==7) seven++;
        if(x%10==5) five++;
        x/=10;
     }
     if(three && seven && five) return true;
     return false;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);

    int ans=0;
    ll n;cin>>n;
    q.push({0,0});
    while(q.size()){
         pa k=q.front();q.pop();
         ll kk=k.first*10+3;
         if(kk<=n && !mp[kk]) {

            mp[kk]++;
            if(k.second || check(kk)) ans++,q.push({kk,1});
            q.push({kk,0});
         }
         kk=k.first*10+5;
         if(kk<=n && !mp[kk]){

            mp[kk]++;
            if(k.second || check(kk)) ans++,q.push({kk,1});
            q.push({kk,0});
         }
         kk=k.first*10+7;
         if(kk<=n && !mp[kk]){
            mp[kk]++;
           if(k.second || check(kk)) ans++,q.push({kk,1});
           q.push({kk,0});
         }

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


Measured memory_bytes: 6028
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t="";
  cin >> s;
  int len = s.size();
  for(int i=0; i<len; i++){
    if(s[i]=='0')
      t.push_back('0');
    else if(s[i]=='1')
      t.push_back('1');
    else if(!t.empty())
      t.pop_back();
  }
  cout << t;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
     
    using namespace std;
     
    int main(void){
      int c[4] = {};
      int N;
      cin >> N;
      for(int i = 0; i < N; i++){
        char color;
        cin >> color;
        switch(color){
          case 'P': c[0]=1; break;
          case 'Y': c[1]=1; break;
          case 'W': c[2]=1; break;
          case 'G': c[3]=1; break;
        }
      }
      if(c[0] + c[1] + c[2] + c[3] == 3) cout << "Three" << endl;
      else cout << "Four" << endl;
      
      return 0;
    }

Measured memory_bytes: 888
N=int(input())

pablist=[]
for _ in range(N):
  A,B=map(int,input().split())  
  pablist.append((A+B,A,B))
pablist.sort()
#print(pablist)

tak_score=0
aok_score=0
turn=0
while pablist:
  p,a,b=pablist.pop()
  if turn&1==0:
    tak_score+=a
  else:
    aok_score+=b
  turn+=1
  
print(tak_score-aok_score)

Measured memory_bytes: 25944
import java.util.Scanner;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
int A1 = sc.nextInt();
int min=A1;
int max=A1;
  for(int i=0;i<2;i++){
    int A = sc.nextInt();
    if(A>max)
    max=A;
    if(A<min)
    min=A;
  }

System.out.println(max-min);
}
}


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

int k;

int main() {
	cin >> k;
	if (!(k & 1) || !(k % 5)) {
		cout << -1 << endl;
		return 0;
	}
	if (!(k % 7))
		k /= 7;
	int a = 1, b = 1, n = 1;
	while (a % k) {
		++n;
		b = b * 10 % k;
		a = (a + b) % k;
	}
	cout << n << endl;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
	"math"
	_ "sort"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	x := make([][]int, n) //スライス
	for i := 0; i < n; i++ {
		x[i] = make([]int, d)
		for j := 0; j < d; j++ {
			fmt.Scan(&x[i][j])
		}
	}

	cnt := 0

	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			dist := 0.0
			for k := 0; k < d; k++ {
				dist += float64((x[i][k] - x[j][k]) * (x[i][k] - x[j][k]))
			}
			dist = math.Sqrt(dist)
			if math.Floor(dist) == dist {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int gcd(int a,int b){
    if(b == 0) return a;
    return gcd(b,a % b);
}

int main(){
    ll n,m;
    cin >> n >> m;
    string s,t;
    cin >> s >> t;
    ll g = gcd(n,m);

    bool flag = true;
    ll ans = n*m/g;
    rep(i,g){
        if(s[i*n/g] != t[i*m/g]) flag = false;
    }
    if(flag) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> as;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    as.push_back(a);
  }
  auto minIx = min_element(as.begin(), as.end());
  auto maxIx = max_element(as.begin(), as.end());

  min_element(as.begin(), as.end());
  auto printIter = abs(*minIx) < abs(*maxIx)
               ? maxIx
               : minIx;
  auto printIx = distance(as.begin(), printIter) + 1;
  if( abs(*minIx) < abs(*maxIx) ){
    cout << n*2-1 << endl;
    for(int i = 1; i <= n; i++) {
      cout << printIx << " " << i << endl;
    }

    for(int i = 1; i < n; i++){
      cout << i << " " << i + 1 << endl;
    }
    
  } else {
    cout << n*2-1 << endl;
    for(int i = 1; i <= n; i++) {
      cout << printIx << " " << i << endl;
    }
    for(int i = n; i > 1; i--){
      cout << i << " " << i - 1 << endl;
    }
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n;
long double x[8],y[8],ans=0.0;

void dfs(int mask, int v, long double dist){
	int u;
	bool flag = true;
	for(u=0; u<n; ++u){
		if(mask&(1<<u)){
			flag = false;
			dfs(mask&~(1<<u),u,dist+sqrt((x[u]-x[v])*(x[u]-x[v])+(y[u]-y[v])*(y[u]-y[v])));
		}
	}
	if(flag){
		ans += dist;
	}
}

int main(void){
	int i,mask;
	cin >> n;
	mask = (1<<n)-1;
	for(i=0; i<n; ++i){
		cin >> x[i] >> y[i];
	}
	for(i=0; i<n; ++i){
		dfs(mask&~(1<<i),i,0.0);
	}
	for(i=1; i<=n; ++i){
		ans /= i;
	}
	cout << fixed << setprecision(50) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(map(str, input()))

# print(S)
# sum_number = int((N*(N-1)*(N-2))/6)
# del_number = N - 2

# print(sum_number)
# print(del_number)

R = S.count("R")
G = S.count("G")
B = S.count("B")


# for i in S:
#     if i == "R":
#         R += 1
#     elif i == "G":
#         G += 1
#     elif i == "B":
#         B += 1

# print(R)
# print(G)
# print(B)

ans = R * G * B

for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        # print(i)
        # print(j)
        # print(k)
        if k > N-1:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1
print(ans)

Measured memory_bytes: 9116
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0

for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    else:
        ans += A[i]
        B2 = B[i] - A[i]
        if A[i+1] >= B2:
            ans += B2
            A[i+1] -= B2
        else:
            ans += A[i+1]
            A[i+1] = 0

print(ans)

Measured memory_bytes: 18624
#include <stdio.h>

typedef struct  {
    int f[6];
} dice;

dice op_s(dice d) {
    dice tmp;
    tmp.f[0] = d.f[4];
    tmp.f[1] = d.f[0];
    tmp.f[2] = d.f[2];
    tmp.f[3] = d.f[3];
    tmp.f[4] = d.f[5];
    tmp.f[5] = d.f[1];
    return tmp;
}

dice op_n(dice d) {
    dice tmp;
    tmp.f[0] = d.f[1];
    tmp.f[1] = d.f[5];
    tmp.f[2] = d.f[2];
    tmp.f[3] = d.f[3];
    tmp.f[4] = d.f[0];
    tmp.f[5] = d.f[4];
    return tmp;
}

dice op_w(dice d) {
    dice tmp;
    tmp.f[0] = d.f[0];
    tmp.f[1] = d.f[2];
    tmp.f[2] = d.f[4];
    tmp.f[3] = d.f[1];
    tmp.f[4] = d.f[3];
    tmp.f[5] = d.f[5];
    return tmp;
}

dice op_e(dice d) {
    dice tmp;
    tmp.f[0] = d.f[0];
    tmp.f[1] = d.f[3];
    tmp.f[2] = d.f[1];
    tmp.f[3] = d.f[4];
    tmp.f[4] = d.f[2];
    tmp.f[5] = d.f[5];
    return tmp;
}

int func(dice *d1, dice *d2)
{
    int i;
    if(d1->f[0] == d2->f[0] && d1->f[5] == d2->f[5]) {
        for(i = 0; i < 4; i++) {
            *d2 = op_e(*d2);
            if(d1->f[1] == d2->f[1] && d1->f[2] == d2->f[2] && d1->f[3] == d2->f[3] && d1->f[4] == d2->f[4]) {
                return 1;
            }
        }
    }
    return 0;
}

int comp(dice *td1, dice *td2)
{
    dice d1, d2;

    d1 = *td1;
    d2 = *td2;
    // top 0
    if(func(&d1, &d2) == 1) {
        return 1;
    }
    // top 1
    d2 = op_n(d2);
    if(func(&d1, &d2) == 1) {
        return 1;
    }
    // top 2
    d2 = op_w(d2);
    d2 = op_n(d2);
    if(func(&d1, &d2) == 1) {
        return 1;
    }
    // top 3
    d2 = op_n(d2);
    d2 = op_n(d2);
    if(func(&d1, &d2) == 1) {
        return 1;
    }
    // top 4
    d2 = op_s(d2);
    if(func(&d1, &d2) == 1) {
        return 1;
    }
    // top 5
    d2 = op_e(d2);
    d2 = op_n(d2);
    if(func(&d1, &d2) == 1) {
        return 1;
    }

    return 0;
}

int main()
{
    int n;
    scanf("%d", &n);
    dice dices[100];
    int i;
    int j;
    int flag;

    for(i = 0; i < n; i++) {
        for(j = 0; j < 6; j++) {
            scanf("%d", &(dices[i].f[j]));
        }
    }

    flag = 0;
    for(i = 0; i < n-1; i++) {
        for(j = i+1; j < n; j++) {
            if(comp(&(dices[i]), &(dices[j])) == 1) {
                flag = 1;
            }
        }
    }

    if(flag == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2100
def CountingSort(A, k):
 C = [0] * (k+1)
 for j in A:
  C[j] += 1
 for i in range(1, k+1):
  C[i] += C[i-1]
 B = [0] *(max(C))
 for j in A[::-1]:
  B[C[j]-1] = j
  C[j] -= 1
 return B

n = int(input())
A = list(map(int, input().split()))
k = max(A)
B =CountingSort(A, k)
print(" ".join(map(str,B)))

Measured memory_bytes: 244376
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(str,S);
  IN(str,T);
  bool ans = true;
  REP(i,S.size()){
    if(S[i] != T[i]){
    ans = false;
    }
  }
  BOUT(ans);
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint S;
    cin >> S;
    lint X1 = 0, Y1 = 0, X2 = 1e9, Y2 = 1, X3, Y3;

    Y3 = (S + ((lint)1e9) - 1) / (lint)1e9;
    X3 = (lint)1e9 * Y3 - S;

    cout << X1 << ' ' << Y1 << ' ';
    cout << X2 << ' ' << Y2 << ' ';
    cout << X3 << ' ' << Y3 << ' ';

    return 0;
}

Measured memory_bytes: 3560
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var pmax = 0; var ptotal = 0;
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            if (a < n) ptotal += n - a;
            pmax = Math.Max(pmax, n - a);
        }
        Console.WriteLine(ptotal - pmax);
    }
}



Measured memory_bytes: 9208
// problem: "https://atcoder.jp/contests/abc160/tasks/abc160_e"

#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll maxDelicious(ll x,ll y,vector<int>&R,ll a,vector<int>&G,ll b,vector<int>&C,ll c)
{
    sort(R.begin(),R.end(),greater<ll>());
    sort(G.begin(),G.end(),greater<ll>());
    sort(C.begin(),C.end(),greater<ll>());

    ll i,j,k,s,l;
    i = j = k = l = s = 0;
    while(i < x && j < y && k < c && l < x+y)
    {
        if(R[i] >= G[j] && R[i] >= C[k])
        {
            l++;
            s += R[i];
            i++;
        }
        else if(G[j] >= R[i] && G[j] >= C[k])
        {
            l++;
            s += G[j];
            j++;
        }
        else
        {
            l++;
            s += C[k];
            k++;
        }
    }

    while(j < y && k < c && l <x+y)
    {
        if(G[j] > C[k])
        {
            l++;
            s += G[j];
            j++;
        }
        else
        {
            l++;
            s += C[k];
            k++;
        }
    }

    while(j < y && i < x && l <x+y)
    {
        if(G[j] > R[i])
        {
            l++;
            s += G[j];
            j++;
        }
        else
        {
            l++;
            s += R[i];
            i++;
        }
    }

    while(i < x && k < c && l <x+y)
    {
        if(R[i] > C[k])
        {
            l++;
            s += R[i];
            i++;
        }
        else
        {
            l++;
            s += C[k];
            k++;
        }
    }

    return s;
}

int main()
{
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    vector<int>R(a),G(b),C(c);
    ll i;
    for(i=0;i!=a;i++)
        cin>>R[i];

    for(i=0;i!=b;i++)
        cin>>G[i];

    for(i=0;i!=c;i++)
        cin>>C[i];

    cout<<maxDelicious(x,y,R,a,G,b,C,c);        // define

    return 0;
}


Measured memory_bytes: 1408
import sys
input = sys.stdin.readline

#l = list(map(int, input().split()))
#import numpy as np
#arr = np.array([int(i) for i in input().split()])
'''
a,b=[],[]
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

s=input().strip("\n")

if s[-1]=="s":
    print(s+"es")
else:
    print(s+"s")

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

public class PriorityQueue<T> where T : IComparable
{
    private IComparer<T> _comparer = null;
    private int _type = 0;
    private T[] _heap;
    private int _sz = 0;
    private int _count = 0;
    /// <summary>
    /// Priority Queue with custom comparer
    /// </summary>
    public PriorityQueue(int maxSize, IComparer<T> comparer)
    {
        _heap = new T[maxSize];
        _comparer = comparer;
    }
    /// <summary>
    /// Priority queue
    /// </summary>
    /// <param name="maxSize">max size</param>
    /// <param name="type">0: asc, 1:desc</param>
    public PriorityQueue(int maxSize, int type = 0)
    {
        _heap = new T[maxSize];
        _type = type;
    }
    private int Compare(T x, T y)
    {
        if (_comparer != null) return _comparer.Compare(x, y);
        return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
    }
    public void Push(T x)
    {
        _count++;
        var i = _sz++;
        while (i > 0)
        {
            var p = (i - 1) / 2;
            if (Compare(_heap[p], x) <= 0) break;
            _heap[i] = _heap[p];
            i = p;
        }
        _heap[i] = x;
    }
    public T Pop()
    {
        _count--;
        T ret = _heap[0];
        T x = _heap[--_sz];
        int i = 0;
        while (i * 2 + 1 < _sz)
        {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b;
            if (Compare(_heap[a], x) >= 0) break;
            _heap[i] = _heap[a];
            i = a;
        }
        _heap[i] = x;
        return ret;
    }
    public int Count() => _count;
    public T Peek() => _heap[0];
    public bool Contains(T x)
    {
        for (int i = 0; i < _sz; i++) if (x.Equals(_heap[i])) return true;
        return false;
    }
    public void Clear()
    {
        while (this.Count() > 0) this.Pop();
    }
    public IEnumerator<T> GetEnumerator()
    {
        var ret = new List<T>();
        while (this.Count() > 0) ret.Add(this.Pop());
        foreach (var r in ret)
        {
            this.Push(r);
            yield return r;
        }
    }
    public T[] ToArray()
    {
        T[] array = new T[_sz];
        int i = 0;
        foreach (var r in this) array[i++] = r;
        return array;
    }
}

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new List<int>[n];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var m = int.Parse(line[0]);
            a[i] = new List<int>();
            for (int j = 0; j < m; j++)
                a[i].Add(int.Parse(line[j + 1]));
        }
        var ans = getAns(a, n);
        Console.WriteLine(ans);
    }
    public static long getAns(List<int>[] a, int n)
    {
        var pq = new PriorityQueue<int>(300000, 1);
        var ans = 0L;
        for (int i = n - 1; i >= 0; i--)
        {
            foreach (var x in a[i]) pq.Push(x);
            ans += pq.Pop();
        }
        return ans;
    }
}




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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

int N;

void f(int u, int p, vector<int>& a, vector<vector<int>>& G, vector<vector<ll>>& dp, vector<vector<ll>>& ep) {
    dp[u] = vector<ll>{a[u]};
    ep[u] = vector<ll>{a[u]};
    for (int v: G[u]) if (v != p) {
        f(v, u, a, G, dp, ep);
        int n = dp[u].size();
        int m = dp[v].size();
        vector<ll> unko(n + m - 1, LLONG_MAX / 10);
        vector<ll> hoge(n + m - 1, LLONG_MAX / 10);
        rep(i, n) rep(j, m) {
            unko[i + j] = min(unko[i + j], dp[u][i] + dp[v][j]);
            hoge[i + j] = min(hoge[i + j], ep[u][i] + ep[v][j]);
        }
        dp[u] = unko;
        ep[u] = hoge;
    }
    if (a[u] < 0) rep(i, ep[u].size()) ep[u][i] = LLONG_MAX / 10;
    dp[u].pb(LLONG_MAX / 10);
    ep[u].pb(LLONG_MAX / 10);
    for (int i = (int)dp[u].size() - 2; i >= 0; i--) {
        if (dp[u][i] < 0 || ep[u][i] < LLONG_MAX / 100) {
            dp[u][i + 1] = min(dp[u][i + 1], 0LL);
            ep[u][i + 1] = min(ep[u][i + 1], 0LL);
        }
    }
}

int main() {
    cin >> N;
    vector<int> a(N);
    rep(u, N) cin >> a[u];
    vector<vector<int>> G(N);
    rep(i, N - 1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].pb(v);
        G[v].pb(u);
    }
    vector<vector<ll>> dp(N), ep(N);
    f(0, -1, a, G, dp, ep);
    int ans = N;
    rep(i, dp[0].size()) if (dp[0][i] < 0 || ep[0][i] < LLONG_MAX / 100)
        ans = min(ans, i);
    cout << ans << endl;
}


Measured memory_bytes: 226048
X = int(input())
A = 1
while True:
    if X > A ** 5:
        S = X - A ** 5
        B = S ** (1 / 5) * (-1)
    else:
        S = A ** 5 - X
        B = S ** (1 / 5)
    if A ** 5 - int(B) ** 5 == X:
        break
    A += 1
print(A, int(B))


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

void trace(int A[], int N){
    for(int i=0; i<N; i++){
        if(i>0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}
/*
void insertionSort(int A[], int N){
    int i, j, tmp;
    for(i=1; i=N; i++){
        tmp = A[i];
        for(j=i-1; j>=0; j--){
            if(A[j] > tmp) A[j + 1] = A[j];
            else{
                A[j + 1] = tmp;
                break;
            };
        }
    }
}
*/


void insertionSort(int A[], int N){
    for(int i=1; i<N; i++){
        int tmp = A[i];
        int j = i - 1;
        while(j>=0 && A[j] > tmp){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = tmp;
        trace(A, N);
    }
}

int main(){
    int N, A[100];
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];

    trace(A, N);
    insertionSort(A, N);

    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main ()
{

char c;
cin >> c;

if(c=='A')
{
	 cout << "T" << endl;
}
else if(c=='T')
{
	 cout << "A" << endl;
}
else if(c=='C')
{
	cout << "G" << endl;
}
else
{
	 cout << "C" << endl;
}


	return 0;
}











Measured memory_bytes: 2956
#13:19
n = int(input())
s = input()
t = []
for i in range(n):
  t.append(ord(s[i])-97)
q = int(input())
scale = 19
seg = [[0 for _ in range(2**(scale+1))] for _ in range(26)]
for i in range(n):
  tmp = int(i) + 2 ** scale
  x = t[i]
  while tmp != 0:
    seg[x][tmp] += 1
    tmp //= 2
#print(seg)
raw = []
for _ in range(q):
  d,a,b = input().split()
  d = int(d)
  if d == 1:
    a = int(a) - 1
    b = ord(b) - 97
  else:
    a = int(a) - 2
    b = int(b) - 1
  raw.append([d,a,b])
for p in range(q):
  d,a,b = raw[p]
  if d == 1:
    tmp = int(a)
    c = t[tmp]
    tmp += 2**scale
    while tmp != 0:
      seg[c][tmp] -= 1
      tmp >>= 1
    tmp = int(a)
    t[tmp] = b
    tmp += 2**scale
    while tmp != 0:
      seg[b][tmp] += 1
      tmp >>= 1
  else:
    ans = 0
    for d in range(26):
      l = 0
      r = 0
      if a == -1:
        l = 0
      else:
        tmp = a + 2**scale
        l += seg[d][tmp]
        while tmp != 1:
          if tmp & 1:
            l += seg[d][tmp-1]
          tmp >>= 1
      tmp = b + 2**scale
      r += seg[d][tmp]
      while tmp != 1:
        if tmp & 1:
          r += seg[d][tmp-1]
        tmp >>= 1
      if r > l:
        ans += 1
      #print(d,r,l)
    print(ans)
#print(t)

Measured memory_bytes: 412468
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
	string s; cin >> s;
	vi iwaiwa,oinuki;
	rep(i,n-1){
		if(s[i]=='#'&&s[i+1]=='#') iwaiwa.push_back(i);
	}
	rep(i,n-2){
		if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.') oinuki.push_back(i);
	}
	rep(i,iwaiwa.size()){
		if(a<=iwaiwa[i]&&iwaiwa[i]<c){
			cout << "No" << endl;
			return 0;
		}
		if(b<=iwaiwa[i]&&iwaiwa[i]<d-2){
			cout << "No" << endl;
			return 0;
		}
	}
	if(c<d){
		cout << "Yes" << endl;
		return 0;
	}else{
		rep(i,oinuki.size()){
			if(b-2<=oinuki[i]&&oinuki[i]<=d-2){
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
	}
}


Measured memory_bytes: 640
import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)

  def main(args: Array[String]): Unit = {
    taskB
  }

  def taskA: Unit = {
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()

    def abs(x: Int): Int = Math.abs(x)
    val ans = if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d) {
      "Yes"
    } else {
      "No"
    }
    println(ans)
  }

  def taskB: Unit = {
    val x = sc.nextInt()

    def isPow(x: Int): Boolean = {
      if (x == 1) {
        true
      } else {
        Range(2, x).exists(i => {
          var t = x
          var cnt = 0
          while (t % i == 0) {
            t /= i
            cnt += 1
          }
          cnt >= 2 && t == 1
        })
      }
    }

    val ans = Range(1, x + 1).reverse.filter(isPow).head
    println(ans)
  }
}

Measured memory_bytes: 31932
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
from collections import deque
import collections
from heapq import *
import json
l=[]
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
for i in range(len(key)):
    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
l.sort(key=lambda x:x[0],reverse=True)
ans=0
num=N-1
for i in range(len(l)):
    if i==0:
        ans=ans+l[i][0]*min(2*l[i][1]-1,num)
        num=num-min(2*l[i][1]-1,num)
    else:
        ans=ans+l[i][0]*min(2*l[i][1],num)
        num=num-min(2*l[i][1],num)
print(ans)

Measured memory_bytes: 137596
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue

#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORd(i,a,b) for(int i=(a);i>=(b);i--)
#define FORl(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORN(i,n) for(int i=(0);i<(n);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................



int main()
{
    fast
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<"\n";
    return 0;
}

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

typedef long long ll;
const int N = 2000006;

int a[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]-a[0];
	
	
	return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
vector<std::vector<int>> x;
void solve1(vector<int> a,std::vector<int> &v,int idx,int n){
  if(idx==v.size()){
    if(a.size()!=0) x.pb(a);
    return ;
  }
  a.pb(v[idx]);
  solve1(a,v,idx+1,n);
  a.pop_back();
  solve1(a,v,idx+1,n );
}
void solve(){
  int n,m,k;
  cin>>n>>m>>k;
  vector<int> v(n,0);
  rep(i,1,n) v[i]=i;
  vector<int> a;
  solve1(a,v,0,n);
  vector<vector<int>> ax(n,vector<int>(m,0));
  vector<ll> c(n);
  rep(i,0,n){cin>>c[i]; rep(j,0,m) cin>>ax[i][j];}

  ll ans=LLONG_MAX;
  rep(i,0,x.size()){
    int flag=0;
    ll tc_=0;
    map<int,int> m1;
    rep(j,0,m) m1[j]=0;
    rep(j,0,x[i].size()){
      rep(l,0,m){
        m1[l]+= ax[x[i][j]][l];
      }
      tc_+=c[x[i][j]];
    }
    for(auto j:m1){
      if(j.second< k){
        flag=1;
        break;
      }
    }
    if(!flag){
      ans=min(ans,tc_);
    }
  }
  if(ans!=LLONG_MAX)
  cout<<ans<<endl;
  else cout<<-1<<endl;
}
int main(){
    optimizeIO();
    // tc
    int n;
    cin>>n;
    ll a[n+1];
    rep(i,0,n+1) cin>>a[i];
    ll pre[n+1];
    pre[n]=a[n];
    rrep(i,n-1,0){
      pre[i]=pre[i+1]+a[i];
    }
    vector<ll> v1(n+1,0);

    if(n==0 && a[0]==1){
      cout<<1<<endl;
      return 0;
    }
    if(n==0 && a[0]!=1){
      cout<<-1<<endl;
      return 0;
    }
    if(a[0]>=1 || pre[0]<n-1){
      cout<<-1<<endl;
      return 0;
    }
    v1[1]=2-a[1];
    // cout<<1<<endl;
    // rep(i,0,n+1) cout<<v1[i]<<" ";
    // cout<<endl;
    if(v1[1]<0 || (v1[1]==0 && n>1) ){
      cout<<-1<<endl;
      return 0;
    }


    rep(i,2,n+1){
      if(v1[i-1]>100000000000000){
        v1[i]=100000000000000+1;
        continue;
      }
      v1[i]=2*v1[i-1]-a[i];

      if(v1[i]<0 || (v1[i]==0 && n>i) ){
        // cout<<i<<endl;
        cout<<-1<<endl;
        return 0;
      }
    }


    ll ans=0;
    int last=0;
    while(v1[last]==0 && last<n){
      ans+=pow(2LL,last);
      last++;
    }
    // cout<<ans+pre[0]<<endl;
    while(last<n){
      if(v1[last]>=pre[last+1]){
        ans+=pre[last+1];
      }
      else{
        ans+=v1[last];
      }
      last++;
    }
    if(ans+pre[0]<=n){
      cout<<-1<<endl;
      return 0;
    }
    cout<<ans+pre[0]<<endl;
}


Measured memory_bytes: 5588
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint k,n;std::cin>>k>>n;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    lint max=k+a.front()-a.back();
    for(lint i=0;i<n-1;i++){
        lint x=a.at(i+1)-a.at(i);
        if(max<x)max=x;
    }
    std::cout<<k-max<<'\n';
}



Measured memory_bytes: 1792
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 2010
ll a[N][3], d[N];

int main(){
	int n, m;
	cin>>n>>m;
	rep(i, m) rep(j, 3) cin>>a[i][j];
	fill(d, d+n+1, (ll)-1e15);
	d[1] = 0;
	rep(_, 2){
		ll prev = d[n];
		rep(__, n){
			rep(j, m) chmax(d[a[j][1]], d[a[j][0]]+a[j][2]);
		}
		if(d[n]!=prev && _){
			cout<<"inf"<<endl;
			return 0;
		}
	}
	cout<<d[n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    rep(i,N){
        cin>>A.at(i);
    }
    for(ll i=K;i<N;i++){
        if(A.at(i)>A.at(i-K))cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 4836
#include<stdio.h>
#include<string.h>
int spow(int x ,int y){
	int i,ans=1;
	if(y==0)
		return 1;
	
	for(i=0;i<y;i++){
		ans*=x;
	}
	return ans;
}
void encode(int num,char* ans){
	char a=0,b;
	char digit[4];
	char digit_c[5]="mcxi";
	for(b=0;b<4;b++){
		digit[b]=num/spow(10,3-b);
		num-=digit[b]*spow(10,3-b);
	}
	for(b=0;b<4;b++){
		if(digit[b]!=0){
			if(digit[b]==1){
				ans[a]=digit_c[b];
				a++;
			}
			else{
				ans[a]='0'+digit[b];
				a++;
				ans[a]=digit_c[b];
				a++;
			}
		}
		
	}
	ans[a]='\0';
}
int decode(char* str){
	int ans=0;
	int a=0,b=0;
	char digit[5]="mcxi";
	while(1){
		if(str[a]=='\0')break;
		if('2'<=str[a]&&str[a]<='9'){
			int d=str[a]-'0';
			a++;
			ans+=d*spow(10,(3-(strchr(digit,str[a])-digit)));
			a++;
		}
		else{
			ans+=spow(10,(3-(strchr(digit,str[a])-digit)));
			a++;
		}
	}
	return ans;
}
int main(){
	char str1[10],str2[10],ans[10];
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",str1,str2);
		encode(decode(str1)+decode(str2),ans);
		puts(ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 #define MAX 1000000000005
 #define ll long long int
 int main()
 {    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        long long int m,sum=0,k=0,i,dd=0,j,sum1=0,x,sum2=0,sum3=0,l,kk,sum4=0,sum5=0,y,z,sum6=0,cc=0;
         ll n;
           cin>>n;
            ll a[n+1],b[n+1]={0};
                 for(i=1;i<=n;i++)
                 {for(j=0;j<=n;j+=i)
                    b[j]++;
                }
                for(i=1;i<=n;i++)
                 sum+=i*b[i];
                 cout<<sum<<endl;
 }




Measured memory_bytes: 81676
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;

int main(){
	cin>>n;
	if(n==3||n==5||n==7) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    ll ans =1;
    for(int i = 0;i<n;i++){
        cin >> a[i];
    }
    sort(all(a));
    for(int i = 0;i<n;i++){
        if(ans ==  0) break; 
        if(INT64_C(1000000000000000000)/ans >= a[i]) ans = ans*a[i]; 
        else ans = -1;
    }
    cout << ans << endl;
   
}

Measured memory_bytes: 3964
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int ans = 0;
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                int y = in.nextInt();
                if (set.contains(y)) {
                    ans--;
                    set.remove(y);
                } else {
                    ans++;
                    set.add(y);
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 45044
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
typedef pair<double, int> pdi;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define mtz(a) ((a)<0?0:(a))

#define DMAX 1e20

struct C{
	double x; double y; double r;
};
 
int main(void){
	int xs, ys, xg, yg, n;
	scanf("%d%d%d%d%d", &xs, &ys, &xg, &yg, &n);
	vector<C> c(n+2);
	vector<vector<pdi>> v(n+2);
	vector<double> d(n+2, DMAX);
	rep(i, n) scanf("%lf%lf%lf", &c[i].x, &c[i].y, &c[i].r);
	c[n].x = xs; c[n].y = ys; c[n].r = 0;
	c[n+1].x = xg; c[n+1].y = yg; c[n+1].r = 0;
	rep(i, n+2) rep(j, i){
		double tx = (c[i].x - c[j].x);
		double ty = (c[i].y - c[j].y);
		double tr = (c[i].r + c[j].r);
		double cost = mtz(sqrt(tx*tx+ty*ty)-tr);
		v[i].push_back(pdi(cost, j));
		v[j].push_back(pdi(cost, i));
	}

	pque(pdi) q;
	q.push(pdi(0, n)); d[n] = 0;
	while(!q.empty()){
		pdi p = q.top(); q.pop();
		if(p.fir > d[p.sec]) continue;
		rep(i, v[p.sec].size()) if(d[v[p.sec][i].sec] > p.fir + v[p.sec][i].fir){
			d[v[p.sec][i].sec] = p.fir + v[p.sec][i].fir;
			q.push(pdi(d[v[p.sec][i].sec], v[p.sec][i].sec));
		}
	}
	
	printf("%.15f\n", d[n+1]);
	
	return 0;
}

Measured memory_bytes: 22512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{
 char b;
  cin >> b;
  
  if ( b == 'A') cout << 'T' << endl;
    if ( b == 'T') cout << 'A' << endl;
    if ( b == 'G') cout << 'C' << endl;
    if ( b == 'C') cout << 'G' << endl;
  
  return 0;
}


Measured memory_bytes: 256
A,B,N = map(int,input().split())

l = None
if B <= N:
    l = B-1
else:
    l = N
#print('len: ', len(l))


'''
for x in range(1, len(l) + 1):
    l[x-1] = ((A*x)//B) - A*(x//B)
'''

print(((A*l)//B) - A*(l//B))



'''m = 0
for x in range(1, N+1):
    j =  ((A*x)//B) - A*(x//B)
    m = max(m,j)


print('MAX',m)
'''


Measured memory_bytes: 9172
#include<stdio.h>

int partition(int[], int, int);
void swap(int*, int*);

int main()
{
	int *a, n, q;
	scanf("%d", &n);
	a = new int[n];
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	q = partition(a, 0, n - 1);
	for (int i = 0; i < n; i++)
	{
		if (i)
			printf(" ");
		if (i == q)
			printf("[");
		printf("%d", a[i]);
		if (i == q)
			printf("]");
	}
	printf("\n");

	return 0;
}

int partition(int a[], int left, int right)
{
	int x, i;
	x = a[right];
	i = left;

	for (int j = left; j < right; j++)
	{
		if (a[j] <= x)
		{
			swap(a + i, a + j);
			i++;
		}
	}
	swap(a + i, a + right);

	return i;
}

void swap(int *a, int *b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
	return;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <complex>
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define ALL(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<long long>;
using vvl = vector<vl>;
using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator-(mint a) { return a.n == 0 ? 0 : MOD - a.n; }
mint operator+(mint a, mint b) { return (a.n += b.n) >= MOD ? a.n - MOD : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + MOD : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

mint dp0[100001];
mint dp1[100001];

int main() {
  int N = si();
  int X = si();
  vector<int> S(N);
  REP(i, N) cin >> S[i];
  sort(ALL(S));
  REP(i, 100001) {
    dp0[i] = i;
  }
  REP(i, N) {
    REP(j, 100001) {
      dp1[j] = dp0[j];
      dp0[j] = 0;
    }
    REP(j, 100001) {
      dp0[j] += dp1[j] * i;
      dp0[j] += dp1[j % S[i]];
    }
  }
  pi(dp0[X].n); br();
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N, X, T; cin >> N >> X >> T;
  ll ans = ((N - 1) / X + 1) * T;

  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3652
#!/usr/bin/env pypy3


def div_ceil(a, b):
    return (a + b - 1) // b


def solve(n, xs, ys):
    ctr = 0
    for i in range(n)[::-1]:
        xs[i] += ctr
        diff = div_ceil(xs[i], ys[i]) * ys[i] - xs[i]
        ctr += diff
    return ctr


def main():
    n = int(input())
    data = (tuple(int(x) for x in input().split()) for _ in range(n))
    xs, ys = (list(line) for line in zip(*data))
    print(solve(n, xs, ys))


if __name__ == '__main__':
    main()


Measured memory_bytes: 25236
#include <iostream>

using namespace std;

int main()
{
    int k, a, b;

    cin >> k >> a >> b;
    bool ok = false;
    for (int i = a; i <= b; i++) {

        if (i % k == 0) {
            ok = true;
            break;
        }
    }
    cout << (ok ? "OK" : "NG" )<< endl;
    return 0;
}




Measured memory_bytes: 3104
N = int(input())
dic = {}
for n in range(N):
    X, Y = input().split()
    x = int(X)
    y = int(Y)
    dic[n] = (x, y)
distancesum = 0    
for a in range(N):
    xa, ya = dic[a]
    #print(xa, ya)
    for b in range(N):
        xb, yb = dic[b]
        #print(xb, yb)
        distance2 = (xa-xb)**2+(ya-yb)**2
        distance = distance2**0.5
        distancesum += distance
#print(distancesum)  
ans = distancesum/N   
print(ans)   

Measured memory_bytes: 3064